From 0eccd2808cdec5fd95dcb044edf9db348f47d1b8 Mon Sep 17 00:00:00 2001 From: Ben Nemec Date: Wed, 15 Oct 2014 12:07:33 -0400 Subject: [PATCH] Allow source-repositories to be disabled completely In our official image builds we are only allowed to use resources that are "blessed" by the build system. This means that external things like git repos and tar files are not allowed. Currently, even in offline mode source-repositories expects those things to be available in the cache, so we need a way to disable it entirely. This change adds an environment variable NO_SOURCE_REPOSITORIES that does so. It can be set in an environment.d script so elements that might rely on a source repository will know it's not available. The 02-lsb script in redhat-common is one such example and is updated to handle this case. Change-Id: I0de63bee6ad79733d6711478c707a9b41593e85f --- elements/redhat-common/pre-install.d/02-lsb | 6 +++++- elements/source-repositories/README.md | 4 ++++ .../source-repositories/extra-data.d/98-source-repositories | 5 +++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/elements/redhat-common/pre-install.d/02-lsb b/elements/redhat-common/pre-install.d/02-lsb index 91c78d0d..7b3096c6 100755 --- a/elements/redhat-common/pre-install.d/02-lsb +++ b/elements/redhat-common/pre-install.d/02-lsb @@ -3,4 +3,8 @@ set -eu set -o pipefail -install -m 0755 -o root -g root /opt/stack/lsb-release/lsb_release /usr/local/bin +if [ -z "${NO_SOURCE_REPOSITORIES:-}" ]; then + install -m 0755 -o root -g root /opt/stack/lsb-release/lsb_release /usr/local/bin +else + install-packages redhat-lsb-core +fi diff --git a/elements/source-repositories/README.md b/elements/source-repositories/README.md index edd8ea5f..19677316 100644 --- a/elements/source-repositories/README.md +++ b/elements/source-repositories/README.md @@ -103,3 +103,7 @@ The base url for all git repositories can be set by use of: So setting DIB\_GITREPOBASE=https://github.com/ when the repo location is set to http://git.openstack.org/openstack/nova.git will result in use of the https://github.com/openstack/nova.git repository. + +When doing image builds in environments where external resources are not allowed, +it is possible to disable fetching of all source repositories by including an +element in the image that sets NO_SOURCE_REPOSITORIES=1 in an environment.d script. diff --git a/elements/source-repositories/extra-data.d/98-source-repositories b/elements/source-repositories/extra-data.d/98-source-repositories index c542cb0e..0a0e9336 100755 --- a/elements/source-repositories/extra-data.d/98-source-repositories +++ b/elements/source-repositories/extra-data.d/98-source-repositories @@ -3,6 +3,11 @@ set -eu set -o pipefail +# Don't provide any source repositories in environments where they are not allowed +if [ -n "${NO_SOURCE_REPOSITORIES:-}" ]; then + exit 0 +fi + # If the old cache exists, move it to the new name function make_new_cache(){ local OLD_CACHE_BASE=$1