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

lintian: r615 - in trunk: checks debian man testset



Author: rra
Date: 2006-04-05 06:12:28 +0200 (Wed, 05 Apr 2006)
New Revision: 615

Added:
   trunk/checks/rules
   trunk/checks/rules.desc
Modified:
   trunk/checks/control-file
   trunk/checks/control-file.desc
   trunk/debian/changelog
   trunk/debian/control
   trunk/man/lintian.1
   trunk/testset/tags.binary
   trunk/testset/tags.empty
   trunk/testset/tags.etcfiles
   trunk/testset/tags.libbaz
Log:
* checks/control-file{.desc,}:
  + [RA] Warn if debian/control in a source package is a symlink.
* 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
    Rene' van Bevern.  (Closes: #294926, #311786)
* debian/control:
  + [RA] Depend on make for debian/rules checks.
* man/lintian.1:
  + [RA] Mention the new rules check class.


Modified: trunk/checks/control-file
===================================================================
--- trunk/checks/control-file	2006-04-04 22:33:46 UTC (rev 614)
+++ trunk/checks/control-file	2006-04-05 04:12:28 UTC (rev 615)
@@ -28,6 +28,10 @@
 my $pkg = shift;
 my $type = shift;
 
+if (-l "debfiles/control") {
+    tag "debian-control-file-is-a-symlink", "";
+}
+
 # check that control is UTF-8 encoded
 my $line = file_is_encoded_in_non_utf8("debfiles/control", $type, $pkg);
 if ($line) {

Modified: trunk/checks/control-file.desc
===================================================================
--- trunk/checks/control-file.desc	2006-04-04 22:33:46 UTC (rev 614)
+++ trunk/checks/control-file.desc	2006-04-05 04:12:28 UTC (rev 615)
@@ -31,3 +31,11 @@
 Info: One of the paragraphs of your debian/control contains the same
  field more than once. This can lead to an unexpected behaviour of dpkg
  and apt.
+
+Tag: debian-control-file-is-a-symlink
+Type: warning
+Info: The <tt>debian/control</tt> file is a symlink rather than a regular
+ file. Using symlinks for required source package files is unnecessary and
+ makes package checking and manipulation more difficult. If the control
+ file should be available in the source package under multiple names, make
+ <tt>debian/control</tt> the real file and the other names symlinks to it.

Added: trunk/checks/rules
===================================================================
--- trunk/checks/rules	2006-04-04 22:33:46 UTC (rev 614)
+++ trunk/checks/rules	2006-04-05 04:12:28 UTC (rev 615)
@@ -0,0 +1,100 @@
+# rules -- lintian check script -*- perl -*-
+
+# Copyright (C) 2006 Russ Allbery <rra@debian.org>
+# Copyright (C) 2005 René van Bevern <rvb@pro-linux.de>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the
+# GNU General Public License for more details.
+
+package Lintian::rules;
+use strict;
+use Tags;
+use Util;
+
+# The following targets are required per Policy.
+my %required = map { $_ => 1 }
+    qw(build binary binary-arch binary-indep clean);
+
+sub run {
+
+my $pkg = shift;
+my $type = shift;
+
+# Policy could be read as allowing debian/rules to be a symlink to some other
+# file, and in a native Debian package it could be a symlink to a file that we
+# didn't unpack.  Warn if it's a symlink (dpkg-source does as well) and skip
+# all the tests if we then can't read it.
+if (-l "debfiles/rules") {
+    tag "debian-rules-is-symlink", "";
+    return 0 unless -f "debfiles/rules";
+}
+
+open(RULES, '< debfiles/rules') or fail("Failed opening rules: $!");
+
+# Check for required #!/usr/bin/make -f opening line.
+my $start = <RULES>;
+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.
+my $includes = 0;
+local $_;
+while (<RULES>) {
+    $includes = 1 if /^ *[s-]?include\s+/;
+}
+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.
+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};
+    }
+}
+
+}
+
+1;
+
+# vim: syntax=perl ts=8 sw=4

Added: trunk/checks/rules.desc
===================================================================
--- trunk/checks/rules.desc	2006-04-04 22:33:46 UTC (rev 614)
+++ trunk/checks/rules.desc	2006-04-05 04:12:28 UTC (rev 615)
@@ -0,0 +1,42 @@
+Check-Script: rules
+Author: Russ Allbery <rra@debian.org>
+Standards-Version: 3.6.2
+Type: source
+Unpack-Level: 1
+Needs-Info: debfiles
+Info: Check targets and actions in debian/rules.
+Abbrev: rul
+
+Tag: debian-rules-is-symlink
+Type: warning
+Info: The file <tt>debian/rules</tt> is a symlink instead of a regular
+ file. This is unnecessary and makes package checking and manipulation
+ more difficult. If the rules file should be available in the source
+ package under multiple names, make <tt>debian/rules</tt> the real
+ file and the other names symlinks to it.
+ .
+ This problem may have prevented lintian from performing other checks,
+ leading to undetected changelog errors.
+
+Tag: debian-rules-not-a-makefile
+Type: error
+Ref: policy 4.8
+Info: The <tt>debian/rules</tt> file for this package does not appear to
+ be a makefile or does not start with the required line.
+ <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
+Info: The <tt>debian/rules</tt> file for this package does not provide one
+ of the required targets.  All of build, binary, binary-arch,
+ binary-indep, and clean must be provided, even if they don't do anything
+ for this package.

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2006-04-04 22:33:46 UTC (rev 614)
+++ trunk/debian/changelog	2006-04-05 04:12:28 UTC (rev 615)
@@ -9,6 +9,8 @@
     + [RA] Include all combinations of cpu and os from the dpkg cputable
       and ostable files (as of dpkg 1.13.16).  (Closes: #337034, #357433)
     + [RA] Include a list of known X metapackages.
+  * checks/control-file{.desc,}:
+    + [RA] Warn if debian/control in a source package is a symlink.
   * checks/debdiff{.desc,}:
     + [RA] Warn if the diff contains debian/substvars.  Based on a patch
       by Michael Ablassmeier.  (Closes: #359646)
@@ -48,6 +50,11 @@
   * checks/po-debconf:
     + [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)
   * checks/scripts{.desc,}:
     + [RA] Ignore text inside single quotes and, for most checks, text
       inside double quotes when checking for bashisms.  Reported by Frank
@@ -73,6 +80,9 @@
       the user's environment.
     + [RA] Run readelf -l to collect interpreter information.
 
+  * debian/control:
+    + [RA] Depend on make for debian/rules checks.
+
   * lib/Dep.pm:
     + [RA] Add initial support for analyzing architecture information in
       dependencies instead of ignoring it.
@@ -81,8 +91,11 @@
   * lib/Util.pm:
     + [RA] Add system_env, like system but sanitizing the environment.
 
- -- Russ Allbery <rra@debian.org>  Tue,  4 Apr 2006 15:32:34 -0700
+  * man/lintian.1:
+    + [RA] Mention the new rules check class.
 
+ -- Russ Allbery <rra@debian.org>  Tue,  4 Apr 2006 20:53:09 -0700
+
 lintian (1.23.16) unstable; urgency=low
 
   The "What's this Russ guy up to?" release

Modified: trunk/debian/control
===================================================================
--- trunk/debian/control	2006-04-04 22:33:46 UTC (rev 614)
+++ trunk/debian/control	2006-04-05 04:12:28 UTC (rev 615)
@@ -9,7 +9,7 @@
 
 Package: lintian
 Architecture: all
-Depends: perl, libdigest-md5-perl | perl (>> 5.8), dpkg-dev (>= 1.13.17), file, binutils, diffstat (>= 1.27-1), man-db (>= 2.3.20-1), gettext, intltool-debian, libparse-debianchangelog-perl (>= 0.6)
+Depends: perl, libdigest-md5-perl | perl (>> 5.8), dpkg-dev (>= 1.13.17), file, binutils, diffstat (>= 1.27-1), man-db (>= 2.3.20-1), gettext, intltool-debian, libparse-debianchangelog-perl (>= 0.6), make
 Suggests: binutils-multiarch
 Description: Debian package checker
  Lintian dissects Debian packages and reports bugs and policy

Modified: trunk/man/lintian.1
===================================================================
--- trunk/man/lintian.1	2006-04-04 22:33:46 UTC (rev 614)
+++ trunk/man/lintian.1	2006-04-05 04:12:28 UTC (rev 615)
@@ -461,6 +461,10 @@
 Looks for common mistakes in packages using po\-debconf.
 
 .TP
+.B rules (rul)
+Looks for common problems in the debian/rules file in source packages.
+
+.TP
 .B scripts (scr)
 Check the the \fB#!\fR lines of scripts in a binary package.
 

Modified: trunk/testset/tags.binary
===================================================================
--- trunk/testset/tags.binary	2006-04-04 22:33:46 UTC (rev 614)
+++ trunk/testset/tags.binary	2006-04-05 04:12:28 UTC (rev 615)
@@ -1,3 +1,4 @@
+E: binary source: debian-rules-missing-required-target binary-indep
 E: binary: changelog-file-not-compressed changelog
 E: binary: debian-changelog-file-missing-or-wrong-name
 E: binary: depends-on-x-metapackage depends: xorg

Modified: trunk/testset/tags.empty
===================================================================
--- trunk/testset/tags.empty	2006-04-04 22:33:46 UTC (rev 614)
+++ trunk/testset/tags.empty	2006-04-05 04:12:28 UTC (rev 615)
@@ -1,3 +1,4 @@
+E: empty source: debian-rules-missing-required-target binary-arch
 E: empty source: maintainer-address-missing empty
 E: empty source: no-standards-version-field
 E: empty: maintainer-address-missing empty

Modified: trunk/testset/tags.etcfiles
===================================================================
--- trunk/testset/tags.etcfiles	2006-04-04 22:33:46 UTC (rev 614)
+++ trunk/testset/tags.etcfiles	2006-04-05 04:12:28 UTC (rev 615)
@@ -1,3 +1,4 @@
+E: etcfiles source: debian-rules-missing-required-target binary-arch
 E: etcfiles: changelog-file-not-compressed changelog
 E: etcfiles: file-in-etc-not-marked-as-conffile /etc/improper
 E: etcfiles: file-in-etc-not-marked-as-conffile /etc/improper-link

Modified: trunk/testset/tags.libbaz
===================================================================
--- trunk/testset/tags.libbaz	2006-04-04 22:33:46 UTC (rev 614)
+++ trunk/testset/tags.libbaz	2006-04-05 04:12:28 UTC (rev 615)
@@ -1,3 +1,4 @@
+E: libbaz source: debian-rules-missing-required-target binary-indep
 E: libbaz1: control-file-has-bad-permissions shlibs 0755 != 0644
 E: libbaz1: duplicate-entry-in-shlibs-control-file libdoesntexist2 1.0
 E: libbaz1: duplicate-entry-in-shlibs-control-file udeb: libdoesntexist2 1.0



Reply to: