From 7f2b9340899a53739a45ee9b66438e5a0321ca63 Mon Sep 17 00:00:00 2001 From: fanquake Date: Wed, 4 Jan 2023 10:19:57 +0000 Subject: [PATCH] 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 --- contrib/install_db4.sh | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/contrib/install_db4.sh b/contrib/install_db4.sh index 560eaa00ed..0f6f9d8d51 100755 --- a/contrib/install_db4.sh +++ b/contrib/install_db4.sh @@ -32,16 +32,15 @@ check_exists() { sha256_check() { # Args: # - 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 }