diff --git a/README.md b/README.md index 3ea86aaf24f76e917a88c25bdba9d820cecad080..764879328f078dd9ebaa51ff10ad6a5ba8015e1a 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,19 @@ Purge unused Ubuntu kernels -## Setup +## Table of Contents + +1. [Setup](#setup) +2. [How it works](#how-it-works) + 1. [Script usage](#script-usage) + 2. [Configuration file](#configuration-file) + 3. [How the script removes the kernels](#how-the-script-removes-the-kernels) + 1. [1stcase](#1stcase) + 2. [2ndcase](#2ndcase) + 3. [3rdtcase](#3rdcase) +3. [ToDo](#todo) + +### Setup I'll wait for better days to come and create a proper release process. Meanwhile I use Git LFS to upload the package inside the [deb/](https://gitlab.com/maxadamo/ubuntu-kernel-cleanup/-/tree/master/deb) directory. @@ -18,25 +30,23 @@ if the dependencies are not met: sudo apt -y -f install ``` -## How it works - -### Script usage +### How it works -you can run the script using `--real-run` to remove the packages or use `--dry-run` to show which package would have been removed. +#### Script usage -Example: +you can run the script using `--real-run` to remove the packages or use `--dry-run` to show which package would have been removed: ```bash ubuntu-kernel-cleanup.py --real-run ``` -or +or: ```bash ubuntu-kernel-cleanup.py --dry-run ``` -### Configuration file +#### Configuration file The script will look for its configuration file in the following locations: @@ -61,9 +71,9 @@ kernel_prefixes = linux-tools, linux-headers, linux-modules, linux-modules-extra kernel_suffixes = generic, aws ``` -### How the script removes the kernels +#### How the script removes the kernels -#### 1st case +##### 1st case you have 4 kernels installed and you use (`count = 1`): @@ -74,7 +84,7 @@ you have 4 kernels installed and you use (`count = 1`): the script will remove **kernel2** and **kernel3** -#### 2nd case +##### 2nd case If the running kernel does not belong to the list of the latest kernels, obtained with the option "count", then `count + 1` will be kept. @@ -88,7 +98,7 @@ For instance, if you use `count = 2` with the following kernels installed: the script will remove **kernel1** and **kernel3** -#### 3rd case +##### 3rd case You reboot and you are running the latest kernel. @@ -101,3 +111,7 @@ If you use `count = 2`, 2 kernels will be kept: * **kernel5**: the latest, **running** kernel, it will be kept the script will remove **kernel1**, **kernel2** and **kernel3** + +### ToDo + +* improve algorithm to remove intermediate kernels, avoiding that in a corner case you get `count` + 1 diff --git a/create_deb_package.sh b/create_deb_package.sh index 5582ac3eead63f17719341bdbc655aa27d911980..c5f1f4b7e045bd7485a71cf4c07c8a7eaf11b3f5 100755 --- a/create_deb_package.sh +++ b/create_deb_package.sh @@ -3,6 +3,14 @@ # the deb is tracked with git lfs: # git lfs track "deb/**" # +# pandoc -o README.txt --to=plain README.md +# git commit ... +# +if ! which fpm &>/dev/null; then + echo "please install 'fpm'" + exit +fi + PROG_NAME="ubuntu-kernel-cleanup" EMAIL="Massimiliano Adamo<massimiliano.adamo@geant.org" DESCRIPTION="Clean up unused kernel packages" @@ -17,13 +25,13 @@ LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1)) PROG_VERSION=${LATEST_TAG:1} git checkout $LATEST_TAG -pandoc -o README.txt --to=plain README.md +chmod 0755 ${PROG_NAME}.py +chmod 0644 README.txt ubuntu-kernel-cleanup.ini -fpm -f -t deb -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 README.txt=usr/share/doc/${PROG_NAME}/README.txt +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 \ + README.txt=usr/share/doc/${PROG_NAME}/README.txt -rm -f *.txt git checkout master