Procházet zdrojové kódy

dpkg-buildpackage: Preset build timestamp to latest changelog entry

Set the SOURCE_DATE_EPOCH environment variable to Unix timestamp since
the epoch of the latest entry in debian/changelog. This enables build
to be easily reproduced as the dates captured in the «.deb» archives
will be deterministic.

SOURCE_DATE_EPOCH can also be externaly set before running
dpkg-buildpackage to reproduce the build with an arbitrary date.

Closes: #759999
Ref: https://reproducible-builds.org/specs/source-date-epoch/
Base-on-patch-by: Jérémy Bobbio <lunar@debian.org>
Guillem Jover před 10 roky
rodič
revize
5dc74874e6
3 změnil soubory, kde provedl 10 přidání a 0 odebrání
  1. 3 0
      debian/changelog
  2. 5 0
      man/dpkg-buildpackage.1
  3. 2 0
      scripts/dpkg-buildpackage.pl

+ 3 - 0
debian/changelog

@@ -33,6 +33,9 @@ dpkg (1.18.8) UNRELEASED; urgency=medium
     in dpkg-deb.
     in dpkg-deb.
   * Set ar timestamp and tar mtime clamping to SOURCE_DATE_EPOCH if defined
   * Set ar timestamp and tar mtime clamping to SOURCE_DATE_EPOCH if defined
     in dpkg-deb. Base on a patch by Jérémy Bobbio <lunar@debian.org>.
     in dpkg-deb. Base on a patch by Jérémy Bobbio <lunar@debian.org>.
+  * Preset build timestamp to latest changelog entry in dpkg-buildpackage,
+    by setting SOURCE_DATE_EPOCH environment variable if it is not already
+    defined. Based on a patch by Jérémy Bobbio <lunar@debian.org>.
     Closes: #759999
     Closes: #759999
   * Perl modules:
   * Perl modules:
     - Use warnings::warnif() instead of carp() for deprecated warnings.
     - Use warnings::warnif() instead of carp() for deprecated warnings.

+ 5 - 0
man/dpkg-buildpackage.1

@@ -470,6 +470,11 @@ standalone should be supported.
 \fBdpkg\-architecture\fP is called with the \fB\-a\fP and \fB\-t\fP
 \fBdpkg\-architecture\fP is called with the \fB\-a\fP and \fB\-t\fP
 parameters forwarded. Any variable that is output by its \fB\-s\fP
 parameters forwarded. Any variable that is output by its \fB\-s\fP
 option is integrated in the build environment.
 option is integrated in the build environment.
+
+.TP
+.B SOURCE_DATE_EPOCH
+This variable is set to the Unix timestamp since the epoch of the
+latest entry in \fIdebian/changelog\fP, if it is not already defined.
 .
 .
 .SH FILES
 .SH FILES
 .TP
 .TP

+ 2 - 0
scripts/dpkg-buildpackage.pl

@@ -415,6 +415,8 @@ if ($changedby) {
     $maintainer = mustsetvar($changelog->{maintainer}, g_('source changed by'));
     $maintainer = mustsetvar($changelog->{maintainer}, g_('source changed by'));
 }
 }
 
 
+# <https://reproducible-builds.org/specs/source-date-epoch/>
+$ENV{SOURCE_DATE_EPOCH} ||= $changelog->{timestamp};
 
 
 my @arch_opts;
 my @arch_opts;
 push @arch_opts, ('--host-arch', $host_arch) if $host_arch;
 push @arch_opts, ('--host-arch', $host_arch) if $host_arch;