Browse code

Install packages only for distros/services.

- We are installing packages only for the services needed.
- We are parsing the packages files and detecting metadatas.
- If there is a NOPRIME as comment mean we are not doing the install
just yet.
- If we have the meta-keyword distro:DISTRO or
distro:DISTRO1,DISTRO2 it will be installed only for those
distros (case insensitive).

Chmouel Boudjnah authored on 2011/11/14 23:20:39
Showing 1 changed files
... ...
@@ -364,10 +364,65 @@ fi
364 364
 #
365 365
 # Openstack uses a fair number of other projects.
366 366
 
367
+# - We are going to install packages only for the services needed.
368
+# - We are parsing the packages files and detecting metadatas.
369
+#  - If there is a NOPRIME as comment mean we are not doing the install
370
+#    just yet.
371
+#  - If we have the meta-keyword distro:DISTRO or
372
+#    distro:DISTRO1,DISTRO2 it will be installed only for those
373
+#    distros (case insensitive).
374
+function get_packages() {
375
+    local file_to_parse="general"
376
+    local service
377
+    
378
+    for service in ${ENABLED_SERVICES//,/ }; do
379
+        if [[ $service == n-* ]]; then
380
+            if [[ ! $file_to_parse =~ nova ]];then
381
+                file_to_parse="${file_to_parse} nova"
382
+            fi
383
+        elif [[ $service == g-* ]];then
384
+            if [[ ! $file_to_parse =~ glance ]];then
385
+                file_to_parse="${file_to_parse} glance"
386
+            fi
387
+        elif [[ $service == key* ]];then
388
+            if [[ ! $file_to_parse =~ keystone ]];then
389
+                file_to_parse="${file_to_parse} keystone"
390
+            fi
391
+        elif [[ -e $FILES/apts/${service} ]];then
392
+            file_to_parse="${file_to_parse} $service"
393
+        fi
394
+    done
395
+
396
+    for file in ${file_to_parse};do
397
+        local fname=${FILES}/apts/${file}
398
+        local OIFS line package distros distro
399
+        [[ -e $fname ]] || { echo "missing: $fname"; exit 1 ;}
400
+
401
+        OIFS=$IFS
402
+        IFS=$'\n'
403
+        for line in $(cat ${fname});do
404
+            if [[ $line =~ "NOPRIME" ]];then
405
+                continue
406
+            fi
407
+
408
+            if [[ $line =~ (.*)#.*dist:([^ ]*) ]];then # We are using BASH regexp matching feature.
409
+                        package=${BASH_REMATCH[1]}
410
+                        distros=${BASH_REMATCH[2]}
411
+                        for distro in ${distros//,/ };do  #In bash ${VAR,,} will lowecase VAR
412
+                            [[ ${distro,,} == ${DISTRO,,} ]] && echo $package
413
+                        done
414
+                        continue
415
+            fi
416
+
417
+            echo ${line%#*}
418
+        done
419
+        IFS=$OIFS
420
+    done
421
+}
367 422
 
368 423
 # install apt requirements
369 424
 apt_get update
370
-apt_get install `cat $FILES/apts/* | cut -d\# -f1 | grep -Ev "mysql-server|rabbitmq-server|memcached"`
425
+apt_get install $(get_packages)
371 426
 
372 427
 # install python requirements
373 428
 sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install `cat $FILES/pips/*`