Skip to content

Commit 4717a5a

Browse files
committed
Merge bitcoin/bitcoin#26772: contrib: fix sha256 check in install_db4.sh for FreeBSD
22e9afe use sha256 command instead of sha256sum on FreeBSD (Murray Nesbitt) Pull request description: The FreeBSD version of `sha256sum` takes different arguments than the GNU version. The `sha256_check` function in `contrib/install_db4.sh` has code specific to FreeBSD, however it doesn't get reached because while the `sha256sum` command does exist on FreeBSD, it is incompatible and results in an error: ``` sha256sum: option requires an argument -- c usage: sha256sum [-pqrtx] [-c file] [-s string] [files ...] ``` This change moves the FreeBSD-specific code before the check for the `sha256sum` command. Fixes: #26774 Top commit has no ACKs. Tree-SHA512: 2485e2e7d8fdca3b072b29fb22bbdfd69e520740537b331b33c64cc645b63da712cfa63a23bdf039bbc92a6558fc7bf03323a51784bf601ff360ff0ef59506c8
2 parents 5365306 + 22e9afe commit 4717a5a

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

contrib/install_db4.sh

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,15 @@ check_exists() {
3232
sha256_check() {
3333
# Args: <sha256_hash> <filename>
3434
#
35-
if check_exists sha256sum; then
36-
echo "${1} ${2}" | sha256sum -c
35+
if [ "$(uname)" = "FreeBSD" ]; then
36+
# sha256sum exists on FreeBSD, but takes different arguments than the GNU version
37+
sha256 -c "${1}" "${2}"
38+
elif check_exists sha256sum; then
39+
echo "${1} ${2}" | sha256sum -c
3740
elif check_exists sha256; then
38-
if [ "$(uname)" = "FreeBSD" ]; then
39-
sha256 -c "${1}" "${2}"
40-
else
41-
echo "${1} ${2}" | sha256 -c
42-
fi
41+
echo "${1} ${2}" | sha256 -c
4342
else
44-
echo "${1} ${2}" | shasum -a 256 -c
43+
echo "${1} ${2}" | shasum -a 256 -c
4544
fi
4645
}
4746

0 commit comments

Comments
 (0)