Quellcode durchsuchen

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 vor 15 Jahren
Ursprung
Commit
df8062d202
2 geänderte Dateien mit 12 neuen und 6 gelöschten Zeilen
  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.
   * dpkg-source will now remove quilt's .pc directory when --unapply-patches
     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 ]
   * 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;
         } elsif (m/^[-+\@ ]/) {
             $difflinefound++;
-        } elsif (m/^\\ No newline at end of file$/) {
+        } elsif (m/^\\ /) {
             warning(_g("file %s has no final newline (either " .
                        "original or modified version)"), $new);
         } else {
@@ -443,16 +443,18 @@ sub analyze {
 	}
 
 	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
 	my $hunk = 0;
 	while (defined($_ = getline($self))) {
 	    # read hunk header (@@)
-	    next if /^\\ No newline/;
+	    next if /^\\ /;
 	    last unless (/^@@ -\d+(,(\d+))? \+\d+(,(\d+))? @\@( .*)?$/);
 	    my ($olines, $nlines) = ($1 ? $2 : 1, $3 ? $4 : 1);
 	    # read hunk
@@ -466,7 +468,7 @@ sub analyze {
                         error(_g("unexpected end of diff `%s'"), $diff);
                     }
 		}
-		next if /^\\ No newline/;
+		next if /^\\ /;
 		# Check stats
 		if    (/^ / || /^$/)  { --$olines; --$nlines; }
 		elsif (/^-/)  { --$olines; }