dbwrap: add a dbwrap_flags argument to db_open_tdb()
[Samba.git] / ctdb / packaging / maketarball.sh
blobc27e2ec63c81af97f7a12d8be5d116fa07e6cd70
1 #!/bin/sh
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)
10 # any later version.
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.
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")
30 cd -P "${DIRNAME}/.."
31 TOPDIR="$PWD"
33 tmpd=$(mktemp -d) || {
34 echo "Failed to create temporary directory"
35 exit 1
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"
45 else
46 GZIP="gzip -9"
49 echo "Creating tarball ... "
50 git archive --prefix="${TAR_PREFIX_TMP}/" HEAD | ( cd "$tmpd" ; tar xf - )
51 if [ $? -ne 0 ]; then
52 echo "Error calling git archive."
53 exit 1
56 set -- $("${TOPDIR}/packaging/mkversion.sh" "$VERSION_H")
57 VERSION=$1
58 RELEASE=$2
59 if [ -z "$VERSION" -o -z "$RELEASE" ]; then
60 exit 1
63 sed -e "s/@VERSION@/${VERSION}/g" \
64 -e "s/@RELEASE@/$RELEASE/g" \
65 < ${SPECFILE_IN} \
66 > ${SPECFILE}
68 TAR_PREFIX="ctdb-${VERSION}"
69 TAR_BASE="ctdb-${VERSION}"
71 cd "${tmpd}/${TAR_PREFIX_TMP}"
72 ./autogen.sh || {
73 echo "Error calling autogen.sh."
74 exit 1
77 make -C doc || {
78 echo "Error building docs."
79 exit 1
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}"
93 cd "$tmpd"
94 tar cf "$TAR_BALL" "$TAR_PREFIX" || {
95 echo "Creation of tarball failed."
96 exit 1
99 $GZIP "$TAR_BALL" || {
100 echo "Zipping tarball failed."
101 exit 1
104 rm -rf "$TAR_PREFIX"
106 mv "${tmpd}/${TAR_GZ_BALL}" "${TARGETDIR}/"
108 rmdir "$tmpd"
110 echo "Done."
111 exit 0