diff options
author | fanquake <fanquake@gmail.com> | 2023-01-04 10:19:57 +0000 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2023-01-04 10:24:00 +0000 |
commit | 4717a5aa31bc9cdb5406f4161f4c600e5c2659c0 (patch) | |
tree | 3a43e229438e6f765cb7e61bd95d0e4ee1ca2446 /contrib | |
parent | 53653060c1470d1a64295e1add0d0edf1938662f (diff) | |
parent | 22e9afe40d987f4f90bc8469f9475df138fe6261 (diff) |
Merge bitcoin/bitcoin#26772: contrib: fix sha256 check in install_db4.sh for FreeBSD
22e9afe40d987f4f90bc8469f9475df138fe6261 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
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/install_db4.sh | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/contrib/install_db4.sh b/contrib/install_db4.sh index 2850c4b993..c7d39f5b99 100755 --- a/contrib/install_db4.sh +++ b/contrib/install_db4.sh @@ -32,16 +32,15 @@ check_exists() { sha256_check() { # Args: <sha256_hash> <filename> # - if check_exists sha256sum; then - echo "${1} ${2}" | sha256sum -c + if [ "$(uname)" = "FreeBSD" ]; then + # sha256sum exists on FreeBSD, but takes different arguments than the GNU version + sha256 -c "${1}" "${2}" + elif check_exists sha256sum; then + echo "${1} ${2}" | sha256sum -c elif check_exists sha256; then - if [ "$(uname)" = "FreeBSD" ]; then - sha256 -c "${1}" "${2}" - else - echo "${1} ${2}" | sha256 -c - fi + echo "${1} ${2}" | sha256 -c else - echo "${1} ${2}" | shasum -a 256 -c + echo "${1} ${2}" | shasum -a 256 -c fi } |