packaging: add a maketarball script
[sahlberg/ctdb.git] / packaging / maketarball.sh
1 #!/bin/sh
2 #
3 # Copyright (C) Michael Adam 2009
4 #
5 # Create CTDB source tarball of the current git branch HEAD.
6 # The version is extracted from the spec file...
7 # The first extra argument will be added as an additional version.
8
9 DIRNAME=$(dirname $0)
10 TOPDIR=${DIRNAME}/..
11 RPMDIR=${DIRNAME}/RPM
12 SPECFILE=${RPMDIR}/ctdb.spec
13
14 EXTRA_SUFFIX="$1"
15
16 VERSION=$(grep ^Version ${SPECFILE} | sed -e 's/^Version:\ \+//')
17
18 if [ "x${EXTRA_SUFFIX}" != "x" ]; then
19         VERSION="${VERSION}-${EXTRA_SUFFIX}"
20 fi
21
22 if echo | gzip -c --rsyncable - > /dev/null 2>&1 ; then
23         GZIP="gzip -9 --rsyncable"
24 else
25         GZIP="gzip -9"
26 fi
27
28 pushd ${TOPDIR}
29 echo -n "Creating ctdb-${VERSION}.tar.gz ... "
30 git archive --prefix=ctdb-${VERSION}/ HEAD | ${GZIP} \
31         > ${TOPDIR}/ctdb-${VERSION}.tar.gz
32 RC=$?
33 popd
34
35 echo "Done."
36
37 if [ $RC -ne 0 ]; then
38         echo "Creation of tarball failed."
39         exit 1
40 fi
41
42 exit 0