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

Bug#242789: lintian: check if dh_clean is used in debian/rules clean without a debhelper dependency in Build-Depends



Package: lintian
Version: 1.22.12
Severity: wishlist
Tags: patch

Heya,

I had this patch in #214231, but it was reported with another issue (the
build-depends-without-arch-dep false positives) which was merged with
other bugs and got closed with the .12 upload.

Please comment on the patch, it'll lead to *many* new errors, as most
Architecture: all packages have this problem.

Marc
Index: debhelper
===================================================================
--- debhelper	(revision 134)
+++ debhelper	(working copy)
@@ -61,8 +61,11 @@
 			   dh_usrlocal
 			   );
 
+my $target = "";
 open(RULES, "debfiles/rules") or fail("cannot read debian/rules: $!");
 while (<RULES>) {
+    $target = $1 if (m/^(\S+):/);
+
     if (m/^\s+(dh_\w+)/) {
         my $dhcommand = $1;
     	if ($dhcommand =~ /dh_testversion(?:\s+(.+))?/) {
@@ -75,6 +78,19 @@
 	if ($dhcommand eq 'dh_suidregister') {
 	    print "W: $pkg $type: dh_suidregister-is-obsolete\n";
 	}
+	
+	if ($dhcommand eq 'dh_clean' && $target eq "clean") {
+	    my $no_dh_clean_dep;
+	    
+	    if (not open (IN, "fields/build-depends")) {
+		$no_dh_clean_dep = "yes";
+	    } else {
+		$no_dh_clean_dep = "yes" unless (grep { /\bdebhelper\b/ } <IN>);
+	    }
+	    close IN;
+	    print "E: $pkg $type: dh_clean-used-without-dephelper-dependency-in-build-depends\n" if $no_dh_clean_dep;
+	}
+
 	# if command is passed -n, it does not modify the scripts
 	if ($commands{$dhcommand} and not m/\s+\-n\s+/) {
 	    $needtomodifyscripts = 1;
Index: debhelper.desc
===================================================================
--- debhelper.desc	(revision 134)
+++ debhelper.desc	(working copy)
@@ -58,6 +58,13 @@
  .
  Please refer to the dh_suidregister(1) manual page for more information.
 
+Tag: dh_clean-used-without-dephelper-dependency-in-build-depends
+Type: error
+Ref: policy 7.6
+Info: This package calls dh_clean in the clean section of its 
+ <tt>debian/rules</tt> file, but has no entry for debhelper in its
+ Build-Depends line.
+
 Tag: declares-possibly-conflicting-debhelper-compat-versions
 Type: error
 Info: The source package declares the debhelper compatibility version

Reply to: