From 999da8724373540cdf1254d053932c2f6418800c Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Fri, 29 Apr 2022 14:41:48 +1000 Subject: [PATCH] yum-minimal: workaround missing $releasedir variable As described inline, work around missing $releasedir variables seen in production builds. Change-Id: Ia114f41d7a2fa86957235996f10a74adeecf767c --- .../elements/yum-minimal/root.d/08-yum-chroot | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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 8dabb0714..8bc81e252 100755 --- a/diskimage_builder/elements/yum-minimal/root.d/08-yum-chroot +++ b/diskimage_builder/elements/yum-minimal/root.d/08-yum-chroot @@ -324,6 +324,25 @@ function _run_chroot { sudo -E chroot $TARGET_ROOT env -u TMPDIR sh -c "$cmd" } +# The rpmdb has been created by the host RPM. CentOS 7 only +# understands bdb-based db's, while the host is (likey as not) a more +# modern rpm that has created a sqlite db. These don't share files in +# common, so to the in-chroot rpm the db just looks empty. This is a +# super-weird state that the system is in, because everything is +# installed and working, but packages don't look like they are. One +# consequence of this is that yum's querying to setup the $releasever +# variable fails and it remains unset. Because the default .repo +# files use this we get invalid repo paths for any yum commands. The +# easiest way around this seems to be to manually set --releasever=7; +# this way yum can rebuild itself and recreate the rpmdb as it likes. +# This is a mess that can hopefully go away when we don't care about +# CentOS 7. For this reason, we only do this for CentOS 7, to avoid +# hiding any problems on other distros. We only need to do this +# for these initial steps, after that the db is correct. +if [[ ${DISTRO_NAME} = centos && ${DIB_RELEASE%-stream} -le 7 ]]; then + YUM="${YUM} --releasever=${DIB_RELEASE}" +fi + # we just installed yum/dnf with "outside" tools (yum/rpm) which # might have created /var/lib/[yum|rpm] (etc) that are slighlty # incompatible. Refresh everything with the in-chroot tools