[Reproducible-commits] [dpkg] 23/74: Dpkg::Changelog: Add new Timestamp field to output

Mattia Rizzolo mattia at debian.org
Sun Jul 3 22:22:53 UTC 2016


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

mattia pushed a commit to annotated tag 1.18.8
in repository dpkg.

commit ea22158eb8b0dcaf42b0cdacd5b4560764f353c8
Author: Guillem Jover <guillem at debian.org>
Date:   Sat Apr 2 03:19:17 2016 +0200

    Dpkg::Changelog: Add new Timestamp field to output
    
    This field contains the date of the entry in seconds since the epoch. To
    make it easier to retrieve the date in a format that is easier to handle.
---
 debian/changelog                   |  2 ++
 man/dpkg-parsechangelog.1          | 11 +++++++++++
 scripts/Dpkg/Changelog.pm          |  8 ++++++++
 scripts/Dpkg/Control/FieldsCore.pm |  5 ++++-
 scripts/t/Dpkg_Changelog.t         |  4 ++++
 5 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index c2d0420..9c8b4e4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -9,6 +9,8 @@ dpkg (1.18.8) UNRELEASED; urgency=medium
       in Dpkg::Changelog.
     - Replace changelog program parsers with perl modules.
     - Add a getter for the Time::Piece object in Dpkg::Changelog.
+    - Add new Timestamp field to Dpkg::Changelog output, which ends up on
+      dpkg-parsechangelog's output.
   * Test suite:
     - Bump perlcritic ValuesAndExpressions::RequireNumberSeparators minimum
       to 99999.
diff --git a/man/dpkg-parsechangelog.1 b/man/dpkg-parsechangelog.1
index 85e3be0..80d45f8 100644
--- a/man/dpkg-parsechangelog.1
+++ b/man/dpkg-parsechangelog.1
@@ -97,6 +97,17 @@ concatenated (space-separated) comments from all the versions requested.
 .BI Maintainer: " author"
 .TP
 .BI Date: " date"
+The date of the entry as a string, as it appears in the changelog.
+With a \fBstrptime\fP(3) format "\fB%a, %d %b %Y %T %z\fP", but where the
+day of the week might not actually correspond to the real day obtained
+from the rest of the date string.
+If you need a more accurate representation of the date, use the
+\fBTimestamp\fP field, but take into account it might not be possible to
+map it back to the exact value in this field.
+.TP
+.BI Timestamp: " timestamp"
+The date of the entry as a timestamp in seconds since the epoch
+(since dpkg 1.18.8).
 .TP
 .BI Closes: " bug-number"
 The Closes fields of all included entries are merged.
diff --git a/scripts/Dpkg/Changelog.pm b/scripts/Dpkg/Changelog.pm
index 2065d42..56b86c1 100644
--- a/scripts/Dpkg/Changelog.pm
+++ b/scripts/Dpkg/Changelog.pm
@@ -495,6 +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->{Changes} = $src->get_dpkg_changes();
 
     # handle optional fields
@@ -550,6 +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->{Changes} = $entry->get_dpkg_changes();
 
 	# handle optional fields
@@ -613,6 +615,10 @@ person that created the (selected) entry
 
 date of the (selected) entry
 
+=item Timestamp
+
+date of the (selected) entry as a timestamp in seconds since the epoch
+
 =item Closes
 
 bugs closed by the (selected) entry/entries, sorted by bug number
@@ -766,6 +772,8 @@ New method: $c->format_range().
 
 Deprecated methods: $c->dpkg(), $c->rfc822().
 
+New field Timestamp in output formats.
+
 =head2 Version 1.00 (dpkg 1.15.6)
 
 Mark the module as public.
diff --git a/scripts/Dpkg/Control/FieldsCore.pm b/scripts/Dpkg/Control/FieldsCore.pm
index 85729a0..1f01ae0 100644
--- a/scripts/Dpkg/Control/FieldsCore.pm
+++ b/scripts/Dpkg/Control/FieldsCore.pm
@@ -332,6 +332,9 @@ our %FIELDS = (
         allowed => ALL_SRC,
         separator => FIELD_SEP_COMMA,
     },
+    'Timestamp' => {
+        allowed => CTRL_CHANGELOG,
+    },
     'Triggers-Awaited' => {
         allowed => CTRL_FILE_STATUS,
         separator => FIELD_SEP_SPACE,
@@ -425,7 +428,7 @@ our %FIELD_ORDER = (
     ],
     CTRL_CHANGELOG() => [
         qw(Source Binary-Only Version Distribution Urgency Maintainer
-        Date Closes Changes)
+        Timestamp Date Closes Changes)
     ],
     CTRL_FILE_STATUS() => [ # Same as fieldinfos in lib/dpkg/parse.c
         qw(Package Essential Status Priority Section Installed-Size Origin
diff --git a/scripts/t/Dpkg_Changelog.t b/scripts/t/Dpkg_Changelog.t
index c095692..8c86cd1 100644
--- a/scripts/t/Dpkg_Changelog.t
+++ b/scripts/t/Dpkg_Changelog.t
@@ -172,6 +172,7 @@ Version: 2.0-0etch1
 Distribution: stable
 Urgency: high
 Maintainer: Frank Lichtenheld <frank at lichtenheld.de>
+Timestamp: 1200235759
 Date: Sun, 13 Jan 2008 15:49:19 +0100
 Closes: 1000000 1111111 2222222
 Changes:
@@ -214,6 +215,7 @@ Version: 2.0-1
 Distribution: unstable frozen
 Urgency: medium
 Maintainer: Frank Lichtenheld <djpig at debian.org>
+Timestamp: 1200149359
 Date: Sun, 12 Jan 2008 15:49:19 +0100
 Closes: 1111111 2222222
 Changes:
@@ -246,6 +248,7 @@ Version: 2.0~b1-1
 Distribution: unstable
 Urgency: low
 Maintainer: Frank Lichtenheld <frank at lichtenheld.de>
+Timestamp: 1200062959
 Date: Sun, 11 Jan 2008 15:49:19 +0100
 Changes:
  fields (2.0~b1-1) unstable; urgency=low,xc-userfield=foobar
@@ -258,6 +261,7 @@ Version: 1.0
 Distribution: experimental
 Urgency: high
 Maintainer: Frank Lichtenheld <djpig at debian.org>
+Timestamp: 1199976559
 Date: Sun, 10 Jan 2008 15:49:19 +0100
 Closes: 1000000
 Changes:

-- 
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