create_artifacts.sh 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/usr/bin/env bash
  2. #
  3. # Artifacts creation script.
  4. # This script generates two things:
  5. # 1) The static binary that can run on all linux distros (built-in dependencies etc)
  6. # 2) The distribution source tarbal
  7. #
  8. # Copyright: SPDX-License-Identifier: GPL-3.0-or-later
  9. #
  10. # Author: Paul Emm. Katsoulakis <paul@netdata.cloud>
  11. #
  12. # shellcheck disable=SC2230
  13. set -e
  14. # If we are not in netdata git repo, at the top level directory, fail
  15. TOP_LEVEL=$(basename "$(git rev-parse --show-toplevel)")
  16. CWD=$(git rev-parse --show-cdup || echo "")
  17. if [ -n "${CWD}" ] || [ ! "${TOP_LEVEL}" == "netdata" ]; then
  18. echo "Run as .travis/$(basename "$0") from top level directory of netdata git repository"
  19. exit 1
  20. fi
  21. if [ ! "${TRAVIS_REPO_SLUG}" == "netdata/netdata" ]; then
  22. echo "Beta mode on ${TRAVIS_REPO_SLUG}, not running anything here"
  23. exit 0
  24. fi;
  25. echo "--- Initialize git configuration ---"
  26. git checkout "${1-master}"
  27. git pull
  28. # Everything from this directory will be uploaded to GCS
  29. mkdir -p artifacts
  30. BASENAME="netdata-$(git describe)"
  31. # Make sure stdout is in blocking mode. If we don't, then conda create will barf during downloads.
  32. # See https://github.com/travis-ci/travis-ci/issues/4704#issuecomment-348435959 for details.
  33. python -c 'import os,sys,fcntl; flags = fcntl.fcntl(sys.stdout, fcntl.F_GETFL); fcntl.fcntl(sys.stdout, fcntl.F_SETFL, flags&~os.O_NONBLOCK);'
  34. echo "--- Create tarball ---"
  35. autoreconf -ivf
  36. ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --with-zlib --with-math --with-user=netdata CFLAGS=-O2
  37. make dist
  38. mv "${BASENAME}.tar.gz" artifacts/
  39. echo "--- Create self-extractor ---"
  40. ./packaging/makeself/build-x86_64-static.sh
  41. # Needed for GCS
  42. echo "--- Copy artifacts to separate directory ---"
  43. #shellcheck disable=SC2164
  44. cp packaging/version artifacts/latest-version.txt
  45. cd artifacts
  46. ln -s "${BASENAME}.tar.gz" netdata-latest.tar.gz
  47. ln -s "${BASENAME}.gz.run" netdata-latest.gz.run
  48. sha256sum -b ./* >"sha256sums.txt"
  49. echo "checksums:"
  50. cat sha256sums.txt