build-dist.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/bin/sh
  2. #
  3. # Builds the netdata-vX.y.Z-xxxx.tar.gz source tarball (dist)
  4. set -e
  5. # shellcheck source=.github/scripts/functions.sh
  6. . "$(dirname "$0")/functions.sh"
  7. NAME="${NAME:-netdata}"
  8. VERSION="${VERSION:-"$(git describe --always)"}"
  9. BASENAME="$NAME-$VERSION"
  10. prepare_build() {
  11. progress "Preparing build"
  12. (
  13. test -d artifacts || mkdir -p artifacts
  14. echo "${VERSION}" > packaging/version
  15. ) >&2
  16. }
  17. build_dist() {
  18. progress "Building dist"
  19. (
  20. command -v git > /dev/null && [ -d .git ] && git clean -d -f
  21. autoreconf -ivf
  22. ./configure \
  23. --prefix=/usr \
  24. --sysconfdir=/etc \
  25. --localstatedir=/var \
  26. --libexecdir=/usr/libexec \
  27. --with-zlib \
  28. --with-math \
  29. --with-user=netdata \
  30. --disable-dependency-tracking \
  31. CFLAGS=-O2
  32. make dist
  33. mv "${BASENAME}.tar.gz" artifacts/
  34. ) >&2
  35. }
  36. prepare_assets() {
  37. progress "Preparing assets"
  38. (
  39. cp packaging/version artifacts/latest-version.txt
  40. cd artifacts || exit 1
  41. ln -f "${BASENAME}.tar.gz" netdata-latest.tar.gz
  42. ln -f "${BASENAME}.gz.run" netdata-latest.gz.run
  43. sha256sum -b ./* > "sha256sums.txt"
  44. ) >&2
  45. }
  46. steps="prepare_build build_dist prepare_assets"
  47. _main() {
  48. for step in $steps; do
  49. if ! run "$step"; then
  50. if [ -t 1 ]; then
  51. debug
  52. else
  53. fail "Build failed"
  54. fi
  55. fi
  56. done
  57. echo "🎉 All Done!"
  58. }
  59. if [ -n "$0" ] && [ x"$0" != x"-bash" ]; then
  60. _main "$@"
  61. fi