yum-minimal: workaround missing $releasedir variable

As described inline, work around missing $releasedir variables seen in
production builds.

Change-Id: Ia114f41d7a2fa86957235996f10a74adeecf767c
This commit is contained in:
Ian Wienand 2022-04-29 14:41:48 +10:00 committed by Jeremy Stanley
parent a25c2e84b6
commit 999da87243

View File

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