Define extra_elements inside disk_image_create_upload

This avoids the need to define a global variable,
and tolerates extra_elements not being set when bash
flag -u is set.

Change-Id: I343951a678bed9ca3cda347a9c902e60c7b70e2d
This commit is contained in:
Steve Baker 2014-12-23 13:13:05 +13:00
parent cc9d7330e9
commit 8874115668

20
lib/dib
View File

@ -35,15 +35,6 @@ OCC_DIR=$DEST/os-collect-config
ORC_DIR=$DEST/os-refresh-config ORC_DIR=$DEST/os-refresh-config
OAC_DIR=$DEST/os-apply-config OAC_DIR=$DEST/os-apply-config
# Include the apt-sources element in builds if we have an
# alternative sources.list specified.
if [ -n "$DIB_APT_SOURCES" ]; then
if [ ! -e "$DIB_APT_SOURCES" ]; then
die $LINENO "DIB_APT_SOURCES set but not found at $DIB_APT_SOURCES"
fi
EXTRA_ELEMENTS="apt-sources"
fi
# Functions # Functions
# --------- # ---------
@ -106,6 +97,15 @@ function disk_image_create_upload {
local image_path=$TOP_DIR/files/$image_name.qcow2 local image_path=$TOP_DIR/files/$image_name.qcow2
# Include the apt-sources element in builds if we have an
# alternative sources.list specified.
if [ -n "$DIB_APT_SOURCES" ]; then
if [ ! -e "$DIB_APT_SOURCES" ]; then
die $LINENO "DIB_APT_SOURCES set but not found at $DIB_APT_SOURCES"
fi
local extra_elements="apt-sources"
fi
# Set the local pip repo as the primary index mirror so the # Set the local pip repo as the primary index mirror so the
# image is built with local packages # image is built with local packages
local pypi_mirror_url=http://$SERVICE_HOST:$DIB_PIP_REPO_PORT/ local pypi_mirror_url=http://$SERVICE_HOST:$DIB_PIP_REPO_PORT/
@ -127,7 +127,7 @@ function disk_image_create_upload {
DIB_OFFLINE=$DIB_BUILD_OFFLINE \ DIB_OFFLINE=$DIB_BUILD_OFFLINE \
PYPI_MIRROR_URL=$pypi_mirror_url \ PYPI_MIRROR_URL=$pypi_mirror_url \
PYPI_MIRROR_URL_1=$pypi_mirror_url_1 \ PYPI_MIRROR_URL_1=$pypi_mirror_url_1 \
disk-image-create -a amd64 $image_elements $EXTRA_ELEMENTS \ disk-image-create -a amd64 $image_elements ${extra_elements:-} \
--image-cache $DIB_IMAGE_CACHE \ --image-cache $DIB_IMAGE_CACHE \
-o $image_path -o $image_path