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