From: PatR Date: Fri, 1 Apr 2016 00:56:11 +0000 (-0700) Subject: REPRODUCIBLE_BUILD X-Git-Tag: NetHack-3.6.1_RC01~850 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c3ef98c4d1fec23f8a7d58221a787495d96b58b8;p=nethack REPRODUCIBLE_BUILD Take the 4-5 line Debian patch and turn it into six dozen lines of new code. The submitted patch introduces use of several C library routines that aren't presently in use, so would need testing by all functional or nearly-functional ports to verify that it wouldn't break anything. It also switched the formatted build date+time from localtime to UTC. This makes the code conditional so it can be ignored by anybody and avoid the risk of breakage. And a lot of the increase in size is comments attempting to explain what the new conditional is for: when REPRODUCIBLE_BUILD is defined, makedefs will use getenv("SOURCE_DATE_EPOCH") (whose value is an integer representing seconds since 1-Jan-1970) instead of current date+time when generating date.h. The purpose is to be able to rebuild at a later date and produce an identical program, which doesn't happen when compile time gets incorporated into the binary. I've added some sanity checking to try to make sure the getenv() value obtained isn't bogus. And the version string put into date.h will be slightly different, allowing someone who sees date.h or 'v' output to tell whether SOURCE_DATE_EPOCH was involved: showing " NetHack last revision " instead of the usual "... last build ". To test, checkout a new branch for building, make any local edits to unixconf.h and config.h, including enabling REPRODUCIBLE_BUILD, git add+commit them, then use SOURCE_DATE_EPOCH=`git log -1 --pretty=%ct` make install Other ports will need a bit more work to set up the environment, but can still use git to track file dates and supply the latest. Building with alternate configurations could be accomplished by using tags instead of 'log -1' or by using distinct build branches where nothing is commited/merged/rebased after completed build. Unresolved issue: BUILD_DATE, VERSION_ID, and COPYRIGHT_BANNER_C contain formatted date+time but omit timezone. SOURCE_DATE_EPOCH is assumed to be UTC but the formatted values don't say so, so it might appear to be incorrect when compared with local time. We definitely don't want to start mucking about with timezones within nethack, so I think we just live with this. It's not an issue for default configruation where REPRODUCIBLE_BUILD is left disabled. --- diff --git a/include/config.h b/include/config.h index 121ce5407..47b2951cc 100644 --- a/include/config.h +++ b/include/config.h @@ -11,6 +11,7 @@ * For "UNIX" select BSD, ULTRIX, SYSV, or HPUX in unixconf.h. * A "VMS" option is not needed since the VMS C-compilers * provide it (no need to change sec#1, vmsconf.h handles it). + * MacOSX uses the UNIX configruation, not the old MAC one. */ #define UNIX /* delete if no fork(), exec() available */ @@ -304,6 +305,28 @@ */ /* #define DLB */ /* not supported on all platforms */ +/* + * Defining REPRODUCIBLE_BUILD causes 'util/makedefs -v' to construct + * date+time in include/date.h (to be shown by nethack's 'v' command) + * from SOURCE_DATE_EPOCH in the build environment rather than use + * current date+time when makedefs is run. + * + * [The version string will show "last revision