This PR is motivated by https://github.com/bitcoin/bitcoin/commit/7bb8eb0bc352b47ee962283898f9becbb4f36c62 commit (see also #23579) and ensures that install_db4.sh will check for curl and wget utilities. Currently, the conditional statement in the http_get() function assumes that wget is always available but we actually do not know it since there is no check or validation for the wget command. So let's make sure that we check for both commands and print an error message if they are missing.
contrib: add check for wget command in install_db4.sh #23658
pull Baumgartl wants to merge 1 commits into bitcoin:master from Baumgartl:contrib-patches changing 1 files +5 −2-
Baumgartl commented at 9:32 PM on December 2, 2021: contributor
-
contrib: add check for wget command in install_db4.sh b062da0090
- DrahtBot added the label Scripts and tools on Dec 2, 2021
- shaavan approved
-
shaavan commented at 1:03 PM on December 3, 2021: contributor
ACK b062da009001c1beb362169d700663d7220eef5e
It makes sense not to assume by default that wget is preinstalled on an OS. I found that curl and wget are not installed by default on Windows OS.
In that case, running this file would cause a ‘wget not found’ error. Though a person might understand the error and solve it accordingly, it doesn’t hurt to make it more verbose and adequately explain that ‘both curl and wget are not available. Please install one.’
Tested that the change works correctly by using the following patch:
--- a/contrib/install_db4.sh +++ b/contrib/install_db4.sh @@ -53,9 +53,9 @@ http_get() { # if [ -f "${2}" ]; then echo "File ${2} already exists; not downloading again" - elif check_exists curl; then + elif ! check_exists curl; then curl --insecure --retry 5 "${1}" -o "${2}" - elif check_exists wget; then + elif ! check_exists wget; then wget --no-check-certificate "${1}" -O "${2}" else echo "Simple transfer utilities 'curl' and 'wget' not found. Please install one of them and try again."I got the following output with this patch:
Screenshot:

-
jamesob commented at 3:37 PM on December 3, 2021: member
-
laanwj commented at 1:50 PM on December 9, 2021: member
Thanks for your contribution! Tested ACK b062da009001c1beb362169d700663d7220eef5e
$ mkdir /tmp/bin $ ln -s $(which patch mkdir) /tmp/bin $ bash $ export PATH="/tmp/bin" $ contrib/install_db4.sh "$PWD" Simple transfer utilities 'curl' and 'wget' not found. Please install one of them and try again. $ exit - laanwj merged this on Dec 9, 2021
- laanwj closed this on Dec 9, 2021
- sidhujag referenced this in commit e7ec69d106 on Dec 10, 2021
- RandyMcMillan referenced this in commit cd43b23135 on Dec 23, 2021
- DrahtBot locked this on Dec 9, 2022