diff --git a/README.md b/README.md index 2cf4c63992f4252305c772464b479dadb615462f..73a7b76e36b8bfb1bd458963b0932a9e3a6e0c1a 100644 --- a/README.md +++ b/README.md @@ -119,4 +119,4 @@ the script will remove **kernel1**, **kernel2** and **kernel3** ### ToDo * The algorithm can be improved to remove intermediate kernels, avoiding that in a corner case you get `count + 1`. If count is set to 1 it won't work in any case (you can't remove the running kernel and you don't want to remove the latest), but, if count is set to a higher number the scenario is the following: - * Imagine you have 3 kernels installed, you have count set to 2 and you are running the older kernel, then you can remove the intermediate kernel. Right now it ends up leaving `count + 1` until reboot happens. + * Imagine you have 3 kernels installed, `count` is set to 2 and you are running the older kernel, then you can remove the intermediate kernel. Right now it ends up leaving `count + 1` until reboot happens. diff --git a/create_deb_package.sh b/create_deb_package.sh index d0d587562737a0858ecffe3ac8e16279870d3cf0..3b7fb41271afb6aec358f5fb56c864d2c32e51c6 100755 --- a/create_deb_package.sh +++ b/create_deb_package.sh @@ -16,7 +16,7 @@ if ! which fpm &>/dev/null; then fi PROG_NAME="ubuntu-kernel-cleanup" -EMAIL="Massimiliano Adamo<massimiliano.adamo@geant.org" +EMAIL="Massimiliano Adamo<massimiliano.adamo@geant.org>" DESCRIPTION="Clean up unused kernel packages" export VERSION EMAIL DESCRIPTION PROG_NAME @@ -34,8 +34,8 @@ chmod 0644 README.txt ubuntu-kernel-cleanup.ini fpm -f -t deb --deb-use-file-permissions -n ${PROG_NAME} -v $PROG_VERSION --maintainer "$EMAIL"\ --vendor "$EMAIL" -a all --description "$DESCRIPTION" --config-files etc/${PROG_NAME}.ini \ - -p deb/${PROG_NAME}_${PROG_VERSION}_all.deb -d python3-docopt -d python3-packaging -s dir \ - ${PROG_NAME}.ini=/etc/${PROG_NAME}.ini ${PROG_NAME}.py=/usr/bin/${PROG_NAME}.py \ + -p deb/${PROG_NAME}_${PROG_VERSION}_all.deb -d python3-docopt -d python3-packaging -d python3-natsort \ + -s dir ${PROG_NAME}.ini=/etc/${PROG_NAME}.ini ${PROG_NAME}.py=/usr/bin/${PROG_NAME}.py \ README.txt=usr/share/doc/${PROG_NAME}/README.txt git checkout master diff --git a/ubuntu-kernel-cleanup.py b/ubuntu-kernel-cleanup.py index da27a9ddff9fd337e8d7f4f4df29ae1585616661..1979ece96a76ed15b0245bffed01c89dca115cad 100755 --- a/ubuntu-kernel-cleanup.py +++ b/ubuntu-kernel-cleanup.py @@ -20,7 +20,7 @@ import re import os import subprocess as sp import configparser -from distutils.version import LooseVersion +from natsort import natsorted import platform import apt try: @@ -53,7 +53,7 @@ def get_packages_list(pkg_match): kernel_versions = [get_version(item) for item in kernels] # sort by version and unique - return sorted(list(set(kernel_versions)), key=LooseVersion) + return natsorted(list(set(kernel_versions))) def process_packages(version_number, prefix, execution_type):