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
This commit is contained in:
Ben Nemec 2014-10-15 12:07:33 -04:00
parent 71d4da7d7e
commit 0eccd2808c
3 changed files with 14 additions and 1 deletions

View File

@ -3,4 +3,8 @@
set -eu set -eu
set -o pipefail 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

View File

@ -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 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 to http://git.openstack.org/openstack/nova.git will result in use of the
https://github.com/openstack/nova.git repository. 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.

View File

@ -3,6 +3,11 @@
set -eu set -eu
set -o pipefail 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 # If the old cache exists, move it to the new name
function make_new_cache(){ function make_new_cache(){
local OLD_CACHE_BASE=$1 local OLD_CACHE_BASE=$1