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

dpkg-source: be a bit less strict when parsing patches

It will now accept seeing the same file twice

Reported-by: Bastian Blank <waldi@debian.org>

It will no longer match on the English text "No newline at end of file" as
it might be translated in some cases. It will only consider the intial
"\ ".

Reported-by: Jan-Marek Glogowski <glogow@fbihome.de>
Raphaël Hertzog лет назад: 15
Родитель
Сommit
df8062d202
2 измененных файлов с 12 добавлено и 6 удалено
  1. 4 0
      debian/changelog
  2. 8 6
      scripts/Dpkg/Source/Patch.pm

+ 4 - 0
debian/changelog

@@ -75,6 +75,10 @@ dpkg (1.16.0) UNRELEASED; urgency=low
     diagnosis.
     diagnosis.
   * dpkg-source will now remove quilt's .pc directory when --unapply-patches
   * dpkg-source will now remove quilt's .pc directory when --unapply-patches
     is in use. Closes: #591858
     is in use. Closes: #591858
+  * dpkg-source is now a bit less strict when parsing patches:
+    - it accepts seeing the same file twice; Closes: #608829
+    - it doesn't match on the English text "No newline at end of file" as it
+      might be translated in some cases. Closes: #612465
 
 
   [ Jonathan Nieder ]
   [ Jonathan Nieder ]
   * Remove support for use of synchronous sync(2), due to its pernicious
   * Remove support for use of synchronous sync(2), due to its pernicious

+ 8 - 6
scripts/Dpkg/Source/Patch.pm

@@ -114,7 +114,7 @@ sub add_diff_file {
             last;
             last;
         } elsif (m/^[-+\@ ]/) {
         } elsif (m/^[-+\@ ]/) {
             $difflinefound++;
             $difflinefound++;
-        } elsif (m/^\\ No newline at end of file$/) {
+        } elsif (m/^\\ /) {
             warning(_g("file %s has no final newline (either " .
             warning(_g("file %s has no final newline (either " .
                        "original or modified version)"), $new);
                        "original or modified version)"), $new);
         } else {
         } else {
@@ -443,16 +443,18 @@ sub analyze {
 	}
 	}
 
 
 	if ($filepatched{$fn}) {
 	if ($filepatched{$fn}) {
-	    error(_g("diff `%s' patches file %s twice"), $diff, $fn);
+	    warning(_g("diff `%s' patches file %s twice"), $diff, $fn)
+		if $opts{"verbose"};
+	} else {
+	    $filepatched{$fn} = 1;
+	    push @patchorder, $fn;
 	}
 	}
-	$filepatched{$fn} = 1;
-	push @patchorder, $fn;
 
 
 	# read hunks
 	# read hunks
 	my $hunk = 0;
 	my $hunk = 0;
 	while (defined($_ = getline($self))) {
 	while (defined($_ = getline($self))) {
 	    # read hunk header (@@)
 	    # read hunk header (@@)
-	    next if /^\\ No newline/;
+	    next if /^\\ /;
 	    last unless (/^@@ -\d+(,(\d+))? \+\d+(,(\d+))? @\@( .*)?$/);
 	    last unless (/^@@ -\d+(,(\d+))? \+\d+(,(\d+))? @\@( .*)?$/);
 	    my ($olines, $nlines) = ($1 ? $2 : 1, $3 ? $4 : 1);
 	    my ($olines, $nlines) = ($1 ? $2 : 1, $3 ? $4 : 1);
 	    # read hunk
 	    # read hunk
@@ -466,7 +468,7 @@ sub analyze {
                         error(_g("unexpected end of diff `%s'"), $diff);
                         error(_g("unexpected end of diff `%s'"), $diff);
                     }
                     }
 		}
 		}
-		next if /^\\ No newline/;
+		next if /^\\ /;
 		# Check stats
 		# Check stats
 		if    (/^ / || /^$/)  { --$olines; --$nlines; }
 		if    (/^ / || /^$/)  { --$olines; --$nlines; }
 		elsif (/^-/)  { --$olines; }
 		elsif (/^-/)  { --$olines; }