Browse code

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

Dean Troyer authored on 2012/03/08 05:52:25
Showing 2 changed files
... ...
@@ -4,7 +4,7 @@
4 4
 # apt-get wrapper to set arguments correctly
5 5
 # apt_get package [package ...]
6 6
 function apt_get() {
7
-    [[ "$OFFLINE" = "True" ]] && return
7
+    [[ "$OFFLINE" = "True" || -z "$@" ]] && return
8 8
     local sudo="sudo"
9 9
     [[ "$(id -u)" = "0" ]] && sudo="env"
10 10
     $sudo DEBIAN_FRONTEND=noninteractive \
... ...
@@ -124,7 +124,7 @@ function is_set() {
124 124
 # pip install wrapper to set cache and proxy environment variables
125 125
 # pip_install package [package ...]
126 126
 function pip_install {
127
-    [[ "$OFFLINE" = "True" ]] && return
127
+    [[ "$OFFLINE" = "True" || -z "$@" ]] && return
128 128
     sudo PIP_DOWNLOAD_CACHE=/var/cache/pip \
129 129
         HTTP_PROXY=$http_proxy \
130 130
         HTTPS_PROXY=$https_proxy \
... ...
@@ -516,12 +516,16 @@ fi
516 516
 #    dist:DISTRO1,DISTRO2 it will be installed only for those
517 517
 #    distros (case insensitive).
518 518
 function get_packages() {
519
-    local file_to_parse="general"
519
+    local package_dir=$1
520
+    local file_to_parse
520 521
     local service
521 522
 
522
-    for service in ${ENABLED_SERVICES//,/ }; do
523
-        # Allow individual services to specify dependencies
524
-        if [[ -e $FILES/apts/${service} ]]; then
523
+    if [[ -z "$package_dir" ]]; then
524
+        echo "No package directory supplied"
525
+        return 1
526
+    fi
527
+    for service in general ${ENABLED_SERVICES//,/ }; do        # Allow individual services to specify dependencies
528
+        if [[ -e ${package_dir}/${service} ]]; then
525 529
             file_to_parse="${file_to_parse} $service"
526 530
         fi
527 531
         if [[ $service == n-* ]]; then
... ...
@@ -540,9 +544,9 @@ function get_packages() {
540 540
     done
541 541
 
542 542
     for file in ${file_to_parse}; do
543
-        local fname=${FILES}/apts/${file}
543
+        local fname=${package_dir}/${file}
544 544
         local OIFS line package distros distro
545
-        [[ -e $fname ]] || { echo "missing: $fname"; exit 1 ;}
545
+        [[ -e $fname ]] || continue
546 546
 
547 547
         OIFS=$IFS
548 548
         IFS=$'\n'
... ...
@@ -568,10 +572,10 @@ function get_packages() {
568 568
 
569 569
 # install apt requirements
570 570
 apt_get update
571
-apt_get install $(get_packages)
571
+apt_get install $(get_packages $FILES/apts)
572 572
 
573 573
 # install python requirements
574
-pip_install `cat $FILES/pips/* | uniq`
574
+pip_install $(get_packages $FILES/pips | sort -u)
575 575
 
576 576
 # compute service
577 577
 git_clone $NOVA_REPO $NOVA_DIR $NOVA_BRANCH