eventscript: clean up forked handler event code
[metze/ctdb/wip.git] / packaging / maketarball.sh
1 #!/bin/sh
2 #
3 # maketarball.sh - create a tarball from the git branch HEAD
4 #
5 # Copyright (C) Michael Adam 2009
6 #
7 # This program is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by the Free
9 # Software Foundation; either version 3 of the License, or (at your option)
10 # any later version.
11 #
12 # This program is distributed in the hope that it will be useful, but WITHOUT
13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
15 # more details.
16 #
17 # You should have received a copy of the GNU General Public License along with
18 # this program; if not, see <http://www.gnu.org/licenses/>.
19 #
20
21 #
22 # Create CTDB source tarball of the current git branch HEAD.
23 # The version is extracted from the spec file...
24 # The first extra argument will be added as an additional version.
25 #
26
27 DIRNAME=$(dirname $0)
28 TOPDIR=${DIRNAME}/..
29 RPMDIR=${DIRNAME}/RPM
30 SPECFILE=${RPMDIR}/ctdb.spec
31
32 EXTRA_SUFFIX="$1"
33
34 VERSION=$(grep ^Version ${SPECFILE} | sed -e 's/^Version:\ \+//')
35
36 if [ "x${EXTRA_SUFFIX}" != "x" ]; then
37         VERSION="${VERSION}-${EXTRA_SUFFIX}"
38 fi
39
40 if echo | gzip -c --rsyncable - > /dev/null 2>&1 ; then
41         GZIP="gzip -9 --rsyncable"
42 else
43         GZIP="gzip -9"
44 fi
45
46 pushd ${TOPDIR}
47 echo -n "Creating ctdb-${VERSION}.tar.gz ... "
48 git archive --prefix=ctdb-${VERSION}/ HEAD | ${GZIP} \
49         > ${TOPDIR}/ctdb-${VERSION}.tar.gz
50 RC=$?
51 popd
52
53 echo "Done."
54
55 if [ $RC -ne 0 ]; then
56         echo "Creation of tarball failed."
57         exit 1
58 fi
59
60 exit 0