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