[dpkg] 171/187: Dpkg::Changelog: Cope gracefully with a missing trailer timestamp

Reiner Herrmann reiner at reiner-h.de
Sun Nov 6 12:46:41 UTC 2016


This is an automated email from the git hooks/post-receive script.

deki-guest pushed a commit to branch master
in repository dpkg.

commit b8227f0b53e67d0b43f295f01dcd8e08a5cce5aa
Author: Guillem Jover <guillem at debian.org>
Date:   Sat Nov 5 19:55:42 2016 +0100

    Dpkg::Changelog: Cope gracefully with a missing trailer timestamp
    
    The get_timepiece methods might return an undef value if there was no
    timestamp in the trailer. Do not call the Time::Piece epoch method in
    that case, as that causes a perl error.
    
    Regression introduced in commit ea22158eb8b0dcaf42b0cdacd5b4560764f353c8.
    
    Closes: #843248
    Based-on-patch-by: Ian Jackson <ijackson at chiark.greenend.org.uk>
---
 debian/changelog                       |  3 +++
 scripts/Dpkg/Changelog.pm              |  4 ++--
 scripts/Dpkg/Changelog/Entry.pm        |  2 ++
 scripts/Dpkg/Changelog/Entry/Debian.pm |  2 ++
 scripts/t/Dpkg_Changelog.t             |  5 +++--
 scripts/t/Dpkg_Changelog/unreleased    | 11 +++++++++++
 6 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 6fcc881..1ecf178 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -123,6 +123,9 @@ dpkg (1.18.11) UNRELEASED; urgency=medium
     - Add new CTRL_FILE_BUILDINFO type to Dpkg::Control.
     - Add new .buildinfo fields to Dpkg::Control::Fields.
     - Add new builtin-system-build-paths Dpkg::Vendor hook.
+    - Cope gracefully with changelogs missing a timestamp trailer.
+      Based on a patch by Ian Jackson <ijackson at chiark.greenend.org.uk>.
+      Regression introduced in dpkg 1.18.8. Closes: #843248
   * Packaging:
     - Add liblocale-gettext-perl to libdpkg-perl Recommends.
     - Wrap and document dependency relationships.
diff --git a/scripts/Dpkg/Changelog.pm b/scripts/Dpkg/Changelog.pm
index 0424db6..db8e3eb 100644
--- a/scripts/Dpkg/Changelog.pm
+++ b/scripts/Dpkg/Changelog.pm
@@ -495,7 +495,7 @@ sub _format_dpkg {
     $f->{Distribution} = join(' ', $src->get_distributions());
     $f->{Maintainer} = $src->get_maintainer() // '';
     $f->{Date} = $src->get_timestamp() // '';
-    $f->{Timestamp} = $src->get_timepiece->epoch // '';
+    $f->{Timestamp} = $src->get_timepiece && $src->get_timepiece->epoch // '';
     $f->{Changes} = $src->get_dpkg_changes();
 
     # handle optional fields
@@ -551,7 +551,7 @@ sub _format_rfc822 {
 	$f->{Distribution} = join(' ', $entry->get_distributions());
 	$f->{Maintainer} = $entry->get_maintainer() // '';
 	$f->{Date} = $entry->get_timestamp() // '';
-	$f->{Timestamp} = $entry->get_timepiece->epoch // '';
+	$f->{Timestamp} = $entry->get_timepiece && $entry->get_timepiece->epoch // '';
 	$f->{Changes} = $entry->get_dpkg_changes();
 
 	# handle optional fields
diff --git a/scripts/Dpkg/Changelog/Entry.pm b/scripts/Dpkg/Changelog/Entry.pm
index f00fcd6..144dacb 100644
--- a/scripts/Dpkg/Changelog/Entry.pm
+++ b/scripts/Dpkg/Changelog/Entry.pm
@@ -285,6 +285,8 @@ sub get_timestamp {
 
 Return the timestamp of the changelog entry as a Time::Piece object.
 
+This function might return undef if there was no timestamp.
+
 =cut
 
 sub get_timepiece {
diff --git a/scripts/Dpkg/Changelog/Entry/Debian.pm b/scripts/Dpkg/Changelog/Entry/Debian.pm
index 30f857b..829eace 100644
--- a/scripts/Dpkg/Changelog/Entry/Debian.pm
+++ b/scripts/Dpkg/Changelog/Entry/Debian.pm
@@ -393,6 +393,8 @@ sub get_timestamp {
 
 Return the timestamp of the changelog entry as a Time::Piece object.
 
+This function might return undef if there was no timestamp.
+
 =cut
 
 sub get_timepiece {
diff --git a/scripts/t/Dpkg_Changelog.t b/scripts/t/Dpkg_Changelog.t
index 8c86cd1..e64ec87 100644
--- a/scripts/t/Dpkg_Changelog.t
+++ b/scripts/t/Dpkg_Changelog.t
@@ -16,7 +16,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 92;
+use Test::More tests => 94;
 
 use File::Basename;
 
@@ -324,7 +324,8 @@ Xb-Userfield2: foobar
     }
 }
 
-foreach my $test (( [ "$datadir/misplaced-tz", 6 ])) {
+foreach my $test (([ "$datadir/misplaced-tz", 6 ],
+                   [ "$datadir/unreleased", 5, 7 ])) {
 
     my $file = shift @$test;
     my $changes = Dpkg::Changelog::Debian->new(verbose => 0);
diff --git a/scripts/t/Dpkg_Changelog/unreleased b/scripts/t/Dpkg_Changelog/unreleased
new file mode 100644
index 0000000..14cacae
--- /dev/null
+++ b/scripts/t/Dpkg_Changelog/unreleased
@@ -0,0 +1,11 @@
+source (2.0) UNRELEASED; urgency=medium
+
+  * This version has not been finished yet.
+
+ --
+
+source (1.0) unstable; urgency=medium
+
+  * New release.
+
+ -- Dpkg Developers <debian-dpkg at lists.debian.org>  Sat, 05 Nov 2016 18:42:23 +0100

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git



More information about the Reproducible-commits mailing list