Source: liblopsub
Version: 1.0.2-1
Severity: wishlist
Tags: patch
User: reproducible-bui...@lists.alioth.debian.org
Usertags: toolchain timestamps
X-Debbugs-Cc: reproducible-b...@lists.alioth.debian.org

Hi,

Whilst working on the Reproducible Builds effort [0], we noticed
that liblopsub generates output that is not reproducible. The
lopsubgen utility does not respect SOURCE_DATE_EPOCH [1] and thus
packages such as src:tfortune are rendered unreproducible as they
then encode the build date and time.

Patch attached.

  [0] https://reproducible-builds.org/
  [1] https://reproducible-builds.org/specs/source-date-epoch/


Regards,

-- 
      ,''`.
     : :'  :     Chris Lamb
     `. `'`      la...@debian.org / chris-lamb.co.uk
       `-
diff --git a/lsg.c b/lsg.c
index 54b7816..bbad187 100644
--- a/lsg.c
+++ b/lsg.c
@@ -626,12 +626,19 @@ static void gen_man(struct lls_parse_result *lpr, const 
char *cmdline)
        if (suite.commands[0].name.orig) {
                char date[200];
                const char *version_string;
-
                if (!suite.date) {
-                       t = time(NULL);
-                       tmp = localtime(&t);
+                       /* Assume that the SOURCE_DATE_EPOCH environment
+                        * variable will contan a correct, positive integer in
+                        * the time_t range. See:
+                        * 
<https://reproducible-builds.org/specs/source-date-epoch/>
+                        * for more information */
+                       char *source_date_epoch;
+                       if ((source_date_epoch = getenv("SOURCE_DATE_EPOCH")) 
== NULL ||
+                               (t = (time_t)strtoll(source_date_epoch, NULL, 
10)) <= 0)
+                                       time(&t);
+                       tmp = gmtime(&t);
                        if (tmp == NULL) {
-                               perror("localtime");
+                               perror("gmtime");
                                exit(EXIT_FAILURE);
                        }
                        if (strftime(date, sizeof(date), "%B %Y", tmp) == 0) {

Reply via email to