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 calculated from git tag in mkversion.sh.
24 # Optional argument is the directory to which tarball is copied.
27 TARGETDIR
="${1:-${PWD}}" # Default target directory is .
29 DIRNAME
=$
(dirname "$0")
33 tmpd
=$
(mktemp
-d) ||
{
34 echo "Failed to create temporary directory"
38 TAR_PREFIX_TMP
="ctdb-tmp"
39 SPECFILE
="${tmpd}/${TAR_PREFIX_TMP}/packaging/RPM/ctdb.spec"
40 SPECFILE_IN
="${SPECFILE}.in"
41 VERSION_H
="${tmpd}/${TAR_PREFIX_TMP}/include/ctdb_version.h"
43 if echo |
gzip -c --rsyncable - > /dev
/null
2>&1 ; then
44 GZIP
="gzip -9 --rsyncable"
49 echo "Creating tarball ... "
50 git archive
--prefix="${TAR_PREFIX_TMP}/" HEAD |
( cd "$tmpd" ; tar xf
- )
52 echo "Error calling git archive."
56 set -- $
("${TOPDIR}/packaging/mkversion.sh" "$VERSION_H")
59 if [ -z "$VERSION" -o -z "$RELEASE" ]; then
63 sed -e "s/@VERSION@/${VERSION}/g" \
64 -e "s/@RELEASE@/$RELEASE/g" \
68 TAR_PREFIX
="ctdb-${VERSION}"
69 TAR_BASE
="ctdb-${VERSION}"
71 cd "${tmpd}/${TAR_PREFIX_TMP}"
73 echo "Error calling autogen.sh."
78 echo "Error building docs."
82 if [ "$DEBIAN_MODE" = "yes" ] ; then
83 TAR_PREFIX
="ctdb-${VERSION}.orig"
84 TAR_BASE
="ctdb_${VERSION}.orig"
85 rm -rf "${tmpd}/${TAR_PREFIX_TMP}/lib/popt"
88 TAR_BALL
="${TAR_BASE}.tar"
89 TAR_GZ_BALL
="${TAR_BALL}.gz"
91 mv "${tmpd}/${TAR_PREFIX_TMP}" "${tmpd}/${TAR_PREFIX}"
94 tar cf
"$TAR_BALL" "$TAR_PREFIX" ||
{
95 echo "Creation of tarball failed."
99 $GZIP "$TAR_BALL" ||
{
100 echo "Zipping tarball failed."
106 mv "${tmpd}/${TAR_GZ_BALL}" "${TARGETDIR}/"