diff --git a/.gitignore b/.gitignore index 9879e811b..24ef443a9 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,6 @@ /vmstorage-data /vmselect-cache /package/temp-deb-* +/package/temp-rpm-* /package/*.deb +/package/*.rpm diff --git a/app/victoria-metrics/Makefile b/app/victoria-metrics/Makefile index 9cfcb1e65..cf763dee1 100644 --- a/app/victoria-metrics/Makefile +++ b/app/victoria-metrics/Makefile @@ -38,17 +38,35 @@ victoria-metrics-pure: victoria-metrics-pure-prod: APP_NAME=victoria-metrics APP_SUFFIX='-pure' DOCKER_OPTS='--env CGO_ENABLED=0' $(MAKE) app-via-docker -### Packaging for Debian - amd64 +### Packaging as DEB - amd64 victoria-metrics-package-deb: victoria-metrics - echo "GO_BUILDINFO:" "$(GO_BUILDINFO)" - echo "PWD:" "$(PWD)" ./package/package_deb.sh amd64 -### Packaging for Debian - arm64 +### Packaging as DEB - arm64 victoria-metrics-package-deb-arm64: victoria-metrics-arm64 ./package/package_deb.sh arm64 +### Packaging as DEB - all victoria-metrics-package-deb-all: \ victoria-metrics-package-deb \ victoria-metrics-package-deb-arm64 +### Packaging as RPM - amd64 +victoria-metrics-package-rpm: victoria-metrics + ./package/package_rpm.sh amd64 + +### Packaging as RPM - arm64 +victoria-metrics-package-rpm-arm64: victoria-metrics-arm64 + ./package/package_rpm.sh arm64 + +### Packaging as RPM - all +victoria-metrics-package-rpm-all: \ + victoria-metrics-package-rpm \ + victoria-metrics-package-rpm-arm64 + +### Packaging as both DEB and RPM - all +victoria-metrics-package-deb-rpm-all: \ + victoria-metrics-package-deb \ + victoria-metrics-package-deb-arm64 \ + victoria-metrics-package-rpm \ + victoria-metrics-package-rpm-arm64 diff --git a/package/package_rpm.sh b/package/package_rpm.sh new file mode 100755 index 000000000..89e21536f --- /dev/null +++ b/package/package_rpm.sh @@ -0,0 +1,90 @@ +#!/bin/bash + +if ! which rpmbuild 2> /dev/null +then + echo "*** Fatal: please install rpmbuild" + exit 1 +fi + +ARCH="amd64" +if [[ $# -ge 1 ]] +then + ARCH="$1" +fi + +# Map to Debian architecture +if [[ "$ARCH" == "amd64" ]]; then + RPM_ARCH=x86_64 + EXENAME_SRC="victoria-metrics" +elif [[ "$ARCH" == "arm64" ]]; then + RPM_ARCH=aarch64 + EXENAME_SRC="victoria-metrics-arm64" +else + echo "*** Unknown arch $ARCH" + exit 1 +fi + +PACKDIR="./package" +TEMPDIR="${PACKDIR}/temp-rpm-${RPM_ARCH}" +EXENAME_DST="victoria-metrics" + +# Pull in version info + +VERSION=`cat ${PACKDIR}/VAR_VERSION | perl -ne 'chomp and print'` +BUILD=`cat ${PACKDIR}/VAR_BUILD | perl -ne 'chomp and print'` + +# Create directories + +[[ -d "${TEMPDIR}" ]] && rm -rf "${TEMPDIR}" + +mkdir -p "${TEMPDIR}" && echo "*** Created : ${TEMPDIR}" + +echo "*** Version : ${VERSION}-${BUILD}" +echo "*** Arch : ${RPM_ARCH}" + +OUT_RPM="victoria-metrics-${VERSION}-${BUILD}.${RPM_ARCH}.rpm" + +echo "*** Out .rpm : ${OUT_RPM}" + +cat > "${TEMPDIR}/victoria-metrics.spec" <