upgrades: Clean up old kernel packages during automatic upgrades

The unattended-upgrades package removes older kernel packages before
starting the upgrade process, so that the current kernel and the newly
installed kernel will be retained and all older kernel packages will
be removed.

The removal of older kernel packages requires "apt autoremove" to list
them. So, a setting to enable autoremoval of packages has been turned
on as well.

When tested on a vagrant box, the current kernel 4.17.0.1 and the new
kernel 4.17.0.3 have been retained. Older kernels were removed
preemptively before the installation of 4.17.0.3

Fixes #1372

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Joseph Nuthalapati 2018-09-05 11:07:39 +05:30 committed by James Valleroy
parent 3c4b254909
commit 0583787a68
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
2 changed files with 9 additions and 0 deletions

View File

@ -0,0 +1,7 @@
// Remove unused automatically installed kernel-related packages
// (kernel images, kernel headers and kernel version locked tools).
Unattended-Upgrade::Remove-Unused-Kernel-Packages "true";
// Do automatic removal of new unused dependencies after the upgrade
// (equivalent to apt-get autoremove)
Unattended-Upgrade::Remove-Unused-Dependencies "true";

View File

@ -233,6 +233,8 @@ setuptools.setup(
glob.glob('data/etc/apache2/sites-available/*.conf')),
('/etc/apache2/includes',
glob.glob('data/etc/apache2/includes/*.conf')),
('/etc/apt/apt.conf.d',
glob.glob('data/etc/apt/apt.conf.d/60unattended-upgrades')),
('/etc/avahi/services/',
glob.glob('data/etc/avahi/services/*.service')),
('/etc/ikiwiki',