Package: dkms
Version: 2.2.0.3-4
Severity: normal
Tags: patch

In some cases, the dkms file is mis-written, or the dh_dkms file
parsing is too brittle to find the package name or version.

This pair of patches should:

 (a) make dh_dkms fail explicitly when the file is unparseable, and

 (b) make the parsing slightly less brittle in cases where
     PACKAGE_VERSION and PACKAGE_NAME are unquoted.

Thanks for dh_dkms!

Regards,

       --dkg


-- System Information:
Debian Release: stretch/sid
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'testing'), (200, 'unstable'), (1, 
'experimental-debug'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.6.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages dkms depends on:
ii  build-essential  11.7
ii  coreutils        8.25-2
ii  dpkg-dev         1.18.7
ii  gcc              4:5.3.1-3
ii  kmod             22-1.1
ii  make             4.1-9
ii  patch            2.7.5-1

Versions of packages dkms recommends:
ii  fakeroot             1.20.2-2
ii  linux-headers-amd64  4.6+74
pn  linux-image          <none>
ii  menu                 2.1.47

dkms suggests no packages.

-- debconf-show failed
>From b5f07ba60f76030b09f2f44db3ebe0487fb4ff25 Mon Sep 17 00:00:00 2001
From: Daniel Kahn Gillmor <d...@fifthhorseman.net>
Date: Thu, 30 Jun 2016 14:08:49 -0400
Subject: [PATCH 1/2] dh_dkms should fail cleanly with unknown package version
 or name

In some cases, the dkms file is mis-written, or the dh_dkms file
parsing is too brittle to find the package name or version.

in these cases, dh_dkms proceeds through, but spews errors like the
following:

Use of uninitialized value $package_version in concatenation (.) or string at /usr/bin/dh_dkms line 150.
Use of uninitialized value $package_version in concatenation (.) or string at /usr/bin/dh_dkms line 152.
Use of uninitialized value $package_version in concatenation (.) or string at /usr/bin/dh_dkms line 154.

This patch catches the error and reports it cleanly as an error.
---
 debian/scripts/dh_dkms | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/debian/scripts/dh_dkms b/debian/scripts/dh_dkms
index f2644ad..f5a1c4b 100755
--- a/debian/scripts/dh_dkms
+++ b/debian/scripts/dh_dkms
@@ -147,6 +147,12 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 		doit("sed", "-i", "s/#MODULE_VERSION#/$package_version/g", $name);
 	}
 
+        error "could not determine package name"
+          unless defined($package_name);
+
+        error "could not determine package version"
+          unless defined($package_version);
+
 	autoscript($package, "prerm", "prerm-dkms",
 	    "s/#MODULE_NAME#/$package_name/;s/#MODULE_VERSION#/$package_version/");
 	autoscript($package, "postinst", "postinst-dkms",
-- 
2.8.1

>From eaeb55be19ca37c7a09d04bc9d6160cf9d03a145 Mon Sep 17 00:00:00 2001
From: Daniel Kahn Gillmor <d...@fifthhorseman.net>
Date: Thu, 30 Jun 2016 14:02:16 -0400
Subject: [PATCH 2/2] handle dkms conf files where PACKAGE_VERSION or
 PACKAGE_NAME is unquoted

Some dkms.conf files do not quote PACKAGE_VERSION or PACKAGE_NAME,
like:

PACKAGE_NAME=blah
PACKAGE_VERSION=0.0.0

This patch lets dh_dkms grok this syntax.
---
 debian/scripts/dh_dkms | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/debian/scripts/dh_dkms b/debian/scripts/dh_dkms
index f5a1c4b..48fe8b3 100755
--- a/debian/scripts/dh_dkms
+++ b/debian/scripts/dh_dkms
@@ -116,8 +116,8 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 	# now, parse our configuration file
 	open(IN, "< $name");
 	while (my $l = <IN>) {
-		$l =~ /PACKAGE_NAME=(["'])(.*)\1/ && ($is_snippet = 1 && $package_name = $2);
-		$l =~ /PACKAGE_VERSION=(["'])(.*)\1/ && ($package_version = $2);
+		$l =~ /PACKAGE_NAME=(["']?)(.*)\1/ && ($is_snippet = 1 && $package_name = $2);
+		$l =~ /PACKAGE_VERSION=(["']?)(.*)\1/ && ($package_version = $2);
 	}
 	close(IN);
 
-- 
2.8.1

Reply via email to