Mon, 06 Apr 2009 23:53:05 +0200
Import package vendor original specs for necessary manipulations.
1 ##
2 ## postfix.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 versions
25 %define V_postfix 2.5.6
26 %define V_pflogsumm 1.1.2
27 %define V_whoson 2.4.0
29 # package information
30 Name: postfix
31 Summary: Mail Transfer Agent (MTA)
32 URL: http://www.postfix.org/
33 Vendor: Wietse Venema
34 Packager: OpenPKG Foundation e.V.
35 Distribution: OpenPKG Community
36 Class: BASE
37 Group: Mail
38 License: IPL
39 Version: %{V_postfix}
40 Release: 20090104
42 # package options
43 %option with_fsl yes
44 %option with_ssl no
45 %option with_sasl no
46 %option with_mysql no
47 %option with_pgsql no
48 %option with_ldap no
49 %option with_whoson no
50 %option with_fdsetsize no
52 # list of sources
53 Source0: ftp://ftp.porcupine.org/mirrors/postfix-release/official/postfix-%{V_postfix}.tar.gz
54 Source1: http://jimsun.linxnet.com/downloads/pflogsumm-%{V_pflogsumm}.tar.gz
55 Source2: postfix.txt
56 Source3: fsl.postfix
57 Source4: rc.postfix
58 Patch0: postfix.patch
59 Patch1: postfix.patch.pfls
60 Patch2: ftp://ftp.openpkg.org/sources/CPY/postfix/postfix-%{V_whoson}-whoson.patch
62 # build information
63 Prefix: %{l_prefix}
64 BuildRoot: %{l_buildroot}
65 BuildPreReq: OpenPKG, openpkg >= 20060823, perl, gcc
66 PreReq: OpenPKG, openpkg >= 20060823, perl, procmail, perl-time
67 BuildPreReq: make, pcre, db
68 PreReq: make, pcre, db
69 %if "%{with_fsl}" == "yes"
70 BuildPreReq: fsl
71 PreReq: fsl
72 %endif
73 %if "%{with_ssl}" == "yes"
74 BuildPreReq: openssl
75 PreReq: openssl
76 %endif
77 %if "%{with_sasl}" == "yes"
78 BuildPreReq: sasl
79 PreReq: sasl
80 %endif
81 %if "%{with_mysql}" == "yes"
82 BuildPreReq: mysql
83 PreReq: mysql
84 %endif
85 %if "%{with_pgsql}" == "yes"
86 BuildPreReq: postgresql, openssl
87 PreReq: postgresql, openssl
88 %endif
89 %if "%{with_ldap}" == "yes"
90 BuildPreReq: openldap, openssl
91 PreReq: openldap, openssl
92 %endif
93 %if "%{with_whoson}" == "yes"
94 BuildPreReq: whoson
95 PreReq: whoson
96 %endif
97 AutoReq: no
98 AutoReqProv: no
99 Provides: MTA
100 Conflicts: exim, sendmail, ssmtp
102 %description
103 Postfix is a new-generation Mail Transfer Agent (MTA) able to fully
104 replace the Sendmail MTA. It is fully standards compliant and
105 supports SMTP, ESMTP, LMTP over IPv4/IPv6 with optional TLS/SASL.
107 Local specifics in this OpenPKG version:
108 o Postfix delivers locally via Procmail
109 o Postfix logs directly to the filesystem via OSSP fsl
110 o Berkeley-DB dictionary support
111 o PCRE matching support
112 o Optional STARTTLS encryption support (see package options)
113 o Optional SASL2 authentication support (see package options)
114 o Optional MySQL dictionary support (see package options)
115 o Optional PostgreSQL dictionary support (see package options)
116 o Optional OpenLDAP dictionary support (see package options)
117 o Optional WHOSON dictionary support (see package options)
119 %track
120 prog postfix = {
121 version = %{V_postfix}
122 url = ftp://ftp.porcupine.org/mirrors/postfix-release/official/
123 regex = postfix-(\d+\.\d+\.\d+)\.tar\.gz
124 }
125 prog postfix:pflogsumm = {
126 version = %{V_pflogsumm}
127 url = http://jimsun.linxnet.com/postfix_contrib.html
128 regex = pflogsumm-(__VER__)\.tar\.gz
129 }
130 prog postfix:whoson = {
131 version = %{V_whoson}
132 url = ftp://ftp.openpkg.org/sources/CPY/postfix/
133 regex = postfix-(__VER__)-whoson.patch
134 }
136 %prep
137 # unpack distribution files
138 %setup -q
139 %setup -q -T -D -a 1
141 # apply OpenPKG patches
142 %patch -p0
143 ( cd pflogsumm-%{V_pflogsumm} && %{l_patch} -p0 -b <%{PATCH1} ) || exit $?
145 # apply vendor WHOSON patch
146 %if "%{with_whoson}" == "yes"
147 %patch -p0 -P 2
148 %endif
150 %build
151 # configure Postfix (hard-core part I)
152 %{l_shtool} subst \
153 -e 's/var_config_dir, /var_command_dir, /' \
154 src/postfix/postfix.c
155 %{l_shtool} subst \
156 -e 's;config_directory/postfix-script;command_directory/postfix-script;' \
157 -e 's;config_directory/post-install;command_directory/postfix-install;' \
158 conf/postfix-script
159 %{l_shtool} subst \
160 -e 's;/usr/include;%{l_prefix}/include;g' \
161 makedefs
163 # configure Postfix (regular part)
164 unset LD_LIBRARY_PATH || true
165 CCARGS=""
166 CCARGS="$CCARGS %{l_cflags -O}"
167 CCARGS="$CCARGS %{l_cppflags}"
168 CCARGS="$CCARGS -DDEF_COMMAND_DIR=\\\"%{l_prefix}/sbin\\\""
169 CCARGS="$CCARGS -DDEF_SENDMAIL_PATH=\\\"%{l_prefix}/sbin/sendmail\\\""
170 CCARGS="$CCARGS -DDEF_CONFIG_DIR=\\\"%{l_prefix}/etc/postfix\\\""
171 CCARGS="$CCARGS -DDEF_DAEMON_DIR=\\\"%{l_prefix}/libexec/postfix\\\""
172 CCARGS="$CCARGS -DDEF_QUEUE_DIR=\\\"%{l_prefix}/var/postfix\\\""
173 CCARGS="$CCARGS -DDEF_DATA_DIR=\\\"%{l_prefix}/var/postfix/data\\\""
174 AUXLIBS=""
175 AUXLIBS="$AUXLIBS %{l_ldflags}"
176 CCARGS="$CCARGS -DHAS_DB"
177 AUXLIBS="$AUXLIBS -ldb"
178 CCARGS="$CCARGS -DHAS_PCRE"
179 AUXLIBS="$AUXLIBS -lpcre"
180 %if "%{with_mysql}" == "yes"
181 CCARGS="$CCARGS -DHAS_MYSQL %{l_cppflags mysql .}"
182 AUXLIBS="$AUXLIBS %{l_ldflags mysql .} -lmysqlclient -lz -lm"
183 %endif
184 %if "%{with_pgsql}" == "yes"
185 CCARGS="$CCARGS -DHAS_PGSQL %{l_cppflags postgresql .}"
186 AUXLIBS="$AUXLIBS -lpq -lssl -lcrypto -lcrypt"
187 %endif
188 %if "%{with_sasl}" == "yes"
189 CCARGS="$CCARGS -DUSE_SASL_AUTH -DUSE_CYRUS_SASL %{l_cppflags sasl .}"
190 AUXLIBS="$AUXLIBS -lsasl2 -lcrypt"
191 if [ -f /usr/lib/libdl.so -o -f /usr/lib/libdl.a ]; then
192 AUXLIBS="$AUXLIBS -ldl"
193 fi
194 if [ -f /usr/lib64/libdl.so -o -f /usr/lib64/libdl.a ]; then
195 AUXLIBS="$AUXLIBS -ldl"
196 fi
197 %endif
198 %if "%{with_ssl}" == "yes"
199 CCARGS="$CCARGS -DUSE_TLS"
200 AUXLIBS="$AUXLIBS -lssl -lcrypto"
201 %endif
202 %if "%{with_ldap}" == "yes"
203 CCARGS="$CCARGS -DHAS_LDAP"
204 AUXLIBS="$AUXLIBS -lldap -llber -lssl -lcrypto"
205 %endif
206 %if "%{with_fsl}" == "yes"
207 AUXLIBS="$AUXLIBS %{l_fsl_ldflags} %{l_fsl_libs}"
208 CCARGS="$CCARGS -DUSE_SOFTLIMITONLY"
209 %endif
210 %if "%{with_fdsetsize}" != "no"
211 %if "%{with_fdsetsize}" == "yes"
212 CCARGS="$CCARGS -DFD_SETSIZE=1024"
213 %else
214 CCARGS="$CCARGS -DFD_SETSIZE=%{with_fdsetsize}"
215 %endif
216 %endif
217 case "%{l_platform -t}" in
218 *-sunos* ) AUXLIBS="$AUXLIBS -lrt" ;;
219 esac
220 %{l_make} %{l_mflags} -f Makefile.init makefiles \
221 CC="%{l_cc}" CCARGS="$CCARGS" AUXLIBS="$AUXLIBS"
223 # configure Postfix (hard-core part II)
224 %{l_shtool} subst \
225 -e 's;#define HAS_DBM;#define HAS_DBM_DISABLED;' \
226 -e 's;#define HAS_DB;#define HAS_DB_DISABLED;' \
227 src/util/sys_defs.h
229 # build Postfix
230 %{l_make} %{l_mflags}
232 %install
233 rm -rf $RPM_BUILD_ROOT
235 # perform standard installation procedure
236 %{l_shtool} subst -e "s;chown;true;" postfix-install
237 sh postfix-install -non-interactive \
238 install_root=$RPM_BUILD_ROOT \
239 config_directory=%{l_prefix}/etc/postfix \
240 daemon_directory=%{l_prefix}/libexec/postfix \
241 command_directory=%{l_prefix}/sbin \
242 queue_directory=%{l_prefix}/var/postfix \
243 data_directory=%{l_prefix}/var/postfix/data \
244 sendmail_path=%{l_prefix}/sbin/sendmail \
245 newaliases_path=%{l_prefix}/sbin/newaliases \
246 mailq_path=%{l_prefix}/sbin/mailq \
247 manpage_directory=%{l_prefix}/man \
248 mail_user=%{l_musr} \
249 setgid_group=%{l_rgrp}
251 # post-adjust binaries
252 rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/mailq
253 ln $RPM_BUILD_ROOT%{l_prefix}/sbin/sendmail \
254 $RPM_BUILD_ROOT%{l_prefix}/sbin/mailq
255 rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/newaliases
256 ln $RPM_BUILD_ROOT%{l_prefix}/sbin/sendmail \
257 $RPM_BUILD_ROOT%{l_prefix}/sbin/newaliases
258 strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
259 strip $RPM_BUILD_ROOT%{l_prefix}/libexec/postfix/* >/dev/null 2>&1 || true
261 # post-adjust configuration
262 for cfg in \
263 *LICENSE makedefs.out bounce.cf.default access aliases \
264 canonical header_checks relocated transport virtual \
265 main.cf master.cf main.cf.default; do
266 rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/$cfg
267 done
268 mv $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/postfix-script \
269 $RPM_BUILD_ROOT%{l_prefix}/sbin/postfix-script
270 rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/postfix-script*
271 mv $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/post-install \
272 $RPM_BUILD_ROOT%{l_prefix}/sbin/postfix-install
274 # install default configuration
275 for name in `grep "^<file" %{SOURCE postfix.txt} | sed -e 's;^.*name=";;' -e 's;".*$;;'`; do
276 (echo ""; cat %{SOURCE postfix.txt}; echo "") |\
277 sed -e "1,/^<file name=\"$name\">/d" -e "/<\/file>/,\$d" >$name
278 %{l_shtool} install -c -m 644 %{l_value -s -a} \
279 $name $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/
280 done
282 # pre-create variable stuff
283 ( cd $RPM_BUILD_ROOT%{l_prefix}/var/postfix
284 %{l_shtool} mkdir -f -p -m 700 data
285 %{l_shtool} mkdir -f -p -m 755 log
286 ) || exit $?
288 # install addons
289 %{l_shtool} install -c -m 755 \
290 -e 's;/usr/sbin/sendmail;%{l_prefix}/sbin/sendmail;g' \
291 auxiliary/rmail/rmail $RPM_BUILD_ROOT%{l_prefix}/sbin/rmail
292 %{l_shtool} install -c -m 755 \
293 -e 's;/usr/bin/perl;%{l_prefix}/bin/perl;g' \
294 -e 's;postconf -h;%{l_prefix}/sbin/postconf -h;' \
295 auxiliary/qshape/qshape.pl $RPM_BUILD_ROOT%{l_prefix}/sbin/qshape
296 %{l_shtool} install -c -m 644 \
297 man/man1/qshape.1 $RPM_BUILD_ROOT%{l_prefix}/man/man8/qshape.8
298 ( cd pflogsumm-%{V_pflogsumm}
299 %{l_shtool} install -c -m 755 \
300 -e 's;/usr/bin/perl;%{l_prefix}/bin/perl;g' \
301 pflogsumm.pl $RPM_BUILD_ROOT%{l_prefix}/sbin/pflogsumm
302 %{l_shtool} install -c -m 644 \
303 pflogsumm.1 $RPM_BUILD_ROOT%{l_prefix}/man/man1/
304 ) || exit $?
306 # install run-command script
307 %{l_shtool} mkdir -f -p -m 755 \
308 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
309 %{l_shtool} install -c -m 755 %{l_value -s -a} \
310 %{SOURCE rc.postfix} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
312 # adjust installation to avoid file name conflicts
313 ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man8
314 mv master.8 postfix_master.8
315 ) || exit $?
317 # install OSSP fsl configuration
318 %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
319 %{l_shtool} install -c -m 644 %{l_value -s -a} \
320 %{SOURCE fsl.postfix} \
321 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
323 # generate file list
324 %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
325 %{l_files_std} \
326 '%config %{l_prefix}/etc/fsl/fsl.postfix' \
327 '%attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/postfix' \
328 '%config %attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/postfix/*' \
329 '%attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/libexec/postfix/*' \
330 '%attr(2755,%{l_musr},%{l_rgrp}) %{l_prefix}/sbin/{postdrop,postqueue}' \
331 '%dir %attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/libexec/postfix' \
332 '%dir %attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/var/postfix' \
333 '%dir %attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/var/postfix/{maildrop,public}'
335 %files -f files
337 %clean
338 rm -rf $RPM_BUILD_ROOT
340 %pre
341 # before upgrade, save status and stop service
342 [ $1 -eq 2 ] || exit 0
343 eval `%{l_rc} postfix status 2>/dev/null | tee %{l_tmpfile}`
344 %{l_rc} postfix stop 2>/dev/null
345 exit 0
347 %post
348 if [ $1 -eq 1 ]; then
349 # after install, generate configuration
350 ( cd $RPM_INSTALL_PREFIX/etc/postfix && %{l_make} all; true ) >/dev/null 2>&1
351 fi
352 if [ $1 -eq 2 ]; then
353 # after upgrade, regenerate configuration
354 ( cd $RPM_INSTALL_PREFIX/etc/postfix && %{l_make} clean all; true ) >/dev/null 2>&1
355 # after upgrade, restore status
356 eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile} >/dev/null 2>&1 || true
357 [ ".$postfix_active" = .yes ] && %{l_rc} postfix start
358 fi
359 exit 0
361 %preun
362 # before erase, stop service and remove log files
363 [ $1 -eq 0 ] || exit 0
364 %{l_rc} postfix stop 2>/dev/null
365 rm -f $RPM_INSTALL_PREFIX/var/postfix/log/postfix.log* >/dev/null 2>&1 || true
366 rm -f $RPM_INSTALL_PREFIX/var/postfix/log/postfix.sum* >/dev/null 2>&1 || true
367 # remove generated configuration files
368 ( cd $RPM_INSTALL_PREFIX/etc/postfix && %{l_make} clean >/dev/null 2>&1; true ) || true
369 # remove generated run-time files and directories
370 rm -rf $RPM_INSTALL_PREFIX/etc/postfix/data/*
371 rm -rf $RPM_INSTALL_PREFIX/var/postfix/pid/*
372 rm -rf $RPM_INSTALL_PREFIX/var/postfix/private/*
373 rm -rf $RPM_INSTALL_PREFIX/var/postfix/public/*
374 find $RPM_INSTALL_PREFIX/var/postfix/active/ -type d -print |\
375 xargs rmdir >/dev/null 2>&1 || true
376 find $RPM_INSTALL_PREFIX/var/postfix/incoming/ -type d -print |\
377 xargs rmdir >/dev/null 2>&1 || true
378 exit 0