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 5a8cf9ea..cccd4ae9 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 @@ -34,9 +34,9 @@ else fi if [ ${DIB_EPEL_DISABLED:-0} -ne 0 ]; then - if [[ ${YUM} == "dnf" ]]; then + if [[ ${YUM} =~ "dnf" ]]; then rpm -q dnf-plugins-core || dnf install -y dnf-plugins-core - dnf config-manager --set-disabled "epel*" + ${YUM} config-manager --set-disabled "epel*" else # Cannot rely on package-installs, it is executed later rpm -q yum-utils || yum install -y yum-utils diff --git a/diskimage_builder/elements/redhat-common/finalise.d/01-clean-old-kernels b/diskimage_builder/elements/redhat-common/finalise.d/01-clean-old-kernels index 1aa4d4c4..5251e871 100755 --- a/diskimage_builder/elements/redhat-common/finalise.d/01-clean-old-kernels +++ b/diskimage_builder/elements/redhat-common/finalise.d/01-clean-old-kernels @@ -13,12 +13,12 @@ fi YUM=${YUM:-yum} -if [[ ${YUM} == "dnf" ]]; then +if [[ ${YUM} =~ "dnf" ]]; then # cribbed from # http://dnf.readthedocs.org/en/latest/cli_vs_yum.html _old_kernels="$(dnf repoquery --installonly --latest-limit=-1 -q)" if [[ -n "${_old_kernels}" ]]; then - dnf remove -y --setopt=protect_running_kernel=False ${_old_kernels} + ${YUM} remove -y --setopt=protect_running_kernel=False ${_old_kernels} fi else install-packages yum-utils 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 44a99ee2..e61ac2f7 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 @@ -25,7 +25,7 @@ else exit 1 fi -if [[ ${YUM} == "dnf" ]]; then +if [[ ${YUM} =~ "dnf" ]]; then mkdir -p /etc/dnf/vars echo $basearch > /etc/dnf/vars/basearch echo $arch > /etc/dnf/vars/arch diff --git a/diskimage_builder/elements/yum/bin/install-packages b/diskimage_builder/elements/yum/bin/install-packages index 04564398..da1bfcdf 100755 --- a/diskimage_builder/elements/yum/bin/install-packages +++ b/diskimage_builder/elements/yum/bin/install-packages @@ -110,8 +110,8 @@ if [ -n "$WHITELIST" ]; then if [ "$ACTION" == "download" ]; then mkdir -p $DOWNLOAD_PATH - if [ ${YUM} == "dnf" ]; then - dnf download --destdir=$DOWNLOAD_PATH $PKGS + if [ ${YUM} =~ "dnf" ]; then + ${YUM} download --destdir=$DOWNLOAD_PATH $PKGS else # note; you don't want to use yum --download only here. # Firstly that only puts things in the yum cache @@ -135,12 +135,18 @@ if [ -n "$WHITELIST" ]; then # [1] https://bugzilla.redhat.com/show_bug.cgi?id=965567 set -o xtrace - ${YUM} -v -y $ACTION $EXTRA_ARGS $PKGS + if [ "$YUM" == "microdnf" ]; then + EXTRA_ARGS=" " + else + EXTRA_ARGS="-v" + fi + + ${YUM} -y $ACTION $EXTRA_ARGS $PKGS if [ "$ACTION" == "install" ]; then - if [ ${YUM} == "dnf" ]; then + if [ ${YUM} =~ "dnf" ]; then # Make sure dnf won't autoremove these packages - dnf mark install $PKGS + ${YUM} mark install $PKGS fi fi $_xtrace 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 df2022e7..3702a59c 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 @@ -7,12 +7,12 @@ set -eu set -o pipefail if [[ -n ${DIB_YUM_DNF_CONTENTDIR:-''} ]]; then - sudo mv /etc/dnf/vars/contentdir.bak /etc/dnf/vars/contentdir - sudo sed -i -e 's,^#mirrorlist,mirrorlist,' -e 's,^baseurl,#baseurl,' /etc/yum.repos.d/*.repo + mv /etc/dnf/vars/contentdir.bak /etc/dnf/vars/contentdir + sed -i -e 's,^#mirrorlist,mirrorlist,' -e 's,^baseurl,#baseurl,' /etc/yum.repos.d/*.repo fi -if [[ ${YUM} == "dnf" ]]; 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/00-01-yum-keepcache b/diskimage_builder/elements/yum/pre-install.d/00-01-yum-keepcache index d471d0cc..46604ae1 100755 --- a/diskimage_builder/elements/yum/pre-install.d/00-01-yum-keepcache +++ b/diskimage_builder/elements/yum/pre-install.d/00-01-yum-keepcache @@ -6,7 +6,7 @@ fi set -eu set -o pipefail -if [[ ${YUM} == "dnf" ]]; then +if [[ ${YUM} =~ "dnf" ]]; then # dnf is slightly different; doesn't have these by default cfg=/etc/dnf/dnf.conf echo "keepcache=1" >> $cfg diff --git a/diskimage_builder/elements/yum/pre-install.d/01-00-centos-python3 b/diskimage_builder/elements/yum/pre-install.d/01-00-centos-python3 index d0233530..84ace192 100755 --- a/diskimage_builder/elements/yum/pre-install.d/01-00-centos-python3 +++ b/diskimage_builder/elements/yum/pre-install.d/01-00-centos-python3 @@ -20,8 +20,8 @@ if [[ ${DISTRO_NAME} =~ (centos|rhel) && ${DIB_RELEASE} == 7 ]]; then yum install -y ${DIB_CENTOS_7_PREINSTALL_EPEL_URL_PACKAGE:-https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm} yum install -y python36-PyYAML yum remove -y epel-release -elif [[ ${DISTRO_NAME} =~ (centos|rhel) && ${DIB_RELEASE} > 7 ]]; then +elif [[ ${DISTRO_NAME} =~ (centos|rhel|rocky) && ${DIB_RELEASE} > 7 ]]; then # For 8 and above ensure the "user" python3 package is installed # so we have /usr/bin/python3 and pyyaml. - dnf install -y python3 python3-pyyaml + ${YUM} install -y python3 python3-pyyaml fi diff --git a/diskimage_builder/elements/yum/pre-install.d/01-module-configuration b/diskimage_builder/elements/yum/pre-install.d/01-module-configuration index b498e478..b0d8e158 100755 --- a/diskimage_builder/elements/yum/pre-install.d/01-module-configuration +++ b/diskimage_builder/elements/yum/pre-install.d/01-module-configuration @@ -16,7 +16,7 @@ set -o pipefail export DIB_DNF_MODULE_STREAMS=${DIB_DNF_MODULE_STREAMS:-} -if [ "${YUM}" == "dnf" ]; then +if [ "${YUM}" =~ "dnf" ]; then for m in ${DIB_DNF_MODULE_STREAMS}; do ${YUM} -y module disable ${m/:*/} ${YUM} -y module enable ${m}