From 77fd4df1a1a6a87d4c05a355eac11a5296936cec Mon Sep 17 00:00:00 2001 From: "Bernhard M. Wiedemann" Date: Tue, 23 Apr 2024 20:10:07 +0200 Subject: [PATCH 1/2] Drop duplicate initialization in DATE_cmd.sh --- proj_mgmt/DATE_cmd.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/proj_mgmt/DATE_cmd.sh b/proj_mgmt/DATE_cmd.sh index 8aece6141..d72045166 100755 --- a/proj_mgmt/DATE_cmd.sh +++ b/proj_mgmt/DATE_cmd.sh @@ -9,7 +9,6 @@ if [ $osType = "Darwin" ]; then if type -p gdate > /dev/null 2>&1; then my_cmd=gdate else - my_cmd=date arg="${arg%% %:z}" fi fi From 9fe9473bb251a7846699c5a37191902d2c8db4c0 Mon Sep 17 00:00:00 2001 From: "Bernhard M. Wiedemann" Date: Tue, 23 Apr 2024 20:11:03 +0200 Subject: [PATCH 2/2] Allow to override build date with SOURCE_DATE_EPOCH 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. This date call works with different variants of date (GNU, FreeBSD, ...). This patch was done while working on reproducible builds for openSUSE. --- proj_mgmt/DATE_cmd.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/proj_mgmt/DATE_cmd.sh b/proj_mgmt/DATE_cmd.sh index d72045166..47a1d9869 100755 --- a/proj_mgmt/DATE_cmd.sh +++ b/proj_mgmt/DATE_cmd.sh @@ -13,5 +13,8 @@ if [ $osType = "Darwin" ]; then fi fi -$my_cmd "$arg" +SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:-$($my_cmd +%s)}" +$my_cmd -d "@$SOURCE_DATE_EPOCH" "$arg" 2>/dev/null || + $my_cmd -r "$SOURCE_DATE_EPOCH" "$arg" 2>/dev/null || + $my_cmd "$arg"