20-openssl.install.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/usr/bin/env bash
  2. # SPDX-License-Identifier: GPL-3.0-or-later
  3. # shellcheck source=packaging/makeself/functions.sh
  4. . "$(dirname "${0}")/../functions.sh" "${@}" || exit 1
  5. # Source of truth for all the packages we bundle in static builds
  6. . "$(dirname "${0}")/../bundled-packages.version"
  7. # shellcheck disable=SC2015
  8. [ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Building OpenSSL" || true
  9. export CFLAGS='-fno-lto -pipe'
  10. export LDFLAGS='-static'
  11. export PKG_CONFIG="pkg-config --static"
  12. if [ -d "${NETDATA_MAKESELF_PATH}/tmp/openssl" ]; then
  13. rm -rf "${NETDATA_MAKESELF_PATH}/tmp/openssl"
  14. fi
  15. if [ -d "${NETDATA_MAKESELF_PATH}/tmp/openssl" ]; then
  16. rm -rf "${NETDATA_MAKESELF_PATH}/tmp/openssl"
  17. fi
  18. cache="${NETDATA_SOURCE_PATH}/artifacts/cache/${BUILDARCH}/openssl"
  19. if [ -d "${cache}" ]; then
  20. echo "Found cached copy of build directory for openssl, using it."
  21. cp -a "${cache}/openssl" "${NETDATA_MAKESELF_PATH}/tmp/"
  22. CACHE_HIT=1
  23. else
  24. echo "No cached copy of build directory for openssl found, fetching sources instead."
  25. run git clone --branch "${OPENSSL_VERSION}" --single-branch --depth 1 "${OPENSSL_SOURCE}" "${NETDATA_MAKESELF_PATH}/tmp/openssl"
  26. CACHE_HIT=0
  27. fi
  28. cd "${NETDATA_MAKESELF_PATH}/tmp/openssl" || exit 1
  29. if [ "${CACHE_HIT:-0}" -eq 0 ]; then
  30. sed -i "s/disable('static', 'pic', 'threads');/disable('static', 'pic');/" Configure
  31. run ./config -static threads no-tests --prefix=/openssl-static --openssldir=/opt/netdata/etc/ssl
  32. run make -j "$(nproc)"
  33. fi
  34. run make -j "$(nproc)" install_sw
  35. if [ -d "/openssl-static/lib" ]; then
  36. cd "/openssl-static" || exit 1
  37. ln -s "lib" "lib64" || true
  38. cd - || exit 1
  39. fi
  40. store_cache openssl "${NETDATA_MAKESELF_PATH}/tmp/openssl"
  41. perl configdata.pm --dump
  42. # shellcheck disable=SC2015
  43. [ "${GITHUB_ACTIONS}" = "true" ] && echo "::endgroup::" || true