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