Author: rra
Date: 2006-04-04 08:34:33 +0200 (Tue, 04 Apr 2006)
New Revision: 606

Added:
   trunk/testset/cdbs-test/setup.py
Removed:
   trunk/testset/cdbs-test/debian/packages
Modified:
   trunk/checks/fields
   trunk/checks/fields.desc
   trunk/debian/changelog
   trunk/testset/cdbs-test/debian/control
   trunk/testset/cdbs-test/debian/rules
   trunk/testset/debconf/debian/rules
   trunk/testset/tags.cdbs-test
   trunk/testset/tags.debconf
   trunk/testset/tags.relations
Log:
  + [RA] Reorganize dependency checking based on debian/rules analysis.
    Diagnose missing build dependencies on the helper packages we know
    about, catch cases where Build-Depends-Indep should be Build-Depends
    because of the clean target, and make sure users of dh_python
    build-depend on python.  yada is no longer a special case.
    (Closes: #242789, #278290)

Modified: trunk/checks/fields
===================================================================
--- trunk/checks/fields 2006-04-03 05:33:13 UTC (rev 605)
+++ trunk/checks/fields 2006-04-04 06:34:33 UTC (rev 606)
@@ -26,6 +26,7 @@
 use strict;
 use lib "$ENV{'LINTIAN_ROOT'}/checks/";
 use common_data;
+use Dep;
 use Tags;
 use Util;
 
@@ -33,8 +34,8 @@
 # arch-specific packages because they're required in order to run the clean
 # rule.  (See Policy 7.6.)  The following is a list of pairs of packages and
 # regular expressions that, if they match anywhere in the debian/rules file,
-# say that this package is allowed in Build-Depends.
-my @global_depends = (
+# say that this package is allowed (and required) in Build-Depends.
+my @global_clean_depends = (
        [ cdbs => '^include\s+/usr/share/cdbs/' ],
        [ dbs => '^include\s+/usr/share/dbs/' ],
        [ debhelper => '^include\s+/usr/share/cdbs/1/rules/debhelper.mk' ],
@@ -42,17 +43,24 @@
        [ quilt => '^include\s+/usr/share/quilt/' ]
 );
 
+# A list of pairs of packages and regular expressions that, if they match
+# anywhere in the debian/rules file, this package must be listed in either
+# Build-Depends or Build-Depends-Indep as appropriate.  dh_python is handled
+# later as a special case rather than a literal package.
+my @global_depends = (
+        [ python => '/usr/share/cdbs/1/class/python-distutils.mk' ],
+        [ dh_python => '^\t\s*dh_python\s' ]
+);
+
 # Similarly, these pairs of packages and regexes say that if the regex matches
 # in one of clean, build-arch, binary-arch, or a rule they depend on, this
-# package is allowed in Build-Depends.
-my @rule_depends = (
-       [ debhelper => '^\s+dh_.+' ],
-       [ dpatch => '^\s+dpatch\s' ]
+# package is allowed (and required) in Build-Depends.
+my @rule_clean_depends = (
+       [ debhelper => '^\t\s*dh_.+' ],
+       [ dpatch => '^\t\s*dpatch\s' ],
+       [ yada => '^\t\s*yada\s' ]
 );
 
-# Note that yada is handled as a special case, based on the existence of
-# debian/packages.
-
 sub run {
 
 my $pkg = shift;
@@ -445,67 +453,54 @@
                                $arch_dep_packages++;
                        }
                }
-       } 
+       }
 
-       if (-e "fields/build-depends" && $arch_dep_packages == 0) {
-               if (not open(BD, "fields/build-depends")) {
-                       fail("Can't open fields/build-depends");
-               } else {
-                       my $build_depends = <BD>;
-                       close BD;
-
-                       my %allowed;
-                       if (not open (RULES, "debfiles/rules")) {
-                               fail("cannot read debfiles/rules: $!");
-                       } else {
-                               my $target = "none";
-                               local $/ = "\n"; #Read this linewise
-                               my @rules = qw(clean binary-arch build-arch);
-                               while (<RULES>) {
-                                   for my $rule (@global_depends) {
-                                       if ($_ =~ /$rule->[1]/) {
-                                           $allowed{$rule->[0]}++;
-                                       }
-                                   }
-                                   if (/^(\S+):(.*)/) {
-                                       $target = $1;
-                                       if (grep ($_ eq $target, @rules)) {
-                                           push (@rules, split (' ', $2));
-                                       }
-                                   }
-                                   if (grep ($_ eq $target, @rules)) {
-                                       for my $rule (@rule_depends) {
-                                           if ($_ =~ /$rule->[1]/) {
-                                               $allowed{$rule->[0]}++;
-                                           }
-                                       }
-                                   }
-                               }
-                               close RULES;
+       # Search through rules and determine which dependencies are required.
+       my (%needed, %needed_clean);
+       open (RULES, "debfiles/rules") or fail("cannot read debfiles/rules: 
$!");
+       my $target = "none";
+       local $/ = "\n";        # Read this linewise
+       my @rules = qw(clean binary-arch build-arch);
+       while (<RULES>) {
+               for my $rule (@global_clean_depends) {
+                       if ($_ =~ /$rule->[1]/) {
+                               $needed_clean{$rule->[0]}++;
                        }
-                       $allowed{yada}++ if -e "debfiles/packages";
-                       my @packages = split /\s*,\s*/, $build_depends;
-                       foreach my $pkg (@packages) {
-                           my ($name) = ($pkg =~ /^(\S+)/);
-                           unless ($allowed{$name}) {
-                               tag "build-depends-without-arch-dep", "";
-                               last;
-                           }
+               }
+               for my $rule (@global_depends) {
+                       if ($_ =~ /$rule->[1]/) {
+                               $needed{$rule->[0]}++;
                        }
                }
+               if (/^(\S+):(.*)/) {
+                       $target = $1;
+                       if (grep ($_ eq $target, @rules)) {
+                               push (@rules, split (' ', $2));
+                       }
+               }
+               if (grep ($_ eq $target, @rules)) {
+                       for my $rule (@rule_clean_depends) {
+                               if ($_ =~ /$rule->[1]/) {
+                                       $needed_clean{$rule->[0]}++;
+                               }
+                       }
+               }
        }
+       close RULES;
 
        tag "build-depends-indep-without-arch-indep", ""
                if (-e "fields/build-depends-indep" && $arch_indep_packages == 
0);
 
        my $is_dep_field = sub { grep { $_ eq $_[0] } qw(build-depends 
build-depends-indep) };
-       
+
+       my %depend;
        for my $field (qw(build-depends build-depends-indep build-conflicts 
build-conflicts-indep)) {
                if (open(FH, "fields/$field")) {
                        #Get data and clean it
                        my $data = <FH>;
                        unfold($field, \$data);
                        $data =~ s/^\s*(.+?)\s*$/$1/;
+                       $depend{$field} = Dep::parse($data);
 
                        for my $dep (split /\s*,\s*/, $data) {
                                my @alternatives;
@@ -542,6 +537,48 @@
                        }
                }
        }
+       $depend{'build-depends'} ||= Dep::parse('');
+       $depend{'build-depends-indep'} ||= Dep::parse('');
+
+       # Make sure that all the required build dependencies are there.  Don't
+       # issue missing-build-dependency errors for debhelper, since there's
+       # another test that does that and it would just be a duplicate.
+       for my $package (keys %needed_clean) {
+               my $dep = Dep::parse($package);
+               unless (Dep::implies($depend{'build-depends'}, $dep)) {
+                       if (Dep::implies($depend{'build-depends-indep'}, $dep)) 
{
+                               tag 
"build-depends-indep-should-be-build-depends", $package;
+                       } else {
+                               tag "missing-build-dependency", $package
+                                   if $package ne 'debhelper';
+                       }
+               }
+       }
+       for my $package (keys %needed) {
+               my $dep = Dep::parse($package);
+               unless (Dep::implies($depend{'build-depends'}, $dep)) {
+                       unless (Dep::implies($depend{'build-depends-indep'}, 
$dep)) {
+                               if ($package eq 'dh_python') {
+                                       tag 
"missing-dh_python-build-dependency";
+                               } else {
+                                       tag "missing-build-dependency", 
$package;
+                               }
+                       }
+               }
+       }
+       if (-e "fields/build-depends" && $arch_dep_packages == 0) {
+               open(FH, "fields/build-depends") or fail("cannot read 
fields/build-depends: $!");
+               my $build_depends = <FH>;
+               close FH;
+               my @packages = split /\s*,\s*/, $build_depends;
+               foreach my $pkg (@packages) {
+                       my ($name) = ($pkg =~ /^(\S+)/);
+                       unless ($needed_clean{$name}) {
+                               tag "build-depends-without-arch-dep", $name;
+                               last;
+                       }
+               }
+       }
 }
 
 #----- Origin

Modified: trunk/checks/fields.desc
===================================================================
--- trunk/checks/fields.desc    2006-04-03 05:33:13 UTC (rev 605)
+++ trunk/checks/fields.desc    2006-04-04 06:34:33 UTC (rev 606)
@@ -446,14 +446,34 @@
 Tag: build-depends-without-arch-dep
 Type: warning
 Ref: policy 7.6
-Info: The control file specifies source relations for architecture-dependent
- packages, but no architecture-dependent packages are built. There are some
- exceptions, e.g. build dependencies that have to be satisfied while calling
- the "clean" target of debian/rules, the most common case of which is a
- Build-Depends: debhelper if you use dh_clean in the "clean" target.
- In other cases, you most likely need to change Build-Depends to
- Build-Depends-Indep.
+Info: The control file lists the given package in Build-Depends, but no
+ architecture-dependent packages are built. If all the packages built are
+ architecture-independent, the only packages that should be listed in
+ Build-Depends are those required to run the clean target (such as
+ debhelper if you use dh_clean). Other build dependencies should be listed
+ in Build-Depends-Indep instead.
 
+Tag: build-depends-indep-should-be-build-depends
+Type: error
+Ref: policy 7.6
+Info: The specified package is required to run the clean target of
+ <tt>debian/rules</tt> and therefore must be listed in Build-Depends, even
+ if no architecture-dependent packages are built.
+
+Tag: missing-build-dependency
+Type: error
+Ref: policy 4.2
+Info: The package doesn't specify a build dependency on a package that is
+ used in <tt>debian/rules</tt>.
+
+Tag: missing-dh_python-build-dependency
+Type: error
+Ref: dh_python man page
+Info: The package runs dh_python in <tt>debian/rules</tt> but doesn't
+ build-depend on python. dh_python requires Python to run, so packages
+ using dh_python must build-depend on python, even if they don't otherwise
+ need Python to build.
+
 Tag: package-has-a-duplicate-relation
 Type: warning
 Info: The package seems to declare a relation on another package which is

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog      2006-04-03 05:33:13 UTC (rev 605)
+++ trunk/debian/changelog      2006-04-04 06:34:33 UTC (rev 606)
@@ -22,6 +22,12 @@
     + [RA] Look for an explicit section of unknown, probably left over
       from dh_make templates, and diagnose it with an error rather than a
       warning.  Reported by Jari Aalto.  (Closes: #355032)
+    + [RA] Reorganize dependency checking based on debian/rules analysis.
+      Diagnose missing build dependencies on the helper packages we know
+      about, catch cases where Build-Depends-Indep should be Build-Depends
+      because of the clean target, and make sure users of dh_python
+      build-depend on python.  yada is no longer a special case.
+      (Closes: #242789, #278290)
   * checks/manpages:
     + [RA] Use system_env instead of system and sanitize the environment
       before running man -l out of caution and to avoid extraneous output

Modified: trunk/testset/cdbs-test/debian/control
===================================================================
--- trunk/testset/cdbs-test/debian/control      2006-04-03 05:33:13 UTC (rev 
605)
+++ trunk/testset/cdbs-test/debian/control      2006-04-04 06:34:33 UTC (rev 
606)
@@ -2,7 +2,8 @@
 Section: devel
 Priority: optional
 Maintainer: Frank Lichtenheld <[EMAIL PROTECTED]>
-Build-Depends: debhelper, cdbs, yada
+Build-Depends: cdbs, yada
+Build-Depends-Indep: debhelper, cdbs
 Standards-Version: 3.6.2
 
 Package: cdbs-test

Deleted: trunk/testset/cdbs-test/debian/packages
===================================================================

Modified: trunk/testset/cdbs-test/debian/rules
===================================================================
--- trunk/testset/cdbs-test/debian/rules        2006-04-03 05:33:13 UTC (rev 
605)
+++ trunk/testset/cdbs-test/debian/rules        2006-04-04 06:34:33 UTC (rev 
606)
@@ -2,3 +2,4 @@
 # -*- makefile -*-
 
 include /usr/share/cdbs/1/rules/debhelper.mk
+include /usr/share/cdbs/1/class/python-distutils.mk

Added: trunk/testset/cdbs-test/setup.py
===================================================================

Modified: trunk/testset/debconf/debian/rules
===================================================================
--- trunk/testset/debconf/debian/rules  2006-04-03 05:33:13 UTC (rev 605)
+++ trunk/testset/debconf/debian/rules  2006-04-04 06:34:33 UTC (rev 606)
@@ -34,6 +34,9 @@
        dh_installdebconf -pdebconf-test-noscripts --noscripts
        dh_installdebconf -pdebconf-udeb
 
+       # Not needed, but it tests dh_python build dependencies.
+       dh_python -a
+
        dh_compress -a
        dh_fixperms -a
 

Modified: trunk/testset/tags.cdbs-test
===================================================================
--- trunk/testset/tags.cdbs-test        2006-04-03 05:33:13 UTC (rev 605)
+++ trunk/testset/tags.cdbs-test        2006-04-04 06:34:33 UTC (rev 606)
@@ -1,2 +1,5 @@
+E: cdbs-test source: build-depends-indep-should-be-build-depends debhelper
+E: cdbs-test source: missing-build-dependency python
 E: cdbs-test source: package-lacks-versioned-build-depends-on-debhelper 5
+W: cdbs-test source: build-depends-without-arch-dep yada
 W: cdbs-test source: native-package-with-dash-version

Modified: trunk/testset/tags.debconf
===================================================================
--- trunk/testset/tags.debconf  2006-04-03 05:33:13 UTC (rev 605)
+++ trunk/testset/tags.debconf  2006-04-04 06:34:33 UTC (rev 606)
@@ -1,4 +1,5 @@
 E: debconf source: declares-possibly-conflicting-debhelper-compat-versions 
rules=4 compat=4
+E: debconf source: missing-dh_python-build-dependency
 E: debconf-test: extended-description-is-empty
 E: debconf-test: mismatch-translated-choices debconf/testmulti choices-de.utf-8
 E: debconf-test: settitle-requires-versioned-depends config

Modified: trunk/testset/tags.relations
===================================================================
--- trunk/testset/tags.relations        2006-04-03 05:33:13 UTC (rev 605)
+++ trunk/testset/tags.relations        2006-04-04 06:34:33 UTC (rev 606)
@@ -23,7 +23,7 @@
 I: relations: unknown-field-in-control bugs
 I: relations: unknown-field-in-control origin
 W: relations source: ancient-standards-version 3.1.1
-W: relations source: build-depends-without-arch-dep
+W: relations source: build-depends-without-arch-dep mail-transport-agent
 W: relations source: redundant-origin-field
 W: relations source: virtual-package-depends-without-real-package-depends 
build-depends: mail-transport-agent
 W: relations-multiple-libs: description-synopsis-might-not-be-phrased-properly


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

Reply via email to