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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 db4 will be built."
  8. echo "This is probably \`pwd\` if you're at the root of the starwels 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_VERSION='db-4.8.30.NC'
  16. BDB_HASH='12edc0df75bf9abd7f82f821795bcee50f42cb2e5f76a6a281b85732798364ef'
  17. BDB_URL="https://download.oracle.com/berkeley-db/${BDB_VERSION}.tar.gz"
  18. check_exists() {
  19. which "$1" >/dev/null 2>&1
  20. }
  21. sha256_check() {
  22. # Args: <sha256_hash> <filename>
  23. #
  24. if check_exists sha256sum; then
  25. echo "${1} ${2}" | sha256sum -c
  26. elif check_exists sha256; then
  27. if [ "$(uname)" = "FreeBSD" ]; then
  28. sha256 -c "${1}" "${2}"
  29. else
  30. echo "${1} ${2}" | sha256 -c
  31. fi
  32. else
  33. echo "${1} ${2}" | shasum -a 256 -c
  34. fi
  35. }
  36. http_get() {
  37. # Args: <url> <filename> <sha256_hash>
  38. #
  39. # It's acceptable that we don't require SSL here because we manually verify
  40. # content hashes below.
  41. #
  42. if [ -f "${2}" ]; then
  43. echo "File ${2} already exists; not downloading again"
  44. elif check_exists curl; then
  45. curl --insecure "${1}" -o "${2}"
  46. else
  47. wget --no-check-certificate "${1}" -O "${2}"
  48. fi
  49. sha256_check "${3}" "${2}"
  50. }
  51. mkdir -p "${BDB_PREFIX}"
  52. http_get "${BDB_URL}" "${BDB_VERSION}.tar.gz" "${BDB_HASH}"
  53. tar -xzvf ${BDB_VERSION}.tar.gz -C "$BDB_PREFIX"
  54. cd "${BDB_PREFIX}/${BDB_VERSION}/"
  55. # Apply a patch necessary when building with clang and c++11 (see https://community.oracle.com/thread/3952592)
  56. CLANG_CXX11_PATCH_URL='https://gist.githubusercontent.com/LnL7/5153b251fd525fe15de69b67e63a6075/raw/7778e9364679093a32dec2908656738e16b6bdcb/clang.patch'
  57. CLANG_CXX11_PATCH_HASH='7a9a47b03fd5fb93a16ef42235fa9512db9b0829cfc3bdf90edd3ec1f44d637c'
  58. http_get "${CLANG_CXX11_PATCH_URL}" clang.patch "${CLANG_CXX11_PATCH_HASH}"
  59. patch -p2 < clang.patch
  60. cd build_unix/
  61. "${BDB_PREFIX}/${BDB_VERSION}/dist/configure" \
  62. --enable-cxx --disable-shared --disable-replication --with-pic --prefix="${BDB_PREFIX}" \
  63. "${@}"
  64. make install
  65. echo
  66. echo "db4 build complete."
  67. echo
  68. echo 'When compiling starwelsd, run `./configure` in the following way:'
  69. echo
  70. echo " export BDB_PREFIX='${BDB_PREFIX}'"
  71. echo ' ./configure BDB_LIBS="-L${BDB_PREFIX}/lib -ldb_cxx-4.8" BDB_CFLAGS="-I${BDB_PREFIX}/include" ...'