[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[SCM] Debian package checker branch, master, updated. 2.2.0-46-ge210ecf



The following commit has been merged in the master branch:
commit 7daa404e4a5f63da52ddc21a478b8a73cf3c8a29
Author: Raphael Geissert <atomo64@gmail.com>
Date:   Sat Jan 31 18:53:03 2009 -0600

    Improve debhelper compatibility level checking
    
    Improve the parsing of debian/rules to extract the DH_COMPAT information,
    only extract the first line of debian/compat, just like debhelper does,
    and warn if the compatibility version either in debian/compat or
    debian/rules is not a number.
    
    Signed-off-by: Raphael Geissert <atomo64@gmail.com>

diff --git a/checks/debhelper b/checks/debhelper
index 19db213..f761c30 100644
--- a/checks/debhelper
+++ b/checks/debhelper
@@ -77,9 +77,9 @@ my @versioncheck;
 while (<RULES>) {
     if (m/^\s+-?(dh_\w+)/) {
         my $dhcommand = $1;
-    	if ($dhcommand =~ /dh_testversion(?:\s+(.+))?/) {
+	if ($dhcommand =~ /dh_testversion(?:\s+([^\s]+))?/) {
 	    $needversiondepends = $1 if ($1);
-            tag "dh_testversion-is-deprecated", "";
+	    tag "dh_testversion-is-deprecated", "";
 	}
 	if ($dhcommand eq 'dh_dhelp') {
 	    tag "dh_dhelp-is-deprecated", "";
@@ -122,12 +122,15 @@ while (<RULES>) {
 	# a debian/compat file if none was found; that logic is handled later.
 	$dhcompatvalue = $cdbscompat;
 	$usescdbs = 1;
-    } elsif (/^\s*export\s+DH_COMPAT\s*:?=\s*(\d+)/) {
+    } elsif (/^\s*export\s+DH_COMPAT\s*:?=\s*([^\s]+)/) {
 	$needversiondepends = $1;
     } elsif (/^\s*export\s+DH_COMPAT/) {
 	$needversiondepends = $dhcompatvalue if $dhcompatvalue;
-    } elsif (/^\s*DH_COMPAT\s*:?=\s*(\d+)/) {
+    } elsif (/^\s*DH_COMPAT\s*:?=\s*([^\s]+)/) {
 	$dhcompatvalue = $1;
+	# one can export and then set the value:
+	$needversiondepends = $1
+	    if ($needversiondepends);
     }
     if (/^\s+dh_python\s/) {
         $seendhpython = 1;
@@ -163,23 +166,37 @@ for my $binpkg (keys %$pkgs) {
 	   and $pkgs->{$binpkg} eq 'deb';
 }
 
+my $compatnan = 0;
 # Check the compat file.  Do this separately from looping over all of the
 # other files since we use the compat value when checking for brace expansion.
 if (-f 'debfiles/compat') {
-    $compat = slurp_entire_file('debfiles/compat');
+    my $compat_file = slurp_entire_file('debfiles/compat');
+    ($compat) = split(/\n/, $compat_file);
     $compat =~ s/^\s+$//;
     if ($compat) {
-	$compat =~ s/\s+$//;
+	chomp $compat;
+	if ($compat !~ m/^\d+$/) {
+	    tag 'debhelper-compat-is-not-a-number', $compat;
+	    $compat =~ s/[^\d]//g;
+	    $compatnan = 1;
+	}
 	if ($needversiondepends) {
 	    tag 'declares-possibly-conflicting-debhelper-compat-versions',
 		"rules=$needversiondepends compat=$compat";
 	} else {
+	    # this is not just to fill in the gap, but because debhelper
+	    # prefers DH_COMPAT over debian/compat
 	    $needversiondepends = $compat;
 	}
     } else {
 	tag 'debhelper-compat-file-is-empty';
     }
 }
+if ($needversiondepends !~ m/^\d+$/ and not $compatnan) {
+    tag 'debhelper-compatibility-version-is-not-a-number', $needversiondepends;
+    $needversiondepends =~ s/[^\d]//g;
+    $compatnan = 1;
+}
 
 # Check the files in the debian directory for various debhelper-related
 # things.
diff --git a/checks/debhelper.desc b/checks/debhelper.desc
index 9f42dfa..8688396 100644
--- a/checks/debhelper.desc
+++ b/checks/debhelper.desc
@@ -82,7 +82,8 @@ Severity: important
 Certainty: certain
 Ref: debhelper(7)
 Info: The source package has an empty debian/compat file. This is an error,
- the compat level of debhelper should be in there.
+ the compat level of debhelper should be in there. Note that only the first
+ line of the file is relevant.
 
 Tag: declares-possibly-conflicting-debhelper-compat-versions
 Severity: important
@@ -160,3 +161,13 @@ Info: The source package declares a weak dependecy on ${misc:Depends} in
  the given binary package's debian/control entry.  A stronger dependency, that
  is one that ensures the package's installation, is required so that the
  additional commands are available to the maintainer scripts when they are run.
+
+Tag: debhelper-compat-is-not-a-number
+Severity: serious
+Certainty: possible
+Info: The compat version specified in <tt>debian/compat</tt> is not a number.
+
+Tag: debhelper-compatibility-version-is-not-a-number
+Severity: serious
+Certainty: possible
+Info: The compatibility version specified in <tt>debian/rules</tt> is not a number.
diff --git a/t/tests/debhelper-compat/debian/debian/compat b/t/tests/debhelper-compat/debian/debian/compat
new file mode 100644
index 0000000..59b4382
--- /dev/null
+++ b/t/tests/debhelper-compat/debian/debian/compat
@@ -0,0 +1 @@
+[7-
diff --git a/t/tests/debhelper-compat/desc b/t/tests/debhelper-compat/desc
new file mode 100644
index 0000000..503ee69
--- /dev/null
+++ b/t/tests/debhelper-compat/desc
@@ -0,0 +1,5 @@
+Testname: debhelper-compat
+Sequence: 6000
+Version: 1.0
+Description: Test the content of debian/compat
+Test-For: debhelper-compat-is-not-a-number
diff --git a/t/tests/debhelper-compat/tags b/t/tests/debhelper-compat/tags
new file mode 100644
index 0000000..283d75a
--- /dev/null
+++ b/t/tests/debhelper-compat/tags
@@ -0,0 +1 @@
+E: debhelper-compat source: debhelper-compat-is-not-a-number [7-
diff --git a/t/tests/debhelper-dh-compat/debian/debian/rules b/t/tests/debhelper-dh-compat/debian/debian/rules
new file mode 100755
index 0000000..a36f8fd
--- /dev/null
+++ b/t/tests/debhelper-dh-compat/debian/debian/rules
@@ -0,0 +1,8 @@
+#!/usr/bin/make -f
+
+export DH_COMPAT=7
+
+%:
+	dh $@
+
+DH_COMPAT='{3'
diff --git a/t/tests/debhelper-dh-compat/desc b/t/tests/debhelper-dh-compat/desc
new file mode 100644
index 0000000..678c159
--- /dev/null
+++ b/t/tests/debhelper-dh-compat/desc
@@ -0,0 +1,5 @@
+Testname: debhelper-dh-compat
+Sequence: 6000
+Version: 1.0
+Description: Test the value of DH_COMPAT
+Test-For: debhelper-compatibility-version-is-not-a-number
diff --git a/t/tests/debhelper-dh-compat/tags b/t/tests/debhelper-dh-compat/tags
new file mode 100644
index 0000000..bac2af5
--- /dev/null
+++ b/t/tests/debhelper-dh-compat/tags
@@ -0,0 +1,4 @@
+E: debhelper-dh-compat source: debhelper-compatibility-version-is-not-a-number '{3'
+E: debhelper-dh-compat source: declares-possibly-conflicting-debhelper-compat-versions rules='{3' compat=7
+W: debhelper-dh-compat source: debian-rules-sets-DH_COMPAT line 3
+W: debhelper-dh-compat source: package-uses-deprecated-debhelper-compat-version 3

-- 
Debian package checker


Reply to: