From 296c81b9ca2c71368d29a8d6638431742865e8f7 Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Mon, 30 Aug 2021 10:20:16 +1200 Subject: [PATCH] Add DIB_YUM_REPO_PACKAGE as an alternative to DIB_YUM_REPO_CONF A custom yum repository can now be configured by defining `DIB_YUM_REPO_PACKAGE` as a yum available package or a URL to an rpm file. This package can install repo files with any associated keys and certificates. A good example of such a package upstream is rdo-release[1] which includes multiple repo files, the repo keys, and a root certificate. This makes these repos impractical to install via DIB_YUM_REPO_CONF. Downstream, repo packages like this a frequently used to bootstrap development builds of RHEL with development repos. [1] https://www.rdoproject.org/repos/rdo-release.rpm Change-Id: I2832e723998c9bd7635cdf7541a4c20eff6294d2 --- .../elements/rhel/environment.d/11-yum-dnf.bash | 6 +++--- diskimage_builder/elements/yum/README.rst | 4 ++++ .../yum/pre-install.d/00-install-repo-package | 11 +++++++++++ releasenotes/notes/repo-package-20fe407795bffd01.yaml | 7 +++++++ 4 files changed, 25 insertions(+), 3 deletions(-) create mode 100755 diskimage_builder/elements/yum/pre-install.d/00-install-repo-package create mode 100644 releasenotes/notes/repo-package-20fe407795bffd01.yaml diff --git a/diskimage_builder/elements/rhel/environment.d/11-yum-dnf.bash b/diskimage_builder/elements/rhel/environment.d/11-yum-dnf.bash index e3e648dc..0ab96fdd 100644 --- a/diskimage_builder/elements/rhel/environment.d/11-yum-dnf.bash +++ b/diskimage_builder/elements/rhel/environment.d/11-yum-dnf.bash @@ -1,7 +1,7 @@ # since RHEL8, dnf is the yum replacement. -if [[ ${DIB_RELEASE} == '8' ]]; then - export YUM=dnf -elif [[ ${DIB_RELEASE} == '7' ]]; then +if [[ $DIB_RELEASE == "7" ]]; then export YUM=yum +else + export YUM=dnf fi diff --git a/diskimage_builder/elements/yum/README.rst b/diskimage_builder/elements/yum/README.rst index 6c471c89..c4442eef 100644 --- a/diskimage_builder/elements/yum/README.rst +++ b/diskimage_builder/elements/yum/README.rst @@ -18,6 +18,10 @@ 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. +The yum repository can also be configured by defining `DIB_YUM_REPO_PACKAGE` as +a yum available package or a URL to an rpm file. This package can install repo +files with any associated keys and certificates. + Environment Variables for Module Selection during Image Creation ---------------------------------------------------------------- The following environment variable is used to select module streams to be diff --git a/diskimage_builder/elements/yum/pre-install.d/00-install-repo-package b/diskimage_builder/elements/yum/pre-install.d/00-install-repo-package new file mode 100755 index 00000000..1a6ae1aa --- /dev/null +++ b/diskimage_builder/elements/yum/pre-install.d/00-install-repo-package @@ -0,0 +1,11 @@ +#!/bin/bash + +if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then + set -x +fi +set -eu +set -o pipefail + +if [ -n "${DIB_YUM_REPO_PACKAGE:-}" ] ; then + rpm -ivh ${DIB_YUM_REPO_PACKAGE} +fi diff --git a/releasenotes/notes/repo-package-20fe407795bffd01.yaml b/releasenotes/notes/repo-package-20fe407795bffd01.yaml new file mode 100644 index 00000000..bf9ee823 --- /dev/null +++ b/releasenotes/notes/repo-package-20fe407795bffd01.yaml @@ -0,0 +1,7 @@ +--- +features: + - | + A custom yum repository can now be configured by defining + `DIB_YUM_REPO_PACKAGE` as a yum available package or a URL to an rpm file. + This package can install repo files with any associated keys and + certificates.