diff --git a/elements/yum/README.rst b/elements/yum/README.rst index b1d45e64..335b36b8 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 aa2f62f3..7795146d 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 5d8556a1..b5b6e98c 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