Author: he
Date: 2007-11-30 23:36:59 +0100 (Fri, 30 Nov 2007)
New Revision: 1008

Modified:
   trunk/checks/rules
   trunk/checks/rules.desc
   trunk/debian/changelog
   trunk/testset/scripts/debian/rules
   trunk/testset/tags.scripts
Log:
* checks/rules:
  + [HE] Implement 'binary-arch-rules-but-pkg-is-arch-indep', checking
         for rules in binary-arch when the package is arch: all.
         (Closes: #409109, #119097)

Modified: trunk/checks/rules
===================================================================
--- trunk/checks/rules  2007-11-30 20:02:31 UTC (rev 1007)
+++ trunk/checks/rules  2007-11-30 22:36:59 UTC (rev 1008)
@@ -36,6 +36,17 @@
     return 0 unless -f "debfiles/rules";
 }
 
+#get architecture field:
+unless (-d "fields") {
+    fail("directory in lintian laboratory for $type package $pkg missing: 
fields");
+}
+
+my $architecture = "";
+if(open (IN, '<', "fields/architecture")) {
+    chomp($architecture = <IN>)
+}
+close(IN);
+
 open(RULES, '<', 'debfiles/rules') or fail("Failed opening rules: $!");
 
 # Check for required #!/usr/bin/make -f opening line.  Allow -r or -e; a
@@ -54,6 +65,8 @@
 my $includes = 0;
 my %seen;
 local $_;
+my @current_targets;
+my ($has_binary_indep_rules, $has_binary_arch_rules) = (0,0);
 while (<RULES>) {
     next if /^\s*\#/;
     $includes = 1 if /^ *[s-]?include\s+/;
@@ -83,12 +96,22 @@
         }
     }
 
-    # After this point, we're only doing target analysis, so skip everything
-    # else.
-    next unless /^([^:]+):/;
-    my @targets = split (' ', $1);
-    for (@targets) {
-        $seen{$_}++ if $required{$_};
+    if (/^([^\s:][^:]+):/) {
+       @current_targets = split (' ', $1);
+       for (@current_targets) {
+           $seen{$_}++ if $required{$_};
+       }
+    } else {
+       #if we have non-empty, non-comment lines, check if one of the
+       #"interesting" targets contains them:
+       if (m/^\s+[^#]/) {
+           if (grep { $_ eq "binary-arch" } @current_targets) {
+               $has_binary_arch_rules = 1;
+           } #not elsif, think of the children and 'binary-arch binary-indep:' 
(ewww)
+           if (grep { $_ eq "binary-indep" } @current_targets) {
+               $has_binary_indep_rules = 1;
+           }
+       }
     }
 }
 close RULES;
@@ -101,8 +124,11 @@
     }
 }
 
+# Make sure we have no content for binary-arch if we are arch-indep:
+if ($architecture eq "all" && $has_binary_arch_rules) {
+    tag "binary-arch-rules-but-pkg-is-arch-indep";
 }
-
+}
 1;
 
 # vim: syntax=perl ts=8 sw=4

Modified: trunk/checks/rules.desc
===================================================================
--- trunk/checks/rules.desc     2007-11-30 20:02:31 UTC (rev 1007)
+++ trunk/checks/rules.desc     2007-11-30 22:36:59 UTC (rev 1008)
@@ -70,3 +70,9 @@
  only to be used for temporarily overriding <tt>debian/compat</tt>.  Any
  line in <tt>debian/rules</tt> that sets it globally should be deleted and
  a separate <tt>debian/compat</tt> file created if needed.
+
+Tag: binary-arch-rules-but-pkg-is-arch-indep
+Type: warning
+Info: It looks like you try to run code in the binary-arch target of 
+ <tt>debian/rules</tt>, even though your package is architecture-
+ independent.

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog      2007-11-30 20:02:31 UTC (rev 1007)
+++ trunk/debian/changelog      2007-11-30 22:36:59 UTC (rev 1008)
@@ -40,6 +40,10 @@
            problems when using patch systems. Start with three
            checks for common dpatch problems. Idea loosely based on
            patch by Carl Fürstenberg <[EMAIL PROTECTED]>. (Closes: #437959)
+  * checks/rules:
+    + [HE] Implement 'binary-arch-rules-but-pkg-is-arch-indep', checking
+           for rules in binary-arch when the package is arch: all.
+           (Closes: #409109, #119097)
   * checks/scripts:
     + [HE] Allow packages to drop snippets into /etc/csh/login.d
            without a dependency on csh. Files there should also

Modified: trunk/testset/scripts/debian/rules
===================================================================
--- trunk/testset/scripts/debian/rules  2007-11-30 20:02:31 UTC (rev 1007)
+++ trunk/testset/scripts/debian/rules  2007-11-30 22:36:59 UTC (rev 1008)
@@ -5,6 +5,7 @@
 build:
 
 binary-arch:
+       echo "Hi, in an arch: all package, I am a bug!"
 
 binary-indep:
        install -d $(tmp)/usr/bin/

Modified: trunk/testset/tags.scripts
===================================================================
--- trunk/testset/tags.scripts  2007-11-30 20:02:31 UTC (rev 1007)
+++ trunk/testset/tags.scripts  2007-11-30 22:36:59 UTC (rev 1008)
@@ -18,6 +18,7 @@
 E: scripts: wrong-path-for-ruby ./usr/bin/rubyfoo #!/bin/ruby1.8
 I: scripts: no-md5sums-control-file
 W: scripts source: ancient-standards-version 3.2.1 (current is 3.7.2)
+W: scripts source: binary-arch-rules-but-pkg-is-arch-indep
 W: scripts source: changelog-should-mention-nmu
 W: scripts source: dpatch-missing-description 
02_i_dont_have_a_description.patch
 W: scripts source: maintainer-script-lacks-debhelper-token debian/postinst


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to