postfix/postfix.spec

Thu, 04 Oct 2012 20:30:05 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 04 Oct 2012 20:30:05 +0200
changeset 715
c10fb90893b9
parent 672
fcc7a5543835
permissions
-rw-r--r--

Correct out of date build configuration, porting to Solaris 11 network
link infrastructure and new libpcap logic. This additionally allows for
device drivers in subdirectories of /dev. Correct packaged nmap
personalities and signatures to work out of the box. Finally, hack
arpd logic to properly close sockets and quit on TERM by repeating
signaling in the run command script. Sadly, all this fails to correct
the run time behaviour of honeyd which fails to bind to the IP layer.

     1 ##
     2 ##  postfix.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 #   package versions
    25 %define       V_postfix      2.9.4
    26 %define       V_pflogsumm    1.1.5
    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:      20120800
    42 #   package options
    43 %option       with_fsl       yes
    44 %option       with_ssl       no
    45 %option       with_sasl      no
    46 %option       with_sqlite    no
    47 %option       with_mysql     no
    48 %option       with_pgsql     no
    49 %option       with_ldap      no
    50 %option       with_whoson    no
    51 %option       with_spfsrs    no
    52 %option       with_fdsetsize no
    54 #   list of sources
    55 Source0:      ftp://ftp.porcupine.org/mirrors/postfix-release/official/postfix-%{V_postfix}.tar.gz
    56 Source1:      http://jimsun.linxnet.com/downloads/pflogsumm-%{V_pflogsumm}.tar.gz
    57 Source2:      postfix.txt
    58 Source3:      fsl.postfix
    59 Source4:      rc.postfix
    60 Patch0:       postfix.patch
    61 Patch1:       postfix.patch.pfls
    62 Patch2:       http://download.openpkg.org/components/versioned/postfix/postfix-%{V_whoson}-whoson.patch
    63 Patch3:       postfix-srs.patch
    65 #   build information
    66 BuildPreReq:  OpenPKG, openpkg >= 20100101, perl, gcc
    67 PreReq:       OpenPKG, openpkg >= 20100101, perl, procmail, perl-time
    68 BuildPreReq:  make, pcre, db
    69 PreReq:       make, pcre, db
    70 %if "%{with_fsl}" == "yes"
    71 BuildPreReq:  fsl
    72 PreReq:       fsl
    73 %endif
    74 %if "%{with_ssl}" == "yes"
    75 BuildPreReq:  openssl
    76 PreReq:       openssl
    77 %endif
    78 %if "%{with_sasl}" == "yes"
    79 BuildPreReq:  sasl
    80 PreReq:       sasl
    81 %endif
    82 %if "%{with_sqlite}" == "yes"
    83 BuildPreReq:  sqlite
    84 PreReq:       sqlite
    85 %endif
    86 %if "%{with_mysql}" == "yes"
    87 BuildPreReq:  mysql
    88 PreReq:       mysql
    89 %endif
    90 %if "%{with_pgsql}" == "yes"
    91 BuildPreReq:  postgresql, openssl
    92 PreReq:       postgresql, openssl
    93 %endif
    94 %if "%{with_ldap}" == "yes"
    95 BuildPreReq:  openldap, openssl
    96 PreReq:       openldap, openssl
    97 %endif
    98 %if "%{with_whoson}" == "yes"
    99 BuildPreReq:  whoson
   100 PreReq:       whoson
   101 %endif
   102 %if "%{with_spfsrs}" == "yes"
   103 BuildPreReq:  libsrs2
   104 PreReq:       libsrs2
   105 %endif
   106 Provides:     MTA
   107 Conflicts:    exim, sendmail, ssmtp
   109 %description
   110     Postfix is a new-generation Mail Transfer Agent (MTA) able to fully
   111     replace the Sendmail MTA. It is fully standards compliant and
   112     supports SMTP, ESMTP, LMTP over IPv4/IPv6 with optional TLS/SASL.
   114     Local specifics in this OpenPKG version:
   115     o Postfix delivers locally via Procmail
   116     o Postfix logs directly to the filesystem via OSSP fsl
   117     o Berkeley-DB dictionary support
   118     o PCRE matching support
   119     o Optional STARTTLS encryption support   (see package options)
   120     o Optional SASL2 authentication support  (see package options)
   121     o Optional SQLite dictionary support     (see package options)
   122     o Optional MySQL dictionary support      (see package options)
   123     o Optional PostgreSQL dictionary support (see package options)
   124     o Optional OpenLDAP dictionary support   (see package options)
   125     o Optional WHOSON dictionary support     (see package options)
   126     o Optional SPF SRS protection support    (see package options)
   128 %track
   129     prog postfix = {
   130         version   = %{V_postfix}
   131         url       = ftp://ftp.porcupine.org/mirrors/postfix-release/official/
   132         regex     = postfix-(\d+\.\d+\.\d+)\.tar\.gz
   133     }
   134     prog postfix:pflogsumm = {
   135         version   = %{V_pflogsumm}
   136         url       = http://jimsun.linxnet.com/postfix_contrib.html
   137         regex     = pflogsumm-(__VER__)\.tar\.gz
   138     }
   139     prog postfix:whoson = {
   140         version   = %{V_whoson}
   141         url       = http://download.openpkg.org/components/versioned/postfix/
   142         regex     = postfix-(__VER__)-whoson.patch
   143     }
   144     prog postfix:spfsrs = {
   145         version   = %{V_spfsrs}
   146         url       = http://www.codefrickler.de/srs/
   147         regex     = postfix-srs-(__VER__).patch
   148     }
   150 %prep
   151     #   unpack distribution files
   152     %setup -q
   153     %setup -q -T -D -a 1
   155     #   apply OpenPKG patches
   156     %patch -p0
   157     ( cd pflogsumm-%{V_pflogsumm} && %{l_patch} -p0 -b <%{PATCH1} ) || exit $?
   159     #   apply vendor WHOSON patch
   160 %if "%{with_whoson}" == "yes"
   161     %patch -p0 -P 2
   162 %endif
   164     #   apply vendor SPF SRS patch
   165 %if "%{with_spfsrs}" == "yes"
   166     %patch -p0 -P 3
   167 %endif
   169     #   remove OpenPKG privelege model incompatible exit conditions
   170     %{l_shtool} subst \
   171         -e 's;msg_fatal\(.*attribute specifies mail system\);msg_info\1;g' \
   172         src/pipe/pipe.c
   174     #   platform specific corrections
   175     case "%{l_platform -t}" in
   176         *-sunos5.11 )
   177             %{l_shtool} subst \
   178                 -e 's;#define HAS_NISPLUS;#undef HAS_NISPLUS;' \
   179                 src/util/sys_defs.h
   180             ;;
   181     esac
   183 %build
   184     #   configure Postfix (hard-core part I)
   185     %{l_shtool} subst \
   186         -e 's/var_config_dir, /var_command_dir, /' \
   187         src/postfix/postfix.c
   188     %{l_shtool} subst \
   189         -e 's;config_directory/postfix-script;command_directory/postfix-script;' \
   190         -e 's;config_directory/post-install;command_directory/postfix-install;' \
   191         conf/postfix-script
   192     %{l_shtool} subst \
   193         -e 's;/usr/include;%{l_prefix}/include;g' \
   194         makedefs
   196     #   configure Postfix (regular part)
   197     rflags=`echo $LD_LIBRARY_PATH | %{l_shtool} subst -e 's;\(.\);-R\1;'`
   198     rflags=`echo $rflags | %{l_shtool} subst -e 's/:/ -R/g'`
   199     unset LD_LIBRARY_PATH || true
   200     CCARGS=""
   201     CCARGS="$CCARGS %{l_cflags -O}"
   202     CCARGS="$CCARGS %{l_cppflags}"
   203     CCARGS="$CCARGS -DDEF_COMMAND_DIR=\\\"%{l_prefix}/sbin\\\""
   204     CCARGS="$CCARGS -DDEF_SENDMAIL_PATH=\\\"%{l_prefix}/sbin/sendmail\\\""
   205     CCARGS="$CCARGS -DDEF_CONFIG_DIR=\\\"%{l_prefix}/etc/postfix\\\""
   206     CCARGS="$CCARGS -DDEF_DAEMON_DIR=\\\"%{l_prefix}/libexec/postfix\\\""
   207     CCARGS="$CCARGS -DDEF_QUEUE_DIR=\\\"%{l_prefix}/var/postfix\\\""
   208     CCARGS="$CCARGS -DDEF_DATA_DIR=\\\"%{l_prefix}/var/postfix/data\\\""
   209     AUXLIBS=""
   210     AUXLIBS="$AUXLIBS $rflags %{l_ldflags}"
   211     CCARGS="$CCARGS -DHAS_DB"
   212     AUXLIBS="$AUXLIBS -ldb"
   213     CCARGS="$CCARGS -DHAS_PCRE"
   214     AUXLIBS="$AUXLIBS -lpcre"
   215 %if "%{with_sqlite}" == "yes"
   216     CCARGS="$CCARGS -DHAS_SQLITE"
   217     AUXLIBS="$AUXLIBS -lsqlite3"
   218 %endif
   219 %if "%{with_mysql}" == "yes"
   220     CCARGS="$CCARGS -DHAS_MYSQL %{l_cppflags mysql .}"
   221     AUXLIBS="$AUXLIBS %{l_ldflags mysql .} -lmysqlclient -lz -lm"
   222 %endif
   223 %if "%{with_pgsql}" == "yes"
   224     CCARGS="$CCARGS -DHAS_PGSQL %{l_cppflags postgresql .}"
   225     AUXLIBS="$AUXLIBS -lpq -lssl -lcrypto -lcrypt"
   226 %endif
   227 %if "%{with_sasl}" == "yes"
   228     CCARGS="$CCARGS -DUSE_SASL_AUTH -DUSE_CYRUS_SASL %{l_cppflags sasl .}"
   229     AUXLIBS="$AUXLIBS -lsasl2 -lcrypt"
   230     if [ -f /usr/lib/libdl.so -o -f /usr/lib/libdl.a ]; then
   231         AUXLIBS="$AUXLIBS -ldl"
   232     fi
   233     if [ -f /usr/lib64/libdl.so -o -f /usr/lib64/libdl.a ]; then
   234         AUXLIBS="$AUXLIBS -ldl"
   235     fi
   236 %endif
   237 %if "%{with_ssl}" == "yes"
   238     CCARGS="$CCARGS -DUSE_TLS"
   239     AUXLIBS="$AUXLIBS -lssl -lcrypto"
   240 %endif
   241 %if "%{with_ldap}" == "yes"
   242     CCARGS="$CCARGS -DHAS_LDAP"
   243     AUXLIBS="$AUXLIBS -lldap -llber -lssl -lcrypto"
   244 %endif
   245 %if "%{with_fsl}" == "yes"
   246     AUXLIBS="$AUXLIBS %{l_fsl_ldflags} %{l_fsl_libs}"
   247     CCARGS="$CCARGS -DUSE_SOFTLIMITONLY"
   248 %endif
   249 %if "%{with_spfsrs}" == "yes"
   250     CCARGS="$CCARGS -DHAS_SRS"
   251     AUXLIBS="$AUXLIBS -lsrs2"
   252 %endif
   253 %if "%{with_fdsetsize}" != "no"
   254 %if "%{with_fdsetsize}" == "yes"
   255     CCARGS="$CCARGS -DFD_SETSIZE=1024"
   256 %else
   257     CCARGS="$CCARGS -DFD_SETSIZE=%{with_fdsetsize}"
   258 %endif
   259 %endif
   260     case "%{l_platform -t}" in
   261         *-sunos* ) AUXLIBS="$AUXLIBS -lrt" ;;
   262     esac
   263     %{l_make} %{l_mflags} -f Makefile.init makefiles \
   264         CC="%{l_cc}" CCARGS="$CCARGS" AUXLIBS="$AUXLIBS"
   266     #   configure Postfix (hard-core part II)
   267     %{l_shtool} subst \
   268         -e 's;#define HAS_DBM;#define HAS_DBM_DISABLED;' \
   269         -e 's;#define HAS_DB;#define HAS_DB_DISABLED;' \
   270         src/util/sys_defs.h
   272     #   build Postfix
   273     %{l_make} %{l_mflags -O}
   275 %install
   277     #   perform standard installation procedure
   278     %{l_shtool} subst -e "s;chown;true;" postfix-install
   279     sh postfix-install -non-interactive \
   280         install_root=$RPM_BUILD_ROOT \
   281         config_directory=%{l_prefix}/etc/postfix \
   282         daemon_directory=%{l_prefix}/libexec/postfix \
   283         command_directory=%{l_prefix}/sbin \
   284         queue_directory=%{l_prefix}/var/postfix \
   285         data_directory=%{l_prefix}/var/postfix/data \
   286         sendmail_path=%{l_prefix}/sbin/sendmail \
   287         newaliases_path=%{l_prefix}/sbin/newaliases \
   288         mailq_path=%{l_prefix}/sbin/mailq \
   289         manpage_directory=%{l_prefix}/man \
   290         mail_user=%{l_musr} \
   291         setgid_group=%{l_rgrp}
   293     #   post-adjust binaries
   294     rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/mailq
   295     ln $RPM_BUILD_ROOT%{l_prefix}/sbin/sendmail \
   296        $RPM_BUILD_ROOT%{l_prefix}/sbin/mailq
   297     rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/newaliases
   298     ln $RPM_BUILD_ROOT%{l_prefix}/sbin/sendmail \
   299        $RPM_BUILD_ROOT%{l_prefix}/sbin/newaliases
   300     strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
   301     strip $RPM_BUILD_ROOT%{l_prefix}/libexec/postfix/* >/dev/null 2>&1 || true
   303     #   post-adjust configuration
   304     for cfg in \
   305         *LICENSE makedefs.out bounce.cf.default access aliases \
   306         canonical header_checks relocated transport virtual \
   307         main.cf master.cf main.cf.default; do
   308         rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/$cfg
   309     done
   311     #   install default configuration
   312     for name in `grep "^<file" %{SOURCE postfix.txt} | sed -e 's;^.*name=";;' -e 's;".*$;;'`; do
   313         (echo ""; cat %{SOURCE postfix.txt}; echo "") |\
   314             sed -e "1,/^<file name=\"$name\">/d" -e "/<\/file>/,\$d" >$name
   315         %{l_shtool} install -c -m 644 %{l_value -s -a} \
   316             $name $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/
   317     done
   319     #   pre-create variable stuff
   320     ( cd $RPM_BUILD_ROOT%{l_prefix}/var/postfix
   321       %{l_shtool} mkdir -f -p -m 700 data
   322       %{l_shtool} mkdir -f -p -m 755 log
   323     ) || exit $?
   325     #   install addons
   326     %{l_shtool} install -c -m 755 \
   327         -e 's;/usr/sbin/sendmail;%{l_prefix}/sbin/sendmail;g' \
   328         auxiliary/rmail/rmail $RPM_BUILD_ROOT%{l_prefix}/sbin/rmail
   329     %{l_shtool} install -c -m 755 \
   330         -e 's;/usr/bin/perl;%{l_prefix}/bin/perl;g' \
   331         -e 's;postconf -h;%{l_prefix}/sbin/postconf -h;' \
   332         auxiliary/qshape/qshape.pl $RPM_BUILD_ROOT%{l_prefix}/sbin/qshape
   333     %{l_shtool} install -c -m 644 \
   334         man/man1/qshape.1 $RPM_BUILD_ROOT%{l_prefix}/man/man8/qshape.8
   335     ( cd pflogsumm-%{V_pflogsumm}
   336       %{l_shtool} install -c -m 755 \
   337           -e 's;/usr/bin/perl;%{l_prefix}/bin/perl;g' \
   338           pflogsumm.pl $RPM_BUILD_ROOT%{l_prefix}/sbin/pflogsumm
   339       %{l_shtool} install -c -m 644 \
   340           pflogsumm.1 $RPM_BUILD_ROOT%{l_prefix}/man/man1/
   341     ) || exit $?
   343     #   install run-command script
   344     %{l_shtool} mkdir -f -p -m 755 \
   345         $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
   346     %{l_shtool} install -c -m 755 %{l_value -s -a} \
   347         %{SOURCE rc.postfix} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
   349     #   adjust installation to avoid file name conflicts
   350     ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man8
   351       mv master.8 postfix_master.8
   352     ) || exit $?
   354     #   install OSSP fsl configuration
   355     %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
   356     %{l_shtool} install -c -m 644 %{l_value -s -a} \
   357         %{SOURCE fsl.postfix} \
   358         $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
   360     #   generate file list
   361     %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
   362         %{l_files_std} \
   363         '%config %{l_prefix}/etc/fsl/fsl.postfix' \
   364         '%attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/postfix' \
   365         '%config %attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/postfix/*' \
   366         '%attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/libexec/postfix/*' \
   367         '%attr(2755,%{l_musr},%{l_rgrp}) %{l_prefix}/sbin/{postdrop,postqueue}' \
   368         '%dir %attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/libexec/postfix' \
   369         '%dir %attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/var/postfix' \
   370         '%dir %attr(-,%{l_susr},%{l_mgrp}) %{l_prefix}/var/postfix/pid' \
   371         '%dir %attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/var/postfix/{maildrop,public}'
   373 %files -f files
   375 %clean
   377 %pre
   378     #   before upgrade, save status and stop service
   379     [ $1 -eq 2 ] || exit 0
   380     eval `%{l_rc} postfix status 2>/dev/null | tee %{l_tmpfile}`
   381     %{l_rc} postfix stop 2>/dev/null
   382     exit 0
   384 %post
   385     if [ $1 -eq 1 ]; then
   386         #   after install, generate configuration
   387         ( cd $RPM_INSTALL_PREFIX/etc/postfix && %{l_make} all; true ) >/dev/null 2>&1
   388     fi
   389     if [ $1 -eq 2 ]; then
   390         #   after upgrade, regenerate configuration
   391         ( cd $RPM_INSTALL_PREFIX/etc/postfix && %{l_make} clean all; true ) >/dev/null 2>&1
   392         #   after upgrade, restore status
   393         eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile} >/dev/null 2>&1 || true
   394         [ ".$postfix_active" = .yes ] && %{l_rc} postfix start
   395     fi
   396     exit 0
   398 %preun
   399     #   before erase, stop service and remove log files
   400     [ $1 -eq 0 ] || exit 0
   401     %{l_rc} postfix stop 2>/dev/null
   402     rm -f $RPM_INSTALL_PREFIX/var/postfix/log/postfix.log* >/dev/null 2>&1 || true
   403     rm -f $RPM_INSTALL_PREFIX/var/postfix/log/postfix.sum* >/dev/null 2>&1 || true
   404     #   remove generated configuration files
   405     ( cd $RPM_INSTALL_PREFIX/etc/postfix && %{l_make} clean >/dev/null 2>&1; true ) || true
   406     #   remove generated runtime files and directories
   407     rm -rf $RPM_INSTALL_PREFIX/var/postfix/data/*
   408     rm -rf $RPM_INSTALL_PREFIX/var/postfix/pid/*
   409     rm -rf $RPM_INSTALL_PREFIX/var/postfix/private/*
   410     rm -rf $RPM_INSTALL_PREFIX/var/postfix/public/*
   411     find $RPM_INSTALL_PREFIX/var/postfix/active/ -type d -print |\
   412         xargs rmdir >/dev/null 2>&1 || true
   413     find $RPM_INSTALL_PREFIX/var/postfix/incoming/ -type d -print |\
   414         xargs rmdir >/dev/null 2>&1 || true
   415     exit 0

mercurial