%{!?python_standard_lib: %define python_standard_lib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(standard_lib=1)")}

Name:           pyicq-t
Version:        0.8
Release:        3
Summary:        ICQ Transport for Jabber Servers

Group:          Applications/Internet
License:        GPL
URL:            http://pyicq-t.blathersource.org/
Source0:        http://www.blathersource.org/download.php/pyicq-t/pyicq-t-%{version}.tar.gz
Source1:        pyicq-t.init
Patch0:         config.patch

BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

BuildArch:      noarch
BuildRequires:  python-devel
Requires:       python-twisted
Requires:       python-imaging
Requires:       pyOpenSSL

Requires(post): /sbin/chkconfig
Requires(preun): /sbin/chkconfig
Requires(preun): /sbin/service
Requires(postun): /sbin/service

%description
The ICQ Transport provides a gateway which allows Jabber users to
communicate with their contacts on the ICQ network.

The transport must be installed on the Jabber server, and it's
operation is nearly transparent to the user. They can interact with
their ICQ contacts in the same way as they do with their Jabber
contacts.

%package mysql
Summary: MySQL backend for ICQ transport
Group: Applications/Internet
Requires: MySQL-python
Requires: pyicq-t = %{version}-%{release}

%description mysql
MySQL backend for ICQ transport

%prep
%setup -q
%patch0 -p0

%build
%{__python}    %{python_standard_lib}/compileall.py .
%{__python} -O %{python_standard_lib}/compileall.py .

%install
rm -rf %{buildroot}
mkdir -p %{buildroot}/etc/pyicq-t
mkdir -p %{buildroot}%{_datadir}/pyicq-t
mkdir -p %{buildroot}/var/spool/pyicq-t
mkdir -p %{buildroot}%{_initrddir}

cp %{S:1} %{buildroot}%{_initrddir}/pyicq-t
chmod a+x %{buildroot}%{_initrddir}/pyicq-t

touch %{buildroot}/etc/pyicq-t/config.xml

cp PyICQt.py* %{buildroot}%{_datadir}/pyicq-t
chmod a+x %{buildroot}%{_datadir}/pyicq-t/PyICQt.py
cp -r data %{buildroot}%{_datadir}/pyicq-t
cp -r src %{buildroot}%{_datadir}/pyicq-t
 
%clean
rm -rf %{buildroot}

%post
/sbin/chkconfig --add pyicq-t

%preun
if [ $1 = 0 ]; then
        /sbin/service pyicq-t stop >/dev/null 2>&1
        /sbin/chkconfig --del pyicq-t
fi

%postun
if [ "$1" -ge "1" ]; then
        /sbin/service pyicq-t condrestart >/dev/null 2>&1
fi

%files
%defattr(-,root,root,-)
%doc AUTHORS ChangeLog config_example.xml COPYING INSTALL NEWS README tools/managessi.py tools/migrate.py

%{_initrddir}/pyicq-t

%dir %{_sysconfdir}/pyicq-t
%ghost %config(noreplace) %{_sysconfdir}/pyicq-t/config.xml

%exclude %{_datadir}/pyicq-t/src/xdb/mysql.py*
%{_datadir}/pyicq-t

%dir %{_localstatedir}/spool/pyicq-t

%files mysql
%defattr(-,root,root,-)
%doc tools/db-setup.mysql

%{_datadir}/pyicq-t/src/xdb/mysql.py*

%changelog
* Fri Dec  8 2006 Jeffrey C. Ollie <jeff@ocjtech.us> - 0.8-3
- Fix up requires for mysql subpackage.

* Fri Dec  8 2006 Jeffrey C. Ollie <jeff@ocjtech.us> - 0.8-2
- Bump release and rebuild for Python 2.5
- Use macro for path to standard library
- Eliminate provides/obsoletes pyicqt

* Tue Oct 31 2006 Jeffrey C. Ollie <jeff@ocjtech.us> - 0.8-1
- Update to 0.8 (see http://www.blathersource.org/releases_view.php?projid=pyicq-t&relid=28)
- Fix init script to create subsys lock file

* Thu Sep  7 2006 Jeffrey C. Ollie <jeff@ocjtech.us> - 0.7-5
- Really no longer ghost *.pyo files

* Mon Aug 14 2006 Jeffrey C. Ollie <jeff@ocjtech.us> - 0.7-4
- No longer ghost *.pyo files

* Wed Aug  2 2006 Jeffrey C. Ollie <jeff@ocjtech.us> - 0.7-3
- Rename more stuff to pyicq-t

* Sun Jul 30 2006 Jeffrey C. Ollie <jeff@ocjtech.us> - 0.7-2
- Rename to pyicq-t
- Change Group tag

* Wed Jul 26 2006 Jeffrey C. Ollie <jeff@ocjtech.us> - 0.7-1
- First version for Fedora Extras