%define uid 96
%define gid 96

Summary: Dovecot Secure imap server
Name: dovecot
Version: 1.0
Release: cvs
License: GPL
Group: System Environment/Daemons
Source: %{name}-%{version}.tar.gz
Source2: dovecot.init
Source3: dovecot.pam
Patch: dovecot-libtool.patch
URL: http://dovecot.procontrol.fi/
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root

%description
Dovecot IMAP server - compiled with openssl, pam and ldap support certs in /etc/ssl

%prep

%setup -q
%patch -p1

%build
#./autogen.sh
%configure --with-ldap --with-ssl=openssl --with-rawlog

make

%install
rm -rf $RPM_BUILD_ROOT
%makeinstall
rm -rf $RPM_BUILD_ROOT/%{_datadir}/%{name}
rm -rf $RPM_BUILD_ROOT/%{_datadir}/doc/%{name}
mv $RPM_BUILD_ROOT/%{_sysconfdir}/dovecot-example.conf $RPM_BUILD_ROOT/%{_sysconfdir}/dovecot.conf
mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/rc.d/init.d
install -m 755 %{SOURCE2} $RPM_BUILD_ROOT/%{_sysconfdir}/rc.d/init.d/dovecot
mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/pam.d
install -m 644 %{SOURCE3} $RPM_BUILD_ROOT/%{_sysconfdir}/pam.d/imap
install -m 644 %{SOURCE3} $RPM_BUILD_ROOT/%{_sysconfdir}/pam.d/imaps
install -m 644 %{SOURCE3} $RPM_BUILD_ROOT/%{_sysconfdir}/pam.d/pop3
install -m 644 %{SOURCE3} $RPM_BUILD_ROOT/%{_sysconfdir}/pam.d/pop3s

%post
/sbin/chkconfig --add dovecot

# Add the dovecot user and group if not found
groupadd -g %{gid} -r dovecot 2>/dev/null || :
useradd -d /var/run/dovecot -s /bin/false -g dovecot -M -r -u %{uid} dovecot 2>/dev/null || :

%preun
/sbin/chkconfig --del dovecot

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%config %{_sysconfdir}/dovecot.conf
%config %{_sysconfdir}/pam.d/*
%config %{_sysconfdir}/rc.d/init.d/dovecot
%dir %{_libexecdir}/%{name}
%{_libexecdir}/%{name}/*
%dir %{_sbindir}
%{_sbindir}/*
%doc doc/*.txt doc/dovecot-* doc/mkcert.sh INSTALL AUTHORS ChangeLog COPYING TODO README NEWS COPYING.LGPL

%changelog
* Mon Mar 24 2003 Levente Farkas <lfarkas@lfarkas.org>
- update a few things for the current cvs

* Sun Feb 28 2003 Zalavary Gabor <zgabor@bnap.hu>
- 0.99.8 rebuild:)

* Sun Dec  1 2002 Seth Vidal <skvidal@phy.duke.edu>
- 0.99.4 and fix startup so it starts imap-master not vsftpd :)

* Tue Nov 26 2002 Seth Vidal <skvidal@phy.duke.edu>
- first build
