From cd1965f7b7e5d6a7ce31fdb816af00ad93166d5d Mon Sep 17 00:00:00 2001 From: Gregory Haynes Date: Thu, 8 Dec 2016 15:30:56 -0800 Subject: [PATCH] Allow disto-specific mirror settings Most of our distros support DIB_DISTRIBUTION_MIRROR for setting the mirror to be used when building. This has a major downside where if someone would like to create a static configuration for building various distro images it cannot set DIB_DISTRIBUTION_MIRROR (think of the case where we want to run our tests). By adding support for DIB_$DISTRO_DISTRIBUTION_MIRROR this problem is resolved. Change-Id: I92964b17ec3e47cf97e3a3091f054b2a205ac768 --- elements/centos/environment.d/10-centos6-distro-name.bash | 4 ++++ elements/centos/pre-install.d/02-yum-repos | 4 +++- elements/centos7/environment.d/10-centos7-distro-name.bash | 4 ++++ elements/debian-minimal/environment.d/10-debian-minimal.bash | 5 +++++ elements/fedora/environment.d/10-fedora-distro-name.bash | 3 +++ .../ubuntu-minimal/environment.d/10-ubuntu-distro-name.bash | 4 ++++ 6 files changed, 23 insertions(+), 1 deletion(-) diff --git a/elements/centos/environment.d/10-centos6-distro-name.bash b/elements/centos/environment.d/10-centos6-distro-name.bash index c65178fd..4f38ab2e 100644 --- a/elements/centos/environment.d/10-centos6-distro-name.bash +++ b/elements/centos/environment.d/10-centos6-distro-name.bash @@ -3,3 +3,7 @@ export DIB_RELEASE=${DIB_RELEASE:-GenericCloud} # Useful for elements that work with fedora (dnf) & centos export YUM=${YUM:-yum} + +if [ -n "${DIB_CENTOS_DISTRIBUTION_MIRROR:-}" ]; then + export DIB_DISTRIBUTION_MIRROR=$DIB_CENTOS_DISTRIBUTION_MIRROR +fi diff --git a/elements/centos/pre-install.d/02-yum-repos b/elements/centos/pre-install.d/02-yum-repos index fb5a0b9b..099a3eb6 100755 --- a/elements/centos/pre-install.d/02-yum-repos +++ b/elements/centos/pre-install.d/02-yum-repos @@ -6,10 +6,12 @@ fi set -eu set -o pipefail +DIB_DISTRIBUTION_MIRROR=${DIB_DISTRIBUTION_MIRROR:-http://mirror.centos.org/centos} + cat << EOF > /etc/yum.repos.d/centos6-latest.repo [rhel6] name=centos6 -baseurl=http://mirror.centos.org/centos/6/os/x86_64/ +baseurl=$DIB_DISTRIBUTION_MIRROR/6/os/x86_64/ enabled=1 metadata_expire=7d gpgcheck=0 diff --git a/elements/centos7/environment.d/10-centos7-distro-name.bash b/elements/centos7/environment.d/10-centos7-distro-name.bash index c9476d07..c0c42a51 100644 --- a/elements/centos7/environment.d/10-centos7-distro-name.bash +++ b/elements/centos7/environment.d/10-centos7-distro-name.bash @@ -3,3 +3,7 @@ export DIB_RELEASE=GenericCloud # Useful for elements that work with fedora (dnf) & centos export YUM=${YUM:-yum} + +if [ -n "${DIB_CENTOS_DISTRIBUTION_MIRROR:-}" ]; then + export DIB_DISTRIBUTION_MIRROR=$DIB_CENTOS_DISTRIBUTION_MIRROR +fi diff --git a/elements/debian-minimal/environment.d/10-debian-minimal.bash b/elements/debian-minimal/environment.d/10-debian-minimal.bash index 13ac22fc..26f51599 100644 --- a/elements/debian-minimal/environment.d/10-debian-minimal.bash +++ b/elements/debian-minimal/environment.d/10-debian-minimal.bash @@ -1,6 +1,11 @@ export DISTRO_NAME=debian export DIB_RELEASE=${DIB_RELEASE:-stable} + +if [ -n "${DIB_DEBIAN_DISTRIBUTION_MIRROR:-}" ]; then + DIB_DISTRIBUTION_MIRROR=$DIB_DEBIAN_DISTRIBUTION_MIRROR +fi export DIB_DISTRIBUTION_MIRROR=${DIB_DISTRIBUTION_MIRROR:-http://ftp.us.debian.org/debian} + export DIB_DEBIAN_COMPONENTS=${DIB_DEBIAN_COMPONENTS:-main} export DIB_DEBIAN_COMPONENTS_WS=${DIB_DEBIAN_COMPONENTS//,/ } diff --git a/elements/fedora/environment.d/10-fedora-distro-name.bash b/elements/fedora/environment.d/10-fedora-distro-name.bash index 3477f1ea..07b4e60e 100644 --- a/elements/fedora/environment.d/10-fedora-distro-name.bash +++ b/elements/fedora/environment.d/10-fedora-distro-name.bash @@ -1,2 +1,5 @@ export DISTRO_NAME=fedora export DIB_RELEASE=${DIB_RELEASE:-24} +if [ -n "${DIB_FEDORA_DISTRIBUTION_MIRROR:-}" ]; then + export DIB_DISTRIBUTION_MIRROR=$DIB_FEDORA_DISTRIBUTION_MIRROR +fi diff --git a/elements/ubuntu-minimal/environment.d/10-ubuntu-distro-name.bash b/elements/ubuntu-minimal/environment.d/10-ubuntu-distro-name.bash index e9ae083e..829952b3 100644 --- a/elements/ubuntu-minimal/environment.d/10-ubuntu-distro-name.bash +++ b/elements/ubuntu-minimal/environment.d/10-ubuntu-distro-name.bash @@ -1,4 +1,8 @@ export DISTRO_NAME=ubuntu export DIB_RELEASE=${DIB_RELEASE:-xenial} export DIB_DEBIAN_COMPONENTS=${DIB_DEBIAN_COMPONENTS:-main,restricted,universe} + +if [ -n "${DIB_UBUNTU_DISTRIBUTION_MIRROR:-}" ]; then + DIB_DISTRIBUTION_MIRROR=$DIB_UBUNTU_DISTRIBUTION_MIRROR +fi export DIB_DISTRIBUTION_MIRROR=${DIB_DISTRIBUTION_MIRROR:-http://archive.ubuntu.com/ubuntu}