build-netdata-rpm.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/usr/bin/env bash
  2. # docker run -it --rm centos:6.9 /bin/sh
  3. # yum -y install rpm-build redhat-rpm-config yum-utils autoconf automake curl gcc git libmnl-devel libuuid-devel make pkgconfig zlib-devel
  4. cd "$(dirname "$0")/../../" || exit 1
  5. # shellcheck disable=SC1091
  6. source "packaging/installer/functions.sh" || exit 1
  7. set -e
  8. run autoreconf -ivf
  9. run ./configure --enable-maintainer-mode
  10. run make dist
  11. typeset version="$(grep PACKAGE_VERSION < config.h | cut -d '"' -f 2)"
  12. if [[ -z "${version}" ]]; then
  13. run_failed "Cannot find netdata version."
  14. exit 1
  15. fi
  16. if [[ "${version//-/}" != "$version" ]]; then
  17. # Remove all -* and _* suffixes to be as close as netdata release
  18. typeset versionfix="${version%%-*}"; versionfix="${versionfix%%_*}"
  19. # Append the current datetime fox a 'unique' build
  20. versionfix+="_$(date '+%m%d%H%M%S')"
  21. # And issue hints & details on why this failed, and how to fix it
  22. run_failed "Current version contains '-' which is forbidden by rpm. You must create a git annotated tag and rerun this script. Example:"
  23. run_failed " git tag -a $versionfix -m 'Release by $(id -nu) on $(uname -n)' && $0"
  24. exit 1
  25. fi
  26. typeset tgz="netdata-${version}.tar.gz"
  27. if [[ ! -f "${tgz}" ]]; then
  28. run_failed "Cannot find the generated tar.gz file '${tgz}'"
  29. exit 1
  30. fi
  31. typeset srpm="$(run rpmbuild -ts "${tgz}" | cut -d ' ' -f 2)"
  32. if [[ -z "${srpm}" ]] || ! [[ -f "${srpm}" ]]; then
  33. run_failed "Cannot find the generated SRPM file '${srpm}'"
  34. exit 1
  35. fi
  36. #if which yum-builddep 2>/dev/null
  37. #then
  38. # run yum-builddep "${srpm}"
  39. #elif which dnf 2>/dev/null
  40. #then
  41. # [ "${UID}" = 0 ] && run dnf builddep "${srpm}"
  42. #fi
  43. run rpmbuild --rebuild "${srpm}"
  44. run_ok "All done! Packages created in '$(rpm -E '%_rpmdir/%_arch')'"