Tue, 02 Jul 2013 18:21:58 +0200
Remove superfluous init scripts and introduce SQL population logic.
1 ##
2 ## jabberd.spec -- OpenPKG RPM Package Specification
3 ## Copyright (c) 2000-2011 OpenPKG Foundation e.V. <http://openpkg.net/>
4 ##
5 ## Permission to use, copy, modify, and distribute this software for
6 ## any purpose with or without fee is hereby granted, provided that
7 ## the above copyright notice and this permission notice appear in all
8 ## copies.
9 ##
10 ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
11 ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
12 ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
13 ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
14 ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
15 ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
16 ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
17 ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
18 ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
19 ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
20 ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
21 ## SUCH DAMAGE.
22 ##
24 # package version
25 %define V_major 2.2
26 %define V_minor 17
27 %define V_mucon 0.8.81
29 # package information
30 Name: jabberd
31 Summary: Jabber Instant Messaging Daemon
32 URL: http://jabberd2.xiaoka.com/
33 Vendor: Jabber Software Foundation
34 Packager: OpenPKG Foundation e.V.
35 Distribution: OpenPKG Community
36 Class: PLUS
37 Group: InstantMessaging
38 License: JOSL/GPL
39 Version: %{V_major}.%{V_minor}
40 Release: 20130000
42 # package options
43 %option with_sqlite yes
44 %option with_mysql no
45 %option with_pgsql no
46 %option with_pam no
47 %option with_mucon yes
49 # list of sources
50 Source0: http://www.github.com/downloads/Jabberd2/jabberd2/jabberd-%{version}.tar.xz
51 Source1: http://download.gna.org/mu-conference/mu-conference-%{V_mucon}.tar.gz
52 Source1: rc.jabberd
53 Patch0: jabberd.patch
55 # build information
56 BuildPreReq: OpenPKG, openpkg >= 20100101, make
57 PreReq: OpenPKG, openpkg >= 20100101, perl
58 BuildPreReq: db, expat, libiconv, libidn, gpg-error, gcrypt, libgsasl, openssl, udns
59 PreReq: db, expat, libiconv, libidn, gpg-error, gcrypt, libgsasl, openssl, udns
60 %if "%{with_sqlite}" == "yes"
61 BuildPreReq: sqlite
62 PreReq: sqlite
63 %endif
64 %if "%{with_mysql}" == "yes"
65 BuildPreReq: mysql
66 PreReq: mysql
67 %endif
68 %if "%{with_pgsql}" == "yes"
69 BuildPreReq: postgresql
70 PreReq: postgresql
71 %endif
72 %if "%{with_pam}" == "yes"
73 BuildPreReq: PAM
74 PreReq: PAM
75 %endif
76 %if "%{with_mucon}" == "yes"
77 BuildPreReq: glib, pkgconfig
78 PreReq: glib
79 %endif
81 %description
82 JabberD is the original server implementation for the Jabber instant
83 messaging platform. JabberD 2 is the next generation of the JabberD
84 server. It has been rewritten from the ground up to be scalable,
85 architecturally sound, and to support the latest protocol extensions
86 coming out of the XSF.
88 %track
89 prog jabberd = {
90 version = %{version}
91 url = http://www.github.com/downloads/Jabberd2/jabberd2/
92 regex = jabberd-(\d+\.\d+(\.\d+)*)\.tar\.xz
93 }
94 prog jabberd:mucon = {
95 version = %{V_mucon}
96 url = http://download.gna.org/mu-conference/
97 regex = mu-conference-(__VER__)\.tar\.gz
98 }
100 %prep
101 %setup -q -n jabberd-%{version}
102 %setup -q -D -T -a 1
103 %{l_sed} <%{PATCH0} -e 's;@l_prefix@;%{l_prefix};g' | %{l_patch} -p0 -b
104 %{l_shtool} subst \
105 -e 's;exec perl;exec %{l_prefix}/bin/perl;' \
106 tools/jabberd.in
107 %{l_shtool} subst \
108 -e 's;\$(initdir);;g' \
109 etc/Makefile.in
110 %if "%{with_mucon}" == "yes"
111 %{l_shtool} subst \
112 -e 's;^\(CFLAGS\ *:=.*pkg-config --cflags glib-2.0\);\1 libidn;' \
113 -e 's;^\(LIBS\ *:=.*\);\1 $(LOCLIBS);' \
114 mu-conference-%{V_mucon}/src/Makefile
115 %{l_shtool} subst \
116 -e 's;mu-conference.log;muc.log;g' \
117 mu-conference-%{V_mucon}/src/jcomp/jcr_log.c
118 %{l_shtool} subst \
119 -e 's;<port>[0-9][0-9]*</port>;<port>5347</port>;' \
120 -e 's;<spool>.*</spool>;<spool>%{l_prefix}/var/jabberd/spool/rooms</spool>;' \
121 -e 's;<logdir>\./syslogs</logdir>;<logdir>%{l_prefix}/var/jabberd/log</logdir>;' \
122 -e 's;<logdir>\./logs/</logdir>;<logdir>%{l_prefix}/var/jabberd/spool/logs</logdir>;' \
123 -e 's;<pidfile>.*</pidfile>;<pidfile>%{l_prefix}/var/jabberd/pid/muc.pid</pidfile>;' \
124 -e 's;<URL>.*</URL>;<URL>http://name.host.tld/</URL>;' \
125 -e 's;<stylesheet>.*</stylesheet>;<stylesheet>%{l_prefix}/share/jabberd/style.css</stylesheet>;' \
126 mu-conference-%{V_mucon}/muc-default.xml
127 echo \
128 'muc @sysconfdir@/muc.xml' \
129 >>etc/jabberd.cfg.dist.in
130 %endif
132 %build
133 # configure program
134 ( echo "ac_cv_func_kqueue=no"
135 ) >config.cache
136 export CC="%{l_cc}"
137 export CFLAGS="%{l_cflags -O}"
138 export CPPFLAGS="%{l_cppflags libidn}"
139 export LDFLAGS="%{l_ldflags}"
140 export LIBS=""
141 case "%{l_platform -t}" in
142 *-linux* ) LIBS="$LIBS -ldl" ;;
143 *-sunos* ) LIBS="$LIBS -lsocket -lnsl -lrt" ;;
144 esac
145 export JHOME=%{l_prefix}/var/jabberd
146 %if "%{with_mysql}" == "yes"
147 CPPFLAGS="$CPPFLAGS %{l_cppflags mysql}"
148 LDFLAGS="$LDFLAGS %{l_ldflags mysql}"
149 LIBS="$LIBS -lz -lm"
150 %endif
151 %if "%{with_pgsql}" == "yes"
152 CPPFLAGS="$CPPFLAGS %{l_cppflags postgresql}"
153 %endif
154 ./configure \
155 --cache-file=./config.cache \
156 --prefix=%{l_prefix} \
157 --sysconfdir=%{l_prefix}/etc/jabberd \
158 --mandir=%{l_prefix}/man \
159 --enable-db \
160 --enable-fs \
161 --enable-pipe \
162 --enable-ssl \
163 --with-sasl=gsasl \
164 %if "%{with_sqlite}" == "yes"
165 --enable-sqlite \
166 %else
167 --disable-sqlite \
168 %endif
169 %if "%{with_mysql}" == "yes"
170 --enable-mysql \
171 %else
172 --disable-mysql \
173 %endif
174 %if "%{with_pgsql}" == "yes"
175 --enable-pgsql \
176 %else
177 --disable-pgsql \
178 %endif
179 %if "%{with_pam}" == "yes"
180 --enable-pam \
181 %else
182 --disable-pam \
183 %endif
184 --disable-oracle \
185 --enable-static \
186 --enable-shared
188 # build program
189 %{l_make} %{l_mflags -O}
191 #http://www.suramya.com/linux/tutorials/JabberSetup/
192 %if "%{with_mucon}" == "yes"
193 loclibs=''
194 case "%{l_platform -t}" in
195 *-sunos* )
196 loclibs='-lsocket -lnsl'
197 ;;
198 esac
199 ( cd mu-conference-%{V_mucon}
200 %{l_make} %{l_mflags -O} LOCLIBS=$loclibs
201 ) || exit $?
202 %endif
204 %install
205 # create installation filesystem structure
206 %{l_shtool} mkdir -f -p -m 755 \
207 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
208 $RPM_BUILD_ROOT%{l_prefix}/etc/jabberd \
209 $RPM_BUILD_ROOT%{l_prefix}/etc/jabberd/templates \
210 $RPM_BUILD_ROOT%{l_prefix}/var/jabberd \
211 $RPM_BUILD_ROOT%{l_prefix}/var/jabberd/db \
212 $RPM_BUILD_ROOT%{l_prefix}/var/jabberd/pid \
213 $RPM_BUILD_ROOT%{l_prefix}/var/jabberd/log
215 # install components
216 %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
218 # install optional components
219 %if "%{with_mucon}" == "yes"
220 %{l_shtool} mkdir -f -p -m 755 \
221 $RPM_BUILD_ROOT%{l_prefix}/share/jabberd \
222 $RPM_BUILD_ROOT%{l_prefix}/var/jabberd/spool/logs \
223 $RPM_BUILD_ROOT%{l_prefix}/var/jabberd/spool/rooms
224 %{l_shtool} install -c -m 644 \
225 mu-conference-%{V_mucon}/muc-default.xml \
226 $RPM_BUILD_ROOT%{l_prefix}/etc/jabberd/muc.xml
227 %{l_shtool} install -c \
228 mu-conference-%{V_mucon}/src/mu-conference \
229 $RPM_BUILD_ROOT%{l_prefix}/bin/
230 %{l_shtool} install -c \
231 mu-conference-%{V_mucon}/style.css \
232 $RPM_BUILD_ROOT%{l_prefix}/share/jabberd
233 %endif
235 # strip installation
236 strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
238 # remove unnecessary files
239 rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/jabberd/*.dist
240 rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/jabberd/jabberd-*.conf
241 rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/jabberd/templates/*.dist
242 rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/jabberd/*.a
244 # install runcommand script
245 %{l_shtool} install -c -m 755 %{l_value -s -a} \
246 %if "%{with_mucon}" == "yes"
247 -e 's;\(jabberd_daemons\s*=.*\)\s\s*\(\w\w*\);\1 mucon\2;' \
248 %endif
249 %{SOURCE rc.jabberd} \
250 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
252 # determine installation files
253 %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
254 %{l_files_std} \
255 '%config %attr(0640,%{l_mgrp},%{l_ngrp}) %{l_prefix}/etc/jabberd/*' \
256 '%dir %attr(-,%{l_nusr},%{l_ngrp}) %{l_prefix}/var/jabberd' \
257 '%dir %attr(-,%{l_nusr},%{l_ngrp}) %{l_prefix}/var/jabberd/*' \
258 '%dir %attr(-,%{l_nusr},%{l_ngrp}) %{l_prefix}/var/jabberd/*/*'
260 %files -f files
262 %clean
264 %post
265 if [ $1 -eq 1 ]; then
266 # print information describing initial population of database
267 ( echo "Jabberd stores data in SQL and requires an existing"
268 echo "local or remote installation of PostgreSQL, MySQL, or"
269 echo "SQLite. Please refer to online documentation to carry"
270 echo "out the SQL configuration, something like:"
271 echo ""
272 %if "%{with_sqlite}" == "yes"
273 echo "$RPM_INSTALL_PREFIX/bin/sqlite $RPM_INSTALL_PREFIX/var/jabberd/db/sqlite.db < $RPM_INSTALL_PREFIX/share/jabberd/db-setup.sqlite"
274 %endif
275 %if "%{with_pgsql}" == "yes"
276 echo "template1=> \i $RPM_INSTALL_PREFIX/share/jabberd/db-setup.pgsql"
277 %endif
278 %if "%{with_mysql}" == "yes"
279 echo "mysql> \. $RPM_INSTALL_PREFIX/share/jabberd/db-setup.mysql"
280 %endif
281 ) | %{l_rpmtool} msg -b -t notice
282 fi
283 [ $1 -eq 2 ] || exit 0
284 # print information describing initial population of database
285 ( echo "The jabberd installation is being upgraded. It may be"
286 echo "necessary to upgrade the database structures as well."
287 echo "To carry this out please refer to online documentation"
288 echo "regarding the SQL configuration, something like:"
289 echo ""
290 %if "%{with_sqlite}" == "yes"
291 echo "$RPM_INSTALL_PREFIX/bin/sqlite $RPM_INSTALL_PREFIX/var/jabberd/db/sqlite.db < $RPM_INSTALL_PREFIX/share/jabberd/db-update.sqlite"
292 %endif
293 %if "%{with_pgsql}" == "yes"
294 echo "template1=> \i $RPM_INSTALL_PREFIX/share/jabberd/db-update.pgsql"
295 %endif
296 %if "%{with_mysql}" == "yes"
297 echo "mysql> \. $RPM_INSTALL_PREFIX/share/jabberd/db-update.mysql"
298 %endif
299 ) | %{l_rpmtool} msg -b -t notice
300 # after upgrade, restart service
301 eval `%{l_rc} jabberd status 2>/dev/null`
302 [ ".$jabberd_active" = .yes ] && %{l_rc} jabberd restart
303 exit 0
305 %preun
306 # before erase, stop service and remove log files
307 [ $1 -eq 0 ] || exit 0
308 %{l_rc} jabberd stop 2>/dev/null
309 rm -f $RPM_INSTALL_PREFIX/var/jabberd/*.log* >/dev/null 2>&1 || true
310 exit 0