Summary: Courier-IMAP IMAP server
Name: courier-imap
Version: 4.15
Release: 1%{?_dist_release}
License: GPL
Group: System Environment/Daemons
Source: http://prdownloads.sourceforge.net/courier/%{name}-%{version}.tar.bz2
Patch0: courier-imap-4.15_startconf.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-root
Requires: /sbin/chkconfig 
Requires: courier-authlib
BuildRequires: openssl-devel gdbm-devel pam-devel
BuildRequires: courier-authlib-devel
BuildRequires: libidn-devel

Vendor: Project Vine
Distribution: Vine Linux
Packager: iwaim

%description
Courier-IMAP is an IMAP server for Maildir mailboxes.  This package contains
the standalone version of the IMAP server that's included in the Courier
mail server package.  This package is a standalone version for use with
other mail servers.  Do not install this package if you intend to install the
full Courier mail server.  Install the Courier package instead.


%prep
%setup -q
%patch0 -p1 -b .orig

%{__cp} libs/imap/README README.imap
%{__cp} libs/imap/README.proxy* .
%{__cp} libs/maildir/README.maildirquota.txt README.maildirquota
%{__cp} libs/maildir/README.sharedfolders.txt README.sharedfolders


%build
%configure \
	--bindir=%{_sbindir} \
	--sysconfdir=%{_sysconfdir}/%{name} \
	--libexecdir=%{_libexecdir}/%{name} \
	--datadir=%{_datadir}/%{name} \
	--localstatedir=/var/run \
	--enable-unicode \
	--with-redhat
	#--with-authdaemonvar=/var/run/authdaemon.%{name} \
	#--without-authldap \
	#--without-authmysql \
	#--without-authpgsql \

make
make check

%install
rm -rf %{buildroot}
mkdir -p %{buildroot}/etc/pam.d
make install-strip DESTDIR=%{buildroot}

mkdir -p %{buildroot}/%{_initdir}
install -m 755 packaging/systemd/courier-imap.sysvinit %{buildroot}%{_initdir}/courier-imap


cd %{buildroot}/%{_sysconfdir}/%{name}
for dist in *.dist; do
	mv $dist ${dist%.dist}
done
cd -

touch %{buildroot}/var/run/imapd.pid
touch %{buildroot}/var/run/imapd-ssl.pid
touch %{buildroot}/var/run/imapd.pid.lock
touch %{buildroot}/var/run/imapd-ssl.pid.lock

touch %{buildroot}/var/run/pop3d.pid
touch %{buildroot}/var/run/pop3d-ssl.pid
touch %{buildroot}/var/run/pop3d.pid.lock
touch %{buildroot}/var/run/pop3d-ssl.pid.lock


%clean
rm -rf $RPM_BUILD_ROOT


%post
/sbin/chkconfig --del courier-imap
/sbin/chkconfig --add courier-imap


%preun
if test "$1" = "0"
then
	rm -f /var/run/couriersslcache
	/sbin/chkconfig --del courier-imap
fi

%{_libexecdir}/%{name}/imapd.rc stop
%{_libexecdir}/%{name}/imapd-ssl.rc stop
%{_libexecdir}/%{name}/pop3d.rc stop
%{_libexecdir}/%{name}/pop3d-ssl.rc stop



%files
%defattr(-,root,root)
%doc NEWS AUTHORS COPYING libs/imap/BUGS README README.imap README.maildirquota
%doc README.sharedfolders
%doc README.proxy*
%dir %{_sysconfdir}/%{name}
%config(noreplace) %{_sysconfdir}/%{name}/*
%config(noreplace) %{_sysconfdir}/pam.d/imap
%config(noreplace) %{_sysconfdir}/pam.d/pop3
%{_initdir}/courier-imap
%{_libexecdir}/courier-imap/
%{_sbindir}/*
%{_datadir}/courier-imap/
%{_mandir}/man*/*
%ghost /var/run/*.pid
%ghost /var/run/*.lock


%changelog
* Sat Jan  4 2014 IWAI, Masaharu <iwaim.sub@gmail.com> 4.15-1
- update to 4.15
- update startconf patch (Patch0)
 - default start: imap-ssl, pop3-ssl
- update document files path

* Thu Jan 17 2013 IWAI, Masaharu <iwai@alib.jp> 4.12.0-1
- new upstream release

* Wed Dec  5 2012 IWAI, Masaharu <iwai@alib.jp> 4.11.0-1
- new upstream release

* Tue May 31 2011 IWAI, Masaharu <iwai@alib.jp> 4.9.3-1
- new upstream release

* Fri Apr 15 2011 IWAI, Masaharu <iwai@alib.jp> 4.9.1-1
- new upstream release

* Thu Apr  7 2011 IWAI, Masaharu <iwai@alib.jp> 4.9.0-1
- new upstream release
- noreplace config files

* Sun Apr  3 2011 IWAI, Masaharu <iwai@alib.jp> 4.8.1-1
- new upstream release
- drop APOP patch (Patch2)
- add Packager tag
- add Vendor and Distribution tags

* Sun Feb 07 2010 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 4.7.0-1
- new upstream release.
- added "BR: libidn-devel".

* Sun Nov 22 2009 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 4.6.0-1
- new upstream release.
- updated APOP patch.

* Sat Aug 30 2008 Shu KONNO <owa@bg.wakwak.com> 4.0.3-1vl5
- applied new versioning policy

* Sun May 22 2005 UECHI Yasumasa <uechi@potaway.net> 4.0.3-0vl2
- new upstream release

* Mon Mar 21 2005 UECHI Yasumasa <uechi@potaway.net> 4.0.2-0vl2
- new upstream release

* Wed Jan 12 2005 UECHI Yasumasa <uechi@potaway.net> 4.0.1-0vl3
- new upstream release
- authentication library is separated from this package
- add README.proxy* to %doc
- revise apop patch

* Mon Sep 20 2004 UECHI Yasumasa <uechi@potaway.net> 3.0.8-0vl1
- new upstream version

* Mon Jun 15 2004 UECHI Yasumasa <uechi@potaway.net> 3.0.5-0vl1
- new upstream version

* Sat May 22 2004 UECHI Yasumasa <uechi@potaway.net> 3.0.4-0vl1
- new upstream version
- revise apop patch

* Thu Apr 01 2004 UECHI Yasumasa <uechi@potaway.net> 3.0.3-0vl1
- new upstream version

* Sun Mar 28 2004 UECHI Yasumasa <uechi@potaway.net> 3.0.2-0vl2
- build with openssl-0.9.7d

* Sat Mar 27 2004 UECHI Yasumasa <uechi@potaway.net> 3.0.2-0vl1
- new upstream version

* Fri Mar 12 2004 UECHI Yasumasa <uechi@potaway.net> 3.0.1-0vl1
- new upstream version

* Tue Mar 09 2004 UECHI Yasumasa <uechi@potaway.net> 3.0.0-0vl1
- new upstream version
- revise courier-imap-startconf.patch
- use wildcard in files section (%{_sbindir}, %{_sysconfig}/%{name})

* Fri Nov 28 2003 UECHI Yasumasa <uh@u.dhis.portside.net> 2.2.1-0vl1
- new upstream version
- add --with-redhat option to configure script

* Fri Oct 31 2003 UECHI Yasumasa <uh@u.dhis.portside.net> 2.2.0-0vl1
- new upstream version

* Tue Sep 30 2003 UECHI Yasumasa <uh@u.dhis.portside.net> 2.1.2-0vl1
- new upstream version

* Mon Aug 18 2003 UECHI Yasumasa <uh@u.dhis.portside.net> 2.1.0-0vl1
- new upstream version

* Sat May 17 2003 UECHI Yasumasa <uh@u.dhis.portside.net> 1.7.3-0vl1
- new upstream version
- fix apop patch for 1.7.3

* Tue Apr 22 2003 HOTTA Michihide <hotta@net-newbie.com> 1.7.1-0vl2
- add apop patch

* Wed Mar 26 2003 UECHI Yasumasa <uh@u.dhis.portside.net> 1.7.1-0vl1
- new upstream version

* Tue Dec 31 2002 UECHI Yasumasa <uh@u.dhis.portside.net> 1.6.2-0vl1
- new upstream version

* Sun Dec 01 2002 UECHI Yasumasa <uh@u.dhis.portside.net> 1.6.1-0vl2
- use --enable-unicode in configure script

* Tue Nov 12 2002 UECHI Yasumasa <uh@u.dhis.portside.net> 1.6.1-0vl1
- new upstream release

* Sat Oct 26 2002 UECHI Yasumasa <uh@u.dhis.portside.net> 1.6.0-0vl1
- new upstream releas
- /usr/bin/* moved to /usr/sbin/

* Fri Aug  9 2002 UECHI Yasumasa <uh@u.dhis.portside.net> 1.5.3-0vl1
- version up to 1.5.3

* Wed Mar 20 2002 UECHI Yasumasa <uh@u.dhis.portside.net> 1.4.3-0vl1
- initial release