From 80bd3766dd8f1729187ed9c8e0ad29f67cea0886 Mon Sep 17 00:00:00 2001 From: Bernhard M. Wiedemann Date: Mon, 2 Dec 2019 11:43:18 +0100 Subject: Allow to override build date with SOURCE_DATE_EPOCH in order to make 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. Fixes #11037 --- INSTALL | 4 ++++ configure.ml | 8 +++++++- doc/changelog/11-infrastructure-and-dependencies/11227-date.rst | 5 +++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 doc/changelog/11-infrastructure-and-dependencies/11227-date.rst diff --git a/INSTALL b/INSTALL index d9efd55b95..31758203fe 100644 --- a/INSTALL +++ b/INSTALL @@ -152,6 +152,10 @@ INSTALLATION PROCEDURE IN DETAILS (NORMAL USERS). c.f. https://caml.inria.fr/mantis/view.php?id=7630 + If you want your build to be reproducible, ensure that the + SOURCE_DATE_EPOCH environment variable is set as documented in + https://reproducible-builds.org/specs/source-date-epoch/ + 4- Still in the root directory, do make diff --git a/configure.ml b/configure.ml index 88bc3f912b..89d9ed9d2a 100644 --- a/configure.ml +++ b/configure.ml @@ -194,6 +194,12 @@ let which prog = let program_in_path prog = try let _ = which prog in true with Not_found -> false +let build_date = + try + float_of_string (Sys.getenv "SOURCE_DATE_EPOCH") + with + Not_found -> Unix.time () + (** * Date *) (** The short one is displayed when starting coqtop, @@ -204,7 +210,7 @@ let months = "July";"August";"September";"October";"November";"December" |] let get_date () = - let now = Unix.localtime (Unix.time ()) in + let now = Unix.gmtime build_date in let year = 1900+now.Unix.tm_year in let month = months.(now.Unix.tm_mon) in sprintf "%s %d" month year, diff --git a/doc/changelog/11-infrastructure-and-dependencies/11227-date.rst b/doc/changelog/11-infrastructure-and-dependencies/11227-date.rst new file mode 100644 index 0000000000..5c08e2b0ea --- /dev/null +++ b/doc/changelog/11-infrastructure-and-dependencies/11227-date.rst @@ -0,0 +1,5 @@ +- **Added:** + Build date can now be overriden by setting the `SOURCE_DATE_EPOCH` + environment variable + (`#11227 `_, + by Bernhard M. Wiedemann). -- cgit v1.2.3