Skip to content

contrib: add check for wget command in install_db4.sh - #23658

Merged
laanwj merged 1 commit into
bitcoin:masterfrom
Baumgartl:contrib-patches
Dec 9, 2021
Merged

laanwj merged 1 commit into
bitcoin:masterfrom
Baumgartl:contrib-patches

Conversation

@Baumgartl

Copy link
Copy Markdown
Contributor

This PR is motivated by 7bb8eb0 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.

@shaavan shaavan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK b062da0

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:

Screenshot from 2021-12-03 18-29-46

@jamesob

jamesob commented Dec 3, 2021

Copy link
Copy Markdown
Contributor

ACK b062da0

@laanwj

laanwj commented Dec 9, 2021

Copy link
Copy Markdown
Member

Thanks for your contribution!
Tested ACK b062da0

$ 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
laanwj merged commit aab5e48 into bitcoin:master Dec 9, 2021
RandyMcMillan pushed a commit to RandyMcMillan/mempool-tab that referenced this pull request Dec 23, 2021
…nstall_db4.sh

332d756 contrib: add check for wget command in install_db4.sh (Florian Baumgartl)

Pull request description:

  This PR is motivated by bitcoin/bitcoin@917d12d commit (see also bitcoin/bitcoin#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.

ACKs for top commit:
  jamesob:
    ACK bitcoin/bitcoin@332d756
  laanwj:
    Tested ACK 332d756
  shaavan:
    ACK 332d756

Tree-SHA512: bfc1ccad9a5b99764b759e02dde1976616c2af4747b7d5af8e71d33624c2cb21d93a09a60d244756e86bbd5fd7541331c62d7eb84d3458b6a059f1d9cb2a5f42
@bitcoin bitcoin locked and limited conversation to collaborators Dec 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants