Source: initramfs-tools Version: 0.91b Severity: wishlist Tags: patch The attached patch triggerises the invocation of mkinitramfs by package maintainer scripts via update-initramfs.
By `triggerises' I mean that the patch arranges for the formulaic update-initramfs invocations by maintainer scripts (eg of udev, kernel packages, etc.) to call dpkg-trigger instead of actually doing the work of update-initramfs and mkinitramfs. update-initramfs and hence mkinitramfs will be actually run out of initramfs-tools's postinst script during trigger processing. The consequence is that all of the initramfs updates during a dpkg run are deferred, and instead the update is done once at the end. This is achieved by new code in update-initramfs. This detects the formulaic invocation by a maintscript, and exec's dpkg-trigger instead (if the conditions are favourable). An alternative approach would be to change all of the packages not to call update-initramfs but instead to call a new script but this would involve a much more complicated and lengthy transition for no significant benefit. The patch is safe to use with a non-triggers-supporting dpkg and in all transitional states: where the trigger system is not properly set up yet, update-initramfs does its work as normal. Note that sid's dpkg does not yet have the triggers patch merged but there has been extensive discussion of the design and interfaces for triggers and the API should IMO be considered stable. These changes have been tested and released as part of Ubuntu 7.10 aka `gutsy gibbon'. The patch below is the consilidation of the results of our testing. So we believe that this patch can and should be safely applied to sid's initramfs-tools straight away. Ian.
diff -ruN ../orig/initramfs-tools-0.85eubuntu16/debian/changelog initramfs-tools-0.85eubuntu18/debian/changelog --- ../orig/initramfs-tools-0.85eubuntu16/debian/changelog 2007-07-31 06:31:15.000000000 +0100 +++ initramfs-tools-0.85eubuntu18/debian/changelog 2007-08-24 15:45:43.000000000 +0100 @@ -1,3 +1,19 @@ +initramfs-tools (0.85eubuntu18) gutsy; urgency=low + + * Use dpkg-trigger even in our own postinst, unless we're doing + trigger processing or the running dpkg version doesn't support + reflexive triggers. This reduces update-initramfs runs from two per + upgrade batch to one per batch. + + -- Ian Jackson <[EMAIL PROTECTED]> Fri, 24 Aug 2007 15:45:38 +0100 + +initramfs-tools (0.85eubuntu17) gutsy; urgency=low + + * Use dpkg-trigger (if available and operational) to save on + calls to update-initramfs. + + -- Ian Jackson <[EMAIL PROTECTED]> Thu, 16 Aug 2007 16:03:52 +0100 + initramfs-tools (0.85eubuntu16) gutsy; urgency=low * Load thermal modules on lpia as well. This may need to change in diff -ruN ../orig/initramfs-tools-0.85eubuntu16/debian/initramfs-tools.postinst initramfs-tools-0.85eubuntu18/debian/initramfs-tools.postinst --- ../orig/initramfs-tools-0.85eubuntu16/debian/initramfs-tools.postinst 2006-12-21 23:32:07.000000000 +0000 +++ initramfs-tools-0.85eubuntu18/debian/initramfs-tools.postinst 2007-08-24 15:45:02.000000000 +0100 @@ -25,9 +25,16 @@ -# Regenerate initramfs on upgrade -if [ "$1" = "configure" ] && [ -n "$2" ]; then +# Regenerate initramfs whenever we go to dpkg state `installed' + +if [ "x$1" != xtriggered ] && \ + dpkg --compare-versions "$DPKG_RUNNING_VERSION" ge '1.14.5ubuntu10~~' +then update-initramfs -u + # ... this activates the trigger, if triggers are working +else + DPKG_MAINTSCRIPT_PACKAGE='' update-initramfs -u + # ... force it to actually happen fi #DEBHELPER# diff -ruN ../orig/initramfs-tools-0.85eubuntu16/debian/initramfs-tools.triggers initramfs-tools-0.85eubuntu18/debian/initramfs-tools.triggers --- ../orig/initramfs-tools-0.85eubuntu16/debian/initramfs-tools.triggers 1970-01-01 01:00:00.000000000 +0100 +++ initramfs-tools-0.85eubuntu18/debian/initramfs-tools.triggers 2007-08-16 16:03:05.000000000 +0100 @@ -0,0 +1 @@ +interest update-initramfs diff -ruN ../orig/initramfs-tools-0.85eubuntu16/debian/rules initramfs-tools-0.85eubuntu18/debian/rules --- ../orig/initramfs-tools-0.85eubuntu16/debian/rules 2006-12-21 23:32:07.000000000 +0000 +++ initramfs-tools-0.85eubuntu18/debian/rules 2007-08-16 16:10:49.000000000 +0100 @@ -8,3 +8,7 @@ for x in `find scripts/ -maxdepth 1 -type d | tail -n+2`; do \ chmod -R +x $$x; \ done + +binary-install/initramfs-tools:: + install -m 644 -o 0 -g 0 debian/initramfs-tools.triggers \ + debian/initramfs-tools/DEBIAN/triggers diff -ruN ../orig/initramfs-tools-0.85eubuntu16/update-initramfs initramfs-tools-0.85eubuntu18/update-initramfs --- ../orig/initramfs-tools-0.85eubuntu16/update-initramfs 2007-04-10 16:07:41.000000000 +0100 +++ initramfs-tools-0.85eubuntu18/update-initramfs 2007-08-16 16:56:23.000000000 +0100 @@ -4,11 +4,24 @@ BOOTDIR=/boot CONF=/etc/initramfs-tools/update-initramfs.conf KPKGCONF=/etc/kernel-img.conf +USETRIGGERS=true set -e [ -r ${CONF} ] && . ${CONF} +if $USETRIGGERS \ + && test x"$DPKG_MAINTSCRIPT_PACKAGE" != x \ + && test $# = 1 \ + && test x"$1" = x-u \ + && dpkg-trigger --check-supported 2>/dev/null +then + if dpkg-trigger --no-await update-initramfs; then + echo "update-initramfs: deferring update (trigger activated)" + exit 0 + fi +fi + usage() { if [ -n "${1}" ]; then