Skip to content

Commit 2db5f08

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Move get_packages() to functions."
2 parents ebad9cc + 7e27051 commit 2db5f08

File tree

2 files changed

+85
-80
lines changed

2 files changed

+85
-80
lines changed

functions

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,91 @@ function get_field() {
7373
}
7474

7575

76+
# get_packages() collects a list of package names of any type from the
77+
# prerequisite files in ``files/{apts|pips}``. The list is intended
78+
# to be passed to a package installer such as apt or pip.
79+
#
80+
# Only packages required for the services in ENABLED_SERVICES will be
81+
# included. Two bits of metadata are recognized in the prerequisite files:
82+
# - ``# NOPRIME`` defers installation to be performed later in stack.sh
83+
# - ``# dist:DISTRO`` or ``dist:DISTRO1,DISTRO2`` limits the selection
84+
# of the package to the distros listed. The distro names are case insensitive.
85+
#
86+
# get_packages dir
87+
function get_packages() {
88+
local package_dir=$1
89+
local file_to_parse
90+
local service
91+
92+
if [[ -z "$package_dir" ]]; then
93+
echo "No package directory supplied"
94+
return 1
95+
fi
96+
if [[ -z "$DISTRO" ]]; then
97+
echo "No distro set in DISTRO"
98+
return 1
99+
fi
100+
for service in general ${ENABLED_SERVICES//,/ }; do
101+
# Allow individual services to specify dependencies
102+
if [[ -e ${package_dir}/${service} ]]; then
103+
file_to_parse="${file_to_parse} $service"
104+
fi
105+
# NOTE(sdague) n-api needs glance for now because that's where
106+
# glance client is
107+
if [[ $service == n-api ]]; then
108+
if [[ ! $file_to_parse =~ nova ]]; then
109+
file_to_parse="${file_to_parse} nova"
110+
fi
111+
if [[ ! $file_to_parse =~ glance ]]; then
112+
file_to_parse="${file_to_parse} glance"
113+
fi
114+
elif [[ $service == c-* ]]; then
115+
if [[ ! $file_to_parse =~ cinder ]]; then
116+
file_to_parse="${file_to_parse} cinder"
117+
fi
118+
elif [[ $service == n-* ]]; then
119+
if [[ ! $file_to_parse =~ nova ]]; then
120+
file_to_parse="${file_to_parse} nova"
121+
fi
122+
elif [[ $service == g-* ]]; then
123+
if [[ ! $file_to_parse =~ glance ]]; then
124+
file_to_parse="${file_to_parse} glance"
125+
fi
126+
elif [[ $service == key* ]]; then
127+
if [[ ! $file_to_parse =~ keystone ]]; then
128+
file_to_parse="${file_to_parse} keystone"
129+
fi
130+
fi
131+
done
132+
133+
for file in ${file_to_parse}; do
134+
local fname=${package_dir}/${file}
135+
local OIFS line package distros distro
136+
[[ -e $fname ]] || continue
137+
138+
OIFS=$IFS
139+
IFS=$'\n'
140+
for line in $(<${fname}); do
141+
if [[ $line =~ "NOPRIME" ]]; then
142+
continue
143+
fi
144+
145+
if [[ $line =~ (.*)#.*dist:([^ ]*) ]]; then
146+
# We are using BASH regexp matching feature.
147+
package=${BASH_REMATCH[1]}
148+
distros=${BASH_REMATCH[2]}
149+
# In bash ${VAR,,} will lowecase VAR
150+
[[ ${distros,,} =~ ${DISTRO,,} ]] && echo $package
151+
continue
152+
fi
153+
154+
echo ${line%#*}
155+
done
156+
IFS=$OIFS
157+
done
158+
}
159+
160+
76161
# Determine OS Vendor, Release and Update
77162
# Tested with OS/X, Ubuntu, RedHat, CentOS, Fedora
78163
# Returns results in global variables:

stack.sh

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -614,86 +614,6 @@ set -o xtrace
614614
#
615615
# Openstack uses a fair number of other projects.
616616

617-
# get_packages() collects a list of package names of any type from the
618-
# prerequisite files in ``files/{apts|pips}``. The list is intended
619-
# to be passed to a package installer such as apt or pip.
620-
#
621-
# Only packages required for the services in ENABLED_SERVICES will be
622-
# included. Two bits of metadata are recognized in the prerequisite files:
623-
# - ``# NOPRIME`` defers installation to be performed later in stack.sh
624-
# - ``# dist:DISTRO`` or ``dist:DISTRO1,DISTRO2`` limits the selection
625-
# of the package to the distros listed. The distro names are case insensitive.
626-
#
627-
# get_packages dir
628-
function get_packages() {
629-
local package_dir=$1
630-
local file_to_parse
631-
local service
632-
633-
if [[ -z "$package_dir" ]]; then
634-
echo "No package directory supplied"
635-
return 1
636-
fi
637-
for service in general ${ENABLED_SERVICES//,/ }; do
638-
# Allow individual services to specify dependencies
639-
if [[ -e ${package_dir}/${service} ]]; then
640-
file_to_parse="${file_to_parse} $service"
641-
fi
642-
# NOTE(sdague) n-api needs glance for now because that's where
643-
# glance client is
644-
if [[ $service == n-api ]]; then
645-
if [[ ! $file_to_parse =~ nova ]]; then
646-
file_to_parse="${file_to_parse} nova"
647-
fi
648-
if [[ ! $file_to_parse =~ glance ]]; then
649-
file_to_parse="${file_to_parse} glance"
650-
fi
651-
elif [[ $service == c-* ]]; then
652-
if [[ ! $file_to_parse =~ cinder ]]; then
653-
file_to_parse="${file_to_parse} cinder"
654-
fi
655-
elif [[ $service == n-* ]]; then
656-
if [[ ! $file_to_parse =~ nova ]]; then
657-
file_to_parse="${file_to_parse} nova"
658-
fi
659-
elif [[ $service == g-* ]]; then
660-
if [[ ! $file_to_parse =~ glance ]]; then
661-
file_to_parse="${file_to_parse} glance"
662-
fi
663-
elif [[ $service == key* ]]; then
664-
if [[ ! $file_to_parse =~ keystone ]]; then
665-
file_to_parse="${file_to_parse} keystone"
666-
fi
667-
fi
668-
done
669-
670-
for file in ${file_to_parse}; do
671-
local fname=${package_dir}/${file}
672-
local OIFS line package distros distro
673-
[[ -e $fname ]] || continue
674-
675-
OIFS=$IFS
676-
IFS=$'\n'
677-
for line in $(<${fname}); do
678-
if [[ $line =~ "NOPRIME" ]]; then
679-
continue
680-
fi
681-
682-
if [[ $line =~ (.*)#.*dist:([^ ]*) ]]; then
683-
# We are using BASH regexp matching feature.
684-
package=${BASH_REMATCH[1]}
685-
distros=${BASH_REMATCH[2]}
686-
# In bash ${VAR,,} will lowecase VAR
687-
[[ ${distros,,} =~ ${DISTRO,,} ]] && echo $package
688-
continue
689-
fi
690-
691-
echo ${line%#*}
692-
done
693-
IFS=$OIFS
694-
done
695-
}
696-
697617
# install package requirements
698618
if [[ "$os_PACKAGE" = "deb" ]]; then
699619
apt_get update

0 commit comments

Comments
 (0)