From 5f475841969cb49e9f7b234938b79b8f0da6f0eb Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Fri, 27 Aug 2021 16:36:15 +1000 Subject: [PATCH] yum-minimal: use DNF tools on host The latest Debian bullseye release doesn't provide yum any more, only DNF. This breaks the minimal builds that are using on-host yum tools to start the chroot. Probe for yumdownloader, and if it's not there, use DNF. Note this requires "dnf download" which may not be packaged. See I21cfbd3935e48be4b92591ea36c7eed301230753 for a sample work-around that installs this plugin in the nodepool-builder container. Change-Id: Ia7f1e4d115cc67c378d865d91af94a07b8cdc6cc --- bindep.txt | 5 +++-- .../elements/yum-minimal/root.d/08-yum-chroot | 16 +++++++++++++--- .../notes/yum-minimal-dnf-63305c349bcccdd4.yaml | 6 ++++++ 3 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 releasenotes/notes/yum-minimal-dnf-63305c349bcccdd4.yaml diff --git a/bindep.txt b/bindep.txt index 30a0f027..d29cddbd 100644 --- a/bindep.txt +++ b/bindep.txt @@ -19,11 +19,12 @@ gnupg2 [!platform:redhat !platform:ubuntu-trusty !platform:suse] # ubuntu apt-transport-https [platform:dpkg] inetutils-ping [platform:dpkg] -python-lzma [platform:dpkg !platform:ubuntu-focal] +python-lzma [platform:dpkg !platform:ubuntu-focal !platform:debian-bullseye] qemu-utils [platform:dpkg] rpm [platform:dpkg] uuid-runtime [platform:dpkg] -yum-utils [platform:dpkg !platform:ubuntu-focal] +yum-utils [platform:dpkg !platform:ubuntu-focal !platform:debian-bullseye] +dnf [platform:debian-bullseye] debootstrap [platform:dpkg] procps [platform:dpkg] diff --git a/diskimage_builder/elements/yum-minimal/root.d/08-yum-chroot b/diskimage_builder/elements/yum-minimal/root.d/08-yum-chroot index 9a3fbd44..3be0fe23 100755 --- a/diskimage_builder/elements/yum-minimal/root.d/08-yum-chroot +++ b/diskimage_builder/elements/yum-minimal/root.d/08-yum-chroot @@ -46,6 +46,16 @@ trap "$EACTION" EXIT YUM_CACHE=$DIB_IMAGE_CACHE/yum mkdir -p $YUM_CACHE +# Debian Bullseye and beyond only has DNF locally +HOST_YUM_DOWNLOADER="yumdownloader" +HOST_YUM="yum" +if ! command -v yumdownloader &> /dev/null +then + HOST_YUM_DOWNLOADER="dnf download" + HOST_YUM="dnf" +fi + + # Note, on Debian/Ubuntu, %_dbpath is set in the RPM macros as # ${HOME}/.rpmdb/ -- this makes sense as RPM isn't the system # packager. This path is relative to the "--root" argument @@ -55,7 +65,7 @@ _RPM="rpm --dbpath=/var/lib/rpm" # chroot, which are needed to bootstrap yum/dnf # # note this runs outside the chroot, where we're assuming the platform -# has yum/yumdownloader +# has yum/yumdownloader/dnf download function _install_repos { local packages local rc @@ -130,7 +140,7 @@ function _install_repos { # can clean it up nicely local temp_tmp temp_tmp=$(mktemp -d) - TMPDIR=${temp_tmp} yumdownloader --verbose \ + TMPDIR=${temp_tmp} ${HOST_YUM_DOWNLOADER} --verbose \ --releasever=${DIB_RELEASE/-*/} \ --setopt=reposdir=$repo \ --setopt=cachedir=$temp_tmp \ @@ -237,7 +247,7 @@ function _install_pkg_manager { sudo ln -s $TARGET_ROOT/etc/dnf/vars $TARGET_ROOT/etc/yum/vars fi - sudo -E yum -y \ + sudo -E ${HOST_YUM} -y \ --disableexcludes=all \ --setopt=cachedir=$YUM_CACHE/$ARCH/$DIB_RELEASE \ --setopt=reposdir=$TARGET_ROOT/etc/yum.repos.d \ diff --git a/releasenotes/notes/yum-minimal-dnf-63305c349bcccdd4.yaml b/releasenotes/notes/yum-minimal-dnf-63305c349bcccdd4.yaml new file mode 100644 index 00000000..89044a7d --- /dev/null +++ b/releasenotes/notes/yum-minimal-dnf-63305c349bcccdd4.yaml @@ -0,0 +1,6 @@ +--- +upgrade: + - | + This includes updates to allow `yum-minimal` elements to work on + host platforms that only supply DNF (e.g. Debian Bullseye). Note + the `dnf download` plugin is required on these platforms.