瀏覽代碼

Dpkg::Source::Package::V3::Quilt: Handle series files with no final newline

Do not mangle the series files when the last line is missing a newline,
by loading and saving the file with the added patch. This is quite ugly
in general, but fixes the immediate problem. The code will be getting a
general overhaul in due time.

Closes: #584233
Guillem Jover 12 年之前
父節點
當前提交
6b153d0784
共有 2 個文件被更改,包括 9 次插入2 次删除
  1. 2 0
      debian/changelog
  2. 7 2
      scripts/Dpkg/Source/Package/V3/Quilt.pm

+ 2 - 0
debian/changelog

@@ -44,6 +44,8 @@ dpkg (1.17.10) UNRELEASED; urgency=low
     - Add missing Dpkg::Deps::Multiple profile_is_concerned() and
       reduce_profiles() methods, inherited by Dpkg::Deps::Union,
       Dpkg::Deps::AND and Dpkg::Deps::OR.
+  * Do not mangle quilt series files with a missing newline on the last line.
+    Closes: #584233
 
   [ Updated manpages translations ]
   * German (Helge Kreutzmann).

+ 7 - 2
scripts/Dpkg/Source/Package/V3/Quilt.pm

@@ -234,8 +234,13 @@ sub _load_file {
 sub _add_line {
     my ($file, $line) = @_;
 
-    open(my $file_fh, '>>', $file) or syserr(_g('cannot write %s'), $file);
-    print { $file_fh } "$line\n";
+    my @lines;
+    @lines = _load_file($file) if -f $file;
+    push @lines, $line;
+    chomp @lines;
+
+    open my $file_fh, '>', $file or syserr(_g('cannot write %s'), $file);
+    print { $file_fh } "$_\n" foreach @lines;
     close($file_fh);
 }