1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
Author: Reiner Herrmann <reiner@reiner-h.de>
Description: enable reproducible building
- set LC_ALL to C so the shell sorts files in DATDLB after
wildcard expansion independent of the configured locale
- read timestamp for the build date from environment.
https://reproducible-builds.org/specs/source-date-epoch/
--- a/sys/unix/Makefile.top
+++ b/sys/unix/Makefile.top
@@ -186,7 +186,7 @@
dlb:
( cd util ; $(MAKE) dlb )
- ( cd dat ; ../util/dlb cf nhdat $(DATDLB) )
+ ( cd dat ; LC_ALL=C ; ../util/dlb cf nhdat $(DATDLB) )
# recover can be used when INSURANCE is defined in include/config.h
# and the checkpoint option is true
--- a/util/makedefs.c
+++ b/util/makedefs.c
@@ -1222,7 +1222,7 @@
#else
time_t clocktim = 0;
#endif
- char *c, cbuf[60], buf[BUFSZ];
+ char *c, cbuf[60], buf[BUFSZ], *source_date_epoch;
const char *ul_sfx;
/* before creating date.h, make sure that xxx_GRAPHICS and
@@ -1244,7 +1244,10 @@
Fprintf(ofp, "%s", Dont_Edit_Code);
(void) time(&clocktim);
- Strcpy(cbuf, ctime(&clocktim));
+ source_date_epoch = getenv("SOURCE_DATE_EPOCH");
+ if (source_date_epoch)
+ clocktim = strtoull(source_date_epoch, NULL, 10);
+ Strcpy(cbuf, asctime(gmtime(&clocktim)));
for (c = cbuf; *c; c++)
if (*c == '\n')
@@ -1281,7 +1284,7 @@
Fprintf(ofp, "\n");
#ifdef AMIGA
{
- struct tm *tm = localtime((time_t *) &clocktim);
+ struct tm *tm = gmtime((time_t *) &clocktim);
Fprintf(ofp, "#define AMIGA_VERSION_STRING ");
Fprintf(ofp, "\"\\0$VER: NetHack %d.%d.%d (%d.%d.%d)\"\n",
VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL, tm->tm_mday,
|