* usr/bin/purge-old-kernels: LP: #1595977

- modify the kernel purge algorithm slightly to better handle efi
    and virtual kernels
This commit is contained in:
Dustin Kirkland 2016-07-29 10:58:36 -05:00
commit aa56b67c99
2 changed files with 15 additions and 3 deletions

3
debian/changelog vendored
View file

@ -7,6 +7,9 @@ byobu (5.110) unreleased; urgency=medium
- fix DISTRO to BYOBU_DISTRO in template - fix DISTRO to BYOBU_DISTRO in template
* debian/control: LP: #1596364 * debian/control: LP: #1596364
- add |xterm to suggests - add |xterm to suggests
* usr/bin/purge-old-kernels: LP: #1595977
- modify the kernel purge algorithm slightly to better handle efi
and virtual kernels
-- Dustin Kirkland <kirkland@ubuntu.com> Tue, 05 Jul 2016 10:47:25 -0500 -- Dustin Kirkland <kirkland@ubuntu.com> Tue, 05 Jul 2016 10:47:25 -0500

View file

@ -45,9 +45,18 @@ while [ ! -z "$1" ]; do
done done
# Build our list of kernel packages to purge # Build our list of kernel packages to purge
CANDIDATES=$(ls -tr /boot/vmlinuz-* | head -n -${KEEP} | grep -v "$(uname -r)$" | cut -d- -f2- | awk '{print "linux-image-" $0 " linux-headers-" $0}' ) VERSIONS=$(ls -f /boot/vmlinuz-* | sed -e "s/[^\-]*-//" -e "s/-[^\-]*$//" | sort -rh)
for c in $CANDIDATES; do count=0
dpkg-query -s "$c" >/dev/null 2>&1 && PURGE="$PURGE $c" for v in $VERSIONS; do
count=$((count+1))
if [ $count -le $KEEP ]; then
continue
fi
for k in linux-image linux-headers linux-signed-image linux-image-virtual; do
for f in generic lowlatency; do
dpkg-query -s "$k-$v-$f" >/dev/null 2>&1 && PURGE="$PURGE $k-$v-$f"
done
done
done done
if [ -z "$PURGE" ]; then if [ -z "$PURGE" ]; then