From 0277d5b91f8ad7763bf32e63d7b6d3c2236fce3c Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Mon, 14 Nov 2011 15:20:39 +0100 Subject: [PATCH] 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). --- stack.sh | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index 1255ad0..1043dc6 100755 --- a/stack.sh +++ b/stack.sh @@ -364,10 +364,65 @@ fi # # Openstack uses a fair number of other projects. +# - We are going to install 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). +function get_packages() { + local file_to_parse="general" + local service + + for service in ${ENABLED_SERVICES//,/ }; do + if [[ $service == n-* ]]; then + if [[ ! $file_to_parse =~ nova ]];then + file_to_parse="${file_to_parse} nova" + fi + elif [[ $service == g-* ]];then + if [[ ! $file_to_parse =~ glance ]];then + file_to_parse="${file_to_parse} glance" + fi + elif [[ $service == key* ]];then + if [[ ! $file_to_parse =~ keystone ]];then + file_to_parse="${file_to_parse} keystone" + fi + elif [[ -e $FILES/apts/${service} ]];then + file_to_parse="${file_to_parse} $service" + fi + done + + for file in ${file_to_parse};do + local fname=${FILES}/apts/${file} + local OIFS line package distros distro + [[ -e $fname ]] || { echo "missing: $fname"; exit 1 ;} + + OIFS=$IFS + IFS=$'\n' + for line in $(cat ${fname});do + if [[ $line =~ "NOPRIME" ]];then + continue + fi + + if [[ $line =~ (.*)#.*dist:([^ ]*) ]];then # We are using BASH regexp matching feature. + package=${BASH_REMATCH[1]} + distros=${BASH_REMATCH[2]} + for distro in ${distros//,/ };do #In bash ${VAR,,} will lowecase VAR + [[ ${distro,,} == ${DISTRO,,} ]] && echo $package + done + continue + fi + + echo ${line%#*} + done + IFS=$OIFS + done +} # install apt requirements apt_get update -apt_get install `cat $FILES/apts/* | cut -d\# -f1 | grep -Ev "mysql-server|rabbitmq-server|memcached"` +apt_get install $(get_packages) # install python requirements sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install `cat $FILES/pips/*`