Просмотр исходного кода

dpkg-source: keep the current patch header when regenerating the automatic patch

When dpkg-source regenerates the automatic patch (with formats "2.0" or
"3.0 (quilt)") it will keep the current patch header to avoid losing
changes made by the maintainer.

Reported-by: Cyril Brulebois <kibi@debian.org>
Raphaël Hertzog лет назад: 14
Родитель
Сommit
fddd49ee21
2 измененных файлов с 12 добавлено и 1 удалено
  1. 3 0
      debian/changelog
  2. 9 1
      scripts/Dpkg/Source/Package/V2.pm

+ 3 - 0
debian/changelog

@@ -5,6 +5,9 @@ dpkg (1.16.5) UNRELEASED; urgency=low
     patch. Closes: #652970
     And it will display a message explaining the most likely cause of
     failure (patch applying with fuzz).
+  * When dpkg-source regenerates the automatic patch (with formats "2.0"
+    or "3.0 (quilt)") it will keep the current patch header to avoid
+    losing changes made by the maintainer.
 
   [ Updated dpkg translations ]
   * Swedish (Peter Krefting).

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

@@ -380,7 +380,14 @@ sub generate_patch {
     my $diff = Dpkg::Source::Patch->new(filename => $tmpdiff,
                                         compression => "none");
     $diff->create();
-    $diff->set_header($self->get_patch_header($dir));
+    if ($opts{'header_from'} and -e $opts{'header_from'}) {
+        my $header_from = Dpkg::Source::Patch->new(
+            filename => $opts{'header_from'});
+        my $analysis = $header_from->analyze($dir, verbose => 0);
+        $diff->set_header($analysis->{'patchheader'});
+    } else {
+        $diff->set_header($self->get_patch_header($dir));
+    }
     $diff->add_diff_directory($tmp, $dir, basedirname => $basedirname,
             %{$self->{'diff_options'}},
             handle_binary_func => $opts{'handle_binary'},
@@ -501,6 +508,7 @@ sub do_build {
     my $autopatch = File::Spec->catfile($dir, "debian", "patches",
                                         $self->get_autopatch_name());
     my $tmpdiff = $self->generate_patch($dir, order_from => $autopatch,
+                                        header_from => $autopatch,
                                         handle_binary => $handle_binary,
                                         skip_auto => $self->{'options'}{'auto_commit'},
                                         usage => 'build');