File netqmail.spec of Package netqmail

#
# Spec file for package netqmail
#
# Copyright (c) 2008 Exata T.I., Maringa, PR, Brasil.
# This file and all modifications and additions to the pristine
# package are under the same license as the package itself.
#
# Please submit bugfixes or comments to matrixworkstation@gmail.com
#

# norootforbuild

Name:           netqmail
Version:        1.06
Release:        0
License:        PDDL-1.0
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  groff
BuildRequires:  netqmail-skel
%if 0%{?suse_version} == 1120
BuildRequires:  -post-build-checks
%endif
Provides:       smtp_daemon, MTA
Group:          Productivity/Networking/Email/Servers
Summary:        Qmail Mail Transfer Agent
URL:            http://www.qmail.org/netqmail
Source:         %{name}-%{version}.tar.bz2
Source1:        %{name}-rpmlintrc
Patch:          install_CHOWN.patch
Patch1:         fix_includes.patch
Patch2:         prototypes.patch
Conflicts:      sendmail, exim, smail, postfix
PreReq:         permissions

%define         qdir /var/qmail

# Groups.
#----------------------------------------------------------------------------------
%define         QMAIL_GID 2107
%define         QMAIL_GID_NAME qmail

%define         NOFILES_GID 2108
%define         NOFILES_GID_NAME nofiles

%define         GROUPADD_QMAIL /usr/sbin/groupadd -g %{QMAIL_GID} -r %{QMAIL_GID_NAME} 2> /dev/null || :
%define         GROUPADD_NOFILES /usr/sbin/groupadd -g %{NOFILES_GID} -r %{NOFILES_GID_NAME} 2> /dev/null || :

# Users.
#----------------------------------------------------------------------------------
%define         QMAIL_ALIAS_UID 7790
%define         QMAIL_ALIAS_UID_NAME alias
%define         QMAIL_ALIAS_COMMENT qmail alias

%define         QMAIL_DAEMON_UID 7791
%define         QMAIL_DAEMON_UID_NAME qmaild
%define         QMAIL_DAEMON_COMMENT qmail daemon

%define         QMAIL_LOGGER_UID 7792
%define         QMAIL_LOGGER_UID_NAME qmaill
%define         QMAIL_LOGGER_COMMENT qmail logger

%define         QMAIL_PASSWD_UID 7793
%define         QMAIL_PASSWD_UID_NAME qmailp
%define         QMAIL_PASSWD_COMMENT qmail passwd

%define         QMAIL_QUEUE_UID 7794
%define         QMAIL_QUEUE_UID_NAME qmailq
%define         QMAIL_QUEUE_COMMENT qmail queue

%define         QMAIL_REMOTE_UID 7795
%define         QMAIL_REMOTE_UID_NAME qmailr
%define         QMAIL_REMOTE_COMMENT qmail remote

%define         QMAIL_SEND_UID 7796
%define         QMAIL_SEND_UID_NAME qmails
%define         QMAIL_SEND_COMMENT qmail send

%define         SHELL /bin/nologin
%define         USERADD_QMAIL_ALIAS /usr/sbin/useradd -r -g %{NOFILES_GID_NAME} -u %{QMAIL_ALIAS_UID} -s %{SHELL} -c "%{QMAIL_ALIAS_COMMENT}" -d %{qdir}/alias %{QMAIL_ALIAS_UID_NAME} 2> /dev/null || :
%define         USERADD_QMAIL_DAEMON /usr/sbin/useradd -r -g %{NOFILES_GID_NAME} -u %{QMAIL_DAEMON_UID} -s %{SHELL} -c "%{QMAIL_DAEMON_COMMENT}" -d %{qdir} %{QMAIL_DAEMON_UID_NAME} 2> /dev/null || :
%define         USERADD_QMAIL_LOGGER /usr/sbin/useradd -r -g %{NOFILES_GID_NAME} -u %{QMAIL_LOGGER_UID} -s %{SHELL} -c "%{QMAIL_LOGGER_COMMENT}" -d %{qdir} %{QMAIL_LOGGER_UID_NAME} 2> /dev/null || :
%define         USERADD_QMAIL_PASSWD /usr/sbin/useradd -r -g %{NOFILES_GID_NAME} -u %{QMAIL_PASSWD_UID} -s %{SHELL} -c "%{QMAIL_PASSWD_COMMENT}" -d %{qdir} %{QMAIL_PASSWD_UID_NAME} 2> /dev/null || :
%define         USERADD_QMAIL_QUEUE /usr/sbin/useradd -r -g %{QMAIL_GID_NAME} -u %{QMAIL_QUEUE_UID} -s %{SHELL} -c "%{QMAIL_QUEUE_COMMENT}" -d %{qdir} %{QMAIL_QUEUE_UID_NAME} 2> /dev/null || :
%define         USERADD_QMAIL_REMOTE /usr/sbin/useradd -r -g %{QMAIL_GID_NAME} -u %{QMAIL_REMOTE_UID} -s %{SHELL} -c "%{QMAIL_REMOTE_COMMENT}" -d %{qdir} %{QMAIL_REMOTE_UID_NAME} 2> /dev/null || :
%define         USERADD_QMAIL_SEND /usr/sbin/useradd -r -g %{QMAIL_GID_NAME} -u %{QMAIL_SEND_UID} -s %{SHELL} -c "%{QMAIL_SEND_COMMENT}" -d %{qdir} %{QMAIL_SEND_UID_NAME} 2> /dev/null || :


%description
**WARNING: This is a not patched netqmail 1.06 release. **

Qmail is a small, fast, secure replacement for the sendmail package, which is
the program that actually receives, routes, and delivers electronic mail.


%package -n netqmail-pop3d
Summary:        POP3 daemon for qmail
Group:          Productivity/Networking/Email/Servers
Requires:       netqmail >= %{version}
#Requires:      vpopmail >= 5.4.17


%description -n netqmail-pop3d
**WARNING: This is a not patched netqmail 1.06 release. **

The qmail-pop3d packages provides POP3 support for qmail mail servers.  If
you need to be able to use POP3 with your qmail server, you should install
this package.


%prep
%setup -q
%patch
%patch1
%patch2

# Remove CRAM-MD5 because qmail-remote-auth doesn't like it
#---------------------------------------------------------------------------------
#%%{__perl} -pi -e "s|\#define AUTHCRAM||g" qmail-smtpd.c
#%%{__perl} -pi -e "s|LDK_PATH|%%{_libdir}/libdomainkeys.a|g" Makefile


%build
echo 'cc %{optflags} -fPIE' > conf-cc
echo 'cc -s %{optflags} -pie' > conf-ld
# Set concurrency to something reasonable.
echo 255 > conf-spawn
# For docs we shall set the runtime dir.
echo %{qdir} > conf-qmail
%{__make} it man
# For the install script we shall set conf-qmail to buildroot dir.
echo %{buildroot}%{qdir} > conf-qmail
%{__make} install instcheck config-fast
#%%{__make} CFLAGS="$RPM_OPT_FLAGS" libdir=%%{_libdir} it man


%install
%{__install} -d %{buildroot}%{qdir}
./install
./instcheck
# Make it just create some necessary files.
./config-fast ""

%{__install} -d -m 755 %{buildroot}%{_mandir}
%{__mv} %{buildroot}%{qdir}/man/* %{buildroot}%{_mandir}

%{__install} -d -m 755 %{buildroot}%{_docdir}/netqmail
%{__mv} %{buildroot}%{qdir}/doc/* %{buildroot}%{_docdir}/netqmail
%{__install} BIN.README BLURB BLURB2 BLURB3 BLURB4 FILES COPYRIGHT README SENDMAIL SECURITY SYSDEPS THANKS TODO THOUGHTS TARGETS VERSION %{buildroot}%{_docdir}/netqmail


%pre
%{GROUPADD_QMAIL}
%{GROUPADD_NOFILES}
%{USERADD_QMAIL_ALIAS}
%{USERADD_QMAIL_DAEMON}
%{USERADD_QMAIL_LOGGER}
%{USERADD_QMAIL_PASSWD}
%{USERADD_QMAIL_QUEUE}
%{USERADD_QMAIL_REMOTE}
%{USERADD_QMAIL_SEND}


%preun
%stop_on_removal qmail


%post
# Compile default tcp.smtp when installing
#-------------------------------------------------------------------------------
if [ $1 = "1" ]
then
    if [ -f /usr/bin/tcprules ]
    then
        echo "Compiling default cdb files in %{_sysconfdir}/tcprules.d..."
        %{_sysconfdir}/init.d/netqmail cdb
    fi
fi

%set_permissions /var/qmail/bin/qmail-queue
%set_permissions /var/qmail/alias
%set_permissions /var/qmail/queue/lock/trigger

%verifyscript
%verify_permissions -e /var/qmail/bin/qmail-queue
%verify_permissions -e /var/qmail/alias
%verify_permissions -e /var/qmail/queue/lock/trigger


%files
# Directories
#----------------------------------------------------------------------------------
%defattr(0755,root,qmail)
%dir %{qdir}
%dir %{qdir}/bin
%dir %{qdir}/boot
%dir %{qdir}/control
%dir %{qdir}/users
%attr(02755,alias,qmail) %dir %{qdir}/alias

# Config (qmail)
#----------------------------------------------------------------------------------
%defattr(0644,root,qmail)
%config(noreplace) %{qdir}/control/defaultdomain
%config(noreplace) %{qdir}/control/locals
%config(noreplace) %{qdir}/control/me
%config(noreplace) %{qdir}/control/plusdomain
%config(noreplace) %{qdir}/control/rcpthosts

# Boot files
#----------------------------------------------------------------------------------
%defattr(0755,root,qmail)
%{qdir}/boot/binm1
%{qdir}/boot/binm1+df
%{qdir}/boot/binm2
%{qdir}/boot/binm2+df
%{qdir}/boot/binm3
%{qdir}/boot/binm3+df
%{qdir}/boot/home
%{qdir}/boot/home+df
%{qdir}/boot/proc
%{qdir}/boot/proc+df

# Bin files
#----------------------------------------------------------------------------------
%{qdir}/bin/bouncesaying
%{qdir}/bin/condredirect
%{qdir}/bin/datemail
%{qdir}/bin/elq
%{qdir}/bin/except
%{qdir}/bin/forward
%{qdir}/bin/maildir2mbox
%{qdir}/bin/maildirmake
%{qdir}/bin/maildirwatch
%{qdir}/bin/mailsubj
%{qdir}/bin/pinq
%{qdir}/bin/predate
%{qdir}/bin/preline
%{qdir}/bin/qail
%{qdir}/bin/qbiff
%{qdir}/bin/qmail-inject
%{qdir}/bin/qmail-qread
%{qdir}/bin/qmail-qstat
%{qdir}/bin/qmail-showctl
%{qdir}/bin/qmail-smtpd
%{qdir}/bin/qmail-qmqpc
%{qdir}/bin/qmail-qmqpd
%{qdir}/bin/qmail-qmtpd
%{qdir}/bin/qmail-tcpok
%{qdir}/bin/qmail-tcpto
%{qdir}/bin/qreceipt
%{qdir}/bin/qsmhook
%{qdir}/bin/sendmail
%{qdir}/bin/tcp-env

%defattr(04711,qmailq,qmail)
%{qdir}/bin/qmail-queue

%defattr(0711,root,qmail)
%{qdir}/bin/qmail-clean
%{qdir}/bin/qmail-getpw
%{qdir}/bin/qmail-local
%{qdir}/bin/qmail-pw2u
%{qdir}/bin/qmail-remote
%{qdir}/bin/qmail-rspawn
%{qdir}/bin/qmail-send
%{qdir}/bin/splogger

%defattr(0700,root,qmail)
%{qdir}/bin/qmail-lspawn
%{qdir}/bin/qmail-newmrh
%{qdir}/bin/qmail-newu
%{qdir}/bin/qmail-start

# Man and Cat pages
#----------------------------------------------------------------------------------
%defattr(0644,root,root,0755)
%doc %{_docdir}/netqmail
%doc %{_mandir}/man1/*
%doc %{_mandir}/man5/*
%doc %{_mandir}/man7/*
%doc %{_mandir}/man8/*
%doc %{_mandir}/cat1
%doc %{_mandir}/cat5
%doc %{_mandir}/cat7
%doc %{_mandir}/cat8
%exclude %{_mandir}/man8/qmail-pop3d.8.gz
%exclude %{_mandir}/man8/qmail-popup.8.gz
%exclude %{_mandir}/cat8/qmail-pop3d.0*
%exclude %{_mandir}/cat8/qmail-popup.0*

# Queue Queue
#----------------------------------------------------------------------------------
%attr(0750,qmailq,qmail) %dir %{qdir}/queue

%defattr(0700,qmailq,qmail)
%dir %{qdir}/queue/pid
%dir %{qdir}/queue/intd

%defattr(0700,qmails,qmail)
%dir %{qdir}/queue/bounce
%dir %{qdir}/queue/info
%dir %{qdir}/queue/info/*
%dir %{qdir}/queue/local
%dir %{qdir}/queue/local/*
%dir %{qdir}/queue/remote
%dir %{qdir}/queue/remote/*

%defattr(0750,qmailq,qmail)
%dir %{qdir}/queue/lock
%dir %{qdir}/queue/mess
%dir %{qdir}/queue/mess/*
%dir %{qdir}/queue/todo

# Lock Dir
%attr(0622,qmails,qmail) %{qdir}/queue/lock/trigger
%attr(0600,qmails,qmail) %{qdir}/queue/lock/sendmutex
%attr(0644,qmailr,qmail) %{qdir}/queue/lock/tcpto


%files -n netqmail-pop3d
%attr(0755,root,qmail) %{qdir}/bin/qmail-pop3d
%attr(0755,root,qmail) %{qdir}/bin/qmail-popup

# Man and Cat pages
#----------------------------------------------------------------------------------
%defattr(0644,root,root,0755)
%doc %{_mandir}/man8/qmail-pop3d.8.gz
%doc %{_mandir}/man8/qmail-popup.8.gz
%doc %{_mandir}/cat8/qmail-pop3d.0*
%doc %{_mandir}/cat8/qmail-popup.0*