Explorar o código

dpkg-source: support debian/source/local-patch-header

Useful to use in combination with a --single-debian-patch option
in debian/source/local-options.

The commit also changes the place where the local-options file is ignored.
Instead of using the default diff_ignore regexp, it's hardcoded in the
initialization function in case the default regexp is not used.

Suggested-by: Russ Allbery <rra@debian.org>
Raphaël Hertzog %!s(int64=15) %!d(string=hai) anos
pai
achega
46d6192d40

+ 3 - 0
debian/changelog

@@ -33,6 +33,9 @@ dpkg (1.16.1) UNRELEASED; urgency=low
   * Check presence of required parameters in dpkg-vendor. Closes: #628726
   * Check presence of required parameters in dpkg-vendor. Closes: #628726
     Thanks to Niels Thykier <niels@thykier.net> for the patch.
     Thanks to Niels Thykier <niels@thykier.net> for the patch.
   * Avoid a Perl warning in dpkg-buildflags when HOME is not set.
   * Avoid a Perl warning in dpkg-buildflags when HOME is not set.
+  * dpkg-source can now also use debian/source/local-patch-header (that is not
+    included in the generated source package) instead of
+    debian/source/patch-header. Closes: #629582
 
 
   [ Guillem Jover ]
   [ Guillem Jover ]
   * Install deb-src-control(5) man pages in dpkg-dev. Closes: #620520
   * Install deb-src-control(5) man pages in dpkg-dev. Closes: #620520

+ 7 - 4
man/dpkg-source.1

@@ -504,9 +504,10 @@ Use \fBdebian/patches/debian-changes\fP instead of
 automatic patch generated during build. This option is particularly
 automatic patch generated during build. This option is particularly
 useful when the package is maintained in a VCS and a patch set can't reliably
 useful when the package is maintained in a VCS and a patch set can't reliably
 be generated. Instead the current diff with upstream should be stored in a
 be generated. Instead the current diff with upstream should be stored in a
-single patch. When using this option, it is recommended to create
-a debian/source/patch-header file explaining how the Debian changes can be
-best reviewed, for example in the VCS that is used.
+single patch. The option would be put in \fBdebian/source/local-options\fP
+and would be accompanied by a \fBdebian/source/local-patch-header\fP file
+explaining how the Debian changes can be best reviewed, for example in the
+VCS that is used.
 .TP
 .TP
 .B \-\-create\-empty\-orig
 .B \-\-create\-empty\-orig
 Automatically create the main original tarball as empty if it's missing
 Automatically create the main original tarball as empty if it's missing
@@ -683,9 +684,11 @@ Exactly like \fBdebian/source/options\fP except that the file is not
 included in the generated source package. It can be useful to store
 included in the generated source package. It can be useful to store
 a preference tied to the maintainer or to the VCS repository where
 a preference tied to the maintainer or to the VCS repository where
 the source package is maintained.
 the source package is maintained.
+.SS debian/source/local-patch-header
 .SS debian/source/patch-header
 .SS debian/source/patch-header
 Free form text that is put on top of the automatic patch generated
 Free form text that is put on top of the automatic patch generated
-in formats "2.0" or "3.0 (quilt)".
+in formats "2.0" or "3.0 (quilt)". \fBlocal-patch-header\fP is not
+included in the generated source package while \fBpatch-header\fP is.
 .SS debian/patches/series
 .SS debian/patches/series
 This file lists all patches that have to be applied (in the given order)
 This file lists all patches that have to be applied (in the given order)
 on top of the upstream source package. Leading and trailing spaces are
 on top of the upstream source package. Leading and trailing spaces are

+ 3 - 3
scripts/Dpkg/Source/Package.pm

@@ -61,8 +61,6 @@ our $diff_ignore_default_regexp = '
 (?:^|/)\..*\.sw.$|
 (?:^|/)\..*\.sw.$|
 # Ignore baz-style junk files or directories
 # Ignore baz-style junk files or directories
 (?:^|/),,.*(?:$|/.*$)|
 (?:^|/),,.*(?:$|/.*$)|
-# local-options must not be exported in the resulting source package
-(?:^|/)debian/source/local-options$|
 # File-names that should be ignored (never directories)
 # File-names that should be ignored (never directories)
 (?:^|/)(?:DEADJOE|\.arch-inventory|\.(?:bzr|cvs|hg|git)ignore)$|
 (?:^|/)(?:DEADJOE|\.arch-inventory|\.(?:bzr|cvs|hg|git)ignore)$|
 # File or directory names that should be ignored
 # File or directory names that should be ignored
@@ -170,13 +168,15 @@ sub init_options {
     # Use full ignore list by default
     # Use full ignore list by default
     # note: this function is not called by V1 packages
     # note: this function is not called by V1 packages
     $self->{'options'}{'diff_ignore_regexp'} ||= $diff_ignore_default_regexp;
     $self->{'options'}{'diff_ignore_regexp'} ||= $diff_ignore_default_regexp;
+    $self->{'options'}{'diff_ignore_regexp'} .= '|(?:^|/)debian/source/local-.*$';
     if (defined $self->{'options'}{'tar_ignore'}) {
     if (defined $self->{'options'}{'tar_ignore'}) {
         $self->{'options'}{'tar_ignore'} = [ @tar_ignore_default_pattern ]
         $self->{'options'}{'tar_ignore'} = [ @tar_ignore_default_pattern ]
             unless @{$self->{'options'}{'tar_ignore'}};
             unless @{$self->{'options'}{'tar_ignore'}};
     } else {
     } else {
         $self->{'options'}{'tar_ignore'} = [ @tar_ignore_default_pattern ];
         $self->{'options'}{'tar_ignore'} = [ @tar_ignore_default_pattern ];
     }
     }
-    push @{$self->{'options'}{'tar_ignore'}}, "debian/source/local-options";
+    push @{$self->{'options'}{'tar_ignore'}}, "debian/source/local-options",
+         "debian/source/local-patch-header";
     # Skip debianization while specific to some formats has an impact
     # Skip debianization while specific to some formats has an impact
     # on code common to all formats
     # on code common to all formats
     $self->{'options'}{'skip_debianization'} ||= 0;
     $self->{'options'}{'skip_debianization'} ||= 0;

+ 4 - 3
scripts/Dpkg/Source/Package/V1.pm

@@ -44,11 +44,12 @@ sub init_options {
     # Don't call $self->SUPER::init_options() on purpose, V1.0 has no
     # Don't call $self->SUPER::init_options() on purpose, V1.0 has no
     # ignore by default
     # ignore by default
     if ($self->{'options'}{'diff_ignore_regexp'}) {
     if ($self->{'options'}{'diff_ignore_regexp'}) {
-	$self->{'options'}{'diff_ignore_regexp'} .= '|(?:^|/)debian/source/local-options$';
+	$self->{'options'}{'diff_ignore_regexp'} .= '|(?:^|/)debian/source/local-.*$';
     } else {
     } else {
-	$self->{'options'}{'diff_ignore_regexp'} = '(?:^|/)debian/source/local-options$';
+	$self->{'options'}{'diff_ignore_regexp'} = '(?:^|/)debian/source/local-.*$';
     }
     }
-    push @{$self->{'options'}{'tar_ignore'}}, "debian/source/local-options";
+    push @{$self->{'options'}{'tar_ignore'}}, "debian/source/local-options",
+         "debian/source/local-patch-header";
     $self->{'options'}{'sourcestyle'} ||= 'X';
     $self->{'options'}{'sourcestyle'} ||= 'X';
     $self->{'options'}{'skip_debianization'} ||= 0;
     $self->{'options'}{'skip_debianization'} ||= 0;
     $self->{'options'}{'abort_on_upstream_changes'} ||= 0;
     $self->{'options'}{'abort_on_upstream_changes'} ||= 0;

+ 4 - 1
scripts/Dpkg/Source/Package/V2.pm

@@ -499,7 +499,10 @@ sub do_build {
 
 
 sub get_patch_header {
 sub get_patch_header {
     my ($self, $dir, $previous) = @_;
     my ($self, $dir, $previous) = @_;
-    my $ph = File::Spec->catfile($dir, "debian", "source", "patch-header");
+    my $ph = File::Spec->catfile($dir, "debian", "source", "local-patch-header");
+    unless (-f $ph) {
+        $ph = File::Spec->catfile($dir, "debian", "source", "patch-header");
+    }
     my $text;
     my $text;
     if (-f $ph) {
     if (-f $ph) {
         open(PH, "<", $ph) || syserr(_g("cannot read %s"), $ph);
         open(PH, "<", $ph) || syserr(_g("cannot read %s"), $ph);

+ 4 - 1
scripts/Dpkg/Source/Package/V3/quilt.pm

@@ -371,7 +371,10 @@ sub register_autopatch {
 
 
 sub get_patch_header {
 sub get_patch_header {
     my ($self, $dir, $previous) = @_;
     my ($self, $dir, $previous) = @_;
-    my $ph = File::Spec->catfile($dir, "debian", "source", "patch-header");
+    my $ph = File::Spec->catfile($dir, "debian", "source", "local-patch-header");
+    unless (-f $ph) {
+        $ph = File::Spec->catfile($dir, "debian", "source", "patch-header");
+    }
     my $text;
     my $text;
     if (-f $ph) {
     if (-f $ph) {
         open(PH, "<", $ph) || syserr(_g("cannot read %s"), $ph);
         open(PH, "<", $ph) || syserr(_g("cannot read %s"), $ph);