Explorar el Código

dpkg-source: support new option --no-unapply-patches

This option is supported by formats "2.0" and "3.0 (quilt)". It disables
the patch unapplication that can happen in the --after-build hook.
Raphaël Hertzog hace 14 años
padre
commit
0725ee2bf0

+ 3 - 0
debian/changelog

@@ -11,6 +11,9 @@ dpkg (1.16.5) UNRELEASED; urgency=low
   * Modify dpkg-source --commit to auto-whitelist modified binary files.
     That way the same command can be used whatever kind of upstream files
     has been modified.
+  * dpkg-source now supports a new option --no-unapply-patches to force
+    patches to be kept applied after build (used by formats "2.0" and "3.0
+    (quilt)"). Closes: #643043
 
   [ Updated dpkg translations ]
   * Swedish (Peter Krefting).

+ 7 - 6
man/dpkg-source.1

@@ -566,12 +566,13 @@ and if there are supplementary original tarballs. This option is meant to
 be used when the source package is just a bundle of multiple upstream
 software and where there's no "main" software.
 .TP
-.B \-\-unapply\-patches
-Unapply the patches in the \fB\-\-after\-build\fP hook. You usually don't
-need this option as dpkg\-source will automatically unapply the patches
-if it did apply them during \fB\-\-before\-build\fP. This
-option is only allowed in \fBdebian/source/local\-options\fP so that all
-generated source packages have the same behavior by default.
+.B \-\-no\-unapply\-patches, \-\-unapply\-patches
+By default, dpkg\-source will automatically unapply the patches in the
+\fB\-\-after\-build\fP hook if it did apply them during
+\fB\-\-before\-build\fP. Those options allow you to forcefully disable
+or enable the patch unapplication process. Those options are only allowed
+in \fBdebian/source/local\-options\fP so that all generated source
+packages have the same behavior by default.
 .TP
 .B \-\-abort\-on\-upstream\-changes
 The process fails if an automatic patch has been generated. This option

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

@@ -57,7 +57,7 @@ sub init_options {
         unless exists $self->{'options'}{'preparation'};
     $self->{'options'}{'skip_patches'} = 0
         unless exists $self->{'options'}{'skip_patches'};
-    $self->{'options'}{'unapply_patches'} = 0
+    $self->{'options'}{'unapply_patches'} = 'auto'
         unless exists $self->{'options'}{'unapply_patches'};
     $self->{'options'}{'skip_debianization'} = 0
         unless exists $self->{'options'}{'skip_debianization'};
@@ -85,7 +85,10 @@ sub parse_cmdline_option {
         $self->{'options'}{'skip_patches'} = 1;
         return 1;
     } elsif ($opt =~ /^--unapply-patches$/) {
-        $self->{'options'}{'unapply_patches'} = 1;
+        $self->{'options'}{'unapply_patches'} = 'yes';
+        return 1;
+    } elsif ($opt =~ /^--no-unapply-patches$/) {
+        $self->{'options'}{'unapply_patches'} = 'no';
         return 1;
     } elsif ($opt =~ /^--skip-debianization$/) {
         $self->{'options'}{'skip_debianization'} = 1;
@@ -278,8 +281,9 @@ sub after_build {
         $reason = <APPLIED>;
         close(APPLIED);
     }
-    if ($reason =~ /^# During preparation/ or
-        $self->{'options'}{'unapply_patches'}) {
+    my $opt_unapply = $self->{'options'}{'unapply_patches'};
+    if (($opt_unapply eq "auto" and $reason =~ /^# During preparation/) or
+        $opt_unapply eq "yes") {
         $self->unapply_patches($dir);
     }
 }

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

@@ -118,7 +118,8 @@ sub apply_patches {
 
     return unless scalar($quilt->series());
 
-    if ($opts{'usage'} eq "preparation") {
+    if ($opts{'usage'} eq "preparation" and
+        $self->{'options'}{'unapply_patches'} eq 'auto') {
         # We're applying the patches in --before-build, remember to unapply
         # them afterwards in --after-build
         my $pc_unapply = $quilt->get_db_file(".dpkg-source-unapply");
@@ -192,7 +193,8 @@ sub after_build {
     my ($self, $dir) = @_;
     my $quilt = $self->build_quilt_object($dir);
     my $pc_unapply = $quilt->get_db_file(".dpkg-source-unapply");
-    if (-e $pc_unapply or $self->{'options'}{'unapply_patches'}) {
+    my $opt_unapply = $self->{'options'}{'unapply_patches'};
+    if (($opt_unapply eq "auto" and -e $pc_unapply) or $opt_unapply eq "yes") {
         unlink($pc_unapply);
         $self->unapply_patches($dir);
     }