Summary: An offline mail server with pop3 client support
Name: masqmail
Version: @VERSION@
Release: 1
Copyright: GPL
Group: Networking/Daemons
Distribution: innominate
Packager: Iain Lea <iain@bricbrac.de>
Source: http://masqmail.cx/masqmail/download/masqmail-@VERSION@.tar.gz
BuildRoot: /var/tmp/masqmail-root/

%description
MasqMail is a mail server designed for hosts that do not have a
permanent internet connection eg. a home network or a single host at
home. It has special support for connections to different ISPs. It
replaces sendmail or other MTAs such as qmail or exim.

%prep

%setup -n masqmail-@VERSION@

%build
#
#choose the a line or a combination:
#
#CFLAGS="$RPM_OPT_FLAGS" ./configure --with-user=mail --with-group=mail --disable-pop3
#CFLAGS="$RPM_OPT_FLAGS" ./configure --with-user=mail --with-group=mail --enable-auth
#CFLAGS="$RPM_OPT_FLAGS" ./configure --with-user=mail --with-group=mail --enable-ident
CFLAGS="$RPM_OPT_FLAGS" ./configure --with-user=mail --with-group=mail

CFLAGS="$RPM_OPT_FLAGS" make

%install
if [ -d $RPM_BUILD_ROOT ] ; then
	rm -rf $RPM_BUILD_ROOT
fi

# setup directory environment:
mkdir $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/var/spool/masqmail
mkdir -p $RPM_BUILD_ROOT/var/spool/masqmail/input
mkdir -p $RPM_BUILD_ROOT/var/spool/masqmail/popuidl
mkdir -p $RPM_BUILD_ROOT/usr/sbin
mkdir -p $RPM_BUILD_ROOT/usr/bin
mkdir -p $RPM_BUILD_ROOT/usr/lib
mkdir -p $RPM_BUILD_ROOT/etc
mkdir -p $RPM_BUILD_ROOT/etc/masqmail
mkdir -p $RPM_BUILD_ROOT/etc/masqmail/tpl
mkdir -p $RPM_BUILD_ROOT/var/masqmail

# install
make DESTDIR=$RPM_BUILD_ROOT install
/usr/bin/strip $RPM_BUILD_ROOT/usr/sbin/masqmail

# sendmail links
ln -fs './masqmail' $RPM_BUILD_ROOT/usr/sbin/sendmail
ln -fs '../sbin/masqmail' $RPM_BUILD_ROOT/usr/bin/mailq
ln -fs '../sbin/masqmail' $RPM_BUILD_ROOT/usr/lib/sendmail

# RedHat specific startup stuff:
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d/
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/rc2.d/
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/rc3.d/
cp -p redhat/masqmail $RPM_BUILD_ROOT/etc/rc.d/init.d/
ln -fs '../init.d/masqmail' $RPM_BUILD_ROOT/etc/rc.d/rc2.d/S20masqmail
ln -fs '../init.d/masqmail' $RPM_BUILD_ROOT/etc/rc.d/rc2.d/K20masqmail
ln -fs '../init.d/masqmail' $RPM_BUILD_ROOT/etc/rc.d/rc3.d/S20masqmail
ln -fs '../init.d/masqmail' $RPM_BUILD_ROOT/etc/rc.d/rc3.d/K20masqmail
ln -fs '../../etc/rc.d/init.d/masqmail' $RPM_BUILD_ROOT/usr/sbin/rcmasqmail

# configuration examples:
cp examples/masqmail.conf $RPM_BUILD_ROOT/etc/
cp examples/example.route $RPM_BUILD_ROOT/etc/masqmail/
cp examples/example.get $RPM_BUILD_ROOT/etc/masqmail/
cp tpl/failmsg.tpl $RPM_BUILD_ROOT/etc/masqmail/tpl

#cp docs/man/masqmail.8 $RPM_BUILD_ROOT/usr/man/man8/
#cp docs/man/masqmail.conf.5 $RPM_BUILD_ROOT/usr/man/man5/
#cp docs/man/masqmail.route.5 $RPM_BUILD_ROOT/usr/man/man5/
#cp docs/man/masqmail.get.5 $RPM_BUILD_ROOT/usr/man/man5/
#cp docs/man/masqmail.aliases.5 $RPM_BUILD_ROOT/usr/man/man5/

# gzip the man pages:
gzip $RPM_BUILD_ROOT/usr/man/man8/masqmail.8
gzip $RPM_BUILD_ROOT/usr/man/man5/masqmail.conf.5
gzip $RPM_BUILD_ROOT/usr/man/man5/masqmail.route.5
gzip $RPM_BUILD_ROOT/usr/man/man5/masqmail.get.5
gzip $RPM_BUILD_ROOT/usr/man/man5/masqmail.aliases.5

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
/usr/sbin/masqmail
/usr/sbin/sendmail
/usr/bin/mailq
/usr/lib/sendmail
/etc/rc.d/init.d/masqmail
/etc/rc.d/rc2.d/S20masqmail
/etc/rc.d/rc2.d/K20masqmail
/etc/rc.d/rc3.d/S20masqmail
/etc/rc.d/rc3.d/K20masqmail
/usr/sbin/rcmasqmail
%config /etc/masqmail.conf /etc/masqmail/tpl/failmsg.tpl
//etc/masqmail/
%doc README INSTALL COPYING NEWS
/usr/man/man8/masqmail.8.gz
/usr/man/man5/masqmail.conf.5.gz
/usr/man/man5/masqmail.route.5.gz
/usr/man/man5/masqmail.get.5.gz
/usr/man/man5/masqmail.aliases.5.gz

%defattr(-,mail,mail)
%dir /var/masqmail/
%dir /var/spool/masqmail/
%dir /var/spool/masqmail/popuidl/
%dir /var/spool/masqmail/input/


