You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

install_db4.sh 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/bin/sh
  2. # Install libdb4.8 (Berkeley DB).
  3. set -e
  4. if [ -z "${1}" ]; then
  5. echo "Usage: ./install_db4.sh <base-dir> [<extra-bdb-configure-flag> ...]"
  6. echo
  7. echo "Must specify a single argument: the directory in which db5 will be built."
  8. echo "This is probably \`pwd\` if you're at the root of the bitcoin repository."
  9. exit 1
  10. fi
  11. expand_path() {
  12. echo "$(cd "${1}" && pwd -P)"
  13. }
  14. BDB_PREFIX="$(expand_path ${1})/db4"; shift;
  15. BDB_EXTRA_CONFIGURE_FLAGS="${@}"
  16. BDB_VERSION='db-4.8.30.NC'
  17. BDB_HASH='12edc0df75bf9abd7f82f821795bcee50f42cb2e5f76a6a281b85732798364ef'
  18. BDB_URL="https://download.oracle.com/berkeley-db/${BDB_VERSION}.tar.gz"
  19. check_exists() {
  20. which "$1" >/dev/null 2>&1
  21. }
  22. sha256_check() {
  23. # Args: <sha256_hash> <filename>
  24. #
  25. if check_exists sha256sum; then
  26. echo "${1} ${2}" | sha256sum -c
  27. elif check_exists sha256; then
  28. echo "${1} ${2}" | sha256 -c
  29. else
  30. echo "${1} ${2}" | shasum -a 256 -c
  31. fi
  32. }
  33. http_get() {
  34. # Args: <url> <filename> <sha256_hash>
  35. #
  36. # It's acceptable that we don't require SSL here because we manually verify
  37. # content hashes below.
  38. #
  39. if [ -f "${2}" ]; then
  40. echo "File ${2} already exists; not downloading again"
  41. elif check_exists curl; then
  42. curl --insecure "${1}" -o "${2}"
  43. else
  44. wget --no-check-certificate "${1}" -O "${2}"
  45. fi
  46. sha256_check "${3}" "${2}"
  47. }
  48. mkdir -p "${BDB_PREFIX}"
  49. http_get "${BDB_URL}" "${BDB_VERSION}.tar.gz" "${BDB_HASH}"
  50. tar -xzvf ${BDB_VERSION}.tar.gz -C "$BDB_PREFIX"
  51. cd "${BDB_PREFIX}/${BDB_VERSION}/"
  52. # Apply a patch when building on OS X to make the build work with Xcode.
  53. #
  54. if [ "$(uname)" = "Darwin" ]; then
  55. BDB_OSX_ATOMIC_PATCH_URL='https://raw.githubusercontent.com/narkoleptik/os-x-berkeleydb-patch/0007e2846ae3fc9757849f5277018f4179ad17ef/atomic.patch'
  56. BDB_OSX_ATOMIC_PATCH_HASH='ba0e2b4f53e9cb0ec58f60a979b53b8567b4565f0384886196f1fc1ef111d151'
  57. http_get "${BDB_OSX_ATOMIC_PATCH_URL}" atomic.patch "${BDB_OSX_ATOMIC_PATCH_HASH}"
  58. patch -p1 < atomic.patch
  59. fi
  60. cd build_unix/
  61. "${BDB_PREFIX}/${BDB_VERSION}/dist/configure" \
  62. --enable-cxx --disable-shared --with-pic --prefix="${BDB_PREFIX}" \
  63. "${BDB_EXTRA_CONFIGURE_FLAGS}"
  64. make install
  65. echo
  66. echo "db4 build complete."
  67. echo
  68. echo 'When compiling bitcoind, run `./configure` in the following way:'
  69. echo
  70. echo " export BDB_PREFIX='${BDB_PREFIX}'"
  71. echo ' ./configure LDFLAGS="-L${BDB_PREFIX}/lib/" CPPFLAGS="-I${BDB_PREFIX}/include/" ...'