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
diff --git a/lib/dib b/lib/dib
index 809217b..88d9fd8 100644
--- a/lib/dib
+++ b/lib/dib
@@ -35,15 +35,6 @@
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 @@
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 @@
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