3 # maketarball.sh - create a tarball from the git branch HEAD
5 # Copyright (C) Michael Adam 2009
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)
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
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/>.
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.
30 TAR_PREFIX_TMP="ctdb-tmp"
31 SPECFILE=/tmp/${TAR_PREFIX_TMP}/packaging/RPM/ctdb.spec
32 SPECFILE_IN=${SPECFILE}.in
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)"
42 GITHASH_SUFFIX=".${GITHASH}"
43 if test "x$USE_GITHASH" = "xno" ; then
47 if echo | gzip -c --rsyncable - > /dev/null 2>&1 ; then
48 GZIP="gzip -9 --rsyncable"
54 echo "Creating tarball ... "
55 git archive --prefix=${TAR_PREFIX_TMP}/ ${GITHASH} | ( cd /tmp ; tar xf - )
58 if [ $RC -ne 0 ]; then
59 echo "Error calling git archive."
63 sed -e s/GITHASH/${GITHASH_SUFFIX}/g \
67 VERSION=$(grep ^Version ${SPECFILE} | sed -e 's/^Version:\ \+//')${GITHASH_SUFFIX}
69 if [ "x${EXTRA_SUFFIX}" != "x" ]; then
70 VERSION="${VERSION}-${EXTRA_SUFFIX}"
73 TAR_PREFIX="ctdb-${VERSION}"
74 TAR_BASE="ctdb-${VERSION}"
76 pushd /tmp/${TAR_PREFIX_TMP}
80 if [ $RC -ne 0 ]; then
81 echo "Error calling autogen.sh."
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
91 TAR_BALL=${TAR_BASE}.tar
92 TAR_GZ_BALL=${TAR_BALL}.gz
94 mv /tmp/${TAR_PREFIX_TMP} /tmp/${TAR_PREFIX}
97 tar cf ${TAR_BALL} ${TAR_PREFIX}
99 if [ $RC -ne 0 ]; then
101 echo "Creation of tarball failed."
107 if [ $RC -ne 0 ]; then
109 echo "Zipping tarball failed."
117 mv /tmp/${TAR_GZ_BALL} .