build-rpm.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/sh
  2. set -e
  3. SRC_DIR="$(CDPATH='' cd -- "$(dirname -- "${0}")" && pwd -P)"
  4. BUILD_DIR=/build
  5. echo "::group::Installing Build Dependencies"
  6. if command -v dnf > /dev/null ; then
  7. dnf distro-sync -y --nodocs || exit 1
  8. dnf install -y --nodocs --setopt=install_weak_deps=False rpm-build cmake make || exit 1
  9. elif command -v yum > /dev/null ; then
  10. yum distro-sync -y || exit 1
  11. yum install -y rpm-build make || exit 1
  12. curl --fail -sSL --connect-timeout 20 --retry 3 --output "cmake-linux-$(uname -m).sh" "https://github.com/Kitware/CMake/releases/download/v3.27.6/cmake-3.27.6-linux-$(uname -m).sh" && \
  13. if [ "$(uname -m)" = "x86_64" ]; then \
  14. echo '8c449dabb2b2563ec4e6d5e0fb0ae09e729680efab71527b59015131cea4a042 cmake-linux-x86_64.sh' | sha256sum -c - ; \
  15. elif [ "$(uname -m)" = "aarch64" ]; then \
  16. echo 'a83e01ed1cdf44c2e33e0726513b9a35a8c09e3b5a126fd720b3c8a9d5552368 cmake-linux-aarch64.sh' | sha256sum -c - ; \
  17. else \
  18. echo "ARCH NOT SUPPORTED BY CMAKE" ; \
  19. exit 1 ; \
  20. fi && \
  21. chmod +x "./cmake-linux-$(uname -m).sh" && \
  22. mkdir -p /cmake && \
  23. "./cmake-linux-$(uname -m).sh" --skip-license --prefix=/cmake
  24. PATH="/cmake/bin:${PATH}"
  25. elif command -v zypper > /dev/null ; then
  26. zypper update -y || exit 1
  27. zypper install -y rpm-build cmake make || exit 1
  28. fi
  29. echo "::endgroup::"
  30. echo "::group::Building Packages"
  31. cmake -S "${SRC_DIR}" -B "${BUILD_DIR}"
  32. cmake --build "${BUILD_DIR}"
  33. cd "${BUILD_DIR}"
  34. cpack -G RPM
  35. echo "::endgroup::"
  36. [ -d "${SRC_DIR}/artifacts" ] || mkdir -p "${SRC_DIR}/artifacts"
  37. find "${BUILD_DIR}/packages/" -type f -name '*.rpm' -exec cp '{}' "${SRC_DIR}/artifacts" \; || exit 1
  38. chown -R --reference="${SRC_DIR}" "${SRC_DIR}/artifacts"