Add code to invirt-reload to de-duplicate multiple invocations. (LP: #439426) 0.0.29
authorEvan Broder <broder@mit.edu>
Thu, 28 Jan 2010 02:53:16 +0000 (21:53 -0500)
committerEvan Broder <broder@mit.edu>
Thu, 28 Jan 2010 02:53:16 +0000 (21:53 -0500)
This uses the dpkg triggers mechanism to de-duplicate multiple
invocations of invirt-reload over the course of a single dpkg run.

The code is largely lifted from Ubuntu's update-initramfs.

svn path=/trunk/packages/invirt-base/; revision=2941

debian/changelog
debian/invirt-base.postinst
scripts/invirt-reload

index dda2cdb..3d3f987 100644 (file)
@@ -1,8 +1,13 @@
 invirt-base (0.0.29) unstable; urgency=low
 
+  [ Greg Brockman ]
   * Added a safestructs for doing config without raising.
 
- -- Greg Brockman <gdb@mit.edu>  Tue, 19 Jan 2010 23:49:19 -0500
+  [ Evan Broder ]
+  * Support running invirt-reload directly from a package postinst,
+    instead of via triggers. (LP: #439426)
+
+ -- Evan Broder <broder@mit.edu>  Wed, 27 Jan 2010 21:18:07 -0500
 
 invirt-base (0.0.28) unstable; urgency=low
 
index a2ae96f..73ea19b 100755 (executable)
@@ -26,7 +26,11 @@ case "$1" in
     ;;
 
     triggered)
-        invirt-reload
+        if dpkg --compare-versions "$DPKG_RUNNING_VERSION" ge '1.14.5ubuntu10~~'; then
+            invirt-reload
+        else
+            DPKG_MAINTSCRIPT_PACKAGE='' invirt-reload
+        fi
     ;;
 
     *)
index 75e9503..84dbe7a 100755 (executable)
@@ -1,5 +1,14 @@
 #!/bin/bash
 
+if [ "$DPKG_MAINTSCRIPT_PACKAGE" != '' ] && \
+    [ $# = 0 ] && \
+    dpkg-trigger --check-supported 2>/dev/null; then
+    if dpkg-trigger --no-await invirt-base; then
+        echo "invirt-reload: deferring update (trigger activated)"
+        exit 0
+    fi
+fi
+
 for script in $(run-parts --test /etc/init.d); do
     if [ "${script#/etc/init.d/invirt-}" != "$script" ]; then
        invoke-rc.d "${script#/etc/init.d/}" force-reload