[dpkg] 39/200: dpkg-genbuildinfo: Add Build-Date field

Ximin Luo infinity0 at debian.org
Wed Apr 5 15:17:12 UTC 2017


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

infinity0 pushed a commit to branch master
in repository dpkg.

commit 8ff4522cf0f08659dee954ac2c6256c607b045df
Author: Guillem Jover <guillem at debian.org>
Date:   Mon Nov 14 00:51:06 2016 +0100

    dpkg-genbuildinfo: Add Build-Date field
    
    This records the time the build happened. This might be useful when
    there is a need to track down problems caused by external time-based
    events not visible from inside the build system. Things like hardware,
    software deployment or other such failures.
---
 debian/changelog                   |  1 +
 man/deb-buildinfo.man              |  5 +++++
 scripts/Dpkg/Control/FieldsCore.pm |  5 ++++-
 scripts/dpkg-genbuildinfo.pl       | 14 ++++++++++++--
 4 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index d404747..e45dbcd 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -7,6 +7,7 @@ dpkg (1.18.15) UNRELEASED; urgency=medium
       Proposed by Szabolcs Nagy <nsz at port70.net>. Closes: #843714
   * On source builds add 'source' to the Architecture field in the
     .buildinfo file in dpkg-genbuildinfo.
+  * Add new Build-Date field to .buildinfo files.
   * Perl modules:
     - Validate architecture arguments in Dpkg::Deps deps_parse().
       Prompted by Johannes Schauer <josch at debian.org>.
diff --git a/man/deb-buildinfo.man b/man/deb-buildinfo.man
index 77caa7b..fba3b62 100644
--- a/man/deb-buildinfo.man
+++ b/man/deb-buildinfo.man
@@ -130,6 +130,11 @@ The name of the distribution this package is originating from.
 The Debian architecture for the installation the packages is being built in.
 Common architectures are \fBamd64\fP, \fBarmel\fP, \fBi386\fP, etc.
 .TP
+.BR Build\-Date: " \fIbuild-date\fP"
+The date the package was built.
+It must be in the same format as the date in a \fBdeb\-changelog\fP(5)
+entry.
+.TP
 .BR Build\-Path: " \fIbuild-path\fP"
 The absolute build path, which correspond to the unpacked source tree.
 This field is only going to be present if the vendor has whitelisted it
diff --git a/scripts/Dpkg/Control/FieldsCore.pm b/scripts/Dpkg/Control/FieldsCore.pm
index 4c0ae50..7c7e759 100644
--- a/scripts/Dpkg/Control/FieldsCore.pm
+++ b/scripts/Dpkg/Control/FieldsCore.pm
@@ -115,6 +115,9 @@ our %FIELDS = (
         dependency => 'union',
         dep_order => 6,
     },
+    'Build-Date' => {
+        allowed => CTRL_FILE_BUILDINFO,
+    },
     'Build-Depends' => {
         allowed => ALL_SRC,
         separator => FIELD_SEP_COMMA,
@@ -472,7 +475,7 @@ our %FIELD_ORDER = (
         qw(Format Source Binary Architecture Version
         Binary-Only-Changes),
         @checksum_fields,
-        qw(Build-Origin Build-Architecture Build-Path
+        qw(Build-Origin Build-Architecture Build-Date Build-Path
            Installed-Build-Depends Environment),
     ],
     CTRL_FILE_CHANGES() => [
diff --git a/scripts/dpkg-genbuildinfo.pl b/scripts/dpkg-genbuildinfo.pl
index ea0f4c5..32c7e73 100755
--- a/scripts/dpkg-genbuildinfo.pl
+++ b/scripts/dpkg-genbuildinfo.pl
@@ -27,7 +27,7 @@ use warnings;
 
 use Cwd;
 use File::Basename;
-use POSIX qw(:fcntl_h strftime);
+use POSIX qw(:fcntl_h :locale_h strftime);
 
 use Dpkg ();
 use Dpkg::Gettext;
@@ -69,6 +69,16 @@ my $checksums = Dpkg::Checksums->new();
 my %archadded;
 my @archvalues;
 
+sub get_build_date {
+    my $date;
+
+    setlocale(LC_TIME, 'C');
+    $date = strftime('%a, %d %b %Y %T %z', localtime);
+    setlocale(LC_TIME, '');
+
+    return $date;
+}
+
 # There is almost the same function in dpkg-checkbuilddeps, they probably
 # should be factored out.
 sub parse_status {
@@ -394,8 +404,8 @@ if ($changelog->{'Binary-Only'}) {
 }
 
 $fields->{'Build-Origin'} = get_current_vendor();
-
 $fields->{'Build-Architecture'} = get_build_arch();
+$fields->{'Build-Date'} = get_build_date();
 
 my $cwd = cwd();
 if ($always_include_path) {

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