-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
111 lines (92 loc) · 3 KB
/
setup.sh
File metadata and controls
111 lines (92 loc) · 3 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
#!/bin/bash
REQUIRED_TOOLS=("gcc" "make" "automake" "autoconf" "flex" "bison" "perl" "pkg-config")
MISSING_TOOLS=()
if [[ "$(uname)" == "Darwin" ]]; then
# macOS - use Homebrew
BREW_PACKAGES=("icu4c" "readline")
MISSING_BREW=()
for tool in "${REQUIRED_TOOLS[@]}"; do
if ! command -v "$tool" >/dev/null 2>&1; then
MISSING_TOOLS+=("$tool")
fi
done
for pkg in "${BREW_PACKAGES[@]}"; do
if ! brew list "$pkg" >/dev/null 2>&1; then
MISSING_BREW+=("$pkg")
fi
done
if [ ${#MISSING_TOOLS[@]} -eq 0 ] && [ ${#MISSING_BREW[@]} -eq 0 ]; then
echo "All required tools and libraries are already installed."
exit 0
fi
if [ ${#MISSING_TOOLS[@]} -gt 0 ]; then
echo "The following tools are missing:"
for tool in "${MISSING_TOOLS[@]}"; do
echo " - $tool"
done
fi
if [ ${#MISSING_BREW[@]} -gt 0 ]; then
echo "The following Homebrew packages are missing:"
for pkg in "${MISSING_BREW[@]}"; do
echo " - $pkg"
done
fi
echo ""
read -p "Do you want to install the missing tools and libraries? (Y/n): " confirm
confirm=${confirm:-Y}
if [[ ! "$confirm" =~ ^[Yy]$ ]]; then
echo "Installation aborted."
exit 1
fi
echo "Installing missing dependencies via Homebrew..."
ALL_MISSING=("${MISSING_TOOLS[@]}" "${MISSING_BREW[@]}")
if [ ${#ALL_MISSING[@]} -gt 0 ]; then
brew install "${ALL_MISSING[@]}"
fi
else
# Linux - use apt-get
REQUIRED_LIBS=("libicu-dev" "libreadline-dev")
MISSING_LIBS=()
for tool in "${REQUIRED_TOOLS[@]}"; do
if ! command -v "$tool" >/dev/null 2>&1; then
MISSING_TOOLS+=("$tool")
fi
done
for lib in "${REQUIRED_LIBS[@]}"; do
if ! dpkg -s "$lib" >/dev/null 2>&1; then
MISSING_LIBS+=("$lib")
fi
done
if [ ${#MISSING_TOOLS[@]} -eq 0 ] && [ ${#MISSING_LIBS[@]} -eq 0 ]; then
echo "All required tools and libraries are already installed."
exit 0
fi
if [ ${#MISSING_TOOLS[@]} -gt 0 ]; then
echo "The following tools are missing:"
for tool in "${MISSING_TOOLS[@]}"; do
echo " - $tool"
done
fi
if [ ${#MISSING_LIBS[@]} -gt 0 ]; then
echo "The following libraries are missing:"
for lib in "${MISSING_LIBS[@]}"; do
echo " - $lib"
done
fi
echo ""
read -p "Do you want to install the missing tools and libraries? (Y/n): " confirm
confirm=${confirm:-Y}
if [[ ! "$confirm" =~ ^[Yy]$ ]]; then
echo "Installation aborted."
exit 1
fi
echo "Installing missing dependencies via apt-get..."
sudo apt-get update
if [ ${#MISSING_TOOLS[@]} -gt 0 ]; then
sudo apt-get install -y "${MISSING_TOOLS[@]}"
fi
if [ ${#MISSING_LIBS[@]} -gt 0 ]; then
sudo apt-get install -y "${MISSING_LIBS[@]}"
fi
fi
echo "All tools and libraries have been installed successfully!"