linux-image: Make a newly installed kernel the default if the package was previously removed

Currently the postinst script distinguishes installation vs upgrade by
checking whether its second argument is empty.  However, it will only
be empty if the package was *never* installed before, or was purged.
If the package has been installed, then removed, and is now being
installed again, it's seen as an upgrade.

Unfortunately dpkg only tells the preinst script whether or not this
is an upgrade.  So create a flag file there, consume it in postinst
and remove it in postrm.
This commit is contained in:
Ben Hutchings 2016-06-04 23:37:04 +01:00
parent 586edb84cd
commit 8ed7991db8
4 changed files with 12 additions and 1 deletions

2
debian/changelog vendored
View File

@ -7,6 +7,8 @@ linux (4.6-1~exp3) UNRELEASED; urgency=medium
for minimal_swap, no_symlinks, use_hard_links and *_hook parameters in
/etc/kernel-img.conf (Closes: #730073).
* linux-image: postrm: Update default symlinks before running hook scripts
* linux-image: Make a newly installed kernel the default if the package
was previously removed
-- Ben Hutchings <ben@decadent.org.uk> Sat, 04 Jun 2016 18:33:11 +0100

View File

@ -13,12 +13,13 @@ fi
depmod $version
if [ -z "$2" ]; then
if [ -f /lib/modules/$version/.fresh-install ]; then
change=install
else
change=upgrade
fi
linux-update-symlinks $change $version $image_path
rm -f /lib/modules/$version/.fresh-install
if [ -d /etc/kernel/postinst.d ]; then
DEB_MAINT_PARAMS="$*" run-parts --report --exit-on-error --arg=$version \

View File

@ -3,6 +3,8 @@
version=@abiname@@localversion@
image_path=/boot/@image-stem@-$version
rm -f /lib/modules/$version/.fresh-install
if [ "$1" != upgrade ] && command -v linux-update-symlinks >/dev/null; then
linux-update-symlinks remove $version $image_path
fi

View File

@ -7,6 +7,12 @@ if [ "$1" = abort-upgrade ]; then
exit 0
fi
if [ "$1" = install ]; then
# Create a flag file for postinst
mkdir -p /lib/modules/$version
touch /lib/modules/$version/.fresh-install
fi
if [ -d /etc/kernel/preinst.d ]; then
DEB_MAINT_PARAMS="$*" run-parts --report --exit-on-error --arg=$version \
--arg=$image_path /etc/kernel/preinst.d