From 107232c3213b09f8a2f77daf0be9406239f09fe1 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Mon, 1 Feb 2010 17:36:18 -0500 Subject: [PATCH] template postinst: Do not skip autogenerated #DEBHELPER# scripts By exiting after common.postinst, the template postinst would skip any autogenerated scripts that replace #DEBHELPER#. Factor this logic out into a separate function so we can return from it instead of exiting the entire script. Also use set -e (as strongly recommended by Debian policy), exit 0 at the end, clean up shell quoting, and print error messages to stderr. Signed-off-by: Anders Kaseorg --- template-dkms-mkdeb/debian/postinst | 35 +++++++++++++++++++++++------------ 1 files changed, 23 insertions(+), 12 deletions(-) diff --git a/template-dkms-mkdeb/debian/postinst b/template-dkms-mkdeb/debian/postinst index afb2ee4..a92c9e1 100644 --- a/template-dkms-mkdeb/debian/postinst +++ b/template-dkms-mkdeb/debian/postinst @@ -4,25 +4,31 @@ # Copyright (C) 2007 Mario Limonciello # Copyright (C) 2009 Alberto Milone +set -e + NAME=MODULE_NAME PACKAGE_NAME=$NAME-dkms CVERSION=`dpkg-query -W -f='${Version}' $PACKAGE_NAME | awk -F "-" '{print $1}' | cut -d\: -f2` ARCH=`dpkg --print-architecture` +dkms_configure () { + for POSTINST in /usr/lib/dkms/common.postinst "/usr/share/$PACKAGE_NAME/postinst"; do + if [ -f "$POSTINST" ]; then + "$POSTINST" "$NAME" "$CVERSION" "/usr/share/$PACKAGE_NAME" "$ARCH" "$2" + return $? + fi + echo "WARNING: $POSTINST does not exist." >&2 + done + echo "ERROR: DKMS version is too old and $PACKAGE_NAME was not" >&2 + echo "built with legacy DKMS support." >&2 + echo "You must either rebuild $PACKAGE_NAME with legacy postinst" >&2 + echo "support or upgrade DKMS to a more current version." >&2 + return 1 +} + case "$1" in configure) - for POSTINST in /usr/lib/dkms/common.postinst /usr/share/$PACKAGE_NAME/postinst; do - if [ -f $POSTINST ]; then - $POSTINST $NAME $CVERSION /usr/share/$PACKAGE_NAME $ARCH $2 - exit $? - fi - echo "WARNING: $POSTINST does not exist." - done - echo "ERROR: DKMS version is too old and $PACKAGE_NAME was not" - echo "built with legacy DKMS support." - echo "You must either rebuild $PACKAGE_NAME with legacy postinst" - echo "support or upgrade DKMS to a more current version." - exit 1 + dkms_configure ;; abort-upgrade|abort-remove|abort-deconfigure) @@ -34,4 +40,9 @@ case "$1" in ;; esac +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + #DEBHELPER# + +exit 0 -- 1.7.0.rc1