packaging: rework maketarball.sh to accept an arbitrary githas to pack
authorMichael Adam <obnox@samba.org>
Tue, 1 Dec 2009 22:51:51 +0000 (23:51 +0100)
committerMichael Adam <obnox@samba.org>
Fri, 4 Dec 2009 10:30:20 +0000 (11:30 +0100)
The githash can be specified through the environment variable "GITHASH"
that can contain a commit hash or a tag name, e.g.

The call syntax is now

[GITHASH=xyz] [USE_GITHASH=yes/no] [DEBIAN_MODE=yes/no] maketarball.sh

Michael

packaging/maketarball.sh

index 1ba353d149b6c9c12d12d75d40bc453ae836f573..ca124a057cd672218aa04a40e16500141f321dc0 100755 (executable)
 
 DIRNAME=$(dirname $0)
 TOPDIR=${DIRNAME}/..
-RPMDIR=${DIRNAME}/RPM
-SPECFILE=${RPMDIR}/ctdb.spec
+
+TAR_PREFIX_TMP="ctdb-tmp"
+SPECFILE=/tmp/${TAR_PREFIX_TMP}/packaging/RPM/ctdb.spec
 SPECFILE_IN=${SPECFILE}.in
 
 EXTRA_SUFFIX="$1"
 
-GITHASH=".$(git log --pretty=format:%h -1)"
-
-if test "x$USE_GITHASH" = "xno" ; then
-       GITHASH=""
+# 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
 
-sed -e s/GITHASH/${GITHASH}/g \
-       < ${SPECFILE_IN} \
-       > ${SPECFILE}
-
-VERSION=$(grep ^Version ${SPECFILE} | sed -e 's/^Version:\ \+//')${GITHASH}
-
-if [ "x${EXTRA_SUFFIX}" != "x" ]; then
-       VERSION="${VERSION}-${EXTRA_SUFFIX}"
+GITHASH_SUFFIX=".${GITHASH}"
+if test "x$USE_GITHASH" = "xno" ; then
+       GITHASH_SUFFIX=""
 fi
 
 if echo | gzip -c --rsyncable - > /dev/null 2>&1 ; then
@@ -54,20 +50,9 @@ else
        GZIP="gzip -9"
 fi
 
-TAR_PREFIX="ctdb-${VERSION}"
-TAR_BASE="ctdb-${VERSION}"
-
-if test "x${DEBIAN_MODE}" = "xyes" ; then
-       TAR_PREFIX="ctdb-${VERSION}.orig"
-       TAR_BASE="ctdb_${VERSION}.orig"
-fi
-
-TAR_BALL=${TAR_BASE}.tar
-TAR_GZ_BALL=${TAR_BALL}.gz
-
 pushd ${TOPDIR}
-echo "Creating ${TAR_BASE}.tar.gz ... "
-git archive --prefix=${TAR_PREFIX}/ HEAD | ( cd /tmp ; tar xf - )
+echo "Creating tarball ... "
+git archive --prefix=${TAR_PREFIX_TMP}/ ${GITHASH} | ( cd /tmp ; tar xf - )
 RC=$?
 popd
 if [ $RC -ne 0 ]; then
@@ -75,7 +60,20 @@ if [ $RC -ne 0 ]; then
        exit 1
 fi
 
-pushd /tmp/${TAR_PREFIX}
+sed -e s/GITHASH/${GITHASH_SUFFIX}/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
+
+TAR_PREFIX="ctdb-${VERSION}"
+TAR_BASE="ctdb-${VERSION}"
+
+pushd /tmp/${TAR_PREFIX_TMP}
 ./autogen.sh
 RC=$?
 popd
@@ -84,6 +82,16 @@ if [ $RC -ne 0 ]; then
        exit 1
 fi
 
+if test "x${DEBIAN_MODE}" = "xyes" ; then
+       TAR_PREFIX="ctdb-${VERSION}.orig"
+       TAR_BASE="ctdb_${VERSION}.orig"
+fi
+
+TAR_BALL=${TAR_BASE}.tar
+TAR_GZ_BALL=${TAR_BALL}.gz
+
+mv /tmp/${TAR_PREFIX_TMP} /tmp/${TAR_PREFIX}
+
 pushd /tmp
 tar cf ${TAR_BALL} ${TAR_PREFIX}
 RC=$?