From 145b09c9a8e32dcaad2888972efe1b5960b34689 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 2 Jul 2010 13:21:08 +1000 Subject: [PATCH] version: generate RPM version from git This unifies our RPM version handling, based on tags. 1) Tags are of form ctdb-. 2) The first starts with .1. 3) Devel versions end with .0...devel to reliably identify them. This means that devel versions will correctly supersede releases and earlier devels, but new releases will correctly supersede older devel RPMs. Making a new release is as simple as creating a new git tag. Signed-off-by: Rusty Russell (This used to be ctdb commit 44009e02a661d4a1e14246f650974fc4ed7a07c9) --- ctdb/packaging/RPM/ctdb.spec.in | 4 ++-- ctdb/packaging/RPM/makerpms.sh | 34 ++++++++++++++++++++++++++------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/ctdb/packaging/RPM/ctdb.spec.in b/ctdb/packaging/RPM/ctdb.spec.in index 6706672cc0a..833dae80954 100644 --- a/ctdb/packaging/RPM/ctdb.spec.in +++ b/ctdb/packaging/RPM/ctdb.spec.in @@ -3,8 +3,8 @@ Name: ctdb Summary: Clustered TDB Vendor: Samba Team Packager: Samba Team -Version: 1.9 -Release: 1GITHASH +Version: @VERSION@ +Release: 1 Epoch: 0 License: GNU GPL version 3 Group: System Environment/Daemons diff --git a/ctdb/packaging/RPM/makerpms.sh b/ctdb/packaging/RPM/makerpms.sh index a51099c543e..266fcfb4cae 100755 --- a/ctdb/packaging/RPM/makerpms.sh +++ b/ctdb/packaging/RPM/makerpms.sh @@ -44,18 +44,38 @@ SPECFILE="ctdb.spec" SPECFILE_IN="ctdb.spec.in" RPMBUILD="rpmbuild" -GITHASH=".$(git log --pretty=format:%h -1)" +# We use tags and determine the version, as follows: +# ctdb-0.9.1 (First release of 0.9). +# ctdb-0.9.23 (23rd minor release of the 112 version) +# +# If we're not directly on a tag, this is a devel release; we append +# .0...devel to the release. +TAG=`git describe` +case "$TAG" in + ctdb-*) + TAG=${TAG##ctdb-} + case "$TAG" in + *-*-g*) # 0.9-168-ge6cf0e8 + # Not exactly on tag: devel version. + VERSION=`echo "$TAG" | sed 's/\([^-]\+\)-\([0-9]\+\)-\(g[0-9a-f]\+\)/\1.0.\2.\3.devel/'` + ;; + *) + # An actual release version + VERSION=$TAG + ;; + esac + ;; + *) + echo Invalid tag "$TAG" >&2 + exit 1 + ;; +esac -if test "x$USE_GITHASH" = "xno" ; then - GITHASH="" -fi - -sed -e s/GITHASH/${GITHASH}/g \ +sed -e s/@VERSION@/$VERSION/g \ < ${DIRNAME}/${SPECFILE_IN} \ > ${DIRNAME}/${SPECFILE} VERSION=$(grep ^Version ${DIRNAME}/${SPECFILE} | sed -e 's/^Version:\ \+//') -RELEASE=$(grep ^Release ${DIRNAME}/${SPECFILE} | sed -e 's/^Release:\ \+//') if echo | gzip -c --rsyncable - > /dev/null 2>&1 ; then GZIP="gzip -9 --rsyncable"