Selaa lähdekoodia

Dpkg::Source: fix parsing of diff's output to be POSIX-compliant

While parsing diff's output, accept any sentence that contains the word
differ (as specified by POSIX) to identify that binary files could
not be compared.
Raphaël Hertzog 16 vuotta sitten
vanhempi
commit
0898ea0048
3 muutettua tiedostoa jossa 8 lisäystä ja 2 poistoa
  1. 3 0
      debian/changelog
  2. 4 1
      scripts/Dpkg/Source/Functions.pm
  3. 1 1
      scripts/Dpkg/Source/Patch.pm

+ 3 - 0
debian/changelog

@@ -33,6 +33,9 @@ dpkg (1.15.6) UNRELEASED; urgency=low
     and the patch. Closes: #569618
   * Add $VERSION numbers to all perl modules. Closes: #465256
     1.00 and higher means that the API should be stable
+  * While parsing diff's output, accept any sentence that contains the word
+    differ (as specified by POSIX) to identify that binary files could not be
+    compared. Closes: #570008
 
   [ Guillem Jover ]
   * Handle argument parsing in dpkg-checkbuilddeps and dpkg-scanpackages

+ 4 - 1
scripts/Dpkg/Source/Functions.pm

@@ -67,6 +67,9 @@ sub fixperms {
 sub is_binary($) {
     my ($file) = @_;
 
+    # TODO: might want to reimplement what diff does, aka checking if the
+    # file contains \0 in the first 4Kb of data
+
     # Use diff to check if it's a binary file
     my $diffgen;
     my $diff_pid = spawn(
@@ -76,7 +79,7 @@ sub is_binary($) {
     );
     my $result = 0;
     while (<$diffgen>) {
-        if (m/^binary/i) {
+        if (m/^(?:binary|[^-+\@ ].*\bdiffer\b)/i) {
             $result = 1;
             last;
         } elsif (m/^[-+\@ ]/) {

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

@@ -107,7 +107,7 @@ sub add_diff_file {
     my $difflinefound = 0;
     my $binary = 0;
     while (<$diffgen>) {
-        if (m/^binary/i) {
+        if (m/^(?:binary|[^-+\@ ].*\bdiffer\b)/i) {
             $binary = 1;
             &$handle_binary($self, $old, $new);
             last;