From e08bbef5bf0884496024ae4b35b3f401e6a1f425 Mon Sep 17 00:00:00 2001 From: "Bernhard M. Wiedemann" Date: Wed, 28 Oct 2020 01:06:00 +0000 Subject: [PATCH] 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. Also use UTC to be independent of timezone. This date call is designed to work with all variants of date. Without this patch, builds of https://build.opensuse.org/package/show/science/lal always varied even when nothing changed. This PR was done while working on reproducible builds for openSUSE. --- gnuscripts/lalsuite_build.m4 | 2 +- gnuscripts/lalsuite_vcs_info.am | 2 +- gnuscripts/reproducible-date | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100755 gnuscripts/reproducible-date diff --git a/gnuscripts/lalsuite_build.m4 b/gnuscripts/lalsuite_build.m4 index 6f4f546cc8..b3b1dd1757 100644 --- a/gnuscripts/lalsuite_build.m4 +++ b/gnuscripts/lalsuite_build.m4 @@ -303,7 +303,7 @@ AC_DEFUN([LALSUITE_VERSION_CONFIGURE_INFO],[ version_devel=`echo "$VERSION" | cut -d. -f4-` test -z "$version_micro" && version_micro=0 test -z "$version_devel" && version_devel=0 - configure_date=`date +"%Y-%m-%dT%H:%M:%S%z"` + configure_date=`$(top_srcdir)/gnuscripts/reproducible-date +"%Y-%m-%dT%H:%M:%S%z"` AC_DEFINE_UNQUOTED(uppercase[_VERSION],["$VERSION"],AC_PACKAGE_NAME[ Version]) AC_DEFINE_UNQUOTED(uppercase[_VERSION_MAJOR],[$version_major],AC_PACKAGE_NAME[ Version Major Number]) AC_DEFINE_UNQUOTED(uppercase[_VERSION_MINOR],[$version_minor],AC_PACKAGE_NAME[ Version Minor Number]) diff --git a/gnuscripts/lalsuite_vcs_info.am b/gnuscripts/lalsuite_vcs_info.am index 0bbbf441df..ccb1fb0d90 100644 --- a/gnuscripts/lalsuite_vcs_info.am +++ b/gnuscripts/lalsuite_vcs_info.am @@ -17,4 +17,4 @@ $(build_info_source): Makefile $(build_info_dependencies) $(AM_V_GEN)echo '/* $@: generated by Makefile */' >$@; \ echo '#define $(PACKAGE_NAME_UCASE)_CONFIGURE_ARGS "'"$(ac_configure_args)"'"' >>$@; \ echo '#define $(PACKAGE_NAME_UCASE)_CONFIGURE_DATE "'"$(configure_date)"'"' >>$@; \ - echo '#define $(PACKAGE_NAME_UCASE)_BUILD_DATE "'`date +"%Y-%m-%dT%H:%M:%S%z"`'"' >>$@ + echo '#define $(PACKAGE_NAME_UCASE)_BUILD_DATE "'`$(top_srcdir)/gnuscripts/reproducible-date +"%Y-%m-%dT%H:%M:%S%z"`'"' >>$@ diff --git a/gnuscripts/reproducible-date b/gnuscripts/reproducible-date new file mode 100755 index 0000000000..7ab245c7b3 --- /dev/null +++ b/gnuscripts/reproducible-date @@ -0,0 +1,3 @@ +#!/bin/sh +SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:-$(date +%s)}" +date -u -d "@$SOURCE_DATE_EPOCH" "$@" 2>/dev/null || date -u -r "$SOURCE_DATE_EPOCH" "$@" 2>/dev/null || date -u "$@" -- GitLab