소스 검색

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.
Guillem Jover 9 년 전
부모
커밋
8ff4522cf0
4개의 변경된 파일22개의 추가작업 그리고 3개의 파일을 삭제
  1. 1 0
      debian/changelog
  2. 5 0
      man/deb-buildinfo.man
  3. 4 1
      scripts/Dpkg/Control/FieldsCore.pm
  4. 12 2
      scripts/dpkg-genbuildinfo.pl

+ 1 - 0
debian/changelog

@@ -7,6 +7,7 @@ dpkg (1.18.15) UNRELEASED; urgency=medium
       Proposed by Szabolcs Nagy <nsz@port70.net>. Closes: #843714
       Proposed by Szabolcs Nagy <nsz@port70.net>. Closes: #843714
   * On source builds add 'source' to the Architecture field in the
   * On source builds add 'source' to the Architecture field in the
     .buildinfo file in dpkg-genbuildinfo.
     .buildinfo file in dpkg-genbuildinfo.
+  * Add new Build-Date field to .buildinfo files.
   * Perl modules:
   * Perl modules:
     - Validate architecture arguments in Dpkg::Deps deps_parse().
     - Validate architecture arguments in Dpkg::Deps deps_parse().
       Prompted by Johannes Schauer <josch@debian.org>.
       Prompted by Johannes Schauer <josch@debian.org>.

+ 5 - 0
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.
 The Debian architecture for the installation the packages is being built in.
 Common architectures are \fBamd64\fP, \fBarmel\fP, \fBi386\fP, etc.
 Common architectures are \fBamd64\fP, \fBarmel\fP, \fBi386\fP, etc.
 .TP
 .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"
 .BR Build\-Path: " \fIbuild-path\fP"
 The absolute build path, which correspond to the unpacked source tree.
 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
 This field is only going to be present if the vendor has whitelisted it

+ 4 - 1
scripts/Dpkg/Control/FieldsCore.pm

@@ -115,6 +115,9 @@ our %FIELDS = (
         dependency => 'union',
         dependency => 'union',
         dep_order => 6,
         dep_order => 6,
     },
     },
+    'Build-Date' => {
+        allowed => CTRL_FILE_BUILDINFO,
+    },
     'Build-Depends' => {
     'Build-Depends' => {
         allowed => ALL_SRC,
         allowed => ALL_SRC,
         separator => FIELD_SEP_COMMA,
         separator => FIELD_SEP_COMMA,
@@ -472,7 +475,7 @@ our %FIELD_ORDER = (
         qw(Format Source Binary Architecture Version
         qw(Format Source Binary Architecture Version
         Binary-Only-Changes),
         Binary-Only-Changes),
         @checksum_fields,
         @checksum_fields,
-        qw(Build-Origin Build-Architecture Build-Path
+        qw(Build-Origin Build-Architecture Build-Date Build-Path
            Installed-Build-Depends Environment),
            Installed-Build-Depends Environment),
     ],
     ],
     CTRL_FILE_CHANGES() => [
     CTRL_FILE_CHANGES() => [

+ 12 - 2
scripts/dpkg-genbuildinfo.pl

@@ -27,7 +27,7 @@ use warnings;
 
 
 use Cwd;
 use Cwd;
 use File::Basename;
 use File::Basename;
-use POSIX qw(:fcntl_h strftime);
+use POSIX qw(:fcntl_h :locale_h strftime);
 
 
 use Dpkg ();
 use Dpkg ();
 use Dpkg::Gettext;
 use Dpkg::Gettext;
@@ -69,6 +69,16 @@ my $checksums = Dpkg::Checksums->new();
 my %archadded;
 my %archadded;
 my @archvalues;
 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
 # There is almost the same function in dpkg-checkbuilddeps, they probably
 # should be factored out.
 # should be factored out.
 sub parse_status {
 sub parse_status {
@@ -394,8 +404,8 @@ if ($changelog->{'Binary-Only'}) {
 }
 }
 
 
 $fields->{'Build-Origin'} = get_current_vendor();
 $fields->{'Build-Origin'} = get_current_vendor();
-
 $fields->{'Build-Architecture'} = get_build_arch();
 $fields->{'Build-Architecture'} = get_build_arch();
+$fields->{'Build-Date'} = get_build_date();
 
 
 my $cwd = cwd();
 my $cwd = cwd();
 if ($always_include_path) {
 if ($always_include_path) {