summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2016-04-02 03:19:17 +0200
committerGuillem Jover <guillem@debian.org>2016-07-03 18:44:22 +0200
commitea22158eb8b0dcaf42b0cdacd5b4560764f353c8 (patch)
treea01bbcf3002e20c7eb0865957e04cc31cdd962ef
parent4e8550c8e2a4f5aab5b803df0ea77c50e089d2dd (diff)
downloaddpkg-ea22158eb8b0dcaf42b0cdacd5b4560764f353c8.tar.gz
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.
-rw-r--r--debian/changelog2
-rw-r--r--man/dpkg-parsechangelog.111
-rw-r--r--scripts/Dpkg/Changelog.pm8
-rw-r--r--scripts/Dpkg/Control/FieldsCore.pm5
-rw-r--r--scripts/t/Dpkg_Changelog.t4
5 files changed, 29 insertions, 1 deletions
diff --git a/debian/changelog b/debian/changelog
index c2d04207a..9c8b4e404 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 85e3be001..80d45f88a 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 2065d429d..56b86c159 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 85729a028..1f01ae0b0 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 c095692d0..8c86cd19d 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@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@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@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@debian.org>
+Timestamp: 1199976559
Date: Sun, 10 Jan 2008 15:49:19 +0100
Closes: 1000000
Changes: