From 65e4fcb5e058d37056e5a0451200a67c84e6eb1d Mon Sep 17 00:00:00 2001 From: Derek Higgins Date: Wed, 16 Sep 2015 10:45:02 +0100 Subject: [PATCH] Add centos7 support for DIB_DISTRIBUTION_MIRROR The ability to specify a distro mirror is part of other distro elements, centos should have one too. Change-Id: I4cc9062ff92fbe301f414820798e08c66e9793f7 --- elements/centos7/README.rst | 8 ++++++++ .../centos7/pre-install.d/01-set-centos-mirror | 15 +++++++++++++++ 2 files changed, 23 insertions(+) create mode 100755 elements/centos7/pre-install.d/01-set-centos-mirror diff --git a/elements/centos7/README.rst b/elements/centos7/README.rst index 64c172681..4adb4f1d9 100644 --- a/elements/centos7/README.rst +++ b/elements/centos7/README.rst @@ -4,3 +4,11 @@ centos7 Use Centos 7 cloud images as the baseline for built disk images. For further details see the redhat-common README. + +DIB_DISTRIBUTION_MIRROR: + :Required: No + :Default: None + :Description: To use a CentOS Yum mirror, set this variable to the mirror URL + before running bin/disk-image-create. This URL should point to + the directory containing the ``5/6/7`` directories. + :Example: ``DIB\_DISTRIBUTION\_MIRROR=http://amirror.com/centos`` diff --git a/elements/centos7/pre-install.d/01-set-centos-mirror b/elements/centos7/pre-install.d/01-set-centos-mirror new file mode 100755 index 000000000..8e2007a92 --- /dev/null +++ b/elements/centos7/pre-install.d/01-set-centos-mirror @@ -0,0 +1,15 @@ +#!/bin/bash + +if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then + set -x +fi +set -eu +set -o pipefail + +DIB_DISTRIBUTION_MIRROR=${DIB_DISTRIBUTION_MIRROR:-} + +[ -n "$DIB_DISTRIBUTION_MIRROR" ] || exit 0 + +# Only set the mirror for the Base, Extras and Updates repositories +# The others arn't enabled and do not exist on all mirrors +sed -e "s|^#baseurl=http://mirror.centos.org/centos|baseurl=$DIB_DISTRIBUTION_MIRROR|;/^mirrorlist=/d" -i /etc/yum.repos.d/CentOS-Base.repo