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

lintian: r616 - in trunk: checks debian



Author: rra
Date: 2006-04-05 22:19:38 +0200 (Wed, 05 Apr 2006)
New Revision: 616

Modified:
   trunk/checks/rules
   trunk/checks/rules.desc
   trunk/debian/changelog
Log:
Don't run make while checking debian/rules.  It's not safe.  Instead,
parse it ourselves, which will hopefully be sufficient for the simple
checks that we're doing.


Modified: trunk/checks/rules
===================================================================
--- trunk/checks/rules	2006-04-05 04:12:28 UTC (rev 615)
+++ trunk/checks/rules	2006-04-05 20:19:38 UTC (rev 616)
@@ -43,50 +43,29 @@
 tag "debian-rules-not-a-makefile", ""
     unless $start =~ m%^\#!\s*/usr/bin/make\s+-f\s*$%;
 
-# Scan debian/rules looking for other things of interest, particularly whether
-# it includes any other files.
+# Scan debian/rules.  We would really like to let make do this for us, but
+# unfortunately there doesn't seem to be a way to get make to syntax-check and
+# analyze a makefile without running at least $(shell) commands.
+#
+# We skip some of the rule analysis if debian/rules includes any other files,
+# since to chase all includes we'd have to have all of its build dependencies
+# installed.
 my $includes = 0;
+my %seen;
 local $_;
 while (<RULES>) {
     $includes = 1 if /^ *[s-]?include\s+/;
+
+    # We're looking only for the required targets.  Ignore everything else.
+    next unless /^([^\s:]+):/;
+    my $target = $1;
+    next unless $required{$target};
+    $seen{$target}++;
 }
 close RULES;
 
-# Analyze the available targets.  If the makefile contained any includes, give
-# it a free pass and assume everything is fine.  It may have included some
-# makefile fragment from its build dependencies that we can't check.
-#
-# Some explanation of the magic here:  -p says to print the database, which
-# lets us use make as the makefile parser instead of having to do it
-# ourselves.  -q is like -n but does even less, since we're throwing away the
-# results (but means either 0 or 1 is a non-error exit status).  -r and -R
-# suppress implicit rules and variables, which we're not interested in and
-# which just bloat the output that we have to throw away and slow things down.
-# Finally, MAKE=true prevents make from using its magic handling of make
-# recursion, which we don't want it to try because the other makefiles that we
-# may be trying to recurse into probably haven't been created yet.
+# Make sure all the required rules were seen.
 unless ($includes) {
-    open(MAKE, 'env - PATH="$PATH" make -f debfiles/rules -qprR MAKE=true |')
-	or fail("Cannot run make: $!");
-    local $_;
-
-    # We're looking only for the required targets.  Ignore everything else.
-    my %seen;
-    while (<MAKE>) {
-	next unless /^([^\s:]+):/;
-	my $target = $1;
-	next unless $required{$target};
-	$seen{$target}++;
-    }
-    close MAKE;
-
-    # If make exited with non-zero status, we probably have a syntactically
-    # invalid makefile (since we already ruled out includes).
-    my $status = ($? >> 8);
-    tag "debian-rules-not-valid-makefile", ""
-	if ($status != 0 && $status != 1);
-
-    # Make sure all the required rules were seen.
     for my $target (sort keys %required) {
 	tag "debian-rules-missing-required-target", $target
 	    unless $seen{$target};

Modified: trunk/checks/rules.desc
===================================================================
--- trunk/checks/rules.desc	2006-04-05 04:12:28 UTC (rev 615)
+++ trunk/checks/rules.desc	2006-04-05 20:19:38 UTC (rev 616)
@@ -26,13 +26,6 @@
  <tt>debian/rules</tt> must be a valid makefile and must have
  "<tt>#!/usr/bin/make -f</tt>" as its first line.
 
-Tag: debian-rules-not-valid-makefile
-Type: error
-Ref: policy 4.8
-Info: The <tt>debian/rules</tt> file for this package does not appear to
- be a syntactically valid makefile. (When <tt>make -n -p</tt> was run on
- <tt>debian/rules</tt>, it returned an error status.)
-
 Tag: debian-rules-missing-required-target
 Type: error
 Ref: policy 4.8

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2006-04-05 04:12:28 UTC (rev 615)
+++ trunk/debian/changelog	2006-04-05 20:19:38 UTC (rev 616)
@@ -51,10 +51,10 @@
     + [RA] Use system_env instead of system out of caution and to avoid
       extraneous output when CDPATH is set.
   * checks/rules{.desc,}:
-    + [RA] Let's try this again.  Bring back the check for a well-formed
-      debian/rules file with all the required rules using the make -p
-      suggestion made on debian-devel.  Based heavily on previous work by
-      René van Bevern.  (Closes: #294926, #311786)
+    + [RA] A new set of checks that parses debian/rules and checks for
+      required rules, debian/rules as a symlink, and the correct first
+      line.  Based heavily on previous work by René van Bevern.
+      (Closes: #294926, #311786)
   * checks/scripts{.desc,}:
     + [RA] Ignore text inside single quotes and, for most checks, text
       inside double quotes when checking for bashisms.  Reported by Frank



Reply to: