Преглед изворни кода

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 година
родитељ
комит
0898ea0048
3 измењених фајлова са 8 додато и 2 уклоњено
  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
     and the patch. Closes: #569618
   * Add $VERSION numbers to all perl modules. Closes: #465256
   * Add $VERSION numbers to all perl modules. Closes: #465256
     1.00 and higher means that the API should be stable
     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 ]
   [ Guillem Jover ]
   * Handle argument parsing in dpkg-checkbuilddeps and dpkg-scanpackages
   * 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($) {
 sub is_binary($) {
     my ($file) = @_;
     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
     # Use diff to check if it's a binary file
     my $diffgen;
     my $diffgen;
     my $diff_pid = spawn(
     my $diff_pid = spawn(
@@ -76,7 +79,7 @@ sub is_binary($) {
     );
     );
     my $result = 0;
     my $result = 0;
     while (<$diffgen>) {
     while (<$diffgen>) {
-        if (m/^binary/i) {
+        if (m/^(?:binary|[^-+\@ ].*\bdiffer\b)/i) {
             $result = 1;
             $result = 1;
             last;
             last;
         } elsif (m/^[-+\@ ]/) {
         } elsif (m/^[-+\@ ]/) {

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

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