Ver código fonte

dpkg-source: Print the correct removed binary filename with --include-removal

When removing a binary file and using --include-removal, we get a bogus
error message about including a pathname relative to /dev/null in
debian/source/include-binaries.

Closes: #755166
Guillem Jover 12 anos atrás
pai
commit
65ad0315be
3 arquivos alterados com 25 adições e 20 exclusões
  1. 2 0
      debian/changelog
  2. 8 7
      scripts/Dpkg/Source/Package/V2.pm
  3. 15 13
      scripts/Dpkg/Source/Patch.pm

+ 2 - 0
debian/changelog

@@ -62,6 +62,8 @@ dpkg (1.17.11) UNRELEASED; urgency=low
   * Try to preallocate the disk size for extracted files on unpack. This
   * Try to preallocate the disk size for extracted files on unpack. This
     might help in avoiding filesystem fragmentation, and possibly improve
     might help in avoiding filesystem fragmentation, and possibly improve
     performance on some filesystems.
     performance on some filesystems.
+  * Print the correct removed binary filename when building a source package
+    with dpkg-source --include-removal. Closes: #755166
 
 
   [ Updated programs translations ]
   [ Updated programs translations ]
   * Danish (Joe Dalton). Closes: #754127
   * Danish (Joe Dalton). Closes: #754127

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

@@ -495,15 +495,16 @@ sub do_build {
 
 
     # Handle modified binary files detected by the auto-patch generation
     # Handle modified binary files detected by the auto-patch generation
     my $handle_binary = sub {
     my $handle_binary = sub {
-        my ($self, $old, $new) = @_;
-        my $relfn = File::Spec->abs2rel($new, $dir);
-        $binaryfiles->new_binary_found($relfn);
-        unless ($include_binaries or $binaryfiles->binary_is_allowed($relfn)) {
-            errormsg(_g('cannot represent change to %s: %s'), $relfn,
+        my ($self, $old, $new, %opts) = @_;
+
+        my $file = $opts{filename};
+        $binaryfiles->new_binary_found($file);
+        unless ($include_binaries or $binaryfiles->binary_is_allowed($file)) {
+            errormsg(_g('cannot represent change to %s: %s'), $file,
                      _g('binary file contents changed'));
                      _g('binary file contents changed'));
             errormsg(_g('add %s in debian/source/include-binaries if you want ' .
             errormsg(_g('add %s in debian/source/include-binaries if you want ' .
                         'to store the modified binary in the debian tarball'),
                         'to store the modified binary in the debian tarball'),
-                     $relfn);
+                     $file);
             $self->register_error();
             $self->register_error();
         }
         }
     };
     };
@@ -644,7 +645,7 @@ sub do_commit {
 
 
     my $binaryfiles = Dpkg::Source::Package::V2::BinaryFiles->new($dir);
     my $binaryfiles = Dpkg::Source::Package::V2::BinaryFiles->new($dir);
     my $handle_binary = sub {
     my $handle_binary = sub {
-        my ($self, $old, $new) = @_;
+        my ($self, $old, $new, %opts) = @_;
         my $fn = File::Spec->abs2rel($new, $dir);
         my $fn = File::Spec->abs2rel($new, $dir);
         $binaryfiles->new_binary_found($fn);
         $binaryfiles->new_binary_found($fn);
     };
     };

+ 15 - 13
scripts/Dpkg/Source/Patch.pm

@@ -43,7 +43,7 @@ sub create {
     $self->ensure_open('w'); # Creates the file
     $self->ensure_open('w'); # Creates the file
     *$self->{errors} = 0;
     *$self->{errors} = 0;
     *$self->{empty} = 1;
     *$self->{empty} = 1;
-    if ($opts{old} and $opts{new}) {
+    if ($opts{old} and $opts{new} and $opts{filename}) {
         $opts{old} = '/dev/null' unless -e $opts{old};
         $opts{old} = '/dev/null' unless -e $opts{old};
         $opts{new} = '/dev/null' unless -e $opts{new};
         $opts{new} = '/dev/null' unless -e $opts{new};
         if (-d $opts{old} and -d $opts{new}) {
         if (-d $opts{old} and -d $opts{new}) {
@@ -51,7 +51,7 @@ sub create {
         } elsif (-f $opts{old} and -f $opts{new}) {
         } elsif (-f $opts{old} and -f $opts{new}) {
             $self->add_diff_file($opts{old}, $opts{new}, %opts);
             $self->add_diff_file($opts{old}, $opts{new}, %opts);
         } else {
         } else {
-            $self->_fail_not_same_type($opts{old}, $opts{new});
+            $self->_fail_not_same_type($opts{old}, $opts{new}, $opts{filename});
         }
         }
         $self->finish() unless $opts{nofinish};
         $self->finish() unless $opts{nofinish};
     }
     }
@@ -66,8 +66,9 @@ sub add_diff_file {
     my ($self, $old, $new, %opts) = @_;
     my ($self, $old, $new, %opts) = @_;
     $opts{include_timestamp} = 0 unless exists $opts{include_timestamp};
     $opts{include_timestamp} = 0 unless exists $opts{include_timestamp};
     my $handle_binary = $opts{handle_binary_func} || sub {
     my $handle_binary = $opts{handle_binary_func} || sub {
-        my ($self, $old, $new) = @_;
-        $self->_fail_with_msg($new, _g('binary file contents changed'));
+        my ($self, $old, $new, %opts) = @_;
+        my $file = $opts{filename};
+        $self->_fail_with_msg($file, _g('binary file contents changed'));
     };
     };
     # Optimization to avoid forking diff if unnecessary
     # Optimization to avoid forking diff if unnecessary
     return 1 if compare($old, $new, 4096) == 0;
     return 1 if compare($old, $new, 4096) == 0;
@@ -112,7 +113,7 @@ sub add_diff_file {
     while (<$diffgen>) {
     while (<$diffgen>) {
         if (m/^(?:binary|[^-+\@ ].*\bdiffer\b)/i) {
         if (m/^(?:binary|[^-+\@ ].*\bdiffer\b)/i) {
             $binary = 1;
             $binary = 1;
-            &$handle_binary($self, $old, $new);
+            &$handle_binary($self, $old, $new, %opts);
             last;
             last;
         } elsif (m/^[-+\@ ]/) {
         } elsif (m/^[-+\@ ]/) {
             $difflinefound++;
             $difflinefound++;
@@ -168,7 +169,7 @@ sub add_diff_directory {
         my $size = (lstat(_))[7];
         my $size = (lstat(_))[7];
         if (-l _) {
         if (-l _) {
             unless (-l "$old/$fn") {
             unless (-l "$old/$fn") {
-                $self->_fail_not_same_type("$old/$fn", "$new/$fn");
+                $self->_fail_not_same_type("$old/$fn", "$new/$fn", $fn);
                 return;
                 return;
             }
             }
             my $n = readlink("$new/$fn");
             my $n = readlink("$new/$fn");
@@ -180,7 +181,7 @@ sub add_diff_directory {
                 syserr(_g('cannot read link %s'), "$old/$fn");
                 syserr(_g('cannot read link %s'), "$old/$fn");
             }
             }
             unless ($n eq $n2) {
             unless ($n eq $n2) {
-                $self->_fail_not_same_type("$old/$fn", "$new/$fn");
+                $self->_fail_not_same_type("$old/$fn", "$new/$fn", $fn);
             }
             }
         } elsif (-f _) {
         } elsif (-f _) {
             my $old_file = "$old/$fn";
             my $old_file = "$old/$fn";
@@ -190,7 +191,7 @@ sub add_diff_directory {
                 }
                 }
                 $old_file = '/dev/null';
                 $old_file = '/dev/null';
             } elsif (not -f _) {
             } elsif (not -f _) {
-                $self->_fail_not_same_type("$old/$fn", "$new/$fn");
+                $self->_fail_not_same_type("$old/$fn", "$new/$fn", $fn);
                 return;
                 return;
             }
             }
 
 
@@ -202,7 +203,7 @@ sub add_diff_directory {
                                $label_old, "$basedir/$fn"];
                                $label_old, "$basedir/$fn"];
         } elsif (-p _) {
         } elsif (-p _) {
             unless (-p "$old/$fn") {
             unless (-p "$old/$fn") {
-                $self->_fail_not_same_type("$old/$fn", "$new/$fn");
+                $self->_fail_not_same_type("$old/$fn", "$new/$fn", $fn);
             }
             }
         } elsif (-b _ || -c _ || -S _) {
         } elsif (-b _ || -c _ || -S _) {
             $self->_fail_with_msg("$new/$fn",
             $self->_fail_with_msg("$new/$fn",
@@ -213,7 +214,7 @@ sub add_diff_directory {
                     syserr(_g('cannot stat file %s'), "$old/$fn");
                     syserr(_g('cannot stat file %s'), "$old/$fn");
                 }
                 }
             } elsif (not -d _) {
             } elsif (not -d _) {
-                $self->_fail_not_same_type("$old/$fn", "$new/$fn");
+                $self->_fail_not_same_type("$old/$fn", "$new/$fn", $fn);
             }
             }
         } else {
         } else {
             $self->_fail_with_msg("$new/$fn", _g('unknown file type'));
             $self->_fail_with_msg("$new/$fn", _g('unknown file type'));
@@ -236,7 +237,7 @@ sub add_diff_directory {
         } elsif (-l _) {
         } elsif (-l _) {
             warning(_g('ignoring deletion of symlink %s'), $fn);
             warning(_g('ignoring deletion of symlink %s'), $fn);
         } else {
         } else {
-            $self->_fail_not_same_type("$old/$fn", "$new/$fn");
+            $self->_fail_not_same_type("$old/$fn", "$new/$fn", $fn);
         }
         }
     };
     };
 
 
@@ -273,6 +274,7 @@ sub add_diff_directory {
         my ($fn, $mode, $size,
         my ($fn, $mode, $size,
             $old_file, $new_file, $label_old, $label_new) = @$diff_file;
             $old_file, $new_file, $label_old, $label_new) = @$diff_file;
         my $success = $self->add_diff_file($old_file, $new_file,
         my $success = $self->add_diff_file($old_file, $new_file,
+                                           filename => $fn,
                                            label_old => $label_old,
                                            label_old => $label_old,
                                            label_new => $label_new, %opts);
                                            label_new => $label_new, %opts);
         if ($success and
         if ($success and
@@ -311,10 +313,10 @@ sub _fail_with_msg {
     $self->register_error();
     $self->register_error();
 }
 }
 sub _fail_not_same_type {
 sub _fail_not_same_type {
-    my ($self, $old, $new) = @_;
+    my ($self, $old, $new, $file) = @_;
     my $old_type = get_type($old);
     my $old_type = get_type($old);
     my $new_type = get_type($new);
     my $new_type = get_type($new);
-    errormsg(_g('cannot represent change to %s:'), $new);
+    errormsg(_g('cannot represent change to %s:'), $file);
     errormsg(_g('  new version is %s'), $new_type);
     errormsg(_g('  new version is %s'), $new_type);
     errormsg(_g('  old version is %s'), $old_type);
     errormsg(_g('  old version is %s'), $old_type);
     $self->register_error();
     $self->register_error();