Add helper script for release management
[citadel] / releaseversion.sh
1 #!/bin/bash
2
3 if test "$1" = '?'; then
4
5     echo 'no help for the lost.'
6     exit
7 fi
8
9 if test "$1" = 'list'; then
10     echo "showing current release version state: "
11     echo "-------- libcitadel: --------"
12     grep AC_INIT libcitadel/configure.in
13     grep 'PACKAGE_VERSION=' libcitadel/configure
14     echo "  - Header version:"
15     grep LIBCITADEL_VERSION_NUMBER libcitadel/lib/libcitadel.h
16     head -n 5 libcitadel/debian/changelog
17     
18     echo "-------- citserver: --------"
19     grep 'PACKAGE_VERSION=' citadel/configure
20     grep '#define REV_LEVEL' citadel/citadel.h
21     grep '#define REV_MIN' citadel/citadel.h
22     grep '#define EXPORT_REV_MIN' citadel/citadel.h
23     grep '#define LIBCITADEL_MIN' citadel/citadel.h
24     head -n 5 citadel/debian/changelog
25
26     echo "-------- textclient: --------"
27     grep 'PACKAGE_VERSION=' textclient/configure
28     head -n 5 textclient/debian/changelog
29
30     echo "-------- webcit: --------"
31     grep 'PACKAGE_VERSION=' webcit/configure
32     grep '#define CLIENT_VERSION' webcit/webcit.h
33     grep '#define MINIMUM_CIT_VERSION' webcit/webcit.h
34     grep '#define LIBCITADEL_MIN' webcit/webcit.h
35     head -n 5 webcit/debian/changelog
36
37     exit
38 fi
39
40
41 if test "$1" = "revert"; then 
42     echo "reverting all changes for version files"
43     git checkout \
44         libcitadel/lib/libcitadel.h \
45         libcitadel/configure.in \
46         libcitadel/debian/changelog \
47         \
48         citadel/citadel.h \
49         citadel/configure.ac \
50         citadel/debian/changelog \
51         \
52         textclient/configure.ac \
53         textclient/debian/changelog \
54         \
55         webcit/webcit.h \
56         webcit/configure.ac \
57         webcit/debian/changelog
58
59     exit
60 fi 
61
62
63 PRINT_VERSION=$1
64 HEADER_VERSION=$2
65
66 if test -z "$PRINT_VERSION" -o -z "$HEADER_VERSION"; then
67     echo "need print version ( 8.xx) and lib version 8xx"
68     exit
69 fi
70
71 export LANG=C
72 RELEASEDATE=`date -R`
73
74
75 function DebChangeLog()
76 {
77     FILE=$1
78     PROJECT=$2
79     (
80         printf "${PROJECT} (${PRINT_VERSION}-1) stable; urgency=low\n\n  * new release\n\n -- Wilfried Goesgens <w.goesgens@outgesourced.org>  ${RELEASEDATE}\n\n"
81         cat ${FILE}
82     ) > /tmp/${PROJECT}_changelog
83     rm -f ${FILE}
84     mv /tmp/${PROJECT}_changelog ${FILE}
85 }
86
87
88 ################################################################################
89 # libcitadel
90
91 DebChangeLog libcitadel/debian/changelog libcitadel
92
93 sed  -i -e "s;^#define LIBCITADEL_VERSION_NUMBER.*[0-9][0-9][0-9]\(.*\)$;#define LIBCITADEL_VERSION_NUMBER\t${HEADER_VERSION}\1;g" \
94     libcitadel/lib/libcitadel.h
95
96 OLD_LIB_PRINTVERSION=`grep AC_INIT libcitadel/configure.in  |sed "s;.*\(....\), http.*;\1;"`
97
98 sed -i -e "s;${OLD_LIB_PRINTVERSION};${PRINT_VERSION};" \
99     -e "s;^LIBREVISION=[0-9][0-9][0-9]\(.*\)$;LIBREVISION=${HEADER_VERSION}\1;g" \
100     libcitadel/configure.in
101
102
103
104 ################################################################################
105 # citserver
106
107 DebChangeLog citadel/debian/changelog citadel
108
109 OLD_PRINTVERSION=`grep AC_INIT citadel/configure.ac  |sed "s;.*\[\(....\)\],.*;\1;"`
110
111 sed -i "s;${OLD_PRINTVERSION};${PRINT_VERSION};" citadel/configure.ac
112
113 sed  -i -e "s;^#define REV_LEVEL.*[0-9][0-9][0-9]\(.*\)$;#define REV_LEVEL\t${HEADER_VERSION}\1;g" \
114     -e "s;^#define LIBCITADEL_MIN.*[0-9][0-9][0-9]\(.*\)$;#define LIBCITADEL_MIN\t${HEADER_VERSION}\1;g" \
115     citadel/citadel.h
116
117 ################################################################################
118 # textclient
119 DebChangeLog textclient/debian/changelog textclient
120 sed -i "s;${OLD_PRINTVERSION};${PRINT_VERSION};" textclient/configure.ac
121
122
123
124 ################################################################################
125 # webcit
126 DebChangeLog webcit/debian/changelog webcit
127 sed -i "s;${OLD_PRINTVERSION};${PRINT_VERSION};" webcit/configure.ac
128
129 sed  -i -e "s;^#define CLIENT_VERSION.*[0-9][0-9][0-9]\(.*\)$;#define CLIENT_VERSION\t\t${HEADER_VERSION}\1;g" \
130     -e "s;^#define MINIMUM_CIT_VERSION.*[0-9][0-9][0-9]\(.*\)$;#define MINIMUM_CIT_VERSION\t${HEADER_VERSION}\1;g" \
131     -e "s;^#define LIBCITADEL_MIN.*[0-9][0-9][0-9]\(.*\)$;#define LIBCITADEL_MIN\t${HEADER_VERSION}\1;g" \
132     webcit/webcit.h
133
134