From 8874115668427b9d60bb65cbe3670d01d3f7eb14 Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Tue, 23 Dec 2014 13:13:05 +1300 Subject: [PATCH] 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 --- lib/dib | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/dib b/lib/dib index 809217bc93..88d9fd8434 100644 --- a/lib/dib +++ b/lib/dib @@ -35,15 +35,6 @@ OCC_DIR=$DEST/os-collect-config ORC_DIR=$DEST/os-refresh-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 # --------- @@ -106,6 +97,15 @@ function disk_image_create_upload { 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 # image is built with local packages 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 \ PYPI_MIRROR_URL=$pypi_mirror_url \ 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 \ -o $image_path