Revert "Dont allow client processes to attach to databases while we are still in...
[sahlberg/ctdb.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
30 TAR_PREFIX_TMP="ctdb-tmp"
31 SPECFILE=/tmp/${TAR_PREFIX_TMP}/packaging/RPM/ctdb.spec
32 SPECFILE_IN=${SPECFILE}.in
33
34 EXTRA_SUFFIX="$1"
35
36 # if no githash was specified on the commandline,
37 # then use the current head
38 if test x"$GITHASH" = "x" ; then
39         GITHASH="$(git log --pretty=format:%h -1)"
40 fi
41
42 GITHASH_SUFFIX=".${GITHASH}"
43 if test "x$USE_GITHASH" = "xno" ; then
44         GITHASH_SUFFIX=""
45 fi
46
47 if echo | gzip -c --rsyncable - > /dev/null 2>&1 ; then
48         GZIP="gzip -9 --rsyncable"
49 else
50         GZIP="gzip -9"
51 fi
52
53 pushd ${TOPDIR}
54 echo "Creating tarball ... "
55 git archive --prefix=${TAR_PREFIX_TMP}/ ${GITHASH} | ( cd /tmp ; tar xf - )
56 RC=$?
57 popd
58 if [ $RC -ne 0 ]; then
59         echo "Error calling git archive."
60         exit 1
61 fi
62
63 sed -e s/GITHASH/${GITHASH_SUFFIX}/g \
64         < ${SPECFILE_IN} \
65         > ${SPECFILE}
66
67 VERSION=$(grep ^Version ${SPECFILE} | sed -e 's/^Version:\ \+//')${GITHASH_SUFFIX}
68
69 if [ "x${EXTRA_SUFFIX}" != "x" ]; then
70         VERSION="${VERSION}-${EXTRA_SUFFIX}"
71 fi
72
73 TAR_PREFIX="ctdb-${VERSION}"
74 TAR_BASE="ctdb-${VERSION}"
75
76 pushd /tmp/${TAR_PREFIX_TMP}
77 ./autogen.sh
78 RC=$?
79 popd
80 if [ $RC -ne 0 ]; then
81         echo "Error calling autogen.sh."
82         exit 1
83 fi
84
85 if test "x${DEBIAN_MODE}" = "xyes" ; then
86         TAR_PREFIX="ctdb-${VERSION}.orig"
87         TAR_BASE="ctdb_${VERSION}.orig"
88         rm -rf /tmp/${TAR_PREFIX_TMP}/lib/popt
89 fi
90
91 TAR_BALL=${TAR_BASE}.tar
92 TAR_GZ_BALL=${TAR_BALL}.gz
93
94 mv /tmp/${TAR_PREFIX_TMP} /tmp/${TAR_PREFIX}
95
96 pushd /tmp
97 tar cf ${TAR_BALL} ${TAR_PREFIX}
98 RC=$?
99 if [ $RC -ne 0 ]; then
100         popd
101         echo "Creation of tarball failed."
102         exit 1
103 fi
104
105 ${GZIP} ${TAR_BALL}
106 RC=$?
107 if [ $RC -ne 0 ]; then
108         popd
109         echo "Zipping tarball failed."
110         exit 1
111 fi
112
113 rm -rf ${TAR_PREFIX}
114
115 popd
116
117 mv /tmp/${TAR_GZ_BALL} .
118
119 echo "Done."
120 exit 0