autobuild: add a target "samba-ctdb" that builds samba (waf) with cluster support
[kai/samba-autobuild/.git] / script / librelease.sh
1 #!/bin/bash
2 # make a release of a Samba library
3
4 [ -z "$GPG_USER" ] && {
5     GPG_USER='Samba Library Distribution Key <samba-bugs@samba.org>'
6 }
7
8 [ -z "$GPG_KEYID" ] && {
9     GPG_KEYID='13084025'
10 }
11
12 if [ ! -d ".git" ]; then
13         echo "Run this script from the top-level directory in the"
14         echo "repository"
15         exit 1
16 fi
17
18 if [ $# -lt 1 ]; then
19     echo "Usage: librelease.sh <LIBNAMES>"
20     exit 1
21 fi
22
23 umask 0022
24
25 release_lib() {
26     lib="$1"
27     srcdir="$2"
28     ftpdir="$3"
29
30     pushd $srcdir
31
32     echo "Releasing library $lib"
33
34     echo "building release tarball"
35     tgzname=$(make dist 2>&1 | grep ^Created | cut -d' ' -f2)
36     [ -f "$tgzname" ] || {
37         echo "Failed to create tarball"
38         exit 1
39     }
40     tarname=$(basename $tgzname .gz)
41     echo "Tarball: $tarname"
42     gunzip -f $tgzname || exit 1
43     [ -f "$tarname" ] || {
44         echo "Failed to decompress tarball $tarname"
45         exit 1
46     }
47
48     tagname=$(basename $tarname .tar)
49     echo "tagging as $tagname"
50     git tag -u $GPG_KEYID -s "$tagname" -m "$lib: tag release $tagname" || {
51         exit 1
52     }
53
54     echo "signing"
55     rm -f "$tarname.asc"
56     gpg -u "$GPG_USER" --detach-sign --armor $tarname || {
57         exit 1
58     }
59     [ -f "$tarname.asc" ] || {
60         echo "Failed to create signature $tarname.asc"
61         exit 1
62     }
63     echo "compressing"
64     gzip -f -9 $tarname
65     [ -f "$tgzname" ] || {
66         echo "Failed to compress $tgzname"
67         exit 1
68     }
69
70     echo "Push git tag $tagname"
71     git push ssh://git.samba.org/data/git/samba.git refs/tags/$tagname:refs/tags/$tagname || {
72         exit 1
73     }
74
75     echo "Transferring for FTP"
76     rsync -Pav $tarname.asc $tgzname master.samba.org:~ftp/pub/$ftpdir/ || {
77         exit 1
78     }
79     rsync master.samba.org:~ftp/pub/$ftpdir/$tarname.*
80
81     popd
82 }
83
84 for lib in $*; do
85     case $lib in
86         talloc | tdb | tevent | ldb)
87             release_lib $lib "lib/$lib" $lib
88             ;;
89         samba4)
90             release_lib $lib "." "samba/$lib"
91             ;;
92         *)
93             echo "Unknown library $lib"
94             exit 1
95     esac
96 done