From c3b4b71308d7c1446bca618220d5ab12a2001e25 Mon Sep 17 00:00:00 2001 From: Pieter Lexis Date: Wed, 22 Apr 2015 16:53:46 +0200 Subject: [PATCH] Generate version number based on git Distribute the generated .version file in the tarballs. Gitignore some generated files --- pdns/dnsdistdist/.gitignore | 3 +++ pdns/dnsdistdist/Makefile.am | 3 ++- pdns/dnsdistdist/build-aux/gen-version | 22 ++++++++++++++++++++++ pdns/dnsdistdist/configure.ac | 2 +- 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 pdns/dnsdistdist/.gitignore create mode 100755 pdns/dnsdistdist/build-aux/gen-version diff --git a/pdns/dnsdistdist/.gitignore b/pdns/dnsdistdist/.gitignore new file mode 100644 index 000000000..4a1df650e --- /dev/null +++ b/pdns/dnsdistdist/.gitignore @@ -0,0 +1,3 @@ +*.tar.gz +*.tar.bz2 +.version diff --git a/pdns/dnsdistdist/Makefile.am b/pdns/dnsdistdist/Makefile.am index 93a802db8..d6341f3fa 100644 --- a/pdns/dnsdistdist/Makefile.am +++ b/pdns/dnsdistdist/Makefile.am @@ -16,7 +16,8 @@ EXTRA_DIST=dnslabeltext.rl \ dnsdistconf.lua \ README.md \ html \ - dnsdist.1 + dnsdist.1\ + .version bin_PROGRAMS = dnsdist dnsdist_SOURCES = \ diff --git a/pdns/dnsdistdist/build-aux/gen-version b/pdns/dnsdistdist/build-aux/gen-version new file mode 100755 index 000000000..a2a42a0d4 --- /dev/null +++ b/pdns/dnsdistdist/build-aux/gen-version @@ -0,0 +1,22 @@ +#!/bin/sh +VERSION="unknown" + +if [ ! -z "$(git rev-parse --abbrev-ref HEAD)" ]; then + if [ $(git rev-parse --abbrev-ref HEAD | grep -q 'rel/') ]; then + REL_TYPE="$(git rev-parse --abbrev-ref HEAD | cut -d/ -f 2 | cut -d- -f 1)" + VERSION="$(git describe --match='${REL_TYPE}-*' --dirty=-dirty )" + else + GIT_VERSION=$(git show --no-patch --format=format:%h HEAD) + BRANCH="$(git rev-parse --abbrev-ref HEAD | perl -p -e 's/-//g')" + if [ "${BRANCH}" = "master" ]; then + VERSION="0.0.${PDNS_BUILD_NUMBER}g${GIT_VERSION}" + else + VERSION="0.0.${BRANCH}.${PDNS_BUILD_NUMBER}g${GIT_VERSION}" + fi + fi + echo "$VERSION" > .version +elif [ -f .version ]; then + VERSION="$(cat .version)" +fi + +echo $VERSION diff --git a/pdns/dnsdistdist/configure.ac b/pdns/dnsdistdist/configure.ac index 1fb994808..fbe1953bc 100644 --- a/pdns/dnsdistdist/configure.ac +++ b/pdns/dnsdistdist/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([dnsdist], [0.1]) +AC_INIT([dnsdist], m4_esyscmd_s(build-aux/gen-version)) AM_INIT_AUTOMAKE([foreign dist-bzip2 parallel-tests 1.11 subdir-objects]) AM_SILENT_RULES([yes]) AC_CONFIG_MACRO_DIR([m4]) -- 2.50.0