s4: torture: Add TALLOC_CTX * to torture_winbind_init().
[Samba.git] / ctdb / packaging / mkversion.sh
blob54dc2cd15fa05708559350225728bbc8584c4787
1 #!/bin/sh
3 # mkversion.sh - extract version string from git branch
5 # Copyright (C) Amitay Isaacs 2012
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 # Common code to generate CTDB version string
25 OUTPUT=$1
27 if [ -z "$OUTPUT" ]; then
28 OUTPUT="include/ctdb_version.h"
31 VERSION=$2
32 RELEASE=1
34 # We use tags and determine the version, as follows:
35 # ctdb-0.9.1 (First release of 0.9).
36 # ctdb-0.9.23 (23rd minor release of the 112 version)
38 # If we're not directly on a tag, this is a devel release; we append
39 # .0.<patchnum>.<checksum>.devel to the release.
40 if [ -z "$VERSION" ]; then
42 TAG=`git describe --match "samba-*"`
43 case "$TAG" in
44 samba-*)
45 TAG=${TAG##samba-}
46 case "$TAG" in
47 *-*-g*) # 0.9-168-ge6cf0e8
48 # Not exactly on tag: devel version.
49 VERSION=`echo "$TAG" | sed 's/\([^-]\+\)-\([0-9]\+\)-\(g[0-9a-f]\+\)/\1.0.\2.\3.devel/'`
50 RELEASE=1
53 # An actual release version
54 VERSION=$TAG
55 RELEASE=1
57 esac
60 echo Invalid tag "$TAG" >&2
62 esac
64 else
66 # If building from tarball, Samba version creation will create
67 # VERSION with UNKNOWN git hash.
68 case "$VERSION" in
69 *UNKNOWN)
70 if [ -f ../include/ctdb_version.h ] ; then
71 VERSION=$(awk -F \" '/CTDB_VERSION_STRING/ {print $2}' ../include/ctdb_version.h)
74 esac
77 cat > "$OUTPUT" <<EOF
78 /* This file is auto-generated by packaging/mkversion.sh */
80 #define CTDB_VERSION_STRING "$VERSION"
82 EOF
84 echo "$VERSION $RELEASE"