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

Bug#499737: [checks/debhelper] emit debhelper-but-no-miscDepends



On Sunday 21 September 2008, you wrote:
> On Sun, Sep 21, 2008 at 01:33:54PM -0500, Raphael Geissert wrote:
> > Forwarding a patch I sent in gahf9p$lps$3@ger.gmane.org to the BTS, so it
> > is noticed.
>
> This one is currently on my 2.1.0 TODO list. Which should not keep
> anyone else from picking it up earlier of course ;)

I'm not really sure, but I think you sent me an email about this and the patch 
no longer applying in master. I can't confirm that you actually said that 
because I haven't found any email stating such a thing but well...

Attached is the output of git diff origin/master -- checks/debhelper*; IOW: if 
the previous patch does no longer apply just don't apply those modifying 
checks/debhelper* and apply the one attached in this email.

And since I haven't found where I sent the script that takes care of updating 
the data files I'm also attaching it.

I hope this isn't a confusion on my side.

>
> Gruesse,

Cheers,
-- 
Raphael Geissert - Debian Maintainer
www.debian.org - get.debian.net
diff --git a/checks/debhelper b/checks/debhelper
index 6dc81b5..0cdfb5c 100644
--- a/checks/debhelper
+++ b/checks/debhelper
@@ -25,6 +25,7 @@ use lib "$ENV{'LINTIAN_ROOT'}/lib";
 use Dep;
 use Tags;
 use Util;
+use Lintian::Data;
 
 # If there is no debian/compat file present but cdbs is being used, cdbs will
 # create one automatically.  Currently it always uses compatibility level 5.
@@ -33,38 +34,9 @@ use Util;
 
 my $cdbscompat = 5;
 
-# Parse the debian/rules file, and try to figure out if debhelper commands
-# are run in it that like to modify maintainer scripts. Those debhelper
-# commands can be found by "grep -l autoscript /usr/bin/dh_*", but I'll
-# hardcode them here.
-
-my %commands;
-map { $commands{$_}=1 } qw(dh_desktop
-			   dh_gconf
-			   dh_icons
-			   dh_installcatalogs
-			   dh_installdebconf
-                           dh_installdefoma
-                           dh_installdocs
-			   dh_installemacsen
-			   dh_installinfo
-			   dh_installinit
-			   dh_installmenu
-			   dh_installmime
-			   dh_installmodules
-			   dh_installtex
-			   dh_installudev
-			   dh_installwm
-			   dh_installxfonts
-			   dh_installxmlcatalogs
-			   dh_makeshlibs
-			   dh_pycentral
-			   dh_pysupport
-			   dh_python
-			   dh_scrollkeeper
-			   dh_suidregister
-			   dh_usrlocal
-			   );
+my $maint_commands = Lintian::Data->new ('debhelper/maint_commands');
+my $miscDeps_commands = Lintian::Data->new ('debhelper/miscDepends_commands');
+my $dh_commands_depends = Lintian::Data->new ('debhelper/dh_commands', '=');
 
 # The version at which debhelper commands were introduced.  Packages that use
 # one of these commands must have a dependency on that version of debhelper or
@@ -91,12 +63,14 @@ my $compat = '';
 my $usescdbs = '';
 my $seendhpython = '';
 my $usescdbspython = '';
+my $needmiscdepends = 0;
+my %missingbdeps;
 
 open(RULES, '<', "debfiles/rules") or fail("cannot read debian/rules: $!");
 my $dhcompatvalue;
 my @versioncheck;
 while (<RULES>) {
-    if (m/^\s+(dh_\w+)/) {
+    if (m/^\s+-?(dh_\w+)/) {
         my $dhcommand = $1;
     	if ($dhcommand =~ /dh_testversion(?:\s+(.+))?/) {
 	    $needversiondepends = $1 if ($1);
@@ -109,9 +83,16 @@ while (<RULES>) {
 	    tag "dh_suidregister-is-obsolete", "";
 	}
 	# if command is passed -n, it does not modify the scripts
-	if ($commands{$dhcommand} and not m/\s+\-n\s+/) {
+	if ($maint_commands->known($dhcommand) and not m/\s+\-n\s+/) {
 	    $needtomodifyscripts = 1;
 	}
+	if ($miscDeps_commands->known($dhcommand)) {
+	    $needmiscdepends = 1;
+	}
+	if ($dh_commands_depends->known($dhcommand)) {
+	    my $dep = $dh_commands_depends->value($dhcommand);
+	    $missingbdeps{$dep} = $dhcommand;
+	}
         if ($versions{$dhcommand}) {
             push (@versioncheck, $dhcommand);
         }
@@ -120,11 +101,13 @@ while (<RULES>) {
     } elsif (m,^\s+dh\s+,) {
 	$seencommand = 1;
 	$needbuilddepends = 1;
+	$needmiscdepends = 1;
 	push (@versioncheck, 'dh');
     } elsif (m,^include\s+/usr/share/cdbs/1/rules/debhelper.mk,) {
 	$seencommand = 1;
 	$needbuilddepends = 1;
 	$needtomodifyscripts = 1;
+	$needmiscdepends = 1;
 
 	# CDBS sets DH_COMPAT but doesn't export it.  It does, however, create
 	# a debian/compat file if none was found; that logic is handled later.
@@ -150,10 +133,23 @@ return unless $seencommand;
 my $pkgs = $info->binaries;
 my $single_pkg = keys(%$pkgs) == 1 ? $pkgs->{(keys(%$pkgs))[0]} : '';
 
+for my $binpkg (keys %$pkgs) {
+    my $depends = '';
+
+    if (open DEPENDS, '<', "control/$binpkg/depends") {
+	chomp ($depends = <DEPENDS>);
+	close(DEPENDS);
+    }
+
+    tag 'debhelper-but-no-miscDepends', $binpkg
+        if ($needmiscdepends and $depends !~ m/\$\{misc:Depends\}/
+            and $pkgs->{$binpkg} eq 'deb');
+}
+
 # If we got this far, they need to have #DEBHELPER# in their scripts.  Search
 # for scripts that look like maintainer scripts.  Also collect dependency
 # information from debian/control and check compatibility level.
-my $depends;
+my $bdepends;
 opendir(DEBIAN, 'debfiles')
     or fail("Can't open debfiles directory.");
 while (defined(my $file=readdir(DEBIAN))) {
@@ -194,16 +190,21 @@ while (defined(my $file=readdir(DEBIAN))) {
 	}
     } elsif ($file =~ m/^control$/) {
         my ($control) = read_dpkg_control("debfiles/$file");
-        $depends = '';
+        $bdepends = '';
         for my $field ('build-depends', 'build-depends-indep') {
             next unless $control->{$field};
-            $depends .= ', ' if $depends;
-            $depends .= $control->{$field};
+            $bdepends .= ', ' if $bdepends;
+            $bdepends .= $control->{$field};
         }
-        $depends = Dep::parse($depends);
-        if ($needbuilddepends && ! Dep::implies($depends, Dep::parse('debhelper'))) {
+        $bdepends = Dep::parse($bdepends);
+        if ($needbuilddepends && ! Dep::implies($bdepends, Dep::parse('debhelper'))) {
 	    tag "package-uses-debhelper-but-lacks-build-depends", "";
 	}
+	for my $dep (keys %missingbdeps) {
+	    my $command = $missingbdeps{$dep};
+	    tag 'missing-build-dependency-for-dh_-command', "$command=$dep"
+		    unless (Dep::implies($bdepends, Dep::parse($dep)));
+	}
     } elsif ($file =~ m/^ex\.|\.ex$/i) {
         tag "dh-make-template-in-source", "debian/$file";
     }
@@ -230,13 +231,13 @@ if ($usescdbs and not $needversiondepends) {
 $needversiondepends ||= 1;
 if ($needversiondepends < 4) {
     tag "package-uses-deprecated-debhelper-compat-version", $needversiondepends;
-} elsif ($needversiondepends > 5 and ! Dep::implies($depends, Dep::parse("debhelper (>= $needversiondepends)"))) {
+} elsif ($needversiondepends > 5 and ! Dep::implies($bdepends, Dep::parse("debhelper (>= $needversiondepends)"))) {
     tag "package-lacks-versioned-build-depends-on-debhelper", $needversiondepends;
 } elsif (@versioncheck) {
     for my $program (@versioncheck) {
         my $required = $versions{$program};
         tag 'debhelper-script-needs-versioned-build-depends', $program, "(>= $required)"
-            unless Dep::implies($depends, Dep::parse("debhelper (>= $required)"));
+            unless Dep::implies($bdepends, Dep::parse("debhelper (>= $required)"));
     }
 }
 
diff --git a/checks/debhelper.desc b/checks/debhelper.desc
index 603eae4..383c868 100644
--- a/checks/debhelper.desc
+++ b/checks/debhelper.desc
@@ -105,6 +105,24 @@ Info: This package uses dh_python but apparently does not tell it to use
  may mean that the package has not been converted to the current Python
  policy, in which case it probably should be.
 
+Tag: debhelper-but-no-miscDepends
+Type: warning
+Severity: normal
+Certainty: certain
+Ref: debhelper(7)
+Info: The source package uses debhelper but it does not have ${misc:Depends} on
+ the given binary package debian/control entry.  This is required so the
+ dependencies are set correctly in case the result of a call to any of the dh_
+ commands cause the package to depend on another package.
+
+Tag: missing-build-dependency-for-dh_-command
+Type: error
+Severity: important
+Certainty: possible
+Info: The source package appears to be using a dh_ command but doesn't build
+ depend on the package that actually provides it.  If it uses it, it must
+ build depend on it.
+
 Tag: debhelper-script-needs-versioned-build-depends
 Severity: normal
 Certainty: certain

Attachment: refresh-debhelper-data
Description: application/shellscript


Reply to: