File sendmail.spec of Package sendmail

# spec file for package sendmail (Version 8.14.3)
# Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany.
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via

# norootforbuild

Name:           sendmail
BuildRequires:  mailx openldap2-devel procmail tcpd-devel vacation
%if %suse_version < 1030
BuildRequires:  db-devel
BuildRequires:  libdb-4_5-devel
%define         SUBDIRS libsmutil libsmdb sendmail mail.local mailstats makemap praliases rmail smrsh libmilter libsm editmap
License:        Any permissive
Group:          Productivity/Networking/Email/Servers
PreReq:         %fillup_prereq %insserv_prereq
PreReq:         /bin/mv /bin/rm /bin/sed
Provides:       sendcf smailcfg smtp_daemon sendmail-tls
Requires:       filesystem procmail netcfg m4 /bin/fuser
Conflicts:      smail postfix postfix-tls
Obsoletes:      sendmail-tls
AutoReqProv:    on
Version:        8.14.3
Release:        50.<RELEASE10>
Summary:        BSD Sendmail
Source0:        sendmail-%{version}.tar.bz2
Source1:        FAQ.sendmail-8.14.bz2
Source2:        sendmail-rpmlintrc
Patch0:         sendmail-%{version}.dif
Patch1:         sendmail-8.13.5-select.dif
Patch22:        sendmail-8.14.3-largeDNS.dif
Patch23:        sendmail-8.14.3-tls-null-char-cert.dif
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%global         _sysconfdir	%{_sysconfdir}
%global         _mailcnfdir	%{_sysconfdir}/mail
%global         _localstatedir  %{_localstatedir}

The "Unix System Administration Handbook" calls sendmail "The most
complex and complete mail delivery system in common use..." .

Ready-made configuration files are included for systems connected by
TCP/IP (with or without a name server) and for systems using UUCP.

'procmail' is used as a local mail agent.

"sendmail" is a trademark of Sendmail, Inc.

    Eric Allman <sendmail@sendmail.ORG>

%package -n sendmail-devel
Summary:        BSD Sendmail Development Kit
License:        Any permissive
Group:          Development/Libraries/Other
AutoReqProv:    on

%description -n sendmail-devel
This package includes libraries and header files for building tools to
access sendmail features.

"sendmail" is a trademark of Sendmail, Inc.

    Eric Allman <sendmail@sendmail.ORG>

%package -n rmail
Version:        8.14.3
Release:        50.<RELEASE10>
Summary:        Rmail of the BSD Sendmail
License:        Any permissive
Group:          Productivity/Networking/Email/Servers
AutoReqProv:    on

%description -n rmail
Rmail interprets incoming mail received via uucp and passing the
processed mail on to the MTA (e.g. sendmail).

    Eric Allman <sendmail@sendmail.ORG>

%patch -P 1 -p 0 -b .select
%patch -P 22 -p 0 -b .largedns
%patch -P 23 -p 0 -b .tlscert
%patch -P 0 -p 0
    set -f
    cat <<-EOF > file-list
	%%dir    %%attr(1750,root,root)   %{_localstatedir}/run/sendmail
	%%dir    %%attr(0750,root,root)   %{_localstatedir}/lib/sendmail
	%%attr(0600,root,root)            %{_localstatedir}/lib/sendmail/statistics
	%%attr(0600,root,root)            %{_mailcnfdir}/statistics
	%%dir    %%attr(0700,root,root)   %{_localstatedir}/spool/mqueue
	%%dir    %%attr(0700,root,root)   %{_localstatedir}/spool/mqueue/.hoststat
	# Part of filesystem RPM
	# %%dir    %%attr(0770,root,mail) %{_localstatedir}/spool/clientmqueue
	%%attr(0660,root,mail)            %{_localstatedir}/spool/clientmqueue/
	%%config %%attr(0644,root,root)   %{_sysconfdir}/permissions.d/sendmail
	%%config %%attr(0644,root,root)   %{_sysconfdir}/permissions.d/sendmail.paranoid
    set +f

    ID=$(id -u)
    RPM_OPT_FLAGS="${RPM_OPT_FLAGS} -fno-strict-aliasing"
    export ARCH_LIB
    # ingnore vacation (we have our own)
    make SUBDIRS="%{SUBDIRS}"

    ID=$(id -u)
    export ARCH_LIB
    if test "$ID" -ne 0 ; then
	mkdir bin
	(cat > bin/install)<<-EOF
	while test \$# -gt 0; do
	    case "\$1" in
	    -o) shift 2;;
	    -g) shift 2;;
	    *)  argv="\${argv:+"\$argv "}\$1"
	set -- \$(echo \${argv})
	exec -a install %{_bindir}/install \${1+"\$@"}
	chmod 755 bin/install
	type -p install
    mkdir -p ${doc}
    mkdir -p %{buildroot}/sbin/conf.d
    mkdir -p %{buildroot}%{_bindir}
    mkdir -p %{buildroot}%{_sbindir}
    mkdir -p %{buildroot}%{_mailcnfdir}/certs
    mkdir -p %{buildroot}%{_mailcnfdir}/auth
    mkdir -p %{buildroot}%{_sysconfdir}/init.d
    mkdir -p %{buildroot}%{_sysconfdir}/pam.d
    mkdir -p %{buildroot}%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services
    mkdir -p %{buildroot}%{_libdir}
    mkdir -p %{buildroot}%{_prefix}/lib/sendmail.d/bin
    mkdir -p %{buildroot}%{_datadir}/sendmail
    mkdir -p %{buildroot}%{_includedir}/sm
    mkdir -p %{buildroot}%{_includedir}/sm/os
    chmod 0750 %{buildroot}%{_mailcnfdir}/certs
    chmod 0750 %{buildroot}%{_mailcnfdir}/auth
    mkdir -p %{buildroot}%{_sysconfdir}/permissions.d
    mkdir -p %{buildroot}%{_mandir}/man1
    mkdir -p %{buildroot}%{_mandir}/man5
    mkdir -p %{buildroot}%{_mandir}/man8
    mkdir -p %{buildroot}%{_localstatedir}/adm/fillup-templates
    make \
	DESTDIR=%{buildroot} \
	MANROOTMAN=%{_mandir}/man \
	MANROOT=%{_mandir}/cat \
    # needed to be able to comple a milter which uses libsm, i.e. amavis-milter
    cd include/sm
    ln -s os/sm_os_linux.h sm_os.h
    cd ../../
    cd include/sm/os
    ln -s sm_os_linux.h sm_os.h
    cd ../../../
    cp -r include/sm   %{buildroot}%{_includedir}/
    test "$ID" -ne 0 || \
    chown root:root    %{buildroot}%{_mailcnfdir}/
    chmod 0644	       %{buildroot}%{_mailcnfdir}/
    test "$ID" -ne 0 || \
    chown root:mail    %{buildroot}%{_sbindir}/sendmail
    ln -sf %{_sbindir}/sendmail %{buildroot}%{_prefix}/lib/sendmail
    mv %{buildroot}%{_sbindir}/praliases \
    mkdir -p           %{buildroot}%{_localstatedir}/spool/mqueue/.hoststat
    test "$ID" -ne 0 || \
    chown -R root:root %{buildroot}%{_localstatedir}/spool/mqueue
    chmod 0700         %{buildroot}%{_localstatedir}/spool/mqueue
    chmod 0700         %{buildroot}%{_localstatedir}/spool/mqueue/.hoststat
    mkdir -p           %{buildroot}%{_localstatedir}/run/sendmail
    chmod 1750         %{buildroot}%{_localstatedir}/run/sendmail
    mkdir -p           %{buildroot}%{_localstatedir}/lib/sendmail
    chmod 0750         %{buildroot}%{_localstatedir}/lib/sendmail
    touch              %{buildroot}%{_localstatedir}/lib/sendmail/statistics
    test "$ID" -ne 0 || \
    chown -R root:root %{buildroot}%{_localstatedir}/lib/sendmail/statistics
    chmod 0600	       %{buildroot}%{_localstatedir}/lib/sendmail/statistics
    ln -sf %{_localstatedir}/lib/sendmail/statistics %{buildroot}%{_mailcnfdir}/statistics
    mkdir -p	       %{buildroot}%{_localstatedir}/spool/clientmqueue
    test "$ID" -ne 0 || \
    chown -R root:mail %{buildroot}%{_localstatedir}/spool/clientmqueue
    chmod 0770         %{buildroot}%{_localstatedir}/spool/clientmqueue
    touch              %{buildroot}%{_localstatedir}/spool/clientmqueue/
    test "$ID" -ne 0 || \
    chown -R root:mail %{buildroot}%{_localstatedir}/spool/clientmqueue/
    chmod 0660         %{buildroot}%{_localstatedir}/spool/clientmqueue/
    chmod 0755         %{buildroot}%{_prefix}/lib/sendmail.d
    chmod 0755         %{buildroot}%{_prefix}/lib/sendmail.d/bin
    chmod 0644         %{buildroot}%{_libdir}/*.a
    ln -sf %{_bindir}/vacation %{buildroot}%{_prefix}/lib/sendmail.d/bin/
    ln -sf %{_bindir}/mail     %{buildroot}%{_prefix}/lib/sendmail.d/bin/
    ln -sf %{_bindir}/procmail %{buildroot}%{_prefix}/lib/sendmail.d/bin/
    install -m 0644 K* README RELE* doc/op/ sendmail/SECURITY \
                       sendmail/TRACEFLAGS suse/README.SuSE \
                       contrib/{e*,re-*,sm*,passwd*}.pl \
		       contrib/etrn.0 ${doc}
    install -m 0644 %{SOURCE1} ${doc}/FAQ.sendmail.bz2
    GROFF_NO_SGR=1 groff -pe -me -mtty-char -Tlatin1 doc/op/ > ${doc}/op.txt
    install -m 0644 smrsh/README ${doc}/README.smrsh
    install -m 0644 libmilter/README ${doc}/README.libmilter
    bzip2 -9f ${doc}/*.ps
    bzip2 -9f ${doc}/*.txt
    bzip2 -9f ${doc}/RELEASE_NOTES
    tar cfC - cf . | tar xfC - %{buildroot}%{_datadir}/sendmail/
    test "$ID" -ne 0 || \
    chown root:root -R	%{buildroot}%{_datadir}/sendmail/
    chmod 0755		%{buildroot}%{_datadir}/sendmail/sh/
    rm -f  %{buildroot}%{_datadir}/sendmail/cf/Build
    rm -f  %{buildroot}%{_datadir}/sendmail/cf/README
    rm -f  %{buildroot}%{_datadir}/sendmail/cf/Makefile
    rm -f  %{buildroot}%{_datadir}/sendmail/cf/*.cf
    rm -fr %{buildroot}%{_datadir}/sendmail/*/*~ ${doc}/*~
    find %{buildroot}%{_datadir}/sendmail/ ${doc}/ \
					-name '*.ldap' -o -name '*.mime' -o \
					-name '*.mrbl' -o -name '*.util' -o \
					-name '*.dif' | xargs -r rm -f
    cd suse/
    # etc/aliases and %{_sysconfdir}/aliases.d are in other packages
    #install -m 0644 aliases %{buildroot}%{_sysconfdir}/
    #install -d -m 0750 %{buildroot}%{_sysconfdir}/aliases.d
    install -m 0644 README Makefile mailertable genericstable userdb domaintable \
		    virtusertable access \ service-nodns.switch \
		    service.switch relay-domains trusted-users \
		    local-host-names %{buildroot}%{_mailcnfdir}/
    install -m 0600 auth-info %{buildroot}%{_mailcnfdir}/auth/
    install -m 0755 sendmail.nissl %{buildroot}%{_sbindir}/
    install -m 0644 permissions %{buildroot}%{_sysconfdir}/permissions.d/sendmail
    install -m 0644 permissions.paranoid %{buildroot}%{_sysconfdir}/permissions.d/sendmail.paranoid
    install -m 0755 rc   %{buildroot}%{_sysconfdir}/init.d/sendmail
    install -m 0644 smtp %{buildroot}%{_sysconfdir}/pam.d/smtp
    install -m 0644 fw   %{buildroot}%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/sendmail
    install SuSEconfig.sendmail %{buildroot}/sbin/conf.d/
    install -m 0644 sysconfig.sendmail      %{buildroot}%{_localstatedir}/adm/fillup-templates/
    install -m 0644 sysconfig.mail-sendmail %{buildroot}%{_localstatedir}/adm/fillup-templates/
    > ${doc}/README.sendmail-local-only
    for m in messages/sendmail-local-only*; do
	cat $m >> ${doc}/README.sendmail-local-only
	echo   >> ${doc}/README.sendmail-local-only
    cd ../
    if test -n "%{buildroot}" ; then
	cat %{buildroot}%{_mailcnfdir}/		| \
	sed "s@include(\`@include(\`%{buildroot}@" | \
	m4 | \
	sed "s@%{buildroot}@@g"	> %{buildroot}%{_sysconfdir}/
	cat %{buildroot}%{_mailcnfdir}/	| \
	sed "s@include(\`@include(\`%{buildroot}@" | \
	m4 | \
	sed "s@%{buildroot}@@g"	> %{buildroot}%{_mailcnfdir}/
	m4 < %{_mailcnfdir}/		> %{_sysconfdir}/
	m4 < %{_mailcnfdir}/	> %{_mailcnfdir}/
    ln -sf %{_sysconfdir}/init.d/sendmail %{buildroot}%{_sbindir}/rcsendmail
    ln -sf ../aliases  %{buildroot}%{_mailcnfdir}/aliases
    pushd %{buildroot}%{_mailcnfdir}/
	make DESTDIR=%{buildroot} short
    # Remove some files we don't wish to package
    rm -f %{buildroot}%{_sysconfdir}/aliases %{buildroot}%{_mailcnfdir}/*.db
    rm -f %{buildroot}%{_mailcnfdir}/*/*.db

rm -rf %{buildroot}

# Check for rc.config: 
if test -f etc/rc.config ; then
  SMTP=$(. etc/rc.config 2>/dev/null; echo $SMTP)
  if test -n "$SMTP" ; then
    echo SMTP=$SMTP > var/adm/run-sendmail

# Trigger rebuild of old db's
for db in etc/aliases.db etc/aliases.d/*.db etc/mail/*.db etc/mail/*/*.db ; do
  test -e "$db"       || continue
  test -e "${db%.db}" || continue
  touch "${db%.db}"
# Put together
if test -f etc/rc.config.d/sendmail.rc.config ; then
  cat etc/rc.config.d/sendmail.rc.config >> etc/rc.config
  rm -f etc/rc.config.d/sendmail.rc.config
# Rename these on update
if test -f etc/rc.config ; then
  SENDMAIL_ARGS=$(. etc/rc.config 2>/dev/null; echo $SENDMAIL_ARGS)
  case "$SENDMAIL_ARGS" in
    *-L*-Am*) ;;
    *-Am*-L*) ;;
    *) SENDMAIL_ARGS="-L sendmail -Am $SENDMAIL_ARGS"
    -e "s@^SENDMAIL_NODNS=@NODNS=@" \
    -e "s@^SENDMAIL_DIALUP=@DIALUP=@" etc/rc.config > etc/
  test -s etc/ && mv etc/ etc/rc.config || true
# Should we listen for remote mails
if test -f var/adm/run-sendmail ; then
  . var/adm/run-sendmail
  if test "$SMTP" = "yes" -a -f var/adm/fillup-templates/sysconfig.mail-sendmail ; then
    sed -e 's@SMTPD_LISTEN_REMOTE="no"@SMTPD_LISTEN_REMOTE="yes"@' \
	  var/adm/fillup-templates/sysconfig.mail-sendmail \
	> var/adm/fillup-templates/
    test -s var/adm/fillup-templates/ &&
         mv var/adm/fillup-templates/ \
            var/adm/fillup-templates/sysconfig.mail-sendmail || true
# Update from newer SuSE releases or new installation
if test -f etc/sysconfig/mail ; then
  . etc/sysconfig/mail
%{fillup_and_insserv -nY sendmail sendmail}
%{fillup_only -an mail}

%{stop_on_removal sendmail}

%{restart_on_update sendmail}

%files -f file-list
%dir %{_mailcnfdir}
# %{_sysconfdir}/aliases.d is part of aaa_dir
# %dir %attr(0750,root,mail) %{_sysconfdir}/aliases.d
%dir %attr(0750,root,root) %{_mailcnfdir}/auth
%dir %attr(0750,root,root) %{_mailcnfdir}/certs
%config(noreplace) %{_sysconfdir}/
# %{_sysconfdir}/aliases is part of netcfg
# %config(noreplace) %{_sysconfdir}/aliases
%doc               %{_mailcnfdir}/README
%config(noreplace) %{_mailcnfdir}/Makefile
# this is a link
%config(noreplace) %{_mailcnfdir}/aliases
%config(noreplace) %attr(0600,root,root) %{_mailcnfdir}/auth/auth-info
%config(noreplace) %{_mailcnfdir}/
%config(noreplace) %{_mailcnfdir}/
%config(noreplace) %{_mailcnfdir}/
%config(noreplace) %{_mailcnfdir}/mailertable
%config(noreplace) %{_mailcnfdir}/genericstable
%config(noreplace) %{_mailcnfdir}/domaintable
%config(noreplace) %{_mailcnfdir}/virtusertable
%config(noreplace) %{_mailcnfdir}/access
%config(noreplace) %{_mailcnfdir}/userdb
%config(noreplace) %{_mailcnfdir}/relay-domains
%config(noreplace) %{_mailcnfdir}/service.switch
%config(noreplace) %{_mailcnfdir}/service-nodns.switch
%config(noreplace) %{_mailcnfdir}/trusted-users
%config(noreplace) %{_mailcnfdir}/local-host-names
%config(noreplace) %{_mailcnfdir}/
%doc %{_defaultdocdir}/sendmail
%config %attr(0644,root,root) %{_sysconfdir}/pam.d/smtp
%config %attr(0644,root,root) %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/sendmail
%config %attr(0744,root,root) %{_sysconfdir}/init.d/sendmail
%config %attr(0755,root,root) /sbin/conf.d/SuSEconfig.sendmail
%dir %attr(0755,root,root) %{_prefix}/lib/sendmail.d/
%dir %attr(0755,root,root) %{_prefix}/lib/sendmail.d/bin/
%attr(0511,root,root) %{_prefix}/lib/sendmail.d/bin/mail.local
%attr(0511,root,root) %{_prefix}/lib/sendmail.d/bin/smrsh
%doc %{_mandir}/man1/mailq.1.gz
%doc %{_mandir}/man1/newaliases.1.gz
%doc %{_mandir}/man5/aliases.5.gz
%doc %{_mandir}/man8/editmap.8.gz
%doc %{_mandir}/man8/makemap.8.gz
#%doc %{_mandir}/man8/rmail.8.gz
%doc %{_mandir}/man8/sendmail.8.gz
%doc %{_mandir}/man8/smrsh.8.gz
%doc %{_mandir}/man8/mail.local.8.gz
%doc %{_mandir}/man8/mailstats.8.gz
%doc %{_mandir}/man8/praliases.8.gz
# Should we do 6555??
%attr(2555,root,mail) %{_sbindir}/sendmail

%files -n sendmail-devel
%dir %{_includedir}/libmilter
%dir %{_includedir}/sm
%dir %{_includedir}/sm/os

%files -n rmail
%doc %{_mandir}/man8/rmail.8.gz