Skip to content

Commit 1bed0f7

Browse files
committed
guix: warn SOURCE_DATE_EPOCH set in guix-codesign
Currently there is a warning for this in guix-build, but we also need one in guix-codesign, otherwise the codesigned hashes are not reproducible. Move common functionality into prelude and call the function in both guix actions.
1 parent 75a5c82 commit 1bed0f7

File tree

3 files changed

+27
-13
lines changed

3 files changed

+27
-13
lines changed

contrib/guix/guix-build

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,7 @@ mkdir -p "$VERSION_BASE"
7373
# SOURCE_DATE_EPOCH should not unintentionally be set
7474
################
7575

76-
if [ -n "$SOURCE_DATE_EPOCH" ] && [ -z "$FORCE_SOURCE_DATE_EPOCH" ]; then
77-
cat << EOF
78-
ERR: Environment variable SOURCE_DATE_EPOCH is set which may break reproducibility.
79-
80-
Aborting...
81-
82-
Hint: You may want to:
83-
1. Unset this variable: \`unset SOURCE_DATE_EPOCH\` before rebuilding
84-
2. Set the 'FORCE_SOURCE_DATE_EPOCH' environment variable if you insist on
85-
using your own epoch
86-
EOF
87-
exit 1
88-
fi
76+
check_source_date_epoch
8977

9078
################
9179
# Build directories should not exist

contrib/guix/guix-codesign

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ EOF
6767
exit 1
6868
fi
6969

70+
################
71+
# SOURCE_DATE_EPOCH should not unintentionally be set
72+
################
73+
74+
check_source_date_epoch
75+
7076
################
7177
# The codesignature git worktree should not be dirty
7278
################

contrib/guix/libexec/prelude.bash

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,26 @@ check_tools() {
2121
done
2222
}
2323

24+
################
25+
# SOURCE_DATE_EPOCH should not unintentionally be set
26+
################
27+
28+
check_source_date_epoch() {
29+
if [ -n "$SOURCE_DATE_EPOCH" ] && [ -z "$FORCE_SOURCE_DATE_EPOCH" ]; then
30+
cat << EOF
31+
ERR: Environment variable SOURCE_DATE_EPOCH is set which may break reproducibility.
32+
33+
Aborting...
34+
35+
Hint: You may want to:
36+
1. Unset this variable: \`unset SOURCE_DATE_EPOCH\` before rebuilding
37+
2. Set the 'FORCE_SOURCE_DATE_EPOCH' environment variable if you insist on
38+
using your own epoch
39+
EOF
40+
exit 1
41+
fi
42+
}
43+
2444
check_tools cat env readlink dirname basename git
2545

2646
################

0 commit comments

Comments
 (0)