From aee9cc0ce686647d1c4f8176427224d116adb753 Mon Sep 17 00:00:00 2001 From: James Slagle Date: Fri, 22 May 2015 15:18:15 -0700 Subject: [PATCH] Make $DIB_YUM_REPO_CONF accept a list of repo files It's useful to be able to pass in multiple yum repo configuration files via $DIB_YUM_REPO_CONF, not just a single one. Change-Id: I43722229a2df58be55bdb2b50c253e957b18e6fe --- elements/yum/README.rst | 9 +++++---- .../yum/cleanup.d/99-remove-yum-repo-conf | 10 +++++++++- elements/yum/extra-data.d/99-yum-repo-conf | 20 ++++++++++++------- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/elements/yum/README.rst b/elements/yum/README.rst index b1d45e641..335b36b8f 100644 --- a/elements/yum/README.rst +++ b/elements/yum/README.rst @@ -12,7 +12,8 @@ increases image building speed when building multiple images, especially on slow connections. This is more effective than using an HTTP proxy as a yum cache since the same rpm from different mirrors is often requested. -A custom yum repository configuration can also be applied by defining -`DIB_YUM_REPO_CONF` to the path to a repo configuration file. The file will -be copied to /etc/yum.repos.d/dib-yum-repo-conf.repo during the image build, -and then removed at the end of the build. +Custom yum repository configurations can also be applied by defining +`DIB_YUM_REPO_CONF` to a space separated list of repo configuration files. The +files will be copied to /etc/yum.repos.d/ during the image build, and then +removed at the end of the build. Each repo file should be named differently to +avoid a filename collision. diff --git a/elements/yum/cleanup.d/99-remove-yum-repo-conf b/elements/yum/cleanup.d/99-remove-yum-repo-conf index aa2f62f31..7795146d9 100755 --- a/elements/yum/cleanup.d/99-remove-yum-repo-conf +++ b/elements/yum/cleanup.d/99-remove-yum-repo-conf @@ -6,4 +6,12 @@ fi set -eu set -o pipefail -sudo rm -f $TMP_MOUNT_PATH/etc/yum.repos.d/dib-yum-repo-conf.repo +# exit directly if DIB_YUM_REPO_CONF is not defined properly +if [ -z "${DIB_YUM_REPO_CONF:-}" ] ; then + echo "DIB_YUM_REPO_CONF is not set - no repo configurations will be cleaned up" + exit 0 +fi + +for file in $DIB_YUM_REPO_CONF; do + sudo rm -f $TMP_MOUNT_PATH/etc/yum.repos.d/$(basename $file) +done diff --git a/elements/yum/extra-data.d/99-yum-repo-conf b/elements/yum/extra-data.d/99-yum-repo-conf index 5d8556a17..b5b6e98c3 100755 --- a/elements/yum/extra-data.d/99-yum-repo-conf +++ b/elements/yum/extra-data.d/99-yum-repo-conf @@ -1,5 +1,5 @@ #!/bin/bash -# Add an additional yum repo configuration with $DIB_YUM_REPO_CONF +# Add additional yum repo configuration(s) with $DIB_YUM_REPO_CONF if [ ${DIB_DEBUG_TRACE:-1} -gt 0 ]; then set -x @@ -11,11 +11,17 @@ set -o pipefail if [ -z "${DIB_YUM_REPO_CONF:-}" ] ; then echo "DIB_YUM_REPO_CONF is not set - no repo configuration will be copied in" exit 0 -elif [ ! -f "$DIB_YUM_REPO_CONF" ] ; then - echo "DIB_YUM_REPO_CONF is not a valid yum repo configuration file." - echo "You should assign a proper yum repo configuration file in DIB_YUM_REPO_CONF" - exit 1 fi -# copy the yum repo configuration -sudo cp -L -f $DIB_YUM_REPO_CONF $TMP_MOUNT_PATH/etc/yum.repos.d/dib-yum-repo-conf.repo +for file in $DIB_YUM_REPO_CONF; do + if [ ! -f $file ]; then + echo "$file is not a valid yum repo configuration file." + echo "You should assign a list of proper yum repo configuration" + echo "files in DIB_YUM_REPO_CONF." + exit 1 + fi + + # copy the yum repo configuration + sudo cp -L -f $file $TMP_MOUNT_PATH/etc/yum.repos.d + +done