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

Bug#484549: Patch to handle quilt series like



tag 484549 + patch
thanks

Hi,

please find attached a patch ready to merge that adds the check that I
requested in this bug report as well as a few others all related to quilt.
This will help prepare the switch to the source format 3.0 (quilt)
by warning people that use quilt in ways that are incompatible with the
new source format.

lintian now checks the quilt patches in the same way that it checks
dpatch patches. I also added some fixes to the current code, it
was forgetting a comma when concatenating build-deps and build-deps-indep
which made it miss some build-dependencies, and it was not always checking
all *.dpatch files.

Thanks for applying!
-- 
Raphaël Hertzog

Le best-seller français mis à jour pour Debian Etch :
http://www.ouaza.com/livre/admin-debian/
>From c632887347cb0fefb73b2b0247881232c04570d7 Mon Sep 17 00:00:00 2001
From: Raphael Hertzog <hertzog@debian.org>
Date: Thu, 26 Jun 2008 22:03:37 +0200
Subject: [PATCH] * checks/patch-systems: add support of quilt

New tags:
- quilt-build-dep-but-no-series-file
- quilt-series-but-no-build-dep
- quilt-patch-with-non-standard-options
- quilt-series-references-non-existant-patch
- patch-modifying-debian-files
- more-than-one-patch-system
---
 checks/patch-systems      |   79 +++++++++++++++++++++++++++++++++++++++++++--
 checks/patch-systems.desc |   58 +++++++++++++++++++++++++++++++++
 2 files changed, 134 insertions(+), 3 deletions(-)

diff --git a/checks/patch-systems b/checks/patch-systems
index a5bfdbe..5ca3329 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.
-- 
1.5.6


Reply to: