Skip to content

Commit a18d362

Browse files
committed
install_dependencies: Added a visual check for dependency installation
1 parent 11edfff commit a18d362

1 file changed

Lines changed: 64 additions & 4 deletions

File tree

etc/install_build_requirements.sh

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,71 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
#
33
# Install dependencies
44

5-
SYSTEM=$1
6-
RELEASE=$2
5+
############################################################
6+
# OPTIONS:
7+
############################################################
78

8-
DEPENDENCIES="curl make clang cmake nasm bridge-utils qemu jq python-jsonschema python-psutil"
9+
BUILD_DEPENDENCIES="curl make clang cmake nasm bridge-utils qemu jq python-jsonschema python-psutil"
10+
TEST_DEPENDENCIES="g++ g++-multilib python-junit.xml"
11+
12+
############################################################
13+
# COMMAND LINE PROPERTIES:
14+
############################################################
15+
16+
# Initialize variables:
17+
SYSTEM=0
18+
RELEASE=0
19+
CHECK_INSTALLED=0
20+
DEPENDENCIES_TO_INSTALL=build
21+
22+
while getopts "h?s:r:cd:" opt; do
23+
case "$opt" in
24+
h|\?)
25+
printf "%s\n" "Options:"\
26+
"-s System: What system to install on"\
27+
"-r Release: What release of said system"\
28+
"-c Check installed: Flag for checking if dependencies are installed"
29+
"-d Dependencies to install: [build | test | all] are the options"
30+
exit 0 ;;
31+
s) SYSTEM=$OPTARG ; shift 2 ;;
32+
r) RELEASE=$OPTARG ; shift 2 ;;
33+
c) CHECK_INSTALLED=1 ;;
34+
d) DEPENDENCIES_TO_INSTALL=$OPTARG ; shift 2 ;;
35+
esac
36+
done
37+
38+
# Figure out which dependencies to check
39+
case "$DEPENDENCIES_TO_INSTALL" in
40+
build) ALL_DEPENDENCIES=$BUILD_DEPENDENCIES ;;
41+
test) ALL_DEPENDENCIES=$TEST_DEPENDENCIES ;;
42+
all) ALL_DEPENDENCIES="$BUILD_DEPENDENCIES $TEST_DEPENDENCIES" ;;
43+
esac
44+
45+
############################################################
46+
# CHECK INSTALLED PACKAGES:
47+
############################################################
48+
49+
if [ $CHECK_INSTALLED -eq 1 ]; then
50+
printf "%-15s %-20s %s \n"\
51+
"Status" "Package" "Version"\
52+
"------" "-------" "-------"
53+
for package in $ALL_DEPENDENCIES; do
54+
dpkg-query -W $package > /dev/null 2>&1
55+
if [ $? -eq 0 ]; then
56+
printf '\e[32m%-15s\e[0m %-20s %s \n'\
57+
"INSTALLED" $(dpkg-query -W $package)
58+
else
59+
printf '\e[31m%-15s\e[0m %-20s %s \n'\
60+
"MISSING" $package
61+
DEPENDENCIES="$DEPENDENCIES $package"
62+
fi
63+
done
64+
fi
65+
66+
############################################################
67+
# INSTALL MISSING PACKAGES:
68+
############################################################
969

1070
case $SYSTEM in
1171
"Darwin")

0 commit comments

Comments
 (0)