-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·105 lines (92 loc) · 2.81 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
# Exit on any command failure
set -e
# Executes a command with a banner
execute_cmd() {
local cmd="$@"
local middle_line="Command: $cmd"
local middle_line_len=$(echo -n "$middle_line" | wc -m)
local extra_chars=20
local total_length=$((middle_line_len + extra_chars))
local hash_line=$(printf '%*s' "$total_length" | tr ' ' '=')
printf "\n"
printf "%s\n" "$hash_line"
printf " %s\n" "$middle_line"
printf "%s\n" "$hash_line"
printf "\n"
# Execute the command and check for errors
if ! eval "$cmd"; then
echo "Command failed: $cmd"
exit 1
fi
}
# Check if the script is running with root privileges
if [ "$(id -u)" -ne 0 ]; then
echo "This script requires root privileges. Please run with sudo/root."
exit 1
fi
# Detect the operating system using uname
OS="$(uname -s)"
INSTALL=""
# Perform necessary setup and get the
# installation command depending on
# the OS
case "$OS" in
Linux*)
# Detect the package manager
PM=""
if command -v apt-get &> /dev/null; then
PM="apt-get"
execute_cmd apt-get -y update
execute_cmd apt-get -y dist-upgrade
elif command -v yum &> /dev/null; then
PM="yum"
execute_cmd yum -y update
# elif command -v dnf &> /dev/null; then
# PM="dnf"
# execute_cmd dnf -y upgrade
else
echo "No known package manager found"
exit 1
fi
INSTALL="$PM install -y"
;;
# Darwin*)
# # Check if Homebrew is installed; install it if not
# if ! command -v brew &> /dev/null; then
# echo "Homebrew not found. Installing Homebrew..."
# execute_cmd curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh
# fi
# INSTALL="brew install"
# ;;
*)
echo "Unknown Operating System $OS"
exit 1
;;
esac
# List of packages to install
PACKAGES="git g++ make cmake wget tar valgrind python3 python3-pip graphviz"
# Install each package and echo the command
for PACKAGE in $PACKAGES; do
CMD="$INSTALL $PACKAGE"
execute_cmd $CMD
done
# Install doxygen
CMD="$INSTALL doxygen || ( \
$INSTALL bison && \
$INSTALL flex && \
wget https://sourceforge.net/projects/doxygen/files/rel-1.8.17/doxygen-1.8.17.src.tar.gz && \
tar xf doxygen-1.8.17.src.tar.gz && \
cd doxygen-1.8.17 && \
mkdir build && cd build && cmake -G \"Unix Makefiles\" .. && make install && \
cd ../.. && \
rm -rf doxygen-1.8.17* \
)"
execute_cmd $CMD
# Python packages to install
PYTHON_PACKAGES="cpplint==1.6.1 gcovr==7.2"
# Install each package and echo the command
for PACKAGE in $PYTHON_PACKAGES; do
CMD="python3 -m pip install -q $PACKAGE"
execute_cmd $CMD
done