Fix release script.
[ab/samba.git/.git] / release-scripts / create-tarball
1 #!/bin/bash
2
3 TOPDIR="`dirname $0`/.."
4
5 cd $TOPDIR
6
7 echo -n "Please enter branch to cut tarball from: "
8 read branch
9
10 if [ "x$branch" = "x" ]; then
11    echo "You must enter a name!  Exiting...."
12    exit 1
13 fi
14
15 git-checkout $branch
16 if [ $? -ne 0 ]; then
17    echo "Invalid branch name!  Exiting...."
18    exit 2
19 fi
20
21 VER_H=source/include/version.h
22 (cd source && ./script/mkversion.sh)
23
24 if [ ! -f $VER_H ]; then
25    echo "Failed to find $VER_H!  Exiting...."
26    exit 1
27 fi
28
29 version=`grep SAMBA_VERSION_OFFICIAL_STRING $VER_H | awk '{print $3}'`
30 vendor_version=`grep SAMBA_VERSION_VENDOR_SUFFIX $VER_H | awk '{print $3}'`
31 if [ -n "$vendor_version" ]; then
32     version="$version-$vendor_version"
33 fi
34 version=`echo $version | sed 's/\"//g'`
35
36 echo "Creating release tarball for Samba $version"
37
38 /bin/rm -rf ../samba-${version}
39 git-archive --format=tar --prefix=samba-${version}/ HEAD | (cd .. && tar xf -)
40
41 pushd ../samba-${version}
42
43 echo "Enter the absolute path to the generated Samba docs directory."
44 echo -n "Just hit return to exclude the docs from the generate tarball: "
45 read docsdir
46
47 if [ "x$docsdir" != "x" ]; then
48    if [ ! -d "$docsdir" ]; then
49       echo "$docsdir does not exist!  Exiting...."
50       exit 1
51    fi
52
53    /bin/rm -rf docs
54    mkdir docs
55    rsync -a --exclude=.svn $docsdir/ docs/
56
57    cd docs
58    /bin/rm -rf test.pdf Samba4*pdf htmldocs/Samba4* htmldocs/test
59    /bin/mv manpages-3 manpages
60    /bin/mv htmldocs/manpages-3 htmldocs/manpages
61    cd ..
62 fi
63
64 cd source
65 ./autogen.sh
66 cd ..
67
68 cd ..
69 tar cf samba-${version}.tar --exclude=.git* --exclude=CVS --exclude=.svn samba-${version}
70 gpg --detach-sign --armor samba-${version}.tar
71 gzip -9 samba-${version}.tar
72
73 popd
74 echo -n "Enter tag name (or hit <enter> to skip): "
75 read tagname
76
77 if [ "x$tagname" != "x" ]; then
78    if [ "x`git-tag -l $tagname`" != "x" ]; then
79       echo -n "Tag exists.  Do you wish to overwrite? (y/N): "
80       read answer
81
82       if [ "x$answer" != "xy" ]; then
83          echo "Tag creation aborted."
84          exit 1
85       fi
86    fi
87
88    git-tag -s ${tagname}
89 fi
90
91 echo "Done!"
92 exit 0