diff -Nru initramfs-tools-0.103ubuntu8/debian/changelog initramfs-tools-0.103ubuntu8triggers4/debian/changelog --- initramfs-tools-0.103ubuntu8/debian/changelog 2014-08-01 16:46:35.000000000 +0100 +++ initramfs-tools-0.103ubuntu8triggers4/debian/changelog 2014-10-04 13:50:06.000000000 +0100 @@ -1,3 +1,10 @@ +initramfs-tools (0.103ubuntu8triggers4) utopic; urgency=medium + + * Widen the scope of triggers so they can handle more than just + initramfs-tools -u. + + -- Andy Whitcroft Fri, 03 Oct 2014 16:12:26 +0100 + initramfs-tools (0.103ubuntu8) utopic; urgency=medium * Add readlink symlink for busybox in the busybox hook, needed to diff -Nru initramfs-tools-0.103ubuntu8/debian/initramfs-tools.postinst initramfs-tools-0.103ubuntu8triggers4/debian/initramfs-tools.postinst --- initramfs-tools-0.103ubuntu8/debian/initramfs-tools.postinst 2012-06-01 04:36:34.000000000 +0100 +++ initramfs-tools-0.103ubuntu8triggers4/debian/initramfs-tools.postinst 2014-10-03 16:12:22.000000000 +0100 @@ -6,13 +6,31 @@ cp /usr/share/initramfs-tools/modules /etc/initramfs-tools/ fi +runner() +{ + local file="$1" + set - update-initramfs + while read arg + do + set - "$@" "$arg" + done <"$file" + echo "triggering: $@" + DPKG_MAINTSCRIPT_PACKAGE='' "$@" +} + # Regenerate initramfs whenever we go to dpkg state `installed' if [ "x$1" != xtriggered ]; then # this activates the trigger, if triggers are working update-initramfs -u else - # force it to actually happen - DPKG_MAINTSCRIPT_PACKAGE='' update-initramfs -u + STATEDIR="/var/lib/initramfs-tools" + + # Run the latest trigger for any one version. + for todo in "$STATEDIR"/.trigger.* + do + runner "$todo" + rm -f "$todo" + done fi #DEBHELPER# diff -Nru initramfs-tools-0.103ubuntu8/update-initramfs initramfs-tools-0.103ubuntu8triggers4/update-initramfs --- initramfs-tools-0.103ubuntu8/update-initramfs 2012-06-01 04:36:34.000000000 +0100 +++ initramfs-tools-0.103ubuntu8triggers4/update-initramfs 2014-10-04 13:49:57.000000000 +0100 @@ -22,16 +22,18 @@ exit 0 fi ;; +esac +trigger="" +case "$DPKG_MAINTSCRIPT_PACKAGE" in ?*) if $USETRIGGERS \ - && [ $# = 1 ] \ - && [ 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 + trigger=`mktemp -p "$STATEDIR" .cmd.XXXXXXXXXX` + for arg in "$@" + do + echo "$arg" + done >>"$trigger" fi ;; esac @@ -464,6 +466,7 @@ if [ "${version}" = "all" ] \ || ( [ "${update_initramfs}" = "all" ] && [ -z "${version}" ] ); then + [ "$trigger" != '' ] && rm -f "$trigger" : FIXME check for --yes, and if not ask are you sure get_sorted_versions if [ -z "${version_list}" ]; then @@ -488,6 +491,19 @@ exit 0 fi +# Handle this as a trigger... +if [ "$trigger" != '' ]; then + tversion=${version} + if [ -z "${tversion}" ]; then + tversion="NONE" + fi + mv -f "$trigger" "$STATEDIR/.trigger.$tversion" + if dpkg-trigger --no-await update-initramfs; then + echo "update-initramfs: deferring update (trigger activated)" + exit 0 + fi + rm -f "$trigger" +fi case "${mode}" in c)