From d0b21e2d1967f650ddd123c1ecc1659b1baff783 Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Wed, 7 Mar 2012 14:52:25 -0600 Subject: [PATCH] Fix dependency list generation corner cases * Handle empty install lists in apt_get() and pip_install() * pip_install now uses get_packages() to get the dependency list Fixes bug 948714 Change-Id: I174a60976df18c670eab2067edcd1871c51d07d6 --- functions | 4 ++-- stack.sh | 20 ++++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/functions b/functions index adcf5bdaa1..c4d56a236f 100644 --- a/functions +++ b/functions @@ -4,7 +4,7 @@ # apt-get wrapper to set arguments correctly # apt_get package [package ...] function apt_get() { - [[ "$OFFLINE" = "True" ]] && return + [[ "$OFFLINE" = "True" || -z "$@" ]] && return local sudo="sudo" [[ "$(id -u)" = "0" ]] && sudo="env" $sudo DEBIAN_FRONTEND=noninteractive \ @@ -124,7 +124,7 @@ function is_set() { # pip install wrapper to set cache and proxy environment variables # pip_install package [package ...] function pip_install { - [[ "$OFFLINE" = "True" ]] && return + [[ "$OFFLINE" = "True" || -z "$@" ]] && return sudo PIP_DOWNLOAD_CACHE=/var/cache/pip \ HTTP_PROXY=$http_proxy \ HTTPS_PROXY=$https_proxy \ diff --git a/stack.sh b/stack.sh index eead8a199f..fa5652f255 100755 --- a/stack.sh +++ b/stack.sh @@ -516,12 +516,16 @@ fi # dist:DISTRO1,DISTRO2 it will be installed only for those # distros (case insensitive). function get_packages() { - local file_to_parse="general" + local package_dir=$1 + local file_to_parse local service - for service in ${ENABLED_SERVICES//,/ }; do - # Allow individual services to specify dependencies - if [[ -e $FILES/apts/${service} ]]; then + if [[ -z "$package_dir" ]]; then + echo "No package directory supplied" + return 1 + fi + for service in general ${ENABLED_SERVICES//,/ }; do # Allow individual services to specify dependencies + if [[ -e ${package_dir}/${service} ]]; then file_to_parse="${file_to_parse} $service" fi if [[ $service == n-* ]]; then @@ -540,9 +544,9 @@ function get_packages() { done for file in ${file_to_parse}; do - local fname=${FILES}/apts/${file} + local fname=${package_dir}/${file} local OIFS line package distros distro - [[ -e $fname ]] || { echo "missing: $fname"; exit 1 ;} + [[ -e $fname ]] || continue OIFS=$IFS IFS=$'\n' @@ -568,10 +572,10 @@ function get_packages() { # install apt requirements apt_get update -apt_get install $(get_packages) +apt_get install $(get_packages $FILES/apts) # install python requirements -pip_install `cat $FILES/pips/* | uniq` +pip_install $(get_packages $FILES/pips | sort -u) # compute service git_clone $NOVA_REPO $NOVA_DIR $NOVA_BRANCH