summaryrefslogtreecommitdiffstats
path: root/build-root/scripts
diff options
context:
space:
mode:
authorThomas F Herbert <therbert@redhat.com>2016-10-13 18:36:50 -0400
committerDamjan Marion <dmarion.lists@gmail.com>2016-11-04 22:22:53 +0000
commit20a29c7b4d1b5b68112498bee21ee7f3fe123b13 (patch)
tree364bb9682084282b94102f6a433111dea3851c24 /build-root/scripts
parentdea606321942132521effe5a3a1bfdaa77d41ebf (diff)
VPP-498: Prepare vpp RPM packaging for use by downstream distros.
Change spec to add new macros to get rid of relative dir reference and use vpp version. Store version string in .version to store metadata in dist archive. New script to create dist archive. Add dist and wipedist targets to Makefile for builds of source RPMs. Change-Id: I7cf0164f0cb094ec70f3dc323ed7fa2ee82bd902 Signed-off-by: Thomas F Herbert <therbert@redhat.com>
Diffstat (limited to 'build-root/scripts')
-rwxr-xr-xbuild-root/scripts/verdist31
-rwxr-xr-xbuild-root/scripts/version45
2 files changed, 67 insertions, 9 deletions
diff --git a/build-root/scripts/verdist b/build-root/scripts/verdist
new file mode 100755
index 00000000000..9d1f1b5adcd
--- /dev/null
+++ b/build-root/scripts/verdist
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+#
+# Add version to dist tarball.
+#
+BR=$1
+prefix=$2
+verstring=$3
+BASE=`pwd`
+
+git rev-parse 2> /dev/null
+if [ $? == 0 ]; then
+ git archive --prefix=${prefix}/ HEAD | gzip -9 > ${verstring}.tar.gz
+else
+ cd ..
+ tar -c ${prefix} | gzip -9 > ${verstring}.tar.gz
+ cp ${verstring}.tar.gz $BASE
+ cd $BASE
+fi
+
+mkdir ${BASE}/tmp
+cd ${BASE}/tmp
+tar -xzf ${BASE}/${verstring}.tar.gz
+rm ${BASE}/${verstring}.tar.gz
+
+cp ${BR}/scripts/.version ${BASE}/tmp/${prefix}/build-root/scripts
+tar -c ${prefix} | gzip -9 > ${verstring}.tar.gz
+mv ${verstring}.tar.gz ${BASE}
+
+cd ${BASE}
+rm -rf tmp
diff --git a/build-root/scripts/version b/build-root/scripts/version
index 84ee5dbe4de..af447286912 100755
--- a/build-root/scripts/version
+++ b/build-root/scripts/version
@@ -1,8 +1,32 @@
#!/bin/bash
-TAG=$(git describe | cut -d- -f1 | sed -e 's/^v//')
-ADD=$(git describe | cut -s -d- -f2)
-CMT=$(git describe --dirty --match 'v*'| cut -s -d- -f3,4)
+path=$( cd "$(dirname "${BASH_SOURCE}")" ; pwd -P )
+
+cd "$path"
+
+git rev-parse 2> /dev/null
+if [ $? == 0 ]; then
+ vstring=$(git describe)
+elif [ -f .version ]; then
+ vstring=$(cat .version)
+else
+ if [ -f ../rpm/*.gz ]; then
+ vstring=$(ls ../rpm/*.gz)
+ else
+ exit 1
+ fi
+fi
+
+TAG=$(echo ${vstring} | cut -d- -f1 | sed -e 's/^v//')
+ADD=$(echo ${vstring} | cut -s -d- -f2)
+
+git rev-parse 2> /dev/null
+if [ $? == 0 ]; then
+ CMT=$(git describe --dirty --match 'v*'| cut -s -d- -f3,4)
+else
+ CMT=$(echo ${vstring} | cut -s -d- -f3,4)
+fi
+CMTR=$(echo $CMT | sed 's/-/_/')
if [ -n "${BUILD_NUMBER}" ]; then
BLD="~b${BUILD_NUMBER}"
@@ -15,13 +39,16 @@ fi
if [ "$1" = "rpm-release" ]; then
[ -z "${ADD}" ] && echo release && exit
- CMT=$(git describe --dirty --match 'v*'| cut -s -d- -f3,4 | sed 's/-/_/')
- echo ${ADD}${CMT:+~${CMT}}${BLD}
+ echo ${ADD}${CMTR:+~${CMTR}}${BLD}
exit
fi
-if [ -n "${ADD}" ]; then
- echo ${TAG}-${ADD}${CMT:+~${CMT}}${BLD}
-else
- echo ${TAG}
+ if [ -n "${ADD}" ]; then
+ if [ "$1" = "rpm-string" ]; then
+ echo ${TAG}-${ADD}${CMTR:+~${CMTR}}${BLD}
+ else
+ echo ${TAG}-${ADD}${CMT:+~${CMT}}${BLD}
+ fi
+ else
+ echo ${TAG}
fi