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

[SCM] Debian package checker branch, master, updated. d31bc18c5f0d22568613de5e2cc98dadb7774a4c



The following commit has been merged in the master branch:
commit d31bc18c5f0d22568613de5e2cc98dadb7774a4c
Author: Raphael Hertzog <hertzog@debian.org>
Date:   Thu Jun 26 22:53:00 2008 +0200

    Also check quilt patches
    
    * checks/patch-systems{,.desc}:
      + [RA] Check quilt patches as well as dpatch patches, and also check
        quilt patches when using the 3.0 (quilt) package format.  Fix build
        dependency checking and check all dpatch files.  Patch from Raphaël
        Hertzog.  (Closes: #484549)

diff --git a/checks/patch-systems b/checks/patch-systems
index a5bfdbe..3e33553 100644
--- a/checks/patch-systems
+++ b/checks/patch-systems
@@ -1,6 +1,7 @@
 # patch-systems -- lintian check script -*- perl -*-
 #
 # Copyright (C) 2007 Marc Brockschmidt
+# Copyright (C) 2008 Raphael Hertzog
 #
 # 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
@@ -46,10 +47,19 @@ sub run {
     }
 	if (open(IN, '<', "fields/build-depends-indep")) {
 		local $/ = undef;
+		$build_deps .= ", " if $build_deps;
 		chomp($build_deps .= <IN>);
 		close(IN);
 	}
 	$build_deps = Dep::parse($build_deps);
+	# Get source package format
+	my $format = "";
+	if (open(IN, '<', "fields/format")) {
+		local $/ = undef;
+		chomp($format .= <IN>);
+		close(IN);
+	}
+	my $quilt_format = ($format =~ /3\.\d+ \(quilt\)/) ? 1 : 0;
 
 	#----- dpatch
 	if (Dep::implies($build_deps, Dep::parse("dpatch"))) {
@@ -86,10 +96,13 @@ sub run {
 
 				# Check each patch.
 				foreach my $patch_file (@patches) {
-					if (! -r "debfiles/patches/$patch_file" && ! -r "debfiles/patches/$patch_file.dpatch") {
+					$patch_file .= ".dpatch" if -e "debfiles/patches/$patch_file.dpatch"
+						and not -e "debfiles/patches/$patch_file";
+					if (! -r "debfiles/patches/$patch_file") {
 						tag "dpatch-index-references-non-existant-patch", $patch_file;
+						next;
 					}
-					if (open(PATCH_FILE, '<', "debfiles/patches/" . $patch_file)) {
+					if (open(PATCH_FILE, '<', "debfiles/patches/$patch_file")) {
 						my $has_comment = 0;
 						while (<PATCH_FILE>) {
 							#stop if something looking like a patch starts:
@@ -102,15 +115,61 @@ sub run {
 							tag "dpatch-missing-description", $patch_file;
 						}
 					}
+					check_patch($patch_file);
+				}
+			}
+		}
+	}
+
+	#----- quilt
+	if (Dep::implies($build_deps, Dep::parse("quilt")) or $quilt_format) {
+		$uses_patch_system++;
+		#check for a debian/patches file:
+		if (! -r "debfiles/patches/series") {
+			tag "quilt-build-dep-but-no-series-file", $pkg unless $quilt_format;
+		} else {
+			if (open(IN, '<', "debfiles/patches/series")) {
+				my @patches;
+				my @badopts;
+				while(<IN>) {
+					chomp; s/^\s+//; s/\s+$//; # Strip leading/trailing spaces
+					s/(^|\s+)#.*$//; # Strip comment
+					next unless $_;
+					if (/^(\S+)\s+(\S.*)$/) {
+						$_ = $1;
+						if ($2 ne '-p1') {
+							push @badopts, $_;
+						}
+					}
+					push @patches, $_;
+				}
+				close(IN);
+				if (scalar(@badopts)) {
+					tag "quilt-patch-with-non-standard-options", @badopts;
+				}
+
+				# Check each patch.
+				foreach my $patch_file (@patches) {
+					if (! -r "debfiles/patches/$patch_file") {
+						tag "quilt-series-references-non-existant-patch", $patch_file;
+						next;
+					}
+					check_patch($patch_file);
 				}
 			}
 		}
+	} else {
+		if (-r "debfiles/patches/series") {
+			# 3.0 (quilt) sources don't need quilt as dpkg-source will do the work
+			tag "quilt-series-but-no-build-dep" unless $quilt_format;
+		}
 	}
 
+
 	#----- general cruft checking:
 	if ($uses_patch_system) {
 		if ($uses_patch_system > 1) {
-			#probably a bug too use more than one system, but we don't check anything but dpatch at the moment
+			tag "more-than-one-patch-system";
 		}
 
 		open(STAT, '<', "diffstat") or fail("cannot open diffstat file: $!");
@@ -126,6 +185,20 @@ sub run {
 	}
 }
 
+# Checks on patches common to all build systems
+sub check_patch($) {
+	my $patch_file = shift;
+	open(DIFFSTAT, "-|", "diffstat -p0 -l debfiles/patches/$patch_file")
+	  or fail("can't fork diffstat");
+	while (<DIFFSTAT>) {
+		chomp;
+		if (m|^(\./)?debian/| or m|^(\./)?[^/]+/debian/|) {
+			tag "patch-modifying-debian-files", $patch_file, $_;
+		}
+	}
+	close(DIFFSTAT) or fail("cannot close pipe to diffstat on $patch_file: $!");
+}
+
 1;
 
 # Local Variables:
diff --git a/checks/patch-systems.desc b/checks/patch-systems.desc
index 8e7a55a..367e899 100644
--- a/checks/patch-systems.desc
+++ b/checks/patch-systems.desc
@@ -26,7 +26,65 @@ Type: warning
 Info: dpatch files should carry a description of the function of the included
  patch. Description lines start with "## DP:".
 
+Tag: quilt-build-dep-but-no-series-file
+Type: warning
+Info: Using quilt requires you to explicitly list all patches you want
+ to apply in debian/patches/series. This package build-depends on quilt,
+ but does not provide a patch list.
+ .
+ You should either remove the quilt build dependency or add a series
+ file.
+
+Tag: quilt-series-but-no-build-dep
+Type: warning
+Info: The package contains a debian/patches/series file usually used by
+ quilt to apply patches at build time, but quilt is not listed in the
+ build dependencies.
+ .
+ You should either remove the series file if it's effectively not useful
+ or add quilt to the build-dependencies if quilt is used during the build
+ process.
+ .
+ If you don't need quilt during build but only during maintenance work,
+ then you can override this warning.
+
+Tag: quilt-patch-with-non-standard-options
+Type: warning
+Info: The quilt series file contains non-standard options to apply some of
+ the listed patches. Quilt uses '-p1' by default if nothing is specified
+ after the name of the patch and the current series file specify something
+ else for some of the patches listed.
+ .
+ For compatibility with the source "3.0 (quilt)" source package format,
+ you should avoid using any option at all and make sure that your patches
+ apply with "-p1". This can be done by refreshing all patches like this:
+ quilt pop -a; while quilt push; do quilt refresh -pab; done
+
+Tag: quilt-series-references-non-existant-patch
+Type: error
+Info: In the series file listing all your quilt patches, you referenced a
+ file that is not existant. This will lead to a fatal error when calling
+ quilt.
+
+Tag: patch-modifying-debian-files
+Type: error
+Info: A patch stored in debian/patches/ should never modify files
+ in the debian directory (even when it's only creating new files) because
+ the debian directory is always directly provided by the Debian packaging.
+ And you shouldn't have to modify what you choose to provide in the first
+ place.
+ .
+ If the patch provides a new file (say a manual page), place that file
+ in the upstream directory hierarchy as if it was ready to be submitted.
+
 Tag: patch-system-but-direct-changes-in-diff
 Type: warning
 Info: The package uses a patch-system, but the Debian diff.gz contains changes
  made on files without being separated out in a patch.
+
+Tag: more-than-one-patch-system
+Type: warning
+Info: The build-dependencies list more than one patch system and it's
+ unlikely that you need both at the same time.
+ .
+ Currently lintian knows only dpatch and quilt.
diff --git a/debian/changelog b/debian/changelog
index 88420ba..0c75909 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -12,6 +12,11 @@ lintian (1.24.2) unstable; urgency=low
       entry as well as --remove.
   * checks/menus{,.desc}:
     + [ADB] Check that menu-method files include menu.h (Closes: #184104)
+  * checks/patch-systems{,.desc}:
+    + [RA] Check quilt patches as well as dpatch patches, and also check
+      quilt patches when using the 3.0 (quilt) package format.  Fix build
+      dependency checking and check all dpatch files.  Patch from Raphaël
+      Hertzog.  (Closes: #484549)
   * checks/scripts:
     + [FL] Apply File::Spec->canonpath() to rpaths to improve
       matching with directories.

-- 
Debian package checker


Reply to: