Author: rra
Date: 2008-06-03 03:18:41 +0200 (Tue, 03 Jun 2008)
New Revision: 1330

Modified:
   trunk/checks/rules
   trunk/checks/rules.desc
   trunk/debian/changelog
   trunk/testset/debconf/debian/rules
   trunk/testset/tags.debconf
Log:
* checks/rules{.desc,}:
  + [RA] Add some basic checks for whether debhelper programs are called
    in a reasonable order.  (Closes: #471869)

Modified: trunk/checks/rules
===================================================================
--- trunk/checks/rules  2008-06-02 22:02:51 UTC (rev 1329)
+++ trunk/checks/rules  2008-06-03 01:18:41 UTC (rev 1330)
@@ -23,6 +23,16 @@
 my %required = map { $_ => 1 }
     qw(build binary binary-arch binary-indep clean);
 
+# Rules about required debhelper command ordering.  Each command is put into a
+# class and the tag is issued if they're called in the wrong order for the
+# classes.  Unknown commands won't trigger this flag.
+my %debhelper_order =
+    (dh_makeshlibs => 1,
+     dh_shlibdeps  => 2,
+     dh_installdeb => 2,
+     dh_gencontrol => 2,
+     dh_builddeb   => 3);
+
 sub run {
 
 my $pkg = shift;
@@ -83,6 +93,7 @@
 local $_;
 my @current_targets;
 my %rules_per_target;
+my $debhelper_group;
 while (<RULES>) {
     next if /^\s*\#/;
     $includes = 1 if /^ *[s-]?include\s+/;
@@ -118,13 +129,26 @@
        for (@current_targets) {
            $seen{$_}++ if $required{$_};
        }
+        $debhelper_group = 0;
     } else {
-       #if we have non-empty, non-comment lines, store them for all current 
targets:
+       # If we have non-empty, non-comment lines, store them for all current
+       # targets and check whether debhelper programs are called in a
+       # reasonable order.
        if (m/^\s+[^\#]/) {
            foreach my $target (@current_targets) {
                $rules_per_target{$target} ||= [];
                push @{$rules_per_target{$target}}, $_;
            }
+            if (m/^\s+(dh_\S+)\b/ and $debhelper_order{$1}) {
+                my $command = $1;
+                my $group = $debhelper_order{$command};
+                if ($group < $debhelper_group) {
+                    tag "debian-rules-calls-debhelper-in-odd-order",
+                        $command, "(line $.)";
+                } else {
+                    $debhelper_group = $group;
+                }
+            }
        }
     }
 }

Modified: trunk/checks/rules.desc
===================================================================
--- trunk/checks/rules.desc     2008-06-02 22:02:51 UTC (rev 1329)
+++ trunk/checks/rules.desc     2008-06-03 01:18:41 UTC (rev 1330)
@@ -83,3 +83,12 @@
 Info: It looks like your package includes a .desktop file and you use
  debhelper to build it, but you don't call dh_desktop in your rules
  file.
+
+Tag: debian-rules-calls-debhelper-in-odd-order
+Type: warning
+Info: One of the targets in the <tt>debian/rules</tt> file for this
+ package calls debhelper programs in an odd order.  Normally,
+ dh_makeshlibs should be called before dh_shlibdeps or dh_installdeb,
+ dh_shlibdeps should be called before dh_gencontrol, and all should be
+ called before dh_builddeb.  Calling them in the wrong order may cause
+ incorrect or missing package files and metadata.

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog      2008-06-02 22:02:51 UTC (rev 1329)
+++ trunk/debian/changelog      2008-06-03 01:18:41 UTC (rev 1330)
@@ -7,6 +7,9 @@
   * checks/md5sums:
     + [FL] Don't complain about missing md5sums file if the
       package only contains conffiles.  (Closes: #482869)
+  * checks/rules{.desc,}:
+    + [RA] Add some basic checks for whether debhelper programs are called
+      in a reasonable order.  (Closes: #471869)
   
   * reporting/templates/clean.tmpl:
     + [FL] Include link to full maintainer report.  Suggested by

Modified: trunk/testset/debconf/debian/rules
===================================================================
--- trunk/testset/debconf/debian/rules  2008-06-02 22:02:51 UTC (rev 1329)
+++ trunk/testset/debconf/debian/rules  2008-06-03 01:18:41 UTC (rev 1330)
@@ -41,11 +41,15 @@
        dh_compress -a
        dh_fixperms -a
 
+# The shlibs stuff doesn't matter here so do it in a weird order to
+# test wwarnings.
        dh_installdeb -a
        dh_shlibdeps -a
+       dh_makeshlibs -a
        dh_gencontrol -a
        dh_md5sums
        dh_builddeb -a
+       dh_makeshlibs -a
 
 # Below here is fairly generic really
 

Modified: trunk/testset/tags.debconf
===================================================================
--- trunk/testset/tags.debconf  2008-06-02 22:02:51 UTC (rev 1329)
+++ trunk/testset/tags.debconf  2008-06-03 01:18:41 UTC (rev 1330)
@@ -9,6 +9,8 @@
 E: debconf-udeb udeb: udeb-postinst-must-not-call-ldconfig
 I: debconf source: package-needs-python-policy-debhelper
 I: debconf-test: debconf-error-requires-versioned-depends debconf/error
+W: debconf source: debian-rules-calls-debhelper-in-odd-order dh_makeshlibs 
(line 48)
+W: debconf source: debian-rules-calls-debhelper-in-odd-order dh_makeshlibs 
(line 52)
 W: debconf source: debian-rules-sets-DH_COMPAT line 3
 W: debconf source: dpatch-build-dep-but-no-patch-list debconf
 W: debconf source: invalid-po-file debian/po/fr.po


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

Reply via email to