build-deb.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/sh
  2. # Needed because dpkg is stupid and tries to configure things interactively if it sees a terminal.
  3. export DEBIAN_FRONTEND=noninteractive
  4. # Pull in our dependencies
  5. apt update || exit 1
  6. apt upgrade -y || exit 1
  7. apt install -y build-essential debhelper curl gnupg || exit 1
  8. # Run the builds in an isolated source directory.
  9. # This removes the need for cleanup, and ensures anything the build does
  10. # doesn't muck with the user's sources.
  11. cp -a /netdata/packaging/repoconfig /usr/src || exit 1
  12. cd /usr/src/repoconfig || exit 1
  13. # pre/post options are after 1.18.8, is simpler to just check help for their existence than parsing version
  14. if dpkg-buildpackage --help | grep "\-\-post\-clean" 2> /dev/null > /dev/null; then
  15. dpkg-buildpackage --post-clean --pre-clean -b -us -uc || exit 1
  16. else
  17. dpkg-buildpackage -b -us -uc || exit 1
  18. fi
  19. # Copy the built packages to /netdata/artifacts (which may be bind-mounted)
  20. # Also ensure /netdata/artifacts exists and create it if it doesn't
  21. [ -d /netdata/artifacts ] || mkdir -p /netdata/artifacts
  22. cp -a /usr/src/*.deb /netdata/artifacts/ || exit 1
  23. # Correct ownership of the artifacts.
  24. # Without this, the artifacts directory and it's contents end up owned
  25. # by root instead of the local user on Linux boxes
  26. chown -R --reference=/netdata /netdata/artifacts