Source: kronosnet Version: 1.1-1 Severity: wishlist Tags: patch User: [email protected] Usertags: timestamps X-Debbugs-Cc: [email protected]
Hi, Whilst working on the Reproducible Builds effort [0], we noticed that kronosnet could not be built reproducibly due to timestamps in the documentation. Patch attached. [0] https://reproducible-builds.org/ Regards, -- ,''`. : :' : Chris Lamb `. `'` [email protected] / chris-lamb.co.uk `-
--- a/debian/patches/reproducible-build.patch 1970-01-01 01:00:00.000000000 +0100 --- b/debian/patches/reproducible-build.patch 2018-03-04 08:56:43.287328923 +0000 @@ -0,0 +1,56 @@ +Description: Make the build reproducible +Author: Chris Lamb <[email protected]> +Last-Update: 2018-03-04 + +--- kronosnet-1.1.orig/man/doxyxml.c ++++ kronosnet-1.1/man/doxyxml.c +@@ -432,6 +432,8 @@ static void print_manpage(char *name, ch + { + char manfilename[PATH_MAX]; + char gendate[64]; ++ char *endptr; ++ char *source_date_epoch; + FILE *manfile; + time_t t; + struct tm *tm; +@@ -443,12 +445,38 @@ static void print_manpage(char *name, ch + unsigned int max_param_type_len; + unsigned int max_param_name_len; + unsigned int num_param_descs; ++ unsigned long long epoch; + int param_count = 0; + int param_num = 0; + struct param_info *pi; + +- t = time(NULL); +- tm = localtime(&t); ++ source_date_epoch = getenv("SOURCE_DATE_EPOCH"); ++ if (source_date_epoch) { ++ errno = 0; ++ epoch = strtoull(source_date_epoch, &endptr, 10); ++ if ((errno == ERANGE && (epoch == ULLONG_MAX || epoch == 0)) ++ || (errno != 0 && epoch == 0)) { ++ fprintf(stderr, "Environment variable $SOURCE_DATE_EPOCH: strtoull: %s\n", strerror(errno)); ++ exit(EXIT_FAILURE); ++ } ++ if (endptr == source_date_epoch) { ++ fprintf(stderr, "Environment variable $SOURCE_DATE_EPOCH: No digits were found: %s\n", endptr); ++ exit(EXIT_FAILURE); ++ } ++ if (*endptr != '\0') { ++ fprintf(stderr, "Environment variable $SOURCE_DATE_EPOCH: Trailing garbage: %s\n", endptr); ++ exit(EXIT_FAILURE); ++ } ++ if (epoch > ULONG_MAX) { ++ fprintf(stderr, "Environment variable $SOURCE_DATE_EPOCH: value must be smaller than or equal to %lu but was found to be: %llu \n", ULONG_MAX, epoch); ++ exit(EXIT_FAILURE); ++ } ++ t = epoch; ++ } else { ++ t = time(NULL); ++ } ++ tm = gmtime(&t); ++ + if (!tm) { + perror("unable to get localtime"); + exit(1); --- a/debian/patches/series 1970-01-01 01:00:00.000000000 +0100 --- b/debian/patches/series 2018-03-04 08:56:42.467312550 +0000 @@ -0,0 +1 @@ +reproducible-build.patch

