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

Dpkg::Source::Patch: capture output of patch and print it on error

patch is now run without its -s flag and thus outputs the usual messages
about which file it's patching and gives more verbose error messages.
Those messages are captured and only displayed to the user when the
patch application failed.
Raphaël Hertzog лет назад: 16
Родитель
Сommit
17f00407a8
3 измененных файлов с 15 добавлено и 3 удалено
  1. 2 0
      debian/changelog
  2. 2 2
      scripts/Dpkg/Source/Package/V3/quilt.pm
  3. 11 1
      scripts/Dpkg/Source/Patch.pm

+ 2 - 0
debian/changelog

@@ -39,6 +39,8 @@ dpkg (1.15.8) UNRELEASED; urgency=low
     source formats 1.0, 2.0 and 3.0 (quilt). It aborts every time that you try
     to build a source package which contains (unmanaged) changes to the
     upstream source code. Closes: #579012
+  * dpkg-source now captures the output of patch and prints it on error so
+    that the user can better diagnose what went wrong. Closes: #575304
 
   [ Guillem Jover ]
   * Require gettext 0.18:

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

@@ -169,7 +169,7 @@ sub apply_quilt_patch {
     info(_g("applying %s"), $patch) if $opts{"verbose"};
     $obj->apply($dir, timestamp => $opts{"timestamp"},
                 force_timestamp => 1, create_dirs => 1, remove_backup => 0,
-                options => [ '-s', '-t', '-F', '0', '-N', '-p1', '-u',
+                options => [ '-t', '-F', '0', '-N', '-p1', '-u',
                              '-V', 'never', '-g0', '-E', '-b',
                              '-B', ".pc/$patch/" ]);
 }
@@ -242,7 +242,7 @@ sub unapply_patches {
         info(_g("unapplying %s"), $patch) if $opts{"verbose"};
         $obj->apply($dir, timestamp => $opts{"timestamp"},
                     force_timestamp => 1, remove_backup => 0,
-                    options => [ '-R', '-s', '-t', '-N', '-p1',
+                    options => [ '-R', '-t', '-N', '-p1',
                                  '-u', '-V', 'never', '-g0', '-E',
                                  '--no-backup-if-mismatch' ]);
         erasedir(File::Spec->catdir($dir, ".pc", $patch));

+ 11 - 1
scripts/Dpkg/Source/Patch.pm

@@ -443,7 +443,7 @@ sub apply {
     $opts{"force_timestamp"} = 1 unless exists $opts{"force_timestamp"};
     $opts{"remove_backup"} = 1 unless exists $opts{"remove_backup"};
     $opts{"create_dirs"} = 1 unless exists $opts{"create_dirs"};
-    $opts{"options"} ||= [ '-s', '-t', '-F', '0', '-N', '-p1', '-u',
+    $opts{"options"} ||= [ '-t', '-F', '0', '-N', '-p1', '-u',
             '-V', 'never', '-g0', '-b', '-z', '.dpkg-orig'];
     $opts{"add_options"} ||= [];
     push @{$opts{"options"}}, @{$opts{"add_options"}};
@@ -452,14 +452,24 @@ sub apply {
     $self->prepare_apply($analysis, %opts);
     # Apply the patch
     $self->ensure_open("r");
+    my ($stdout, $stderr) = ('', '');
     spawn(
 	'exec' => [ 'patch', @{$opts{"options"}} ],
 	'chdir' => $destdir,
 	'env' => { LC_ALL => 'C', LANG => 'C' },
 	'delete_env' => [ 'POSIXLY_CORRECT' ], # ensure expected patch behaviour
 	'wait_child' => 1,
+	'nocheck' => 1,
 	'from_handle' => $self->get_filehandle(),
+	'to_string' => \$stdout,
+	'error_to_string' => \$stderr,
     );
+    if ($?) {
+	print STDOUT $stdout;
+	print STDERR $stderr;
+	subprocerr("LC_ALL=C patch " . join(" ", @{$opts{"options"}}) .
+	           " < " . $self->get_filename());
+    }
     $self->close();
     # Reset the timestamp of all the patched files
     # and remove .dpkg-orig files