blob: af4472869123f0c488ce48a9fde8a7506126ca30 [file] [log] [blame]
Ed Warnickecb9cada2015-12-08 15:45:58 -07001#!/bin/bash
2
Thomas F Herbert20a29c72016-10-13 18:36:50 -04003path=$( cd "$(dirname "${BASH_SOURCE}")" ; pwd -P )
4
5cd "$path"
6
7git rev-parse 2> /dev/null
8if [ $? == 0 ]; then
9 vstring=$(git describe)
10elif [ -f .version ]; then
11 vstring=$(cat .version)
12else
13 if [ -f ../rpm/*.gz ]; then
14 vstring=$(ls ../rpm/*.gz)
15 else
16 exit 1
17 fi
18fi
19
20TAG=$(echo ${vstring} | cut -d- -f1 | sed -e 's/^v//')
21ADD=$(echo ${vstring} | cut -s -d- -f2)
22
23git rev-parse 2> /dev/null
24if [ $? == 0 ]; then
25 CMT=$(git describe --dirty --match 'v*'| cut -s -d- -f3,4)
26else
27 CMT=$(echo ${vstring} | cut -s -d- -f3,4)
28fi
29CMTR=$(echo $CMT | sed 's/-/_/')
Ed Warnickecb9cada2015-12-08 15:45:58 -070030
Damjan Marion4e6be682016-05-16 15:55:36 +020031if [ -n "${BUILD_NUMBER}" ]; then
32 BLD="~b${BUILD_NUMBER}"
33fi
34
Ed Warnickecb9cada2015-12-08 15:45:58 -070035if [ "$1" = "rpm-version" ]; then
36 echo ${TAG}
37 exit
38fi
39
40if [ "$1" = "rpm-release" ]; then
41 [ -z "${ADD}" ] && echo release && exit
Thomas F Herbert20a29c72016-10-13 18:36:50 -040042 echo ${ADD}${CMTR:+~${CMTR}}${BLD}
Ed Warnickecb9cada2015-12-08 15:45:58 -070043 exit
44fi
45
Thomas F Herbert20a29c72016-10-13 18:36:50 -040046 if [ -n "${ADD}" ]; then
47 if [ "$1" = "rpm-string" ]; then
48 echo ${TAG}-${ADD}${CMTR:+~${CMTR}}${BLD}
49 else
50 echo ${TAG}-${ADD}${CMT:+~${CMT}}${BLD}
51 fi
52 else
53 echo ${TAG}
Ed Warnickecb9cada2015-12-08 15:45:58 -070054fi