michael@146: ## michael@146: ## postfix.spec -- OpenPKG RPM Package Specification michael@178: ## Copyright (c) 2000-2009 OpenPKG Foundation e.V. michael@146: ## michael@146: ## Permission to use, copy, modify, and distribute this software for michael@146: ## any purpose with or without fee is hereby granted, provided that michael@146: ## the above copyright notice and this permission notice appear in all michael@146: ## copies. michael@146: ## michael@146: ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED michael@146: ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF michael@146: ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. michael@146: ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR michael@146: ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, michael@146: ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT michael@146: ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF michael@146: ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND michael@146: ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, michael@146: ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT michael@146: ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF michael@146: ## SUCH DAMAGE. michael@146: ## michael@146: michael@146: # package versions michael@495: %define V_postfix 2.9.4 michael@495: %define V_pflogsumm 1.1.5 michael@146: %define V_whoson 2.4.0 michael@146: michael@146: # package information michael@146: Name: postfix michael@146: Summary: Mail Transfer Agent (MTA) michael@146: URL: http://www.postfix.org/ michael@146: Vendor: Wietse Venema michael@146: Packager: OpenPKG Foundation e.V. michael@146: Distribution: OpenPKG Community michael@146: Class: BASE michael@146: Group: Mail michael@146: License: IPL michael@146: Version: %{V_postfix} michael@495: Release: 20120800 michael@146: michael@146: # package options michael@146: %option with_fsl yes michael@146: %option with_ssl no michael@146: %option with_sasl no michael@495: %option with_sqlite no michael@146: %option with_mysql no michael@146: %option with_pgsql no michael@146: %option with_ldap no michael@146: %option with_whoson no michael@676: %option with_spfsrs no michael@146: %option with_fdsetsize no michael@146: michael@146: # list of sources michael@146: Source0: ftp://ftp.porcupine.org/mirrors/postfix-release/official/postfix-%{V_postfix}.tar.gz michael@146: Source1: http://jimsun.linxnet.com/downloads/pflogsumm-%{V_pflogsumm}.tar.gz michael@146: Source2: postfix.txt michael@146: Source3: fsl.postfix michael@146: Source4: rc.postfix michael@146: Patch0: postfix.patch michael@146: Patch1: postfix.patch.pfls michael@495: Patch2: http://download.openpkg.org/components/versioned/postfix/postfix-%{V_whoson}-whoson.patch michael@676: Patch3: postfix-srs.patch michael@146: michael@146: # build information michael@671: BuildPreReq: OpenPKG, openpkg >= 20100101, perl, gcc michael@671: PreReq: OpenPKG, openpkg >= 20100101, perl, procmail, perl-time michael@146: BuildPreReq: make, pcre, db michael@146: PreReq: make, pcre, db michael@146: %if "%{with_fsl}" == "yes" michael@146: BuildPreReq: fsl michael@146: PreReq: fsl michael@146: %endif michael@146: %if "%{with_ssl}" == "yes" michael@146: BuildPreReq: openssl michael@146: PreReq: openssl michael@146: %endif michael@146: %if "%{with_sasl}" == "yes" michael@146: BuildPreReq: sasl michael@146: PreReq: sasl michael@146: %endif michael@495: %if "%{with_sqlite}" == "yes" michael@495: BuildPreReq: sqlite michael@495: PreReq: sqlite michael@495: %endif michael@146: %if "%{with_mysql}" == "yes" michael@146: BuildPreReq: mysql michael@146: PreReq: mysql michael@146: %endif michael@146: %if "%{with_pgsql}" == "yes" michael@146: BuildPreReq: postgresql, openssl michael@146: PreReq: postgresql, openssl michael@146: %endif michael@146: %if "%{with_ldap}" == "yes" michael@146: BuildPreReq: openldap, openssl michael@146: PreReq: openldap, openssl michael@146: %endif michael@146: %if "%{with_whoson}" == "yes" michael@146: BuildPreReq: whoson michael@146: PreReq: whoson michael@146: %endif michael@676: %if "%{with_spfsrs}" == "yes" michael@676: BuildPreReq: libsrs2 michael@676: PreReq: libsrs2 michael@676: %endif michael@146: Provides: MTA michael@146: Conflicts: exim, sendmail, ssmtp michael@146: michael@146: %description michael@146: Postfix is a new-generation Mail Transfer Agent (MTA) able to fully michael@146: replace the Sendmail MTA. It is fully standards compliant and michael@146: supports SMTP, ESMTP, LMTP over IPv4/IPv6 with optional TLS/SASL. michael@146: michael@146: Local specifics in this OpenPKG version: michael@146: o Postfix delivers locally via Procmail michael@146: o Postfix logs directly to the filesystem via OSSP fsl michael@146: o Berkeley-DB dictionary support michael@146: o PCRE matching support michael@146: o Optional STARTTLS encryption support (see package options) michael@146: o Optional SASL2 authentication support (see package options) michael@495: o Optional SQLite dictionary support (see package options) michael@146: o Optional MySQL dictionary support (see package options) michael@146: o Optional PostgreSQL dictionary support (see package options) michael@146: o Optional OpenLDAP dictionary support (see package options) michael@146: o Optional WHOSON dictionary support (see package options) michael@676: o Optional SPF SRS protection support (see package options) michael@146: michael@146: %track michael@146: prog postfix = { michael@146: version = %{V_postfix} michael@146: url = ftp://ftp.porcupine.org/mirrors/postfix-release/official/ michael@146: regex = postfix-(\d+\.\d+\.\d+)\.tar\.gz michael@146: } michael@146: prog postfix:pflogsumm = { michael@146: version = %{V_pflogsumm} michael@146: url = http://jimsun.linxnet.com/postfix_contrib.html michael@146: regex = pflogsumm-(__VER__)\.tar\.gz michael@146: } michael@146: prog postfix:whoson = { michael@146: version = %{V_whoson} michael@495: url = http://download.openpkg.org/components/versioned/postfix/ michael@146: regex = postfix-(__VER__)-whoson.patch michael@146: } michael@676: prog postfix:spfsrs = { michael@676: version = %{V_spfsrs} michael@676: url = http://www.codefrickler.de/srs/ michael@676: regex = postfix-srs-(__VER__).patch michael@676: } michael@146: michael@146: %prep michael@146: # unpack distribution files michael@146: %setup -q michael@146: %setup -q -T -D -a 1 michael@146: michael@146: # apply OpenPKG patches michael@146: %patch -p0 michael@146: ( cd pflogsumm-%{V_pflogsumm} && %{l_patch} -p0 -b <%{PATCH1} ) || exit $? michael@146: michael@495: # apply vendor WHOSON patch michael@495: %if "%{with_whoson}" == "yes" michael@495: %patch -p0 -P 2 michael@495: %endif michael@495: michael@676: # apply vendor SPF SRS patch michael@676: %if "%{with_spfsrs}" == "yes" michael@676: %patch -p0 -P 3 michael@676: %endif michael@676: michael@178: # remove OpenPKG privelege model incompatible exit conditions michael@178: %{l_shtool} subst \ michael@178: -e 's;msg_fatal\(.*attribute specifies mail system\);msg_info\1;g' \ michael@178: src/pipe/pipe.c michael@178: michael@495: # platform specific corrections michael@495: case "%{l_platform -t}" in michael@495: *-sunos5.11 ) michael@495: %{l_shtool} subst \ michael@495: -e 's;#define HAS_NISPLUS;#undef HAS_NISPLUS;' \ michael@495: src/util/sys_defs.h michael@495: ;; michael@495: esac michael@146: michael@146: %build michael@146: # configure Postfix (hard-core part I) michael@146: %{l_shtool} subst \ michael@146: -e 's/var_config_dir, /var_command_dir, /' \ michael@146: src/postfix/postfix.c michael@146: %{l_shtool} subst \ michael@146: -e 's;config_directory/postfix-script;command_directory/postfix-script;' \ michael@146: -e 's;config_directory/post-install;command_directory/postfix-install;' \ michael@146: conf/postfix-script michael@146: %{l_shtool} subst \ michael@146: -e 's;/usr/include;%{l_prefix}/include;g' \ michael@146: makedefs michael@146: michael@146: # configure Postfix (regular part) michael@672: rflags=`echo $LD_LIBRARY_PATH | %{l_shtool} subst -e 's;\(.\);-R\1;'` michael@672: rflags=`echo $rflags | %{l_shtool} subst -e 's/:/ -R/g'` michael@146: unset LD_LIBRARY_PATH || true michael@146: CCARGS="" michael@146: CCARGS="$CCARGS %{l_cflags -O}" michael@146: CCARGS="$CCARGS %{l_cppflags}" michael@146: CCARGS="$CCARGS -DDEF_COMMAND_DIR=\\\"%{l_prefix}/sbin\\\"" michael@146: CCARGS="$CCARGS -DDEF_SENDMAIL_PATH=\\\"%{l_prefix}/sbin/sendmail\\\"" michael@146: CCARGS="$CCARGS -DDEF_CONFIG_DIR=\\\"%{l_prefix}/etc/postfix\\\"" michael@146: CCARGS="$CCARGS -DDEF_DAEMON_DIR=\\\"%{l_prefix}/libexec/postfix\\\"" michael@146: CCARGS="$CCARGS -DDEF_QUEUE_DIR=\\\"%{l_prefix}/var/postfix\\\"" michael@146: CCARGS="$CCARGS -DDEF_DATA_DIR=\\\"%{l_prefix}/var/postfix/data\\\"" michael@146: AUXLIBS="" michael@672: AUXLIBS="$AUXLIBS $rflags %{l_ldflags}" michael@146: CCARGS="$CCARGS -DHAS_DB" michael@146: AUXLIBS="$AUXLIBS -ldb" michael@146: CCARGS="$CCARGS -DHAS_PCRE" michael@146: AUXLIBS="$AUXLIBS -lpcre" michael@495: %if "%{with_sqlite}" == "yes" michael@495: CCARGS="$CCARGS -DHAS_SQLITE" michael@495: AUXLIBS="$AUXLIBS -lsqlite3" michael@495: %endif michael@146: %if "%{with_mysql}" == "yes" michael@146: CCARGS="$CCARGS -DHAS_MYSQL %{l_cppflags mysql .}" michael@146: AUXLIBS="$AUXLIBS %{l_ldflags mysql .} -lmysqlclient -lz -lm" michael@146: %endif michael@146: %if "%{with_pgsql}" == "yes" michael@146: CCARGS="$CCARGS -DHAS_PGSQL %{l_cppflags postgresql .}" michael@146: AUXLIBS="$AUXLIBS -lpq -lssl -lcrypto -lcrypt" michael@146: %endif michael@146: %if "%{with_sasl}" == "yes" michael@146: CCARGS="$CCARGS -DUSE_SASL_AUTH -DUSE_CYRUS_SASL %{l_cppflags sasl .}" michael@146: AUXLIBS="$AUXLIBS -lsasl2 -lcrypt" michael@146: if [ -f /usr/lib/libdl.so -o -f /usr/lib/libdl.a ]; then michael@146: AUXLIBS="$AUXLIBS -ldl" michael@146: fi michael@146: if [ -f /usr/lib64/libdl.so -o -f /usr/lib64/libdl.a ]; then michael@146: AUXLIBS="$AUXLIBS -ldl" michael@146: fi michael@146: %endif michael@146: %if "%{with_ssl}" == "yes" michael@146: CCARGS="$CCARGS -DUSE_TLS" michael@146: AUXLIBS="$AUXLIBS -lssl -lcrypto" michael@146: %endif michael@146: %if "%{with_ldap}" == "yes" michael@146: CCARGS="$CCARGS -DHAS_LDAP" michael@146: AUXLIBS="$AUXLIBS -lldap -llber -lssl -lcrypto" michael@146: %endif michael@146: %if "%{with_fsl}" == "yes" michael@146: AUXLIBS="$AUXLIBS %{l_fsl_ldflags} %{l_fsl_libs}" michael@146: CCARGS="$CCARGS -DUSE_SOFTLIMITONLY" michael@146: %endif michael@676: %if "%{with_spfsrs}" == "yes" michael@676: CCARGS="$CCARGS -DHAS_SRS" michael@676: AUXLIBS="$AUXLIBS -lsrs2" michael@676: %endif michael@146: %if "%{with_fdsetsize}" != "no" michael@146: %if "%{with_fdsetsize}" == "yes" michael@146: CCARGS="$CCARGS -DFD_SETSIZE=1024" michael@146: %else michael@146: CCARGS="$CCARGS -DFD_SETSIZE=%{with_fdsetsize}" michael@146: %endif michael@146: %endif michael@146: case "%{l_platform -t}" in michael@146: *-sunos* ) AUXLIBS="$AUXLIBS -lrt" ;; michael@146: esac michael@146: %{l_make} %{l_mflags} -f Makefile.init makefiles \ michael@146: CC="%{l_cc}" CCARGS="$CCARGS" AUXLIBS="$AUXLIBS" michael@146: michael@146: # configure Postfix (hard-core part II) michael@146: %{l_shtool} subst \ michael@146: -e 's;#define HAS_DBM;#define HAS_DBM_DISABLED;' \ michael@146: -e 's;#define HAS_DB;#define HAS_DB_DISABLED;' \ michael@146: src/util/sys_defs.h michael@146: michael@146: # build Postfix michael@495: %{l_make} %{l_mflags -O} michael@146: michael@146: %install michael@146: michael@146: # perform standard installation procedure michael@146: %{l_shtool} subst -e "s;chown;true;" postfix-install michael@146: sh postfix-install -non-interactive \ michael@146: install_root=$RPM_BUILD_ROOT \ michael@146: config_directory=%{l_prefix}/etc/postfix \ michael@146: daemon_directory=%{l_prefix}/libexec/postfix \ michael@146: command_directory=%{l_prefix}/sbin \ michael@146: queue_directory=%{l_prefix}/var/postfix \ michael@146: data_directory=%{l_prefix}/var/postfix/data \ michael@146: sendmail_path=%{l_prefix}/sbin/sendmail \ michael@146: newaliases_path=%{l_prefix}/sbin/newaliases \ michael@146: mailq_path=%{l_prefix}/sbin/mailq \ michael@146: manpage_directory=%{l_prefix}/man \ michael@146: mail_user=%{l_musr} \ michael@146: setgid_group=%{l_rgrp} michael@146: michael@146: # post-adjust binaries michael@146: rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/mailq michael@146: ln $RPM_BUILD_ROOT%{l_prefix}/sbin/sendmail \ michael@146: $RPM_BUILD_ROOT%{l_prefix}/sbin/mailq michael@146: rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/newaliases michael@146: ln $RPM_BUILD_ROOT%{l_prefix}/sbin/sendmail \ michael@146: $RPM_BUILD_ROOT%{l_prefix}/sbin/newaliases michael@146: strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true michael@146: strip $RPM_BUILD_ROOT%{l_prefix}/libexec/postfix/* >/dev/null 2>&1 || true michael@146: michael@146: # post-adjust configuration michael@146: for cfg in \ michael@146: *LICENSE makedefs.out bounce.cf.default access aliases \ michael@146: canonical header_checks relocated transport virtual \ michael@146: main.cf master.cf main.cf.default; do michael@146: rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/$cfg michael@146: done michael@146: michael@146: # install default configuration michael@146: for name in `grep "^/d" -e "/<\/file>/,\$d" >$name michael@146: %{l_shtool} install -c -m 644 %{l_value -s -a} \ michael@146: $name $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/ michael@146: done michael@146: michael@146: # pre-create variable stuff michael@146: ( cd $RPM_BUILD_ROOT%{l_prefix}/var/postfix michael@146: %{l_shtool} mkdir -f -p -m 700 data michael@146: %{l_shtool} mkdir -f -p -m 755 log michael@146: ) || exit $? michael@146: michael@146: # install addons michael@146: %{l_shtool} install -c -m 755 \ michael@146: -e 's;/usr/sbin/sendmail;%{l_prefix}/sbin/sendmail;g' \ michael@146: auxiliary/rmail/rmail $RPM_BUILD_ROOT%{l_prefix}/sbin/rmail michael@146: %{l_shtool} install -c -m 755 \ michael@146: -e 's;/usr/bin/perl;%{l_prefix}/bin/perl;g' \ michael@146: -e 's;postconf -h;%{l_prefix}/sbin/postconf -h;' \ michael@146: auxiliary/qshape/qshape.pl $RPM_BUILD_ROOT%{l_prefix}/sbin/qshape michael@146: %{l_shtool} install -c -m 644 \ michael@146: man/man1/qshape.1 $RPM_BUILD_ROOT%{l_prefix}/man/man8/qshape.8 michael@146: ( cd pflogsumm-%{V_pflogsumm} michael@146: %{l_shtool} install -c -m 755 \ michael@146: -e 's;/usr/bin/perl;%{l_prefix}/bin/perl;g' \ michael@146: pflogsumm.pl $RPM_BUILD_ROOT%{l_prefix}/sbin/pflogsumm michael@146: %{l_shtool} install -c -m 644 \ michael@146: pflogsumm.1 $RPM_BUILD_ROOT%{l_prefix}/man/man1/ michael@146: ) || exit $? michael@146: michael@146: # install run-command script michael@146: %{l_shtool} mkdir -f -p -m 755 \ michael@146: $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d michael@146: %{l_shtool} install -c -m 755 %{l_value -s -a} \ michael@146: %{SOURCE rc.postfix} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/ michael@146: michael@146: # adjust installation to avoid file name conflicts michael@146: ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man8 michael@146: mv master.8 postfix_master.8 michael@146: ) || exit $? michael@146: michael@146: # install OSSP fsl configuration michael@146: %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl michael@146: %{l_shtool} install -c -m 644 %{l_value -s -a} \ michael@146: %{SOURCE fsl.postfix} \ michael@146: $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/ michael@146: michael@146: # generate file list michael@146: %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \ michael@146: %{l_files_std} \ michael@146: '%config %{l_prefix}/etc/fsl/fsl.postfix' \ michael@146: '%attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/postfix' \ michael@146: '%config %attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/postfix/*' \ michael@146: '%attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/libexec/postfix/*' \ michael@146: '%attr(2755,%{l_musr},%{l_rgrp}) %{l_prefix}/sbin/{postdrop,postqueue}' \ michael@146: '%dir %attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/libexec/postfix' \ michael@146: '%dir %attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/var/postfix' \ michael@495: '%dir %attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/var/postfix/pid' \ michael@146: '%dir %attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/var/postfix/{maildrop,public}' michael@146: michael@146: %files -f files michael@146: michael@146: %clean michael@146: michael@146: %pre michael@146: # before upgrade, save status and stop service michael@146: [ $1 -eq 2 ] || exit 0 michael@146: eval `%{l_rc} postfix status 2>/dev/null | tee %{l_tmpfile}` michael@146: %{l_rc} postfix stop 2>/dev/null michael@146: exit 0 michael@146: michael@146: %post michael@146: if [ $1 -eq 1 ]; then michael@146: # after install, generate configuration michael@146: ( cd $RPM_INSTALL_PREFIX/etc/postfix && %{l_make} all; true ) >/dev/null 2>&1 michael@146: fi michael@146: if [ $1 -eq 2 ]; then michael@146: # after upgrade, regenerate configuration michael@146: ( cd $RPM_INSTALL_PREFIX/etc/postfix && %{l_make} clean all; true ) >/dev/null 2>&1 michael@146: # after upgrade, restore status michael@146: eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile} >/dev/null 2>&1 || true michael@146: [ ".$postfix_active" = .yes ] && %{l_rc} postfix start michael@146: fi michael@146: exit 0 michael@146: michael@146: %preun michael@146: # before erase, stop service and remove log files michael@146: [ $1 -eq 0 ] || exit 0 michael@146: %{l_rc} postfix stop 2>/dev/null michael@146: rm -f $RPM_INSTALL_PREFIX/var/postfix/log/postfix.log* >/dev/null 2>&1 || true michael@146: rm -f $RPM_INSTALL_PREFIX/var/postfix/log/postfix.sum* >/dev/null 2>&1 || true michael@146: # remove generated configuration files michael@146: ( cd $RPM_INSTALL_PREFIX/etc/postfix && %{l_make} clean >/dev/null 2>&1; true ) || true michael@495: # remove generated runtime files and directories michael@495: rm -rf $RPM_INSTALL_PREFIX/var/postfix/data/* michael@146: rm -rf $RPM_INSTALL_PREFIX/var/postfix/pid/* michael@146: rm -rf $RPM_INSTALL_PREFIX/var/postfix/private/* michael@146: rm -rf $RPM_INSTALL_PREFIX/var/postfix/public/* michael@146: find $RPM_INSTALL_PREFIX/var/postfix/active/ -type d -print |\ michael@146: xargs rmdir >/dev/null 2>&1 || true michael@146: find $RPM_INSTALL_PREFIX/var/postfix/incoming/ -type d -print |\ michael@146: xargs rmdir >/dev/null 2>&1 || true michael@146: exit 0 michael@146: