Merge "Use dnf to cleanup old kernels"

This commit is contained in:
Jenkins 2016-02-15 22:56:11 +00:00 committed by Gerrit Code Review
commit 9e16c8c5f1
3 changed files with 32 additions and 11 deletions

View File

@ -9,18 +9,21 @@ set -o pipefail
# TODO(lucasagomes): optimize the ramdisk for other OSs # TODO(lucasagomes): optimize the ramdisk for other OSs
if [ $DISTRO_NAME = 'fedora' ] ; then 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 if [ $DIB_RELEASE -ge 22 ]; then
# Remove yum, >= F22 defaults to dnf # if we are on F22, we can remove yum if there, because it has
dnf remove yum -y # been superseeded by dnf
# Remove package manager cache _remove_yum='yum'
dnf clean all
else
# Remove package manager cache
yum clean all
fi 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 # Rebuilding the rpm database after removing packages will reduce
# its size # its size
rpm --rebuilddb rpm --rebuilddb

View File

@ -6,6 +6,16 @@ fi
set -eu set -eu
set -o pipefail 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

View File

@ -122,6 +122,14 @@ if [ -n "$WHITELIST" ]; then
exit 0 exit 0
fi 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 ${YUM} -v -y $ACTION $EXTRA_ARGS $PKGS
if [ "$ACTION" == "install" ]; then if [ "$ACTION" == "install" ]; then