summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2014-05-17 03:34:04 +0200
committerGuillem Jover <guillem@debian.org>2014-05-17 13:30:54 +0200
commit6b153d07845ebcc98b195d47d07638b21c43db29 (patch)
tree042c775fc700ede73ca60e19817e67b4f6e104f3
parentd8ec10fa65cee0fe67cf557bd48f18ac2442a5f6 (diff)
downloaddpkg-6b153d07845ebcc98b195d47d07638b21c43db29.tar.gz
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
-rw-r--r--debian/changelog2
-rw-r--r--scripts/Dpkg/Source/Package/V3/Quilt.pm9
2 files changed, 9 insertions, 2 deletions
diff --git a/debian/changelog b/debian/changelog
index dc840d50d..0422e21aa 100644
--- a/debian/changelog
+++ b/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).
diff --git a/scripts/Dpkg/Source/Package/V3/Quilt.pm b/scripts/Dpkg/Source/Package/V3/Quilt.pm
index 43076cc5f..2c348b83f 100644
--- a/scripts/Dpkg/Source/Package/V3/Quilt.pm
+++ b/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);
}