packaging: Use common code to generate VERSION string
authorAmitay Isaacs <amitay@gmail.com>
Mon, 22 Oct 2012 04:12:50 +0000 (15:12 +1100)
committerAmitay Isaacs <amitay@gmail.com>
Mon, 22 Oct 2012 07:15:17 +0000 (18:15 +1100)
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
packaging/RPM/makerpms.sh
packaging/maketarball.sh

index e2f60512be602e0696f582ca41212fda8ff6ef05..254abde84860ab69c1c2ca5d396c128d72263099 100755 (executable)
@@ -52,32 +52,10 @@ mkdir -p `rpm --eval %_rpmdir`/noarch
 mkdir -p `rpm --eval %_rpmdir`/i386
 mkdir -p `rpm --eval %_rpmdir`/x86_64
 
-# 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.<patchnum>.<checksum>.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
+VERSION=$(${TOPDIR}/packaging/mkversion.sh)
+if [ -z "$VERSION" ]; then
+    exit 1
+fi
 
 sed -e s/@VERSION@/$VERSION/g \
        < ${DIRNAME}/${SPECFILE_IN} \
index 5843bd979615493567e41eaeda72571a2694daa0..677e1e714850e026e25512e6f84c9a228660e0d2 100755 (executable)
@@ -33,15 +33,9 @@ SPECFILE_IN=${SPECFILE}.in
 
 EXTRA_SUFFIX="$1"
 
-# if no githash was specified on the commandline,
-# then use the current head
-if test x"$GITHASH" = "x" ; then
-       GITHASH="$(git log --pretty=format:%h -1)"
-fi
-
-GITHASH_SUFFIX=".${GITHASH}"
-if test "x$USE_GITHASH" = "xno" ; then
-       GITHASH_SUFFIX=""
+VERSION=$(${TOPDIR}/packaging/mkversion.sh)
+if [ -z "$VERSION" ]; then
+    exit 1
 fi
 
 if echo | gzip -c --rsyncable - > /dev/null 2>&1 ; then
@@ -52,7 +46,7 @@ fi
 
 pushd ${TOPDIR}
 echo "Creating tarball ... "
-git archive --prefix=${TAR_PREFIX_TMP}/ ${GITHASH} | ( cd /tmp ; tar xf - )
+git archive --prefix=${TAR_PREFIX_TMP}/ HEAD | ( cd /tmp ; tar xf - )
 RC=$?
 popd
 if [ $RC -ne 0 ]; then
@@ -60,12 +54,10 @@ if [ $RC -ne 0 ]; then
        exit 1
 fi
 
-sed -e s/GITHASH/${GITHASH_SUFFIX}/g \
+sed -e s/@VERSION@/${VERSION}/g \
        < ${SPECFILE_IN} \
        > ${SPECFILE}
 
-VERSION=$(grep ^Version ${SPECFILE} | sed -e 's/^Version:\ \+//')${GITHASH_SUFFIX}
-
 if [ "x${EXTRA_SUFFIX}" != "x" ]; then
        VERSION="${VERSION}-${EXTRA_SUFFIX}"
 fi