From b57714af75e5332014eae8234a7660aa8f6644e9 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Wed, 25 Sep 2019 04:05:18 +0000 Subject: [PATCH] Use $YUM instead of direct calls in more places A few places we either assume centos uses "yum" directly, or have switching based on the distro type. In both cases, we can use ${YUM} directly to avoid ambiguity Change-Id: I71095a9bd1862f8956b5982fbbb3e1d213926c14 --- .../elements/epel/pre-install.d/05-rpm-epel-release | 8 ++++++-- .../rpm-distro/pre-install.d/01-override-yum-arch | 4 ++-- .../elements/yum/post-install.d/99-reset-yum-conf | 2 +- .../elements/yum/pre-install.d/01-yum-keepcache | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/diskimage_builder/elements/epel/pre-install.d/05-rpm-epel-release b/diskimage_builder/elements/epel/pre-install.d/05-rpm-epel-release index 22734afa..a4eef6fc 100755 --- a/diskimage_builder/elements/epel/pre-install.d/05-rpm-epel-release +++ b/diskimage_builder/elements/epel/pre-install.d/05-rpm-epel-release @@ -8,7 +8,7 @@ set -o pipefail if [[ ${DISTRO_NAME} =~ "centos" ]]; then # Centos has "epel-release" in extras, which is default enabled. - yum install -y epel-release + ${YUM} install -y epel-release else # For RHEL, we have to scrape the download page to find the latest # release and install that @@ -34,7 +34,11 @@ else fi if [ ${DIB_EPEL_DISABLED:-0} -ne 0 ]; then - yum-config-manager --disable epel + if [[ ${YUM} == "dnf" ]]; then + dnf config-manager --set-disabled epel + else + yum-config-manager --disable epel + fi fi DIB_EPEL_MIRROR=${DIB_EPEL_MIRROR:-} diff --git a/diskimage_builder/elements/rpm-distro/pre-install.d/01-override-yum-arch b/diskimage_builder/elements/rpm-distro/pre-install.d/01-override-yum-arch index 3b20ff63..88fa480b 100755 --- a/diskimage_builder/elements/rpm-distro/pre-install.d/01-override-yum-arch +++ b/diskimage_builder/elements/rpm-distro/pre-install.d/01-override-yum-arch @@ -28,7 +28,7 @@ else exit 1 fi -if [[ $DISTRO_NAME == "fedora" ]]; then +if [[ ${YUM} == "dnf" ]]; then mkdir -p /etc/dnf/vars echo $basearch > /etc/dnf/vars/basearch echo $arch > /etc/dnf/vars/arch @@ -43,5 +43,5 @@ if [[ ${DISTRO_NAME} =~ "centos" ]]; then else contentdir=altarch fi - echo $contentdir > /etc/yum/vars/contentdir + echo $contentdir > /etc/${YUM}/vars/contentdir fi diff --git a/diskimage_builder/elements/yum/post-install.d/99-reset-yum-conf b/diskimage_builder/elements/yum/post-install.d/99-reset-yum-conf index 6a6b741e..d4fad1cc 100755 --- a/diskimage_builder/elements/yum/post-install.d/99-reset-yum-conf +++ b/diskimage_builder/elements/yum/post-install.d/99-reset-yum-conf @@ -6,7 +6,7 @@ fi set -eu set -o pipefail -if [[ $DISTRO_NAME == "fedora" && $DIB_RELEASE -ge 22 ]]; then +if [[ ${YUM} == "dnf" ]]; then cfg=/etc/dnf/dnf.conf cachedir=/var/cache/dnf else diff --git a/diskimage_builder/elements/yum/pre-install.d/01-yum-keepcache b/diskimage_builder/elements/yum/pre-install.d/01-yum-keepcache index 8105ce5e..d471d0cc 100755 --- a/diskimage_builder/elements/yum/pre-install.d/01-yum-keepcache +++ b/diskimage_builder/elements/yum/pre-install.d/01-yum-keepcache @@ -6,7 +6,7 @@ fi set -eu set -o pipefail -if [[ $DISTRO_NAME == "fedora" && $DIB_RELEASE -ge 22 ]]; then +if [[ ${YUM} == "dnf" ]]; then # dnf is slightly different; doesn't have these by default cfg=/etc/dnf/dnf.conf echo "keepcache=1" >> $cfg