build_package_install_test.sh 997 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-3.0-or-later
  3. set -e
  4. # If we are not in netdata git repo, at the top level directory, FAIL
  5. TOP_LEVEL=$(basename "$(git rev-parse --show-toplevel)")
  6. CWD=$(git rev-parse --show-cdup || echo "")
  7. if [ -n "${CWD}" ] || [ ! "${TOP_LEVEL}" = "netdata" ]; then
  8. echo "Run as ./packaging/$(basename "$0") from top level directory of netdata git repository"
  9. exit 1
  10. fi
  11. if [ $# -lt 2 ] || [ $# -gt 3 ]; then
  12. echo "Usage: ./packaging/$(basename "$0") <distro> <distro_version> [<netdata_version>]"
  13. exit 1
  14. fi
  15. if ! command -v docker > /dev/null; then
  16. echo "Docker CLI not found. You need Docker to run this!"
  17. exit 2
  18. fi
  19. DISTRO="$1"
  20. DISTRO_VERSION="$2"
  21. # TODO: Auto compute this?
  22. VERSION="${3:-1.19.0}"
  23. TAG="netdata/netdata:${DISTRO}_${DISTRO_VERSION}"
  24. docker build \
  25. -f ./packaging/Dockerfile.packager \
  26. --build-arg DISTRO="$DISTRO" \
  27. --build-arg DISTRO_VERSION="$DISTRO_VERSION" \
  28. --build-arg VERSION="$VERSION" \
  29. -t "$TAG" . |
  30. tee build.log