[Pkg-dkms-maint] [PATCH 1/4] Insert the package version directly into postinst at creation time

Frédéric Brière fbriere at fbriere.net
Wed Feb 17 21:14:09 UTC 2010


dh_dkms already knows the package version, so it can insert it directly
into the package's postinst, instead of trying to figure it out during
the installation.  This was already the case for prerm, but not for
postinst.

(Besides, the dpkg-query invocation did not account for '-' being
allowed in the upstream version.)

This also renames $DKMS_CVERSION to $DKMS_VERSION, in line with prerm.
---
 debian/scripts/dh_dkms       |    2 +-
 debian/scripts/postinst-dkms |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/debian/scripts/dh_dkms b/debian/scripts/dh_dkms
index 085b232..f2644ad 100755
--- a/debian/scripts/dh_dkms
+++ b/debian/scripts/dh_dkms
@@ -150,7 +150,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 	autoscript($package, "prerm", "prerm-dkms",
 	    "s/#MODULE_NAME#/$package_name/;s/#MODULE_VERSION#/$package_version/");
 	autoscript($package, "postinst", "postinst-dkms",
-	    "s/#MODULE_NAME#/$package_name/");
+	    "s/#MODULE_NAME#/$package_name/;s/#MODULE_VERSION#/$package_version/");
 	doit("install", "-p", "-D", "-m644", "$name", "$tmp/usr/src/$package_name-$package_version/dkms.conf");
 }
 
diff --git a/debian/scripts/postinst-dkms b/debian/scripts/postinst-dkms
index 706a9a6..0084a6e 100644
--- a/debian/scripts/postinst-dkms
+++ b/debian/scripts/postinst-dkms
@@ -3,7 +3,7 @@
 
 DKMS_NAME=#MODULE_NAME#
 DKMS_PACKAGE_NAME=$DKMS_NAME-dkms
-DKMS_CVERSION=$(dpkg-query -W -f='${Version}' $DKMS_PACKAGE_NAME | awk -F "-" '{print $1}' | cut -d\: -f2)
+DKMS_VERSION=#MODULE_VERSION#
 
 postinst_found=0
 
@@ -11,7 +11,7 @@ case "$1" in
 	configure)
 		for DKMS_POSTINST in /usr/lib/dkms/common.postinst /usr/share/$DKMS_PACKAGE_NAME/postinst; do
 			if [ -f $DKMS_POSTINST ]; then
-				$DKMS_POSTINST $DKMS_NAME $DKMS_CVERSION /usr/share/$DKMS_PACKAGE_NAME "" $2
+				$DKMS_POSTINST $DKMS_NAME $DKMS_VERSION /usr/share/$DKMS_PACKAGE_NAME "" $2
 				postinst_found=1
 				break
 			fi
-- 
1.7.0




More information about the Pkg-dkms-maint mailing list