Use dnf to cleanup old kernels
As described in the comment, there is a dnf equivalent of this command that doesn't require us installing yum-utils (which drags in yum on dnf-only systems such as f23) This is a small consequence to this -- due to us not installing yum-utils some installs will now be completely yum free. This causes a breakage in ironic-agent 99-remove-extra-packages where we remove the yum package. There is a long-standing bug/feature where missing packages in a group of packages do not cause yum/dnf to exit with failure, but uninstalling a single package will. Because we have made the systems yum-free, the uninstall of yum can fail in this corner case. It has always been like this, so I'm in favour of the "ain't broke" approach. To work-around this, I have just put yum into the existing list of packages to be cleaned up. I have added a note to the yum installer taking note of this behaviour for future reference. Change-Id: I8bbdc07ccdb89a105b4fc70d5a215077c42fcd03
This commit is contained in:
parent
5ee1cbac4a
commit
cb0e0e903d
@ -9,18 +9,21 @@ set -o pipefail
|
||||
# TODO(lucasagomes): optimize the ramdisk for other OSs
|
||||
if [ $DISTRO_NAME = 'fedora' ] ; then
|
||||
|
||||
install-packages -e kernel-debug-devel gcc fedora-logos python3 rsync sudo pykickstart grubby make genisoimage tcpdump man-db policycoreutils kbd-misc plymouth cronie
|
||||
|
||||
_remove_yum=''
|
||||
if [ $DIB_RELEASE -ge 22 ]; then
|
||||
# Remove yum, >= F22 defaults to dnf
|
||||
dnf remove yum -y
|
||||
# Remove package manager cache
|
||||
dnf clean all
|
||||
else
|
||||
# Remove package manager cache
|
||||
yum clean all
|
||||
# if we are on F22, we can remove yum if there, because it has
|
||||
# been superseeded by dnf
|
||||
_remove_yum='yum'
|
||||
fi
|
||||
|
||||
install-packages -e kernel-debug-devel gcc fedora-logos \
|
||||
python3 rsync sudo pykickstart \
|
||||
grubby make genisoimage tcpdump \
|
||||
man-db policycoreutils kbd-misc \
|
||||
plymouth cronie ${_remove_yum}
|
||||
|
||||
${YUM:-yum} clean all
|
||||
|
||||
# Rebuilding the rpm database after removing packages will reduce
|
||||
# its size
|
||||
rpm --rebuilddb
|
||||
|
@ -6,6 +6,16 @@ fi
|
||||
set -eu
|
||||
set -o pipefail
|
||||
|
||||
install-packages yum-utils
|
||||
YUM=${YUM:-yum}
|
||||
|
||||
package-cleanup --oldkernels -y --count=1
|
||||
if [[ ${YUM} == "dnf" ]]; then
|
||||
# cribbed from
|
||||
# http://dnf.readthedocs.org/en/latest/cli_vs_yum.html
|
||||
_old_kernels="$(dnf repoquery --installonly --latest-limit -1 -q)"
|
||||
if [[ -n "${_old_kernels}" ]]; then
|
||||
dnf remove -y ${_old_kernels}
|
||||
fi
|
||||
else
|
||||
install-packages yum-utils
|
||||
package-cleanup --oldkernels -y --count=1
|
||||
fi
|
||||
|
@ -122,6 +122,14 @@ if [ -n "$WHITELIST" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# yum & dnf have a feature/bug where missing packages in a list of
|
||||
# packages for install/erase do not raise an error exit [1].
|
||||
# There is a corner case when specifying just *one* package, where
|
||||
# it will fail if the package is missing. Thus install-packages
|
||||
# follows this behaviour; we may need to re-evaluate this at some
|
||||
# point.
|
||||
#
|
||||
# [1] https://bugzilla.redhat.com/show_bug.cgi?id=965567
|
||||
${YUM} -v -y $ACTION $EXTRA_ARGS $PKGS
|
||||
|
||||
if [ "$ACTION" == "install" ]; then
|
||||
|
Loading…
Reference in New Issue
Block a user