Thu, 05 Nov 2009 18:06:08 +0100
Specify required statedir, correct permissions, improve config.
1 ##
2 ## dovecot.spec -- OpenPKG RPM Package Specification
3 ## Copyright (c) 2000-2009 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 1.2
26 %define V_minor 6
27 %define V_sieve_base 1.2
28 %define V_sieve 0.1.13
29 %define V_managesieve_base 1.2.6
30 %define V_managesieve 0.11.9
31 %define V_managesieved_base 1.2
32 %define V_managesieved 0.11.9
34 # package information
35 Name: dovecot
36 Summary: IMAP4 & POP3 Server
37 URL: http://www.dovecot.org/
38 Vendor: Timo Sirainen et al.
39 Packager: OpenPKG Foundation e.V.
40 Distribution: OpenPKG Community
41 Class: EVAL
42 Group: Mail
43 License: MIT+LGPL
44 Version: %{V_major}.%{V_minor}
45 Release: 20091104
47 # package options
48 %option with_fsl yes
49 %option with_pam yes
50 %option with_sieve yes
51 %option with_managesieve yes
52 %option with_ldap no
53 %option with_mysql no
54 %option with_pgsql no
55 %option with_sqlite no
57 # list of sources
58 Source0: http://www.dovecot.org/releases/%{V_major}/dovecot-%{V_major}.%{V_minor}.tar.gz
59 Source1: http://www.rename-it.nl/dovecot/%{V_major}/dovecot-%{V_sieve_base}-sieve-%{V_sieve}.tar.gz
60 Source2: http://www.rename-it.nl/dovecot/%{V_major}/dovecot-%{V_managesieved_base}-managesieve-%{V_managesieved}.tar.gz
61 Source3: fsl.dovecot
62 Source4: rc.dovecot
63 Source5: dovecot.conf
64 Patch0: dovecot.patch
65 Patch1: http://www.rename-it.nl/dovecot/%{V_major}/dovecot-%{V_managesieve_base}-managesieve-%{V_managesieve}.diff.gz
67 # build information
68 Prefix: %{l_prefix}
69 BuildRoot: %{l_buildroot}
70 BuildPreReq: OpenPKG, openpkg >= 20060823
71 PreReq: OpenPKG, openpkg >= 20060823, MTA, x509
72 BuildPreReq: libiconv, openssl
73 PreReq: libiconv, openssl
74 %if "%{with_fsl}" == "yes"
75 BuildPreReq: fsl
76 PreReq: fsl
77 %endif
78 %if "%{with_ldap}" == "yes"
79 BuildPreReq: openldap
80 PreReq: openldap
81 %endif
82 %if "%{with_managesieve}" == "yes"
83 BuildPreReq: gettext
84 PreReq: gettext
85 %endif
86 %if "%{with_pam}" == "yes"
87 BuildPreReq: PAM
88 PreReq: PAM
89 %endif
90 %if "%{with_mysql}" == "yes"
91 BuildPreReq: mysql, zlib
92 PreReq: mysql, zlib
93 %endif
94 %if "%{with_pgsql}" == "yes"
95 BuildPreReq: postgresql
96 PreReq: postgresql
97 %endif
98 %if "%{with_sqlite}" == "yes"
99 BuildPreReq: sqlite
100 PreReq: sqlite
101 %endif
102 AutoReq: no
103 AutoReqProv: no
105 %description
106 Dovecot is an Open Source IMAP and POP3 server, written with
107 security primarily in mind. Dovecot is an excellent choice for both
108 small and large installations. It's fast, simple to set up, requires
109 no special administration and it uses very little memory.
111 %track
112 prog dovecot = {
113 version = %{V_major}.%{V_minor}
114 url = http://www.dovecot.org/download.html
115 regex = dovecot-(__VER__)\.tar\.gz
116 }
117 prog dovecot:sieve = {
118 version = %{V_sieve}
119 url = http://www.rename-it.nl/dovecot/%{V_major}/
120 regex = dovecot-%{V_sieve_base}-sieve-(__VER__)\.tar\.gz
121 }
122 prog dovecot:managesieved = {
123 version = %{V_managesieved}
124 url = http://www.rename-it.nl/dovecot/%{V_major}/
125 regex = dovecot-%{V_managesieved_base}-managesieve-(__VER__)\.tar\.gz
126 }
127 prog dovecot:managesieve = {
128 version = %{V_managesieve}
129 url = http://www.rename-it.nl/dovecot/%{V_major}/
130 regex = dovecot-%{V_managesieve_base}-managesieve-(__VER__)\.diff\.gz
131 }
133 %prep
134 %setup -q
135 %if "%{with_sieve}" == "yes"
136 %setup -q -T -D -a 1
137 %endif
138 %if "%{with_managesieve}" == "yes"
139 %setup -q -T -D -a 2
140 %{l_gzip} -dc <%{PATCH1} | %{l_patch} -p1 -b
141 %endif
142 %{l_sed} <%{PATCH0} %{l_value -s -a} | %{l_patch} -p0 -b
144 %build
145 cppflags="%{l_cppflags}"
146 ldflags="%{l_ldflags} %{l_fsl_ldflags}"
147 libs="%{l_fsl_libs}"
148 sql_drivers=""
149 %if "%{with_ldap}" == "yes"
150 libs="$libs -llber -lssl -lcrypto"
151 %endif
152 %if "%{with_mysql}" == "yes"
153 cppflags="$cppflags %{l_cppflags mysql}"
154 ldflags="$ldflags %{l_ldflags mysql}"
155 sql_drivers="$sql_drivers,mysql"
156 %endif
157 %if "%{with_pgsql}" == "yes"
158 libs="$libs -lssl -lcrypto -lcrypt"
159 sql_drivers="$sql_drivers,pgsql"
160 %endif
161 %if "%{with_sqlite}" == "yes"
162 sql_drivers="$sql_drivers,sqlite"
163 %endif
164 sql_drivers=`echo "$sql_drivers" | sed 's;^,;;'`
166 CC="%{l_cc}" \
167 CFLAGS="%{l_cflags -O}" \
168 CPPFLAGS="$cppflags" \
169 LDFLAGS="$ldflags" \
170 LIBS="$libs" \
171 ./configure \
172 --prefix=%{l_prefix} \
173 --mandir=%{l_prefix}/man \
174 --sysconfdir=%{l_prefix}/etc/dovecot \
175 --with-ssldir=%{l_prefix}/etc/dovecot/ssl \
176 --datadir=%{l_prefix}/share/dovecot \
177 --docdir=%{l_prefix}/share/dovecot/doc \
178 --with-rundir=%{l_prefix}/var/dovecot/run \
179 --with-statedir=%{l_prefix}/var/dovecot/dat \
180 --with-libiconv-prefix=%{l_prefix} \
181 --with-ssl=openssl \
182 --with-docs \
183 %if "%{with_ldap}" == "yes"
184 --with-ldap \
185 %else
186 --without-ldap \
187 %endif
188 %if "%{with_mysql}" == "yes" || "%{with_pgsql}" == "yes" || "%{with_sqlite}" == "yes"
189 --with-sql \
190 --with-sql-drivers="$sql_drivers" \
191 %if "%{with_mysql}" == "yes"
192 --with-mysql \
193 %else
194 --without-mysql \
195 %endif
196 %if "%{with_pgsql}" == "yes"
197 --with-pgsql \
198 %else
199 --without-pgsql \
200 %endif
201 %if "%{with_sqlite}" == "yes"
202 --with-sqlite \
203 %else
204 --without-sqlite \
205 %endif
206 %else
207 --without-sql \
208 --without-sql-drivers \
209 --without-mysql \
210 --without-pgsql \
211 --without-sqlite \
212 %endif
213 %if "%{with_pam}" == "yes"
214 --with-pam \
215 %else
216 --without-pam \
217 %endif
218 --without-gc \
219 --without-gssapi \
220 --without-lucene \
221 --without-vpopmail \
222 --disable-static
223 %{l_make} %{l_mflags -O}
225 %if "%{with_sieve}" == "yes"
226 # build optional Dovecot LDA sieve plugin
227 ( cd dovecot-%{V_sieve_base}-sieve-%{V_sieve}
228 CC="%{l_cc}" \
229 CFLAGS="%{l_cflags -O}" \
230 CPPFLAGS="%{l_cppflags}" \
231 LDFLAGS="%{l_ldflags}" \
232 ./configure \
233 --prefix=%{l_prefix} \
234 --mandir=%{l_prefix}/man \
235 --with-dovecot=`pwd`/..
236 %{l_make} %{l_mflags -O}
237 ) || exit $?
238 %endif
239 %if "%{with_managesieve}" == "yes"
240 # build optional Dovecot LDA managesieve daemon
241 ( cd dovecot-%{V_managesieved_base}-managesieve-%{V_managesieved}
242 CC="%{l_cc}" \
243 CFLAGS="%{l_cflags -O}" \
244 CPPFLAGS="%{l_cppflags}" \
245 LDFLAGS="%{l_ldflags}" \
246 ./configure \
247 --prefix=%{l_prefix} \
248 --mandir=%{l_prefix}/man \
249 --with-dovecot-sieve=`pwd`/../dovecot-%{V_sieve_base}-sieve-%{V_sieve} \
250 --with-dovecot=`pwd`/..
251 %{l_make} %{l_mflags -O}
252 ) || exit $?
253 %endif
255 %install
256 rm -rf $RPM_BUILD_ROOT
257 %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
259 %if "%{with_sieve}" == "yes"
260 # install optional Dovecot LDA sieve plugin
261 ( cd dovecot-%{V_sieve_base}-sieve-%{V_sieve}
262 %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
263 ) || exit $?
264 %endif
265 %if "%{with_managesieve}" == "yes"
266 # install optional Dovecot LDA managesieve daemon
267 ( cd dovecot-%{V_managesieved_base}-managesieve-%{V_managesieved}
268 %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
269 ) || exit $?
270 %endif
272 # create additional dirctories
273 %{l_shtool} mkdir -f -p -m 755 \
274 $RPM_BUILD_ROOT%{l_prefix}/etc/dovecot/ssl \
275 $RPM_BUILD_ROOT%{l_prefix}/var/dovecot/dat \
276 $RPM_BUILD_ROOT%{l_prefix}/var/dovecot/log \
277 $RPM_BUILD_ROOT%{l_prefix}/var/dovecot/run/login
279 # install runcommand script
280 %{l_shtool} mkdir -f -p -m 755 \
281 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
282 %{l_shtool} install -c -m 755 %{l_value -s -a} \
283 %{SOURCE rc.dovecot} \
284 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
286 # strip installation
287 rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/dovecot/dovecot*example.conf
288 rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/dovecot/{,*}/*.la \
289 >/dev/null 2>&1 || true
290 rmdir $RPM_BUILD_ROOT%{l_prefix}/lib/dovecot/auth \
291 $RPM_BUILD_ROOT%{l_prefix}/include/dovecot \
292 $RPM_BUILD_ROOT%{l_prefix}/include \
293 >/dev/null 2>&1 || true
294 strip \
295 $RPM_BUILD_ROOT%{l_prefix}/sbin/* \
296 $RPM_BUILD_ROOT%{l_prefix}/libexec/dovecot/* \
297 >/dev/null 2>&1 || true
299 # install default server configuration
300 %{l_shtool} mkdir -f -p -m 755 \
301 $RPM_BUILD_ROOT%{l_prefix}/etc/dovecot
302 %{l_shtool} install -c -m 640 %{l_value -s -a} \
303 %{SOURCE dovecot.conf} \
304 $RPM_BUILD_ROOT%{l_prefix}/etc/dovecot/
306 # install OSSP fsl configuration
307 %{l_shtool} mkdir -f -p -m 755 \
308 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
309 %{l_shtool} install -c -m 644 %{l_value -s -a} \
310 %{SOURCE fsl.dovecot} \
311 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
313 # generate file list
314 %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std} \
315 '%not %dir %{l_prefix}/etc/fsl' \
316 '%config %{l_prefix}/etc/fsl/fsl.dovecot' \
317 '%config %attr(0600,%{l_musr},%{l_mgrp}) %{l_prefix}/etc/dovecot/*' \
318 '%config %attr(0640,%{l_musr},%{l_rgrp}) %{l_prefix}/etc/dovecot/dovecot.conf' \
319 '%dir %attr(0700,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/dovecot/ssl' \
320 '%dir %attr(0755,%{l_musr},%{l_mgrp}) %{l_prefix}/var/dovecot' \
321 '%dir %attr(0770,%{l_musr},%{l_rgrp}) %{l_prefix}/var/dovecot/dat' \
322 '%dir %attr(0770,%{l_musr},%{l_rgrp}) %{l_prefix}/var/dovecot/log' \
323 '%dir %attr(0750,%{l_musr},%{l_rgrp}) %{l_prefix}/var/dovecot/run' \
324 '%dir %attr(0750,%{l_musr},%{l_ngrp}) %{l_prefix}/var/dovecot/run/login' \
325 '%doc %{l_prefix}/share/dovecot/doc' \
326 '%doc %{l_prefix}/share/dovecot/doc/wiki'
328 %files -f files
330 %clean
331 rm -rf $RPM_BUILD_ROOT
333 %post
334 # after upgrade, restart service
335 [ $1 -eq 2 ] || exit 0
336 eval `%{l_rc} dovecot status 2>/dev/null`
337 [ ".$dovecot_active" = .yes ] && %{l_rc} dovecot restart
338 exit 0
340 %preun
341 # before erase, stop service and remove log files
342 [ $1 -eq 0 ] || exit 0
343 %{l_rc} dovecot stop 2>/dev/null
344 rm -f $RPM_INSTALL_PREFIX/var/dovecot/* >/dev/null 2>&1 || true
345 rm -f $RPM_INSTALL_PREFIX/var/dovecot/dat/* >/dev/null 2>&1 || true
346 rm -f $RPM_INSTALL_PREFIX/var/dovecot/log/* >/dev/null 2>&1 || true
347 rm -f $RPM_INSTALL_PREFIX/var/dovecot/run/* >/dev/null 2>&1 || true
348 rm -f $RPM_INSTALL_PREFIX/var/dovecot/run/login/* >/dev/null 2>&1 || true
349 exit 0