##
## postfix.spec -- OpenPKG RPM Specification
## Copyright (c) 2000-2003 The OpenPKG Project
## Copyright (c) 2000-2003 Ralf S. Engelschall
## Copyright (c) 2000-2003 Cable & Wireless
##
## Permission to use, copy, modify, and distribute this software for
## any purpose with or without fee is hereby granted, provided that
## the above copyright notice and this permission notice appear in all
## copies.
##
## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
## SUCH DAMAGE.
##
# package versions
%define V_postfix 2.0.16
%define V_tls 0.8.16-2.0.16-0.9.7b
%define V_pflogsumm 1.0.15
%define V_whoson 2.0.0.2
# package information
Name: postfix
Summary: Mail Transfer Agent (MTA)
URL: http://www.postfix.org/
Vendor: Wietse Venema
Packager: The OpenPKG Project
Distribution: OpenPKG [BASE]
Group: Mail
License: IPL
Version: %{V_postfix}
Release: 20031017
# package options
%option with_fsl yes
%option with_tls no
%option with_sasl no
%option with_mysql no
%option with_ldap no
%option with_whoson no
%option with_fdsetsize no
# list of sources
Source0: ftp://ftp.porcupine.org/mirrors/postfix-release/official/postfix-%{V_postfix}.tar.gz
Source1: ftp://ftp.aet.tu-cottbus.de/pub/postfix_tls/pfixtls-%{V_tls}.tar.gz
Source2: http://jimsun.linxnet.com/downloads/pflogsumm-%{V_pflogsumm}.tar.gz
Source3: http://sbserv.stahl.bau.tu-bs.de/~hildeb/postfix/scripts/qshape
Source4: etc.tar
Source5: fsl.postfix
Source6: rc.postfix
Patch0: postfix.patch
Patch1: postfix.patch.pfls
Patch2: ftp://victor.teaser.fr/pub/lwa/postfix/postfix-%{V_whoson}-whoson.patch
# build information
Prefix: %{l_prefix}
BuildRoot: %{l_buildroot}
BuildPreReq: OpenPKG, openpkg >= 20030718, perl
PreReq: OpenPKG, openpkg >= 20030718, perl, procmail, perl-time
BuildPreReq: pcre, db
PreReq: pcre, db
%if "%{with_fsl}" == "yes"
BuildPreReq: fsl >= 1.3.0
PreReq: fsl >= 1.3.0
%endif
%if "%{with_tls}" == "yes"
BuildPreReq: openssl
PreReq: openssl
%endif
%if "%{with_sasl}" == "yes"
BuildPreReq: sasl
PreReq: sasl
%endif
%if "%{with_mysql}" == "yes"
BuildPreReq: mysql
PreReq: mysql
%endif
%if "%{with_ldap}" == "yes"
BuildPreReq: openldap, openssl
PreReq: openldap, openssl
%endif
%if "%{with_whoson}" == "yes"
BuildPreReq: whoson
PreReq: whoson
%endif
AutoReq: no
AutoReqProv: no
Provides: MTA
Conflicts: exim, sendmail, ssmtp
%description
Postfix is a new-generation Mail Transfer Agent (MTA) able to fully
replace the Sendmail MTA.
Local specifics in this OpenPKG version:
o Postfix delivers locally via Procmail
o Postfix logs directly to the filesystem and not via syslog(3)
o Berkeley-DB lookup table support
o PCRE matching support
o Optional STARTTLS support (see package options below)
o Optional SASL2 authentication support (see package options below)
o Optional MySQL support (see package options below)
o Optional OpenLDAP support (see package options below)
o Optional WHOSON support (see package options below)
%prep
# unpack distribution files
%setup0 -q
%if "%{with_tls}" == "yes"
%setup1 -q -T -D -a 1
%endif
%setup2 -q -T -D -a 2
%setup4 -q -T -D -a 4
# apply SSL/TLS patch
%if "%{with_tls}" == "yes"
%{l_patch} -p1 /dev/null 2>&1 || true
strip $RPM_BUILD_ROOT%{l_prefix}/libexec/postfix/* >/dev/null 2>&1 || true
# post-adjust configuration
%{l_shtool} subst \
-e "s;^\\(mail_owner[^=]*=\\).*;\\1 %{l_musr};" \
$RPM_BUILD_ROOT%{l_prefix}/etc/postfix/main.cf
rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/*.orig
rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/LICENSE
mv $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/postfix-script \
$RPM_BUILD_ROOT%{l_prefix}/sbin/postfix-script
rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/postfix-script*
mv $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/post-install \
$RPM_BUILD_ROOT%{l_prefix}/sbin/postfix-install
( cd $RPM_BUILD_ROOT%{l_prefix}/etc/postfix
%{l_shtool} mkdir -f -p -m 755 sample
for cfg in access aliases canonical pcre_table regexp_table \
relocated sample-* transport virtual \
main.cf master.cf main.cf.default; do
mv $cfg sample/
done
) || exit $?
# install default configuration
%{l_shtool} install -c -m 644 %{l_value -s -a} \
etc/* $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/
# pre-create variable stuff
( cd $RPM_BUILD_ROOT%{l_prefix}/var/postfix
%{l_shtool} mkdir -f -p -m 700 \
active bounce corrupt defer deferred \
flush incoming private saved
%{l_shtool} mkdir -f -p -m 730 maildrop
%{l_shtool} mkdir -f -p -m 710 public
%{l_shtool} mkdir -f -p -m 755 log pid
) || exit $?
# install addons
( cd pflogsumm-%{V_pflogsumm}
%{l_shtool} install -c -m 755 \
-e 's;/usr/bin/perl;%{l_prefix}/bin/perl;g' \
pflogsumm.pl $RPM_BUILD_ROOT%{l_prefix}/sbin/pflogsumm
%{l_shtool} install -c -m 644 \
pflogsumm.1 $RPM_BUILD_ROOT%{l_prefix}/man/man1/
) || exit $?
%{l_shtool} install -c -m 750 \
-e 's;^#!/usr/bin/perl;#!%{l_prefix}/bin/perl;' \
-e 's;/usr/sbin/postconf;%{l_prefix}/sbin/postconf;' \
%{SOURCE qshape} $RPM_BUILD_ROOT%{l_prefix}/sbin/
# install run-command script
%{l_shtool} mkdir -f -p -m 755 \
$RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
%{l_shtool} install -c -m 755 %{l_value -s -a} \
%{SOURCE rc.postfix} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
# adjust installation to avoid file name conflicts
( cd $RPM_BUILD_ROOT%{l_prefix}/man/man8
mv master.8 postfix_master.8
) || exit $?
# install OSSP fsl configuration
%{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
%{l_shtool} install -c -m 644 %{l_value -s -a} \
%{SOURCE fsl.postfix} \
$RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
# generate file list
%{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
%{l_files_std} \
'%not %dir %{l_prefix}/etc/fsl' \
'%config %{l_prefix}/etc/fsl/fsl.postfix' \
'%attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/postfix' \
'%config %attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/postfix/*' \
'%attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/libexec/postfix/*' \
'%attr(2755,%{l_musr},%{l_rgrp}) %{l_prefix}/sbin/{postdrop,postqueue}' \
'%attr(0750,%{l_susr},%{l_mgrp}) %{l_prefix}/sbin/qshape' \
'%dir %attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/libexec/postfix' \
'%dir %attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/var/postfix' \
'%dir %attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/var/postfix/{maildrop,public}'
%files -f files
%clean
rm -rf $RPM_BUILD_ROOT
%pre
# before upgrade, save status and stop service
[ $1 -eq 2 ] || exit 0
eval `%{l_rc} postfix status 2>/dev/null | tee %{l_tmpfile}`
%{l_rc} postfix stop 2>/dev/null
exit 0
%post
if [ $1 -eq 1 ]; then
# after install, generate configuration
( cd $RPM_INSTALL_PREFIX/etc/postfix && %{l_make} all; true ) >/dev/null 2>&1
fi
if [ $1 -eq 2 ]; then
# after upgrade, regenerate configuration
( cd $RPM_INSTALL_PREFIX/etc/postfix && %{l_make} clean all; true ) >/dev/null 2>&1
# after upgrade, restore status
eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile} >/dev/null 2>&1 || true
[ ".$postfix_active" = .yes ] && %{l_rc} postfix start
fi
exit 0
%preun
# before erase, stop service and remove log files
[ $1 -eq 0 ] || exit 0
%{l_rc} postfix stop 2>/dev/null
rm -f $RPM_INSTALL_PREFIX/var/postfix/log/postfix.log* >/dev/null 2>&1 || true
# remove generated configuration files
( cd $RPM_INSTALL_PREFIX/etc/postfix/; %{l_make} clean >/dev/null 2>&1 || true ) || true
# remove generated run-time files and directories
rm -rf $RPM_INSTALL_PREFIX/etc/postfix/prng_exch
rm -rf $RPM_INSTALL_PREFIX/var/postfix/pid/*
rm -rf $RPM_INSTALL_PREFIX/var/postfix/private/*
rm -rf $RPM_INSTALL_PREFIX/var/postfix/public/*
find $RPM_INSTALL_PREFIX/var/postfix/active/ -type d -print |\
xargs rmdir >/dev/null 2>&1 || true
find $RPM_INSTALL_PREFIX/var/postfix/incoming/ -type d -print |\
xargs rmdir >/dev/null 2>&1 || true
exit 0