[build] Add a script for installing db4 #11702

pull jamesob wants to merge 2 commits into bitcoin:master from jamesob:install-db4-script changing 5 files +117 −43
  1. jamesob commented at 4:59 AM on November 16, 2017: member

    Instead of maintaining rote instructions for building BerkeleyDB in doc/build-{unix,openbsd}.md, reference a script that does the same thing and can be called from unanticipated contexts, e.g. Docker builds.

    The script was written with portability in mind, though I haven't tested it on openbsd.

    I wasn't sure if we wanted to create a separate directory for this sort of thing (e.g. contrib/install) so I just stuck it in contrib/; happy to move it around if anyone has another preference.

  2. fanquake added the label Scripts and tools on Nov 16, 2017
  3. in contrib/install_db4.sh:31 in 1287963547 outdated
      26 | +
      27 | +tar -xzvf ${BDB_VERSION}.tar.gz -C $BDB_PREFIX
      28 | +
      29 | +rm "${BDB_VERSION}.tar.gz"
      30 | +
      31 | +cd "${BDB_PREFIX}/${BDB_VERSION}/build_unix/"
    


    jonasschnelli commented at 6:19 AM on November 16, 2017:

    seems not to work with relative path

  4. in contrib/install_db4.sh:23 in 1287963547 outdated
      18 | +BDB_HASH='12edc0df75bf9abd7f82f821795bcee50f42cb2e5f76a6a281b85732798364ef'
      19 | +BDB_URL="https://download.oracle.com/berkeley-db/${BDB_VERSION}.tar.gz"
      20 | +
      21 | +mkdir -p $BDB_PREFIX
      22 | +
      23 | +wget --no-check-certificate "${BDB_URL}" -O "${BDB_VERSION}.tar.gz"
    


    jonasschnelli commented at 6:20 AM on November 16, 2017:

    would be great if we could have a curl --insecure fallback if wget is not present. IMO curl should be the default nowadays.

  5. in contrib/install_db4.sh:25 in 1287963547 outdated
      20 | +
      21 | +mkdir -p $BDB_PREFIX
      22 | +
      23 | +wget --no-check-certificate "${BDB_URL}" -O "${BDB_VERSION}.tar.gz"
      24 | +
      25 | +echo "${BDB_HASH}  ${BDB_VERSION}.tar.gz" | sha256sum -c
    


    jonasschnelli commented at 6:21 AM on November 16, 2017:

    sha256sum should have a fallback to shasum -a 256

  6. jonasschnelli commented at 6:23 AM on November 16, 2017: contributor

    Concept ACK. Ideally this would also work on OSX. See points above and maybe – if you can – apply this patch in case of macOS: https://github.com/narkoleptik/os-x-berkeleydb-patch/blob/master/atomic.patch

    If not interested to support this on OSX (can also be done later...), please mention in the new script that this is linux/bsd only.

  7. jamesob force-pushed on Nov 16, 2017
  8. jamesob force-pushed on Nov 16, 2017
  9. jamesob commented at 7:17 AM on November 16, 2017: member

    Thanks for the good feedback, @jonasschnelli. I've incorporated your inline comments and am now testing use on OS X. Will report back when I finish testing.

  10. jamesob force-pushed on Nov 16, 2017
  11. jamesob commented at 7:39 AM on November 16, 2017: member

    I've completed testing on Ubuntu 17.04 and macOS 10.12.1. I've also added reference to the script in doc/build-osx.md.

  12. laanwj commented at 7:57 AM on November 16, 2017: member

    Very nice! Concept ACK. I'll test on OpenBSD.

  13. in contrib/install_db4.sh:45 in 18e3dca599 outdated
      25 | +check_exists() {
      26 | +  which "$1" >/dev/null 2>&1 
      27 | +}
      28 | +
      29 | +http_get() {
      30 | +  if check_exists curl; then
    


    laanwj commented at 8:16 AM on November 16, 2017:

    Might add a comment that this skipping cert check is acceptable because we check the SHA256 hash later, or even roll the sha256_check into the download function so that it is impossible to accidentally skip it.


    jamesob commented at 8:23 AM on November 16, 2017:

    Good idea, will do.

  14. in contrib/install_db4.sh:1 in 18e3dca599 outdated
       0 | @@ -0,0 +1,77 @@
       1 | +#!/bin/sh
    


    laanwj commented at 8:19 AM on November 16, 2017:

    Should be part of the tarball / make dist (DIST_CONTRIB in Makefile.am)


    jamesob commented at 8:36 AM on November 16, 2017:

    Done, thanks!

  15. jamesob force-pushed on Nov 16, 2017
  16. jamesob force-pushed on Nov 16, 2017
  17. in contrib/install_db4.sh:46 in 18e3dca599 outdated
      41 | +    echo "${1}  ${2}" | shasum -a 256 -c
      42 | +  fi
      43 | +}
      44 | +
      45 | +mkdir -p "${BDB_PREFIX}"
      46 | +http_get "${BDB_URL}" "${BDB_VERSION}.tar.gz"
    


    laanwj commented at 8:53 AM on November 16, 2017:

    We shouldn't download the file if it already exists.

  18. laanwj commented at 9:11 AM on November 16, 2017: member

    Small patch for openbsd:

    --- install_db4.sh      Thu Nov 16 10:10:50 2017
    +++ install_db4.sh.new  Thu Nov 16 09:56:10 2017
    @@ -31,6 +31,8 @@
       #
       if check_exists sha256sum; then
         echo "${1}  ${2}" | sha256sum -c
    +  elif check_exists sha256; then
    +    echo "${1}  ${2}" | sha256 -c
       else
         echo "${1}  ${2}" | shasum -a 256 -c
       fi
    

    With this, it works. I'm surprised :)

  19. in contrib/install_db4.sh:57 in d573d7c678 outdated
      52 | +}
      53 | +
      54 | +mkdir -p "${BDB_PREFIX}"
      55 | +http_get "${BDB_URL}" "${BDB_VERSION}.tar.gz" "${BDB_HASH}"
      56 | +tar -xzvf ${BDB_VERSION}.tar.gz -C "$BDB_PREFIX"
      57 | +rm "${BDB_VERSION}.tar.gz"
    


    laanwj commented at 9:14 AM on November 16, 2017:

    I personally wouldn't remove the tar.gz here. I like to keep it around in case I want/need to re-build (e.g. new gcc version).

  20. jamesob commented at 6:30 PM on November 16, 2017: member

    Great, thanks for the patch & testing @laanwj. I'll apply that and incorporate your other feedback as soon as I get a few minutes.

  21. jonasschnelli commented at 7:05 PM on November 16, 2017: contributor

    Nice! Works on macOS.

    Tested ACK (OSX) d573d7c6783b658283c60689524cc3c3e2a407a8.

  22. [build] Add a script for installing db4
    Instead of maintaining not-easily-tested instructions for building BerkeleyDB
    in doc/build-unix.md, package the installation as a script in contrib/. This
    allows shared usage from a number of contexts, e.g. Docker.
    
    Thanks to @jonasschnelli, @laanwj for feedback.
    af9103eb75
  23. [docs] Add reference to install_db4.sh in OS X build instructions 6e4cdd67b1
  24. jamesob force-pushed on Nov 16, 2017
  25. jamesob commented at 7:51 PM on November 16, 2017: member

    Incorporated @laanwj's patch and feedback (wasn't sure how to best do attribution for the patch -- happy to rebase it differently). Tested on Ubuntu 16.04 (with and without existing bdb download).

  26. laanwj commented at 11:04 AM on November 17, 2017: member

    wasn't sure how to best do attribution for the patch

    it's ok - mentioning in the commit message is ok for those two lines, no need to keep it as separate commit :)

    Re-tested ACK https://github.com/bitcoin/bitcoin/pull/11702/commits/6e4cdd67b1f2b3927a525ebba843c27ef3c63e1c

  27. laanwj merged this on Nov 17, 2017
  28. laanwj closed this on Nov 17, 2017

  29. laanwj referenced this in commit 41221126c8 on Nov 17, 2017
  30. laanwj added the label Needs backport on Nov 17, 2017
  31. fanquake removed the label Needs backport on Mar 7, 2018
  32. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-27 21:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me