On Thu, Jul 11, 10:43, Chris Lamb wrote > 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.
Good catch. I've applied your patch and made some minor edits to improve code readability and to fix the typo in the new comment. Are you OK with the commit below? Thanks Andre --- commit 0a8299dd8da7dba7437550d12bf180d9e10d512b Author: Chris Lamb <la...@debian.org> Date: Fri Jul 12 07:59:50 2019 +0200 lsg.c: Make the output of lopsubgen reproducible. 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. This patch makes lopsubgen honour SOURCE_DATE_EPOCH. [0] https://reproducible-builds.org/ [1] https://reproducible-builds.org/specs/source-date-epoch/ Signed-off-by: Andre Noll <m...@tuebingen.mpg.de> diff --git a/lsg.c b/lsg.c index 54b7816..83a72da 100644 --- a/lsg.c +++ b/lsg.c @@ -610,7 +610,7 @@ static char *get_output_path(const char *suffix, const char *arg, static void gen_man(struct lls_parse_result *lpr, const char *cmdline) { int i; - time_t t; + time_t t = 0; struct tm *tmp; FILE *out; char *outpath = get_output_path("man", @@ -626,12 +626,22 @@ 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); + /* + * If the SOURCE_DATE_EPOCH environment variable + * contains a positive integer in the time_t range, use + * that instead of the current time. See: + * <https://reproducible-builds.org/specs/source-date-epoch/> + * for more information. + */ + char *source_date_epoch = getenv("SOURCE_DATE_EPOCH"); + if (source_date_epoch != NULL) + t = strtoll(source_date_epoch, NULL, 10); + if (t <= 0) + t = time(NULL); + tmp = gmtime(&t); if (tmp == NULL) { - perror("localtime"); + perror("gmtime"); exit(EXIT_FAILURE); } if (strftime(date, sizeof(date), "%B %Y", tmp) == 0) { -- Max Planck Institute for Developmental Biology Max-Planck-Ring 5, 72076 Tübingen, Germany. Phone: (+49) 7071 601 829 http://people.tuebingen.mpg.de/maan/
signature.asc
Description: PGP signature