[Reproducible-commits] [dpkg] 03/07: dpkg-deb: Allow to set the build timestamp using SOURCE_DATE_EPOCH

Jérémy Bobbio lunar at moszumanska.debian.org
Fri Mar 4 17:44:47 UTC 2016


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 bcf7d8d0472bc6168fc411f2d7a7b37babd837e4
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Thu Oct 8 15:02:12 2015 +0000

    dpkg-deb: Allow to set the build timestamp using SOURCE_DATE_EPOCH
    
    In order to allow Debian packages to be built reproducibly, we need a way for
    users to reproduce the dates captured in the .deb archives.
    
    dpkg-deb now support the SOURCE_DATE_EPOCH environment variable. If set we will
    use its value for the build timestamp instead of the current time. The build
    timestamp is used to set the modification time in ar headers, and for archived
    files created later than the build timestamp.
    
    SOURCE_DATE_EPOCH specification is available at:
    https://reproducible-builds.org/specs/source-date-epoch/
---
 dpkg-deb/build.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/dpkg-deb/build.c b/dpkg-deb/build.c
index 381e70b..83be2cb 100644
--- a/dpkg-deb/build.c
+++ b/dpkg-deb/build.c
@@ -419,6 +419,24 @@ gen_dest_pathname_from_pkg(const char *dir, struct pkginfo *pkg)
                  arch_sep, pkg->available.arch->name, DEBEXT);
 }
 
+static time_t
+get_build_timestamp(void)
+{
+  time_t timestamp;
+  const char *value;
+  char *end;
+
+  errno = 0;
+  value = getenv("SOURCE_DATE_EPOCH");
+  if (!value)
+    return time(NULL);
+
+  timestamp = strtol(value, &end, 10);
+  if (value == end || *end || errno != 0)
+    ohshite(_("unable to parse SOURCE_DATE_EPOCH"));
+  return timestamp;
+}
+
 typedef void filenames_feed_func(const char *dir, int fd_out);
 
 /**
@@ -564,7 +582,7 @@ do_build(const char *const *argv)
 
   tar_supports_clamp_mtime = does_tar_support("--clamp-mtime");
 
-  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. */

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