#!/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-linux-amd64-prod" elif [[ "$ARCH" == "arm64" ]]; then RPM_ARCH=aarch64 EXENAME_SRC="victoria-metrics-linux-arm64-prod" else echo "*** Unknown arch $ARCH" exit 1 fi PACKDIR="./package" TEMPDIR="${PACKDIR}/temp-rpm-${RPM_ARCH}" EXENAME_DST="victoria-metrics-prod" # 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" <