1#!/bin/bash
2
3if [ "$1" = "" ]; then
4    echo "Please provide version string, eg: 1.2.0"
5    exit 1
6fi
7
8if [ ! -d "lib/talloc" ]; then
9    echo "Run this script from the samba base directory."
10    exit 1
11fi
12
13# Check exports and signatures are up to date
14pushd lib/talloc
15./script/abi_checks.sh talloc talloc.h
16abicheck=$?
17popd
18if [ ! "$abicheck" = "0" ]; then
19    echo "ERROR: ABI Checks produced warnings!"
20    exit 1
21fi
22
23git clean -f -x -d lib/talloc
24git clean -f -x -d lib/replace
25
26curbranch=`git branch |grep "^*" | tr -d "* "`
27
28version=$1
29strver=`echo ${version} | tr "." "-"`
30
31# Checkout the release tag
32git branch -f talloc-release-script-${strver} talloc-${strver}
33if [ ! "$?" = "0" ];  then
34    echo "Unable to checkout talloc-${strver} release"
35    exit 1
36fi
37
38git checkout talloc-release-script-${strver}
39
40# Test configure agrees with us
41confver=`grep "^AC_INIT" lib/talloc/configure.ac | tr -d "AC_INIT(talloc, " | tr -d ")"`
42if [ ! "$confver" = "$version" ]; then
43    echo "Wrong version, requested release for ${version}, found ${confver}"
44    exit 1
45fi
46
47# Now build tarball
48cp -a lib/talloc talloc-${version}
49cp -a lib/replace talloc-${version}/libreplace
50pushd talloc-${version}
51./autogen.sh
52popd
53tar cvzf talloc-${version}.tar.gz talloc-${version}
54rm -fr talloc-${version}
55
56#Clean up
57git checkout $curbranch
58git branch -d talloc-release-script-${strver}
59