@@ -16,22 +16,25 @@ TEST_DEPENDENCIES="g++ g++-multilib python-junit.xml"
1616# Initialize variables:
1717SYSTEM=0
1818RELEASE=0
19- CHECK_INSTALLED=0
19+ CHECK_ONLY=0
20+ PRINT_INSTALL_STATUS=0
2021DEPENDENCIES_TO_INSTALL=build
2122
22- while getopts " h?s:r:cd :" opt; do
23+ while getopts " h?s:r:cpd :" opt; do
2324 case " $opt " in
2425 h|\? )
2526 printf " %s\n" " Options:" \
2627 " -s System: What system to install on" \
2728 " -r Release: What release of said system" \
28- " -c Check installed: Flag for checking if dependencies are installed"
29+ " -c Only check: Will only check what packages are needed (will always print status as well)" \
30+ " -p Print install status: Flag for wheter or not to print dependency status" \
2931 " -d Dependencies to install: [build | test | all] are the options"
3032 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 ;;
33+ s) SYSTEM=$OPTARG ;;
34+ r) RELEASE=$OPTARG ;;
35+ c) CHECK_ONLY=1 ; PRINT_INSTALL_STATUS=1;;
36+ p) PRINT_INSTALL_STATUS=1 ;;
37+ d) DEPENDENCIES_TO_INSTALL=$OPTARG ;;
3538 esac
3639done
3740
4649# CHECK INSTALLED PACKAGES:
4750# ###########################################################
4851
49- if [ $CHECK_INSTALLED -eq 1 ]; then
52+ if [ $PRINT_INSTALL_STATUS -eq 1 ]; then
5053 printf " %-15s %-20s %s \n" \
5154 " Status" " Package" " Version" \
5255 " ------" " -------" " -------"
@@ -61,6 +64,16 @@ if [ $CHECK_INSTALLED -eq 1 ]; then
6164 DEPENDENCIES=" $DEPENDENCIES $package "
6265 fi
6366 done
67+ # Exits if CHECK_ONLY is set, exit code 1 if there are packages to install
68+ if [ $CHECK_ONLY -eq 1 ]; then
69+ if [ -z " $DEPENDENCIES " ]; then
70+ exit 0
71+ else
72+ exit 1
73+ fi
74+ fi
75+ else
76+ DEPENDENCIES=$ALL_DEPENDENCIES
6477fi
6578
6679# ###########################################################
@@ -72,24 +85,21 @@ case $SYSTEM in
7285 exit 0;
7386 ;;
7487 " Linux" )
75- echo " >>> Installing dependencies (requires sudo):"
88+ echo " >>> Installing missing dependencies (requires sudo):"
7689 case $RELEASE in
7790 " debian" |" ubuntu" |" linuxmint" )
7891 DEPENDENCIES=" $DEPENDENCIES "
79- echo " Packages: $DEPENDENCIES "
8092 sudo apt-get -qq update || exit 1
8193 sudo apt-get -qqy install $DEPENDENCIES > /dev/null || exit 1
8294 exit 0;
8395 ;;
8496 " fedora" )
8597 DEPENDENCIES=" $DEPENDENCIES "
86- echo " Packages: $DEPENDENCIES "
8798 sudo dnf install $DEPENDENCIES || exit 1
8899 exit 0;
89100 ;;
90101 " arch" )
91102 DEPENDENCIES=" $DEPENDENCIES python2 python2-jsonschema python2-psutil"
92- echo " Packages: $DEPENDENCIES "
93103 sudo pacman -Syyu
94104 sudo pacman -S --needed $DEPENDENCIES
95105 exit 0;
0 commit comments