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
| ... | ... |
@@ -35,15 +35,6 @@ OCC_DIR=$DEST/os-collect-config |
| 35 | 35 |
ORC_DIR=$DEST/os-refresh-config |
| 36 | 36 |
OAC_DIR=$DEST/os-apply-config |
| 37 | 37 |
|
| 38 |
-# Include the apt-sources element in builds if we have an |
|
| 39 |
-# alternative sources.list specified. |
|
| 40 |
-if [ -n "$DIB_APT_SOURCES" ]; then |
|
| 41 |
- if [ ! -e "$DIB_APT_SOURCES" ]; then |
|
| 42 |
- die $LINENO "DIB_APT_SOURCES set but not found at $DIB_APT_SOURCES" |
|
| 43 |
- fi |
|
| 44 |
- EXTRA_ELEMENTS="apt-sources" |
|
| 45 |
-fi |
|
| 46 |
- |
|
| 47 | 38 |
# Functions |
| 48 | 39 |
# --------- |
| 49 | 40 |
|
| ... | ... |
@@ -106,6 +97,15 @@ function disk_image_create_upload {
|
| 106 | 106 |
|
| 107 | 107 |
local image_path=$TOP_DIR/files/$image_name.qcow2 |
| 108 | 108 |
|
| 109 |
+ # Include the apt-sources element in builds if we have an |
|
| 110 |
+ # alternative sources.list specified. |
|
| 111 |
+ if [ -n "$DIB_APT_SOURCES" ]; then |
|
| 112 |
+ if [ ! -e "$DIB_APT_SOURCES" ]; then |
|
| 113 |
+ die $LINENO "DIB_APT_SOURCES set but not found at $DIB_APT_SOURCES" |
|
| 114 |
+ fi |
|
| 115 |
+ local extra_elements="apt-sources" |
|
| 116 |
+ fi |
|
| 117 |
+ |
|
| 109 | 118 |
# Set the local pip repo as the primary index mirror so the |
| 110 | 119 |
# image is built with local packages |
| 111 | 120 |
local pypi_mirror_url=http://$SERVICE_HOST:$DIB_PIP_REPO_PORT/ |
| ... | ... |
@@ -127,7 +127,7 @@ function disk_image_create_upload {
|
| 127 | 127 |
DIB_OFFLINE=$DIB_BUILD_OFFLINE \ |
| 128 | 128 |
PYPI_MIRROR_URL=$pypi_mirror_url \ |
| 129 | 129 |
PYPI_MIRROR_URL_1=$pypi_mirror_url_1 \ |
| 130 |
- disk-image-create -a amd64 $image_elements $EXTRA_ELEMENTS \ |
|
| 130 |
+ disk-image-create -a amd64 $image_elements ${extra_elements:-} \
|
|
| 131 | 131 |
--image-cache $DIB_IMAGE_CACHE \ |
| 132 | 132 |
-o $image_path |
| 133 | 133 |
|