diff --git a/contrib/guix/guix-build b/contrib/guix/guix-build index 715568c1543..ee285bf322c 100755 --- a/contrib/guix/guix-build +++ b/contrib/guix/guix-build @@ -73,19 +73,7 @@ mkdir -p "$VERSION_BASE" # SOURCE_DATE_EPOCH should not unintentionally be set ################ -if [ -n "$SOURCE_DATE_EPOCH" ] && [ -z "$FORCE_SOURCE_DATE_EPOCH" ]; then -cat << EOF -ERR: Environment variable SOURCE_DATE_EPOCH is set which may break reproducibility. - - Aborting... - -Hint: You may want to: - 1. Unset this variable: \`unset SOURCE_DATE_EPOCH\` before rebuilding - 2. Set the 'FORCE_SOURCE_DATE_EPOCH' environment variable if you insist on - using your own epoch -EOF -exit 1 -fi +check_source_date_epoch ################ # Build directories should not exist diff --git a/contrib/guix/guix-codesign b/contrib/guix/guix-codesign index dedee135b4a..ac7aae3a180 100755 --- a/contrib/guix/guix-codesign +++ b/contrib/guix/guix-codesign @@ -67,6 +67,12 @@ EOF exit 1 fi +################ +# SOURCE_DATE_EPOCH should not unintentionally be set +################ + +check_source_date_epoch + ################ # The codesignature git worktree should not be dirty ################ diff --git a/contrib/guix/libexec/prelude.bash b/contrib/guix/libexec/prelude.bash index f7fc932dfd3..d25c371a10c 100644 --- a/contrib/guix/libexec/prelude.bash +++ b/contrib/guix/libexec/prelude.bash @@ -21,6 +21,26 @@ check_tools() { done } +################ +# SOURCE_DATE_EPOCH should not unintentionally be set +################ + +check_source_date_epoch() { + if [ -n "$SOURCE_DATE_EPOCH" ] && [ -z "$FORCE_SOURCE_DATE_EPOCH" ]; then + cat << EOF +ERR: Environment variable SOURCE_DATE_EPOCH is set which may break reproducibility. + + Aborting... + +Hint: You may want to: + 1. Unset this variable: \`unset SOURCE_DATE_EPOCH\` before rebuilding + 2. Set the 'FORCE_SOURCE_DATE_EPOCH' environment variable if you insist on + using your own epoch +EOF + exit 1 + fi +} + check_tools cat env readlink dirname basename git ################