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

dpkg-source: fix automatic patch registration in format 3.0 (quilt)

When the automatic patch is updated due to a second call to
dpkg-source, it's not always properly registered with quilt.
It must be applied with quilt itself otherwise quilt pop
then quilt push might fail when supplementary files have been modified
outside of quilt's knowledge.

Furthermore quilt import was not a good choice as it failed trying to copy
the patch over itself. The new approach is to revert the patch and let
quilt reapply it with quilt fold. It will go over the list of files
modified by the new patch and add those which were not yet part of the
previous patch (hence adding the required unmodified files in
.pc/<patch-name>/).

Based-on-patch-by: Goswin von Brederlow <goswin-v-b@web.de>
Raphael Hertzog лет назад: 17
Родитель
Сommit
50e6ea1dc0
2 измененных файлов с 22 добавлено и 4 удалено
  1. 4 0
      debian/changelog
  2. 18 4
      scripts/Dpkg/Source/Package/V3/quilt.pm

+ 4 - 0
debian/changelog

@@ -70,6 +70,10 @@ dpkg (1.15.1) UNRELEASED; urgency=low
     /etc/dpkg/origins. It can be used in debian/rules to enable different
     /etc/dpkg/origins. It can be used in debian/rules to enable different
     behaviour depending on the current vendor at the time of the build.
     behaviour depending on the current vendor at the time of the build.
     Closes: #498380
     Closes: #498380
+  * Ensure that the automatic patch created in format "3.0 (quilt)" is always
+    well registered with quilt even when it's updated by a new call to
+    dpkg-source. Thanks to Goswin von Brederlow for the initial patch.
+    Closes: #525858
 
 
   [ Guillem Jover ]
   [ Guillem Jover ]
   * Fix typo in dpkg output (‘unexecpted’ → ‘unexpected’). Closes: #519082
   * Fix typo in dpkg output (‘unexecpted’ → ‘unexpected’). Closes: #519082

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

@@ -248,13 +248,15 @@ sub register_autopatch {
                 not $self->{'options'}{'without_quilt'})
                 not $self->{'options'}{'without_quilt'})
             {
             {
                 # Registering the new patch with quilt requires some
                 # Registering the new patch with quilt requires some
-                # trickery: reverse-apply the patch, import it, apply it
-                # again with quilt this time
+                # trickery: reverse-apply the patch, create a new quilt patch,
+                # fold the patch into the quilt-managed one
                 my $patch_obj = Dpkg::Source::Patch->new(filename => $patch);
                 my $patch_obj = Dpkg::Source::Patch->new(filename => $patch);
                 $patch_obj->apply($dir, add_options => ['-R', '-E']);
                 $patch_obj->apply($dir, add_options => ['-R', '-E']);
-                $self->run_quilt($dir, ['import', "$absdir/debian/patches/$auto_patch"],
+                $self->run_quilt($dir, ['new', "$auto_patch"],
+                                 wait_child => 1, to_file => '/dev/null');
+                $self->run_quilt($dir, ['fold'],
+                                 from_file => "$absdir/debian/patches/$auto_patch",
                                  wait_child => 1, to_file => '/dev/null');
                                  wait_child => 1, to_file => '/dev/null');
-                $self->run_quilt($dir, ['push'], wait_child => 1, to_file => '/dev/null');
             } else {
             } else {
                 open(SERIES, ">>", $series) || syserr(_g("cannot write %s"), $series);
                 open(SERIES, ">>", $series) || syserr(_g("cannot write %s"), $series);
                 print SERIES "$auto_patch\n";
                 print SERIES "$auto_patch\n";
@@ -263,6 +265,18 @@ sub register_autopatch {
             open(APPLIED, ">>", $applied) || syserr(_g("cannot write %s"), $applied);
             open(APPLIED, ">>", $applied) || syserr(_g("cannot write %s"), $applied);
             print APPLIED "$auto_patch\n";
             print APPLIED "$auto_patch\n";
             close(APPLIED);
             close(APPLIED);
+        } else {
+            # If quilt was used, ensure its meta-information are
+            # synchronized with the updated patch
+            if (-d "$dir/.pc" and not $self->{'options'}{'without_quilt'}) {
+                # Some trickery needed: reverse-apply the patch, fold the
+                # new patch into the quilt-managed one
+                my $patch_obj = Dpkg::Source::Patch->new(filename => $patch);
+                $patch_obj->apply($dir, add_options => ['-R', '-E']);
+                $self->run_quilt($dir, ['fold'],
+                                 from_file => "$absdir/debian/patches/$auto_patch",
+                                 wait_child => 1, to_file => '/dev/null');
+            }
         }
         }
     } else {
     } else {
         # Remove auto_patch from series
         # Remove auto_patch from series