File wader.spec of Package Wader

%define waderroot %{_datadir}/wader
%define python_sitearch %(%{__python} -c 'from distutils import sysconfig; print sysconfig.get_python_lib()')

Name:           wader
Version:        0.3.2
Release:        1
Summary:        Wader
Source:         ftp://ftp.noexists.org/pub/wader/%{name}-%{version}.tar.bz2
Group:          Applications/Telephony
License:        GPL

%description
Wader is a fork of the core of "Vodafone Mobile Connect Card driver for Linux",
with some of its parts rewritten and improved to be able to interact via DBus
with other applications of the Linux/OSX desktop. Wader has two main
components, a core and a simple UI. The core can be extended to support more
devices and distros/OSes through plugins.

%package core
Summary:        The core of Wader
Group:          Applications/Telephony
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  python-devel, python-setuptools
%if 0%{?suse_version}
BuildRequires:  dbus-1-python, python-messaging, python-epsilon
BuildRequires:  update-desktop-files
%endif
Requires:       python-twisted, python-twisted-conch, python-crypto, python-pytz, python-messaging, python-epsilon, usb_modeswitch, ozerocdoff
Conflicts:      ModemManager

%description core
The core of Wader. The core can be extended to support more devices and
distros/OSes through plugins.

%if 0%{?suse_version}
# dependencies for SUSE
Requires: python-serial, dbus-1-python
%else
# dependencies for Fedora
Requires: pyserial, dbus-python
%endif

%prep
%setup -q

%build
%{__make} -C resources/po/ mo

CFLAGS="%{optflags}" %{__python} setup.py build
CFLAGS="%{optflags}" %{__python} setup-gtk.py build

%install
%if 0%{?suse_version}
%{__python} setup.py install --skip-build --root=%{buildroot} --prefix=%{_prefix} --record-rpm=INSTALLED_FILES_CORE
%{__python} setup-gtk.py install --skip-build --root=%{buildroot} --prefix=%{_prefix} --record-rpm=INSTALLED_FILES_GTK
%else
%{__python} setup.py install --skip-build --root=%{buildroot} --prefix=%{_prefix} --record=INSTALLED_FILES_CORE
%{__python} setup-gtk.py install --skip-build --root=%{buildroot} --prefix=%{_prefix} --record=INSTALLED_FILES_GTK
%endif

# gettext
%{__mkdir_p} %{buildroot}%{_datadir}
%{__cp} -R resources/po/locale %{buildroot}%{_datadir}
# config files
%{__mkdir_p} %{buildroot}%{_datadir}/dbus-1/system-services/
%{__mkdir_p} %{buildroot}%{_sysconfdir}/dbus-1/system.d/
%{__mkdir_p} %{buildroot}/usr/share/doc/wader/guide/devel/api
%{__mkdir_p} %{buildroot}%{_sysconfdir}/udev/rules.d
%{__install} -m0644 resources/dbus/org.freedesktop.ModemManager.service %{buildroot}%{_datadir}/dbus-1/system-services/org.freedesktop.ModemManager.service
%{__install} -m0644 resources/dbus/org.freedesktop.ModemManager.conf %{buildroot}%{_sysconfdir}/dbus-1/system.d/org.freedesktop.ModemManager.conf
%{__install} -m0644 resources/udev/99-huawei-e169.rules %{buildroot}%{_sysconfdir}/udev/rules.d/99-huawei-e169.rules
%{__install} -m0644 resources/udev/99-novatel-eu870d.rules %{buildroot}%{_sysconfdir}/udev/rules.d/99-novatel-eu870d.rules
%{__install} -m0644 resources/udev/99-novatel-mc950d.rules %{buildroot}%{_sysconfdir}/udev/rules.d/99-novatel-mc950d.rules
%{__install} -m0644 resources/udev/99-option-icon-225.rules %{buildroot}%{_sysconfdir}/udev/rules.d/99-option-icon-225.rules

# install desktop files
%{__mkdir_p} %{buildroot}%{_datadir}/applications
%{__mkdir_p} %{buildroot}%{_datadir}/pixmaps
%{__install} -m0644 resources/desktop/wader-gtk.desktop %{buildroot}%{_datadir}/applications/wader-gtk.desktop
%{__install} -m0644 resources/desktop/wader-gtk.png %{buildroot}%{_datadir}/pixmaps/wader-gtk.png
%if 0%{?suse_version}
%suse_update_desktop_file wader-gtk
%endif

# API && devel docs
lore --config template=doc/devel/template.tpl \
     --config baseurl=api/%s.html doc/devel/*.xhtml
%{__cp} doc/devel/*.html doc/devel/*.css %{buildroot}/usr/share/doc/wader/guide/devel
%{__rm} doc/devel/*.html
pydoctor --system-class=pydoctor.twistedmodel.TwistedSystem \
         --project-name=wader-core \
         --html-output=%{buildroot}/usr/share/doc/wader/guide/devel/api \
         --make-html \
         --html-write-function-pages \
         --add-package wader
# user docs
%{__mkdir_p} %{buildroot}/usr/share/doc/wader/guide/user/images
%if 0%{?suse_version}
rst2html.py doc/user/tutorial.rst > %{buildroot}/usr/share/doc/wader/guide/user/tutorial.html
%else
rst2html doc/user/tutorial.rst > %{buildroot}/usr/share/doc/wader/guide/user/tutorial.html
%endif
%{__cp} doc/user/images/* %{buildroot}/usr/share/doc/wader/guide/user/images/

%clean
%{__rm} -rf %{buildroot}

%post core
if [ $1 = 1 ]; then
    # kill modem-manager asap
    kill -9 `pidof modem-manager`
    # restart DBus
    if [ -e /var/run/dbus/system_bus_socket ]; then
        kill -HUP `cat /var/run/dbus/pid`
    fi
fi
if [ $1 = 2 ]; then
    # update plugins cache
    rm -rf /usr/share/wader/plugins/dropin.cache
    python -c "from twisted.plugin import IPlugin, getPlugins;import wader.plugins; list(getPlugins(IPlugin, package=wader.plugins))"
    # restart wader-core
    /usr/bin/restart-wader-core
fi

%files core -f INSTALLED_FILES_CORE
%defattr(-,root,root)
%doc LICENSE README NEWS

%ghost %{_datadir}/wader/plugins/dropin.cache

%{waderroot}
%dir %{_sysconfdir}/udev
%dir %{_sysconfdir}/udev/rules.d

%config %{_datadir}/dbus-1/system-services/org.freedesktop.ModemManager.service
%config %{_sysconfdir}/dbus-1/system.d/org.freedesktop.ModemManager.conf
%config %{_sysconfdir}/udev/rules.d/99-huawei-e169.rules
%config %{_sysconfdir}/udev/rules.d/99-novatel-eu870d.rules
%config %{_sysconfdir}/udev/rules.d/99-novatel-mc950d.rules
%config %{_sysconfdir}/udev/rules.d/99-option-icon-225.rules

%changelog
* Thu Feb 05 2009 Pablo Marti <pmarti@warp.es> 0.3.2
- 0.3.2 Release
* Mon Feb 02 2009 Pablo Marti <pmarti@warp.es> 0.3.1
- 0.3.1 Release
* Mon Dec 01 2008 Pablo Marti <pmarti@warp.es> 0.3.0
- 0.3.0 Release

%package gtk
Summary:        GTK+ UI for Wader
Group:          Applications/Telephony
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Requires:       wader-core, python-gtk, python-gobject2, python-gnome-extras, wmctrl, python-notify, python-gtkmvc, python-axiom

%description gtk
A simple GTK+ UI for Wader.

%files gtk -f INSTALLED_FILES_GTK
%defattr(-,root,root)

%lang(fr) %{_datadir}/locale/fr/*/wader.mo
%lang(es) %{_datadir}/locale/es/*/wader.mo
%{_datadir}/applications/wader-gtk.desktop
%{_datadir}/pixmaps/wader-gtk.png

%package doc
Summary:        The doc of Wader
Group:          Applications/Telephony
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  python-twisted-lore, python-pydoctor
%if 0%{?suse_version}
BuildRequires: docutils
%else
BuildRequires: python-docutils
%endif

%description doc
Documentation for Wader: Development guide and API.

%files doc
%defattr(-,root,root)
%docdir /usr/share/doc/wader
/usr/share/doc/wader

openSUSE Build Service is sponsored by