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