-
Notifications
You must be signed in to change notification settings - Fork 1
/
requirements.sh
executable file
·40 lines (36 loc) · 1.06 KB
/
requirements.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
#! /bin/sh
pkgs="ninja-build libglib2.0-dev make gcc g++ pkg-config"
print_requirements(){
echo "Required packages (note that these are apt-based package names):"
for pkg in $pkgs; do
echo "[*] $pkg"
done
}
dpkg_status=$(dpkg-query --help > /dev/null 2>&1)
if [ $? -ne 0 ]; then
echo "dpkg-query not available. Probably your current OS is using a package manager different from apt"
echo "Please, install the required packages manually, then launch make"
echo ""
print_requirements
exit 0
fi
for pkg in $pkgs; do
status=$(dpkg-query -W -f='${db:Status-Status}' "$pkg" 2>/dev/null | grep -c "installed")
echo ""
if [ $? -ne 0 ] || [ $status -eq 0 ]; then
echo "$pkg not installed"
echo "Attempt to install the missing package. NOTE: SUDO PASSWORD MAY BE REQUESTED"
sudo apt-get -y install $pkg
if [ $? -eq 0 ]; then
echo "$pkg successfully installed"
else
echo "$pkg installation failed. Please manually install the required packages and retry."
print_requirements
exit 1
fi
echo ""
echo ""
else
echo "$pkg already installed"
fi
done