From 8b0111477e49cd733d0c27cc25c00a1a7cdf964b Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Wed, 10 Oct 2018 10:50:34 +1100 Subject: [PATCH] Set EPEL mirror during openstack-ci-mirrors We want to set DIB_EPEL_MIRROR for the epel element, which means we need access to the CI mirror info script in the chroot. Copy it into the temp directory with extra-data.d and update the environment file to find it. Change-Id: Ia12f0cbdeb194eef3155497ceb5ffc4a452aad76 --- .../11-dib-distribution-mirror.bash | 58 +++++++++++-------- .../extra-data.d/75-copy-mirror-info | 17 ++++++ 2 files changed, 52 insertions(+), 23 deletions(-) create mode 100755 diskimage_builder/elements/openstack-ci-mirrors/extra-data.d/75-copy-mirror-info diff --git a/diskimage_builder/elements/openstack-ci-mirrors/environment.d/11-dib-distribution-mirror.bash b/diskimage_builder/elements/openstack-ci-mirrors/environment.d/11-dib-distribution-mirror.bash index 1d94de7b8..61d79ca70 100644 --- a/diskimage_builder/elements/openstack-ci-mirrors/environment.d/11-dib-distribution-mirror.bash +++ b/diskimage_builder/elements/openstack-ci-mirrors/environment.d/11-dib-distribution-mirror.bash @@ -1,30 +1,41 @@ -# Set DIB_DISTRIBUTION_MIRROR if running in openstack gate +# Set DIB_DISTRIBUTION_MIRROR and related if running in openstack gate + +# don't spam logs with this source +_xtrace=$(set +o | grep xtrace) +set +o xtrace + if [ -f /etc/ci/mirror_info.sh ]; then + # outside chroot + mirror_info=/etc/ci/mirror_info.sh +elif [ -f /tmp/in_target.d/mirror_info.sh ]; then + # inside chroot + mirror_info=/tmp/in_target.d/mirror_info.sh +else + echo "No mirror file found. Not an OpenStack CI node?" + return 0 +fi - # don't spam logs with this source - _xtrace=$(set +o | grep xtrace) - set +o xtrace - source /etc/ci/mirror_info.sh - $_xtrace +source $mirror_info +$_xtrace - # note 11- is after 10- which is where DISTRO_NAME is set usually - - if [[ "${DISTRO_NAME}" == "ubuntu" ]]; then - export DIB_DISTRIBUTION_MIRROR=$NODEPOOL_UBUNTU_MIRROR - export DIB_DEBOOTSTRAP_EXTRA_ARGS+=" --no-check-gpg" - elif [[ "${DISTRO_NAME}" == "debian" ]]; then - export DIB_DISTRIBUTION_MIRROR=$NODEPOOL_DEBIAN_MIRROR - export DIB_DEBOOTSTRAP_EXTRA_ARGS+=" --no-check-gpg" - elif [[ "${DISTRO_NAME}" == "fedora" ]]; then - export DIB_DISTRIBUTION_MIRROR=$NODEPOOL_FEDORA_MIRROR - elif [[ "${DISTRO_NAME}" == "centos" ]]; then - export DIB_DISTRIBUTION_MIRROR=$NODEPOOL_CENTOS_MIRROR - elif [[ "${DISTRO_NAME}" == "centos7" ]]; then - export DIB_DISTRIBUTION_MIRROR=$NODEPOOL_CENTOS_MIRROR - elif [[ "${DISTRO_NAME}" == "opensuse" ]]; then - export DIB_DISTRIBUTION_MIRROR=$NODEPOOL_OPENSUSE_MIRROR - fi +# note 11- is after 10- which is where DISTRO_NAME is set usually +if [[ "${DISTRO_NAME}" == "ubuntu" ]]; then + export DIB_DISTRIBUTION_MIRROR=$NODEPOOL_UBUNTU_MIRROR + export DIB_DEBOOTSTRAP_EXTRA_ARGS+=" --no-check-gpg" +elif [[ "${DISTRO_NAME}" == "debian" ]]; then + export DIB_DISTRIBUTION_MIRROR=$NODEPOOL_DEBIAN_MIRROR + export DIB_DEBOOTSTRAP_EXTRA_ARGS+=" --no-check-gpg" +elif [[ "${DISTRO_NAME}" == "fedora" ]]; then + export DIB_DISTRIBUTION_MIRROR=$NODEPOOL_FEDORA_MIRROR +elif [[ "${DISTRO_NAME}" == "centos" ]]; then + export DIB_DISTRIBUTION_MIRROR=$NODEPOOL_CENTOS_MIRROR + export DIB_EPEL_MIRROR=$NODEPOOL_EPEL_MIRROR +elif [[ "${DISTRO_NAME}" == "centos7" ]]; then + export DIB_DISTRIBUTION_MIRROR=$NODEPOOL_CENTOS_MIRROR + export DIB_EPEL_MIRROR=$NODEPOOL_EPEL_MIRROR +elif [[ "${DISTRO_NAME}" == "opensuse" ]]; then + export DIB_DISTRIBUTION_MIRROR=$NODEPOOL_OPENSUSE_MIRROR fi # Infra doesn't mirror non-free repos, so instruct to ignore these @@ -42,3 +53,4 @@ if [[ -d ${WORKSPACE:-/not/a/path/}/dib-mirror ]]; then fi fi + diff --git a/diskimage_builder/elements/openstack-ci-mirrors/extra-data.d/75-copy-mirror-info b/diskimage_builder/elements/openstack-ci-mirrors/extra-data.d/75-copy-mirror-info new file mode 100755 index 000000000..15906a90b --- /dev/null +++ b/diskimage_builder/elements/openstack-ci-mirrors/extra-data.d/75-copy-mirror-info @@ -0,0 +1,17 @@ +#!/bin/bash + +if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then + set -x +fi +set -eu +set -o pipefail + +# On infra nodes, make a copy of the mirror_info.sh script inside the +# chroot for elements running in chroot like EPEL that want to +# reference it. +mirror_info=/etc/ci/mirror_info.sh + +if [ -f $mirror_info ]; then + cp /etc/ci/mirror_info.sh $TMP_HOOKS_PATH/mirror_info.sh +fi +