yum-minimal : better cleanup of initial yum failure

If the initial yum install into the chroot fails, we can leave behind
a lockfile and an incorrectly modified rpmmacros.

Change this so we run the cleanup unconditionally.

Change-Id: Ia9f9c4c845e5f34d33ff9a4ab7226c9175283757
This commit is contained in:
Ian Wienand 2016-04-20 09:42:42 +10:00
parent 1fabb01a4f
commit e2c0d16f84

View File

@ -124,15 +124,22 @@ function _install_pkg_manager {
( (
flock -w 1200 9 || die "Can not lock .rpmmacros" flock -w 1200 9 || die "Can not lock .rpmmacros"
echo "%_dbpath /var/lib/rpm" >> $HOME/.rpmmacros echo "%_dbpath /var/lib/rpm" >> $HOME/.rpmmacros
sudo -E yum -y \ sudo -E yum -y \
--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 \
--releasever=$DIB_RELEASE \ --releasever=$DIB_RELEASE \
--installroot $TARGET_ROOT \ --installroot $TARGET_ROOT \
install $@ install $@ && rc=$? || rc=$?
sed -i '$ d' $HOME/.rpmmacros
) 9>$HOME/.rpmmacros.dib.lock # We modified the base system - make sure we clean up always!
rm $HOME/.rpmmacros.dib.lock rm $HOME/.rpmmacros.dib.lock
sed -i '$ d' $HOME/.rpmmacros
if [ $rc != 0 ]; then
die "Initial yum install to chroot failed! Can not continue."
fi
) 9>$HOME/.rpmmacros.dib.lock
# Set gpg path back because subsequent actions will take place in # Set gpg path back because subsequent actions will take place in
# the chroot # the chroot
sudo sed -i "s,$TARGET_ROOT/etc/pki/rpm-gpg,/etc/pki/rpm-gpg,g" \ sudo sed -i "s,$TARGET_ROOT/etc/pki/rpm-gpg,/etc/pki/rpm-gpg,g" \