[Reproducible-commits] [debhelper] 01/01: set env var SOURCE_DATE_EPOCH with last debian/changelog timestamp and TZ=UTC
Eduard Sanou
dhole-guest at moszumanska.debian.org
Thu Jul 2 15:22:00 UTC 2015
This is an automated email from the git hooks/post-receive script.
dhole-guest pushed a commit to branch pu/reproducible_builds
in repository debhelper.
commit 95d1d8f8a8bfba3ab88e2f7f912cb65f36efceef
Author: Dhole <dhole at openmailbox.org>
Date: Thu Jul 2 17:16:13 2015 +0200
set env var SOURCE_DATE_EPOCH with last debian/changelog timestamp and TZ=UTC
---
Debian/Debhelper/Dh_Lib.pm | 34 +++++++++++++++++++++++++++++++++-
debian/changelog | 9 +++++++--
2 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index 68be424..6f39053 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -1146,12 +1146,44 @@ sub cross_command {
}
}
+# Read latest debian/changelog timestamp and export the environment variable
+# SOURCE_DATE_EPOCH with its value, so that any package can read it and replace
+# calls to localtime (or other undeterministic timestamps) with the exported
+# timestamp to get reproducible builds.
+sub set_source_date_epoch {
+ eval "use Dpkg::Changelog::Debian";
+ if ($@) {
+ warning "unable to set SOURCE_DATE_EPOCH: $@";
+ return;
+ }
+ eval "use Time::Piece";
+ if ($@) {
+ warning "unable to set SOURCE_DATE_EPOCH: $@";
+ return;
+ }
+
+ my $changelog = Dpkg::Changelog::Debian->new();
+ $changelog->load("debian/changelog");
+
+ my $tt = @{$changelog}[0]->get_timestamp();
+ $tt =~ s/\s*\([^\)]+\)\s*$//; # Remove the optional timezone codename
+ my $timestamp = Time::Piece->strptime($tt, "%a, %d %b %Y %T %z");
+
+ $ENV{SOURCE_DATE_EPOCH} = $timestamp->epoch();
+}
+
# Sets environment variables from dpkg-buildflags. Avoids changing
# any existing environment variables.
sub set_buildflags {
- return if $ENV{DH_INTERNAL_BUILDFLAGS} || compat(8);
+ return if $ENV{DH_INTERNAL_BUILDFLAGS};
$ENV{DH_INTERNAL_BUILDFLAGS}=1;
+ set_source_date_epoch();
+ # Set env timezone to UTC to help packages build reproducibly
+ $ENV{TZ} = "UTC";
+
+ return if compat(8);
+
eval "use Dpkg::BuildFlags";
if ($@) {
warning "unable to load build flags: $@";
diff --git a/debian/changelog b/debian/changelog
index 3bb7c1d..dc64395 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,4 @@
-debhelper (9.20150628.0~reproducible2) UNRELEASED; urgency=medium
+debhelper (9.20150702.0~reproducible1) UNRELEASED; urgency=medium
[ Jérémy Bobbio ]
* dh_builddeb: fix mtimes for reproducibility. (Closes: #759886)
@@ -12,7 +12,12 @@ debhelper (9.20150628.0~reproducible2) UNRELEASED; urgency=medium
[ Mattia Rizzolo ]
* fix mtimes also for ddebs.
- -- Mattia Rizzolo <mattia at mapreri.org> Sun, 28 Jun 2015 15:40:17 +0000
+ [ Eduard Sanou ]
+ * export the env var SOURCE_DATE_EPOCH with the last debian/changelog
+ timestamp.
+ * set env TZ=UTC
+
+ -- Dhole <dhole at openmailbox.org> Thu, 02 Jul 2015 14:46:00 +0200
debhelper (9.20150628) unstable; urgency=medium
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/debhelper.git
More information about the Reproducible-commits
mailing list