Commit 6da00af9 authored by Andy Whitcroft's avatar Andy Whitcroft Committed by Juerg Haefliger

UBUNTU: [Packaging] switch to triggers for postinst.d postrm.d handling

When we install linux-image we have to run kernel postinst.d support in
case this kernel has no linux-image-extra.  Should it have an extra and
we install we then have to assume that is being installed cold
and that the same processing is neeed.  If we are installing both at the
same time, we necessarily trigger kernel postinst.d twice.  As this
includes rebuilding the initramfs and reconfiguring the boot loader this
is very inefficient.

For removal of linux-image-extra when we remove the package we also
need to run postinst.d handling in order to pare down the initramfs to
linux-image contents only.  However when we are removing both packages
we immediatly remove the rebuilt initramfs.  Doubly annoying.

This patch switches us to using a trigger against the linux-image package
for all postinst.d and postrm.d handling.  On installation postinst.d
gets triggered twice once by linux-image and once by linux-image-extra.
As triggers are non-cumulative we will only run this processing
once.  When removing both packages we will trigger postinst.d from
linux-image-extra and then in linux-image postrm.d we effectivly ignore
the pending trigger and simply run the postrm.d.  This prevents us from
rebuilding the initramfs.

BugLink: http://bugs.launchpad.net/bugs/1764794Signed-off-by: default avatarAndy Whitcroft <apw@canonical.com>
Acked-by: default avatarThadeu Lima de Souza Cascardo <cascardo@canonical.com>
Acked-by: default avatarSeth Forshee <seth.forshee@canonical.com>
Signed-off-by: default avatarSeth Forshee <seth.forshee@canonical.com>
Signed-off-by: default avatarAndy Whitcroft <apw@canonical.com>
Acked-by: default avatarStefan Bader <stefan.bader@canonical.com>
Acked-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
parent e4813f7a
......@@ -240,6 +240,7 @@ endif
$(pkgdir)/lib/modules/$(abi_release)-$*/initrd/; \
fi
echo "interest linux-update-$(abi_release)-$*" >"$(DROOT)/$(bin_pkg_name)-$*.triggers"
$(call install_control,$(bin_pkg_name)-$*,image,postinst postrm preinst prerm)
ifeq ($(do_extras_package),true)
......
......@@ -10,8 +10,12 @@ fi
depmod -a -F /boot/System.map-$version $version || true
if [ -d /etc/kernel/postinst.d ]; then
DEB_MAINT_PARAMS="$*" run-parts --report --exit-on-error --arg=$version \
mkdir -p /usr/lib/linux/triggers
cat - >/usr/lib/linux/triggers/$version <<EOF
DEB_MAINT_PARAMS="$*" run-parts --report --exit-on-error --arg=$version \
--arg="$image_path" /etc/kernel/postinst.d
EOF
dpkg-trigger --no-await linux-update-$version
fi
exit 0
......@@ -9,9 +9,24 @@ if [ "$1" != remove ]; then
fi
depmod -a -F /boot/System.map-$version $version 2>/dev/null || true
if [ -d /etc/kernel/postinst.d ]; then
DEB_MAINT_PARAMS="$*" run-parts --report --exit-on-error --arg=$version \
--arg="$image_path" /etc/kernel/postinst.d
fi
#
# We should be rebuilding the initramfs here on removal to pare down the
# initramfs if it contains any of the objects we just removed. But people
# commonly remove kernels in order to free space in /boot, and rebuilding the
# initramfs now risks ENOSPC when we are trying to make space. The files we
# leave lying about could be confusing, but we trade that against safety on
# removal.
#
#if [ -d /etc/kernel/postinst.d ]; then
# # We want to behave as if linux-image (without us) was installed, therefore
# # we do not want the postinst support to know we are being removed, claim
# # this is an installation event.
# mkdir -p /usr/lib/linux/triggers
# cat - >/usr/lib/linux/triggers/$version <<EOF
#DEB_MAINT_PARAMS="configure" run-parts --report --exit-on-error --arg=$version \
# --arg="$image_path" /etc/kernel/postinst.d
#EOF
# dpkg-trigger --no-await linux-update-$version
#fi
exit 0
......@@ -4,6 +4,38 @@ set -e
version=@abiname@@localversion@
image_path=/boot/@image-stem@-$version
#
# When we install linux-image we have to run kernel postinst.d support to
# generate the initramfs, create links etc. Should it have an associated
# linux-image-extra package and we install that we also need to run kernel
# postinst.d, to regenerate the initramfs. If we are installing both at the
# same time, we necessarily trigger kernel postinst.d twice. As this includes
# rebuilding the initramfs and reconfiguring the boot loader this is very time
# consuming.
#
# Similarly for removal when we remove the linux-image-extra package we need to
# run kernel postinst.d handling in order to pare down the initramfs to
# linux-image contents only. When we remove the linux-image need to remove the
# now redundant initramfs. If we are removing both at the same time, then
# we will rebuilt the initramfs and then immediatly remove it.
#
# Switches to using a trigger against the linux-image package for all
# postinst.d and postrm.d handling. On installation postinst.d gets triggered
# twice once by linux-image and once by linux-image-extra. As triggers are
# non-cumulative we will only run this processing once. When removing both
# packages we will trigger postinst.d from linux-image-extra and then in
# linux-image postrm.d we effectivly ignore the pending trigger and simply run
# the postrm.d. This prevents us from rebuilding the initramfs.
#
if [ "$1" = triggered ]; then
trigger=/usr/lib/linux/triggers/$version
if [ -f "$trigger" ]; then
sh "$trigger"
rm -f "$trigger"
fi
exit 0
fi
if [ "$1" != configure ]; then
exit 0
fi
......@@ -19,8 +51,12 @@ 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 \
mkdir -p /usr/lib/linux/triggers
cat - >/usr/lib/linux/triggers/$version <<EOF
DEB_MAINT_PARAMS="$*" run-parts --report --exit-on-error --arg=$version \
--arg=$image_path /etc/kernel/postinst.d
EOF
dpkg-trigger --no-await linux-update-$version
fi
exit 0
......@@ -11,6 +11,15 @@ if [ "$1" != upgrade ] && command -v linux-update-symlinks >/dev/null; then
fi
if [ -d /etc/kernel/postrm.d ]; then
# We cannot trigger ourselves as at the end of this we will no longer
# exist and can no longer respond to the trigger. The trigger would
# then become lost. Therefore we clear any pending trigger and apply
# postrm directly.
if [ -f /usr/lib/linux/triggers/$version ]; then
echo "$0 ... removing pending trigger"
rm -f /usr/lib/linux/triggers/$version
rmdir --ignore-fail-on-non-empty /usr/lib/linux/triggers
fi
DEB_MAINT_PARAMS="$*" run-parts --report --exit-on-error --arg=$version \
--arg=$image_path /etc/kernel/postrm.d
fi
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment