Przeglądaj źródła

Dpkg::Source: Make patching a file multiple times fatal for first quilt patch

When we check if the first quilt patch in a series can be applied, we
use «patch --dry-run» with other options, but that cannot work if the
same diff patches a file multiple times, as patch does not record the
previous state in memory.

We are alredy detecting this condition, but only emitting a warning,
instead make it possible to turn it into a fatal error.

Closes: #810720
Reported-by: Apollon Oikonomopoulos <apoikos@debian.org>
Guillem Jover 10 lat temu
rodzic
commit
3f11ae3b3d

+ 3 - 0
debian/changelog

@@ -11,6 +11,9 @@ dpkg (1.18.5) UNRELEASED; urgency=medium
     - Add new CTRL_REPO_RELEASE control block type to Dpkg::Control.
     - Add new CTRL_COPYRIGHT_HEADER, CTRL_COPYRIGHT_FILES and
       CTRL_COPYRIGHT_LICENSE control block types to Dpkg::Control.
+    - Make patching a file multiple times fatal for the first quilt patch in
+      Dpkg::Source. Reported by Apollon Oikonomopoulos <apoikos@debian.org>.
+      Closes: #810720
   * Documentation:
     - Say value instead of option in deb-control(5).
     - Mark debian changelog format in bold in dpkg-parsechangelog(1).

+ 1 - 1
scripts/Dpkg/Source/Package/V3/Quilt.pm

@@ -215,7 +215,7 @@ sub check_patches_applied {
 
     my $first_patch = File::Spec->catfile($dir, 'debian', 'patches', $next);
     my $patch_obj = Dpkg::Source::Patch->new(filename => $first_patch);
-    return unless $patch_obj->check_apply($dir);
+    return unless $patch_obj->check_apply($dir, fatal_dupes => 1);
 
     $self->apply_patches($dir, usage => 'preparation', verbose => 1);
 }

+ 7 - 2
scripts/Dpkg/Source/Patch.pm

@@ -491,8 +491,13 @@ sub analyze {
 	}
 
 	if ($filepatched{$fn}) {
-	    warning(g_("diff '%s' patches file %s twice"), $diff, $fn)
-		if $opts{verbose};
+            if ($opts{fatal_dupes}) {
+                error(g_("diff '%s' patches files multiple times; split the " .
+                         "diff in multiple files or merge the hunks into a " .
+                         "single one"), $diff);
+            } elsif ($opts{verbose}) {
+                warning(g_("diff '%s' patches file %s twice"), $diff, $fn)
+            }
 	} else {
 	    $filepatched{$fn} = 1;
 	    push @patchorder, $fn;