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
This commit is contained in:
Ian Wienand 2021-08-27 16:36:15 +10:00
parent a6ee4d0c21
commit 5f47584196
3 changed files with 22 additions and 5 deletions

View File

@ -19,11 +19,12 @@ gnupg2 [!platform:redhat !platform:ubuntu-trusty !platform:suse]
# ubuntu # ubuntu
apt-transport-https [platform:dpkg] apt-transport-https [platform:dpkg]
inetutils-ping [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] qemu-utils [platform:dpkg]
rpm [platform:dpkg] rpm [platform:dpkg]
uuid-runtime [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] debootstrap [platform:dpkg]
procps [platform:dpkg] procps [platform:dpkg]

View File

@ -46,6 +46,16 @@ trap "$EACTION" EXIT
YUM_CACHE=$DIB_IMAGE_CACHE/yum YUM_CACHE=$DIB_IMAGE_CACHE/yum
mkdir -p $YUM_CACHE 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 # Note, on Debian/Ubuntu, %_dbpath is set in the RPM macros as
# ${HOME}/.rpmdb/ -- this makes sense as RPM isn't the system # ${HOME}/.rpmdb/ -- this makes sense as RPM isn't the system
# packager. This path is relative to the "--root" argument # 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 # chroot, which are needed to bootstrap yum/dnf
# #
# note this runs outside the chroot, where we're assuming the platform # note this runs outside the chroot, where we're assuming the platform
# has yum/yumdownloader # has yum/yumdownloader/dnf download
function _install_repos { function _install_repos {
local packages local packages
local rc local rc
@ -130,7 +140,7 @@ function _install_repos {
# can clean it up nicely # can clean it up nicely
local temp_tmp local temp_tmp
temp_tmp=$(mktemp -d) temp_tmp=$(mktemp -d)
TMPDIR=${temp_tmp} yumdownloader --verbose \ TMPDIR=${temp_tmp} ${HOST_YUM_DOWNLOADER} --verbose \
--releasever=${DIB_RELEASE/-*/} \ --releasever=${DIB_RELEASE/-*/} \
--setopt=reposdir=$repo \ --setopt=reposdir=$repo \
--setopt=cachedir=$temp_tmp \ --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 sudo ln -s $TARGET_ROOT/etc/dnf/vars $TARGET_ROOT/etc/yum/vars
fi fi
sudo -E yum -y \ sudo -E ${HOST_YUM} -y \
--disableexcludes=all \ --disableexcludes=all \
--setopt=cachedir=$YUM_CACHE/$ARCH/$DIB_RELEASE \ --setopt=cachedir=$YUM_CACHE/$ARCH/$DIB_RELEASE \
--setopt=reposdir=$TARGET_ROOT/etc/yum.repos.d \ --setopt=reposdir=$TARGET_ROOT/etc/yum.repos.d \

View File

@ -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.