Subject: [PATCH] Check for ${misc:Depends} again in suggests and recommends, but emmit weak-dependency-on-misc-depends in that case

From: Raphael Geissert <[email-masked]>
Date: Mon, 19 Jan 2009 20:56:30 -0600

Signed-off-by: Raphael Geissert <[email-masked]>
---
 checks/debhelper                                   |   19 +++++++++++++++----
 checks/debhelper.desc                              |    9 +++++++++
 t/tests/6000_debhelper-no-depends.desc             |    1 +
 .../debhelper-no-depends/debian/debian/control.in  |   18 ++++++++++++++++++
 t/tests/debhelper-no-depends/tags                  |    1 +
 5 files changed, 44 insertions(+), 4 deletions(-)

diff --git a/checks/debhelper b/checks/debhelper
index 7fe7088..5ac54f4 100644
--- a/checks/debhelper
+++ b/checks/debhelper
@@ -143,18 +143,29 @@ my $pkgs = $info->binaries;
 my $single_pkg = keys(%$pkgs) == 1 ? $pkgs->{(keys(%$pkgs))[0]} : '';
 
 for my $binpkg (keys %$pkgs) {
-    my $depends = '';
+    my ($weak_depends, $strong_depends, $depends) = ('','','');
     local $/;
 
-    foreach my $field (qw(pre-depends depends recommends)) {
+    foreach my $field (qw(pre-depends depends)) {
 	if (open DEPENDS, '<', "control/$binpkg/$field") {
-	    chomp ($depends .= <DEPENDS>);
+	    chomp ($strong_depends .= <DEPENDS>);
 	    close(DEPENDS);
 	}
     }
+    foreach my $field (qw(recommends suggests)) {
+	if (open DEPENDS, '<', "control/$binpkg/$field") {
+	    chomp ($weak_depends .= <DEPENDS>);
+	    close(DEPENDS);
+	}
+    }
+    $depends = $weak_depends . $strong_depends;
 
     tag 'debhelper-but-no-misc-depends', $binpkg
-        if $needmiscdepends and $depends !~ m/\$\{misc:Depends\}/
+	if $needmiscdepends and $depends !~ m/\$\{misc:Depends\}/
+	   and $pkgs->{$binpkg} eq 'deb';
+
+    tag 'weak-dependency-on-misc-depends', $binpkg
+	if $weak_depends =~ m/\$\{misc:Depends\}/
 	   and $pkgs->{$binpkg} eq 'deb';
 }
 
diff --git a/checks/debhelper.desc b/checks/debhelper.desc
index 8df17ad..a6c9b6a 100644
--- a/checks/debhelper.desc
+++ b/checks/debhelper.desc
@@ -153,3 +153,12 @@ Info: This debhelper config file appears to use shell brace expansion
  to an accident of implementation but is not a supported feature.  Only
  <tt>?</tt>, <tt>*</tt>, and <tt>[...]</tt> are supported.
 Ref: debhelper(1)
+
+Tag: weak-dependency-on-misc-depends
+Severity: normal
+Certainty: possible
+Ref: debhelper(7)
+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.
diff --git a/t/tests/6000_debhelper-no-depends.desc b/t/tests/6000_debhelper-no-depends.desc
index ea1b967..9c7a7a6 100644
--- a/t/tests/6000_debhelper-no-depends.desc
+++ b/t/tests/6000_debhelper-no-depends.desc
@@ -6,3 +6,4 @@ Test-For:
  missing-build-dependency-for-dh_-command
  package-lacks-versioned-build-depends-on-debhelper
  package-uses-debhelper-but-lacks-build-depends
+ weak-dependency-on-misc-depends
diff --git a/t/tests/debhelper-no-depends/debian/debian/control.in b/t/tests/debhelper-no-depends/debian/debian/control.in
index 32a68ca..4c9af3e 100644
--- a/t/tests/debhelper-no-depends/debian/debian/control.in
+++ b/t/tests/debhelper-no-depends/debian/debian/control.in
@@ -10,3 +10,21 @@ Description: {$description}
  This is a test package designed to exercise some feature or tag of
  Lintian.  It is part of the Lintian test suite and may do very odd
  things.  It should not be installed like a regular package.
+
+Package: debhelper-pre-depends
+Architecture: {$architecture}
+Pre-Depends: $\{misc:Depends\}
+Description: {$description} extra string
+ This is a test package designed to exercise some feature or tag of
+ Lintian.  It is part of the Lintian test suite and may do very odd
+ things.  It should not be installed like a regular package. Extra
+ string to not to trigger duplicated description tags.
+
+Package: debhelper-suggests
+Architecture: {$architecture}
+Suggests: $\{misc:Depends\}
+Description: {$description} another extra string
+ This is a test package designed to exercise some feature or tag of
+ Lintian.  It is part of the Lintian test suite and may do very odd
+ things.  It should not be installed like a regular package. Extra
+ string.
diff --git a/t/tests/debhelper-no-depends/tags b/t/tests/debhelper-no-depends/tags
index 344eb61..3b42b9d 100644
--- a/t/tests/debhelper-no-depends/tags
+++ b/t/tests/debhelper-no-depends/tags
@@ -4,3 +4,4 @@ E: debhelper-no-depends source: missing-build-dependency-for-dh_-command dh_lisp
 E: debhelper-no-depends source: package-uses-debhelper-but-lacks-build-depends
 W: debhelper-no-depends source: debhelper-but-no-misc-depends debhelper-no-depends
 W: debhelper-no-depends source: package-lacks-versioned-build-depends-on-debhelper 7
+W: debhelper-no-depends source: weak-dependency-on-misc-depends debhelper-suggests