remove-old-kernels: add "epoch" support

Signed-off-by: Vladimir V. Kamarzin <vvk@altlinux.org>
This commit is contained in:
Vladimir V. Kamarzin 2008-12-28 17:41:11 +05:00
parent 60e3e84b71
commit 1799b39030

View File

@ -20,9 +20,16 @@
. shell-error
flavour_version_release="$(uname -r | awk -F- '{print $2"-"$3"-"$1"-"$4}')"
old_kernels="$(rpm -qa | fgrep kernel-image | fgrep -v $flavour_version_release | sed -e "s,-,#, 4" | tr '\n' ' ')"
old_kernels="$(rpm -qa | fgrep kernel-image | fgrep -v $flavour_version_release | tr '\n' ' ')"
# calculate arguments for apt
for kernel in $old_kernels
do
apt_list="$apt_list $(rpm -q --queryformat '%{NAME}#%{EPOCH}:%{VERSION}-%{RELEASE}\n' $kernel \
| sed -e "s,(none):,,g")"
done
# use sudo(1) if running as unprivileged user
[ "$UID" = "0" ] && SUDO= || SUDO=sudo
$SUDO apt-get remove $old_kernels
$SUDO apt-get remove $apt_list