Skip to content

Commit d5f425c

Browse files
committed
install_dependencies: Added printing of dependencies part of install.sh script
1 parent a18d362 commit d5f425c

2 files changed

Lines changed: 43 additions & 16 deletions

File tree

etc/install_build_requirements.sh

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,25 @@ TEST_DEPENDENCIES="g++ g++-multilib python-junit.xml"
1616
# Initialize variables:
1717
SYSTEM=0
1818
RELEASE=0
19-
CHECK_INSTALLED=0
19+
CHECK_ONLY=0
20+
PRINT_INSTALL_STATUS=0
2021
DEPENDENCIES_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
3639
done
3740

@@ -46,7 +49,7 @@ esac
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
6477
fi
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;

install.sh

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,15 @@ if [ "Darwin" = "$SYSTEM" ]; then
107107
exit 1
108108
fi
109109
else
110-
if ! ./etc/install_build_requirements.sh $SYSTEM $RELEASE; then
111-
printf "%s\n" ">>> Sorry <<<"\
112-
"Could not install build requirements."
113-
exit 1
110+
# Will only check if build dependencies are installed at this point
111+
if [ $INCLUDEOS_ENABLE_TEST == "ON" ]; then
112+
dependency_level=all
113+
else
114+
dependency_level=build
115+
fi
116+
echo ">>> Dependencies required:"
117+
if ! ./etc/install_build_requirements.sh -s $SYSTEM -r $RELEASE -c -d $dependency_level; then
118+
missing_dependencies=1
114119
fi
115120
fi
116121

@@ -141,6 +146,9 @@ done
141146

142147
# Print currently set install options
143148
printf "\n\n>>> IncludeOS will be installed with the following options:\n\n"
149+
if [ ! -z $missing_dependencies ]; then
150+
printf ' \e[31m%-s\e[0m %-s\n\n' "[NOTICE]" "Missing dependencies will be installed"
151+
fi
144152
printf " %-25s %-25s %s\n"\
145153
"Env variable" "Description" "Value"\
146154
"------------" "-----------" "-----"\
@@ -162,6 +170,15 @@ if tty -s && [ $install_yes -eq 0 ]; then
162170
esac
163171
fi
164172

173+
# Install dependencies if there are any missing
174+
if [ ! -z $missing_dependencies ]; then
175+
if ! ./etc/install_build_requirements.sh -s $SYSTEM -r $RELEASE; then
176+
printf "%s\n" ">>> Sorry <<<"\
177+
"Could not install dependencies"
178+
exit 1
179+
fi
180+
fi
181+
165182
# Trap that cleans the cmake output file in case of exit
166183
function clean {
167184
if [ -f /tmp/cmake_output.txt ]; then

0 commit comments

Comments
 (0)