Source: man2html Version: 1.6g-7 Severity: wishlist Tags: patch User: reproducible-bui...@lists.alioth.debian.org Usertags: timestamps X-Debbugs-Cc: reproducible-bui...@lists.alioth.debian.org
Hi! While working on the "reproducible builds" effort [1], we have noticed that man2html does not allow to build documentation reproducibly. The Debian reproducible builds team recently proposed a new environment variable $SOURCE_DATE_EPOCH to be used by packages to produce reproducible timestamps [2]. I propose the attached patch which makes man2html use the latest date in debian/changelog as the timestamp for its html output if $SOURCE_DATE_EPOCH is exported. Otherwise man2html will continue with its default behaviour of using the date of today to produce its timestamps. A version of man2html with this patch is currently being used in the reproducible builds git repository and it has been successful at making a package become reproducible. The version of man2html in my patch is the version that we have in the reproducible builds git repository. Kind Regards, akira [1] https://wiki.debian.org/ReproducibleBuilds [2] https://wiki.debian.org/ReproducibleBuilds/TimestampsProposal
commit 4d334e23a95ba7f0804e326ef8094e750cf4ef7b Author: akira <marival...@gmail.com> Date: Sat Aug 15 14:35:00 2015 +0200 Use $SOURCE_DATE_EPOCH to produce reproducible output diff --git a/debian/changelog b/debian/changelog index 5c6a1b3..6b82ce4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +man2html (1.6g-7.0~reproducible1) UNRELEASED; urgency=medium + + * Non-maintainer upload. + * Apply patch Use-SOURCE-DATE-EPOCH to produce reproducible timestamps in + documentation + + -- akira <marival...@gmail.com> Fri, 14 Aug 2015 11:24:55 +0200 + man2html (1.6g-7) unstable; urgency=low * utils.c: Fix querystring2argv() to create argv in case man2html and diff --git a/debian/patches/Use-SOURCE-DATE-EPOCH b/debian/patches/Use-SOURCE-DATE-EPOCH new file mode 100644 index 0000000..b1dc420 --- /dev/null +++ b/debian/patches/Use-SOURCE-DATE-EPOCH @@ -0,0 +1,51 @@ +--- a/man2html/cgibase.c ++++ b/man2html/cgibase.c +@@ -8,6 +8,8 @@ + #include <ctype.h> /* tolower() */ + #include <string.h> /* strlen() */ + #include "defs.h" ++#include <errno.h> ++#include <limits.h> + + /* + * The default is to use cgibase. With relative html style +@@ -83,11 +85,39 @@ void print_sig() + char timebuf[TIMEBUFSZ]; + struct tm *timetm; + time_t now; ++ char *source_date_epoch; ++ unsigned long long epoch; ++ char *endptr; + + timebuf[0] = 0; + #ifdef TIMEFORMAT + sprintf(timebuf, "Time: "); ++ 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); ++ } ++ now=epoch; ++ } ++ else { + now=time(NULL); ++ } + timetm=gmtime(&now); + strftime(timebuf+6, TIMEBUFSZ-6, TIMEFORMAT, timetm); + timebuf[TIMEBUFSZ-1] = 0; diff --git a/debian/patches/series b/debian/patches/series index d262411..dd48540 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -28,3 +28,4 @@ 032-man2html-man-remove-LO-tags.patch 033-gcc-warnings.patch 034-UTF8-charset.patch +Use-SOURCE-DATE-EPOCH
signature.asc
Description: OpenPGP digital signature