]> git.ipfire.org Git - thirdparty/pdns.git/blame - build-aux/gen-version
recursor: Allow pdnslog to Lua configuration files
[thirdparty/pdns.git] / build-aux / gen-version
CommitLineData
a4e9add5 1#!/bin/sh
081735df
PD
2
3if [ ! -z "$BUILDER_VERSION" ]; then
4 printf $BUILDER_VERSION
5 echo $BUILDER_VERSION > .version
6 exit 0
7fi
8
a4e9add5
PL
9VERSION="unknown"
10
d529cb25
PL
11DIRTY=""
12git status | grep -q clean || DIRTY='.dirty'
13
14# Special environment variable to signal that we are building a release, as this
43577d15 15# has consequences for the version number.
d529cb25
PL
16if [ "${IS_RELEASE}" = "YES" ]; then
17 TAG="$(git describe --tags --exact-match 2> /dev/null | cut -d- -f 2-)"
18 if [ -n "${TAG}" ]; then
19 # We're on a tag
b7a6009a
PL
20 echo "${TAG}${DIRTY}" > .version
21 printf "${TAG}${DIRTY}"
d529cb25
PL
22 exit 0
23 fi
24 echo 'This is not a tag, either tag this commit or do not set $IS_RELEASE' >&2
25 exit 1
26fi
27
28#
29# Generate the version number based on the branch
30#
a4e9add5
PL
31if [ ! -z "$(git rev-parse --abbrev-ref HEAD 2> /dev/null)" ]; then
32 if $(git rev-parse --abbrev-ref HEAD | grep -q 'rel/'); then
33 REL_TYPE="$(git rev-parse --abbrev-ref HEAD | cut -d/ -f 2 | cut -d- -f 1)"
d7269a2b 34 VERSION="$(git describe --match=${REL_TYPE}-* --tags --dirty=.dirty | cut -d- -f 2-)"
a4e9add5
PL
35 else
36 GIT_VERSION=$(git show --no-patch --format=format:%h HEAD)
d439789d 37 BRANCH=".$(git rev-parse --abbrev-ref HEAD | perl -p -e 's/[^[:alnum:]]//g;')"
a4e9add5 38 [ "${BRANCH}" = ".master" ] && BRANCH=''
a4e9add5
PL
39 VERSION="0.0${BRANCH}.${PDNS_BUILD_NUMBER}g${GIT_VERSION}${DIRTY}"
40 fi
41 echo "$VERSION" > .version
42elif [ -f .version ]; then
43 VERSION="$(cat .version)"
44fi
45
27f25e0d 46printf $VERSION