[Reproducible-commits] [dpkg] 37/40: Preset build timestamp to latest changelog entry
Jérémy Bobbio
lunar at moszumanska.debian.org
Sat May 30 09:52:52 UTC 2015
This is an automated email from the git hooks/post-receive script.
lunar pushed a commit to branch pu/reproducible_builds
in repository dpkg.
commit 3b8c480943929bbeabcbbc46831c356170a1ca98
Author: Jérémy Bobbio <lunar at debian.org>
Date: Tue Aug 27 23:53:22 2013 +0200
Preset build timestamp to latest changelog entry
dpkg-buildpackage will set the DEB_BUILD_TIMESTAMP environment variable to the
date 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.
DEB_BUILD_TIMESTAMP can also be externaly set before running dpkg-buildpackage.
to reproduce the build with an arbitrary date.
Closes: #759999
---
dpkg-deb/build.c | 20 +++++++++++++++++++-
scripts/dpkg-buildpackage.pl | 5 +++++
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/dpkg-deb/build.c b/dpkg-deb/build.c
index 8d1a2b2..d8e9793 100644
--- a/dpkg-deb/build.c
+++ b/dpkg-deb/build.c
@@ -547,6 +547,24 @@ gen_dest_pathname_from_pkg(const char *dir, struct pkginfo *pkg)
return path;
}
+static time_t
+get_build_timestamp(void)
+{
+ time_t timestamp;
+ const char *value;
+ char *end;
+
+ errno = 0;
+ value = getenv("DEB_BUILD_TIMESTAMP");
+ if (!value)
+ return time(NULL);
+
+ timestamp = strtol(value, &end, 10);
+ if (value == end || *end || errno != 0)
+ ohshite(_("unable to parse timestamp `%.255s'"), value);
+ return timestamp;
+}
+
/**
* Overly complex function that builds a .deb file.
*/
@@ -591,7 +609,7 @@ do_build(const char *const *argv)
}
m_output(stdout, _("<standard output>"));
- build_timestamp = time(NULL);
+ build_timestamp = get_build_timestamp();
/* Now that we have verified everything its time to actually
* build something. Let's start by making the ar-wrapper. */
diff --git a/scripts/dpkg-buildpackage.pl b/scripts/dpkg-buildpackage.pl
index 3b5b9c0..a090c7c 100755
--- a/scripts/dpkg-buildpackage.pl
+++ b/scripts/dpkg-buildpackage.pl
@@ -428,6 +428,11 @@ if ($changedby) {
$maintainer = mustsetvar($changelog->{maintainer}, g_('source changed by'));
}
+if (!$ENV{DEB_BUILD_TIMESTAMP}) {
+ my $timestamp = `date -d'$changelog->{date}' +%s`;
+ chomp $timestamp;
+ $ENV{DEB_BUILD_TIMESTAMP} = $timestamp;
+}
my @arch_opts;
push @arch_opts, ('--host-arch', $host_arch) if $host_arch;
--
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