From: Boris Ranto Date: Fri, 27 Jul 2018 21:19:07 +0000 (+0200) Subject: Add srpm script X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bd8f1286bc5b7241b1982c91783d31bded4cadb1;p=cephmetrics.git Add srpm script Signed-off-by: Boris Ranto --- diff --git a/build_srpm b/build_srpm new file mode 100755 index 0000000..1c496b0 --- /dev/null +++ b/build_srpm @@ -0,0 +1,52 @@ +#! /usr/bin/bash +set -ex + +## Install any setup-time deps (to make dist package) + +# We need this to get the major version from lsb_release +#sudo yum install -y redhat-lsb-core mock git wget + +# Run the install-deps.sh upstream script if it exists +if [ -x install-deps.sh ]; then + echo "Ensuring dependencies are installed" + sudo ./install-deps.sh +fi + +# Clean dist dir +rm -rf dist/ && mkdir dist +rm -f *.any.src.rpm + +## Get some basic information about the system and the repository +DESCRIBE="$(git describe --tags 2>/dev/null | cut -b 2-)" +test -z "$DESCRIBE" && DESCRIBE="0.1-$(git rev-list --count HEAD)-g$(git rev-parse --short HEAD)" +VERSION="$(echo $DESCRIBE | cut -d - -f 1)" +REVISION="$(echo $DESCRIBE | cut -s -d - -f 2-)" +test -z "$REVISION" && REVISION=0 +RPM_RELEASE=$(echo $REVISION | tr '-' '_') # the '-' has a special meaning + + +## Build the source tarball +echo "Building source distribution" +git archive --format=zip --prefix=cephmetrics-${VERSION}/ HEAD > dist/cephmetrics-${VERSION}.zip +#wget https://grafana.com/api/plugins/vonage-status-panel/versions/1.0.4/download -O dist/vonage-status-panel-1.0.4.zip +#wget https://grafana.com/api/plugins/grafana-piechart-panel/versions/1.1.5/download -O dist/grafana-piechart-panel-1.1.5.zip + + +## Prepare the spec file for build +sed -e "s/@VERSION@/${VERSION}/g" -e "s/@RELEASE@/${RPM_RELEASE}/g" < cephmetrics.spec.in > dist/cephmetrics.spec + + +## Create the source rpm +echo "Building SRPM" +rpmbuild \ + --define "_sourcedir ./dist" \ + --define "_specdir ." \ + --define "_builddir ." \ + --define "_srcrpmdir ." \ + --define "_rpmdir ." \ + --define "dist .any" \ + --define "fedora 21" \ + --define "rhel 7" \ + --nodeps -bs dist/cephmetrics.spec +SRPM=$(readlink -f *.src.rpm) +echo "SRPM='$SRPM'"