From cb216b6cd861a9646c3bff295d82306eff23bd2a Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Thu, 16 Mar 2023 13:40:59 +1300 Subject: [PATCH] Add DIB_IPA_HARDWARE_RDO to define repo behaviour Currently the latest RDO repo is installed on centos9 for the python-hardware package. This would not be appropriate in the following cases: * When repos are copied in from the host via DIB_YUM_REPO_CONF * When another element is responsible for setting up repos This change adds environment variable DIB_IPA_HARDWARE_RDO, which will only be set to `1` on centos9, when DIB_YUM_REPO_CONF isn't set, and when the user hasn't explicitly set DIB_IPA_HARDWARE_RDO. This retains the current default behaviour of just working, while giving flexibility for repos to be set up another way. Change-Id: I1cc0b9833baf642866e9762c6bae44360bffe20d --- dib/extra-hardware/README.rst | 2 ++ .../environment.d/10-enable-rdo-deps.bash | 14 ++++++++++++++ .../pre-install.d/10-enable-rdo-deps | 7 +++++-- 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100755 dib/extra-hardware/environment.d/10-enable-rdo-deps.bash diff --git a/dib/extra-hardware/README.rst b/dib/extra-hardware/README.rst index 00d7c85..7b16fe6 100644 --- a/dib/extra-hardware/README.rst +++ b/dib/extra-hardware/README.rst @@ -19,3 +19,5 @@ doing a source-based installation: * ``DIB_IPA_HARDWARE_VERSION`` the version of the ``hardware`` package to install when ``DIB_IPA_HARDWARE_PACKAGE`` is unset. If unset, the latest version will be installed. +* ``DIB_IPA_HARDWARE_RDO`` set to ``0`` to prevent the latest RDO package repositories + being installed on CentOS-9-Stream (ignored when ``DIB_YUM_REPO_CONF`` is set). diff --git a/dib/extra-hardware/environment.d/10-enable-rdo-deps.bash b/dib/extra-hardware/environment.d/10-enable-rdo-deps.bash new file mode 100755 index 0000000..ed75a30 --- /dev/null +++ b/dib/extra-hardware/environment.d/10-enable-rdo-deps.bash @@ -0,0 +1,14 @@ + +if [[ "${DISTRO_NAME}${DIB_RELEASE}" =~ "centos9" ]]; then + + if [ -n "${DIB_YUM_REPO_CONF:-}" ] ; then + # Always disable if DIB_YUM_REPO_CONF is defined + export DIB_IPA_HARDWARE_RDO=0 + else + # Default to enabled, but overridable by the host + export DIB_IPA_HARDWARE_RDO=${DIB_IPA_HARDWARE_RDO:-1} + fi +else + # Always disable if not centos-9 + export DIB_IPA_HARDWARE_RDO=0 +fi diff --git a/dib/extra-hardware/pre-install.d/10-enable-rdo-deps b/dib/extra-hardware/pre-install.d/10-enable-rdo-deps index 2bb9168..03ca8b3 100755 --- a/dib/extra-hardware/pre-install.d/10-enable-rdo-deps +++ b/dib/extra-hardware/pre-install.d/10-enable-rdo-deps @@ -1,6 +1,9 @@ #!/bin/bash -# It enables RDO deps repo for CentOS Stream 9 +# It enables RDO deps repo when DIB_IPA_HARDWARE_RDO=1 -if [[ "${DISTRO_NAME}${DIB_RELEASE}" =~ "centos9" ]]; then +set -eux +set -o pipefail + +if [ ${DIB_IPA_HARDWARE_RDO:-0} -ne 0 ]; then curl -o /etc/yum.repos.d/dlrn-deps.repo https://trunk.rdoproject.org/centos9-master/dlrn-deps.repo fi