-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
114 lines (101 loc) · 3.2 KB
/
install.sh
File metadata and controls
114 lines (101 loc) · 3.2 KB
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
106
107
108
109
110
111
112
113
114
#!/usr/bin/env 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
}
# Detect if running as root (UID 0)
if [ "$(id -u)" -eq 0 ]; then
SUDO=""
else
SUDO="sudo"
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="$SUDO apt-get"
execute_cmd $SUDO apt-get -y update
execute_cmd $SUDO apt-get -y dist-upgrade
elif command -v yum &> /dev/null; then
PM="$SUDO yum"
execute_cmd $SUDO yum -y update
# elif command -v dnf &> /dev/null; then
# PM="$SUDO dnf"
# execute_cmd $SUDO dnf -y upgrade
else
echo "No known package manager found"
exit 1
fi
INSTALL="$PM install -y"
# List of packages to install
PACKAGES="git g++ make cmake wget tar python3 python3-pip pipx graphviz valgrind clang-format"
;;
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"
# List of packages to install
PACKAGES="git gcc make cmake wget gnu-tar python pipx graphviz clang-format"
;;
*)
echo "Unknown Operating System $OS"
exit 1
;;
esac
# 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.9.8/doxygen-1.9.8.src.tar.gz && \
tar xf doxygen-1.9.8.src.tar.gz && \
cd doxygen-1.9.8 && \
mkdir build && cd build && cmake -G \"Unix Makefiles\" .. && make install && \
cd ../.. && \
rm -rf doxygen-1.9.8* \
)"
execute_cmd $CMD
# Python packages to install
PYTHON_PACKAGES="git+https://github.com/cpplint/cpplint.git@2.0.0#egg=cpplint git+https://github.com/gcovr/gcovr.git@8.3#egg=gcovr"
# Install each package and echo the command
for PACKAGE in $PYTHON_PACKAGES; do
if [ "$(id -u)" -eq 0 ]; then
CMD="pip install --break-system-packages $PACKAGE"
else
CMD="pipx install $PACKAGE"
fi
execute_cmd $CMD
done
execute_cmd pipx ensurepath
printf "\n============Please Restart your Terminal============\n"