jabberd/jabberd.spec

Tue, 02 Jul 2013 18:21:58 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 02 Jul 2013 18:21:58 +0200
changeset 782
de3379343a7c
parent 768
70baf26f1088
permissions
-rw-r--r--

Remove superfluous init scripts and introduce SQL population logic.

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

mercurial