Allow to override the build date
authorBernhard M. Wiedemann <[email protected]>
Wed, 3 May 2017 13:15:15 +0000 (15:15 +0200)
committerDamjan Marion <[email protected]>
Wed, 10 May 2017 22:08:53 +0000 (22:08 +0000)
using the SOURCE_DATE_EPOCH env var
to make vpp package builds reproducible.

See https://reproducible-builds.org/ for why this is good
and https://reproducible-builds.org/specs/source-date-epoch/
for the definition of this variable.

Change-Id: Iae0935c9bb4ccdfdb65600be543945a88f2e137f
Signed-off-by: Bernhard M. Wiedemann <[email protected]>
src/tools/vppapigen/node.c

index 15868ee..1f9905b 100644 (file)
@@ -1114,7 +1114,12 @@ char *fixup_input_filename(void)
 void generate_top_boilerplate(FILE *fp)
 
 {
-    char *datestring = ctime(&starttime);
+    time_t curtime;
+    char *datestring;
+    char *source_date_epoch;
+    if ((source_date_epoch = getenv("SOURCE_DATE_EPOCH")) == NULL || (curtime = (time_t)strtol(source_date_epoch, NULL, 10)) <= 0)
+        curtime = starttime;
+    datestring = asctime(gmtime(&curtime));
     fixed_name = fixup_input_filename();
 
     datestring[24] = 0;