Skip to content
Snippets Groups Projects
Unverified Commit 8b91ecea authored by Max Adamo's avatar Max Adamo
Browse files

replace deprecated distutil with natsort

parent 7b848884
No related branches found
No related tags found
No related merge requests found
...@@ -119,4 +119,4 @@ the script will remove **kernel1**, **kernel2** and **kernel3** ...@@ -119,4 +119,4 @@ the script will remove **kernel1**, **kernel2** and **kernel3**
### ToDo ### 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: * 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.
...@@ -16,7 +16,7 @@ if ! which fpm &>/dev/null; then ...@@ -16,7 +16,7 @@ if ! which fpm &>/dev/null; then
fi fi
PROG_NAME="ubuntu-kernel-cleanup" 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" DESCRIPTION="Clean up unused kernel packages"
export VERSION EMAIL DESCRIPTION PROG_NAME export VERSION EMAIL DESCRIPTION PROG_NAME
...@@ -34,8 +34,8 @@ chmod 0644 README.txt ubuntu-kernel-cleanup.ini ...@@ -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"\ 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 \ --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 \ -p deb/${PROG_NAME}_${PROG_VERSION}_all.deb -d python3-docopt -d python3-packaging -d python3-natsort \
${PROG_NAME}.ini=/etc/${PROG_NAME}.ini ${PROG_NAME}.py=/usr/bin/${PROG_NAME}.py \ -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 README.txt=usr/share/doc/${PROG_NAME}/README.txt
git checkout master git checkout master
...@@ -20,7 +20,7 @@ import re ...@@ -20,7 +20,7 @@ import re
import os import os
import subprocess as sp import subprocess as sp
import configparser import configparser
from distutils.version import LooseVersion from natsort import natsorted
import platform import platform
import apt import apt
try: try:
...@@ -53,7 +53,7 @@ def get_packages_list(pkg_match): ...@@ -53,7 +53,7 @@ def get_packages_list(pkg_match):
kernel_versions = [get_version(item) for item in kernels] kernel_versions = [get_version(item) for item in kernels]
# sort by version and unique # 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): def process_packages(version_number, prefix, execution_type):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment