%define	pyver		%(python -c 'import sys;print(sys.version[0:3])')

%global title RabbitVCS

Summary:	Integrated Subversion support for Nautilus
Summary(ja): 	Subversion サポートを Nautilus に追加する拡張
Name:		rabbitvcs
Version:	0.15.2
Release: 	3%{?_dist_release}
Source0:	http://rabbitvcs.googlecode.com/files/%{name}-%{version}.tar.bz2
Source1:	rabbitvcs-0.15.2-ja.po
License:	GPL
Group:		Development/Tools
URL:		http://rabbitvcs.org/

BuildRequires: gettext
BuildRequires: gtk2-devel
BuildRequires: pygtk2-devel
BuildRequires: python-devel
Requires(post): gtk2
Requires(postun): gtk2
#BuildArch:	noarch
Obsoletes:      rabbitvcs <= 0.14.2.1

BuildRoot:	%{_tmppath}/%{name}-%{version}-root

Packager:	kazutaka

%description
RabbitVCS is a set of graphical tools written to provide simple
and straightforward access to the version control systems you use.

This package containg core part of RabbitVCS and not connected
to to any file manager or text editor.

Front-ends or clients is privided separetely as  a Nautilus 
extention, Thunar extention and Gedit plugin, and a command line
utility.

%description -l ja
RabbitVCS はバージョン管理システムにシンプルかつ直感的にアクセス
できるよう設計された GUI のツールです。

このパッケージには RabbitVCS のコアとなる部分だけが含まれており、
特定のファイルマネージャやテキストエディタに依存しないようになっ
ています。

フロントエンドやクライアントは Nautilus 及び Thunar 用の拡張と、
Gedit 用のプラグイン、そしてコマンドラインのユーティリティが、
別パッケージとして提供されています。


%package core
Summary:        Core package of RabbitVCS
Summary:        RabbitVCS のコアパッケージ
Group:          Development/Tools

Requires:       dbus-python
Requires:       meld
Requires:       pygobject
Requires:       pygtk2
Requires:       pygtk2-libglade
Requires:       pysvn
Requires:       python-configobj
Requires:       python-dulwich
Requires:       subversion

Obsoletes:      rabbitvcs <= 0.14.2.1
BuildArch:      noarch

#Requires:	nautilus, pygtk2,  python-configobj
#Requires:	pygobject, pygtk2-libglade
#Requires:	subversion, pysvn, python-simplejson


%description core
Contains packages shared between the RabbitVCS extensions.

%package nautilus
Summary:       Nautilus extension for RabbitVCS
Summary(ja): 	RabbitVCS の Nautilus 拡張
Group:		Development/Tools
Requires:	nautilus >= 2.22.0
Requires:	nautilus-python >= 0.7.0
Requires:	rabbitvcs-core = %{version}-%{release}
Obsoletes:	nautilussvn

%description nautilus
RabbitVCS is a set of graphical tools written to provide simple
and straightforward access to the version control systems you use.

With this package, You can acces to the version control systems
by Nautilus file manager.

%description nautilus -l ja
RabbitVCS はバージョン管理システムにシンプルかつ直感的にアクセス
できるよう設計された GUI のツールです。

このパッケージを利用することで、Nautilus ファイルマネージャに
統合された形でバージョン管理システムにアクセスできるようになり
ます。

%package thunar
Summary:       Thunar extension for RabbitVCS
Summary(ja):    RabbitVCS の Thunar 拡張
Group:         Development/Tools
Requires:	rabbitvcs-core = %{version}-%{release}
Requires:      Thunar >= 0.4.0
Requires:      thunarx-python >= 0.2.0

%description thunar
An extension for Thunar to allow better integration with the 
Subversion source control system.

%package gedit
Summary:       Gedit extension for RabbitVCS
Summary(ja):    RabbitVCS の Gedit 拡張
Group:         Development/Tools
Requires:	rabbitvcs-core = %{version}-%{release}
Requires:      gedit

%description gedit
RabbitVCS is a set of graphical tools written to provide simple and 
straightforward access to the version control systems you use. This is the 
extension for gedit text editor

%package cli
Summary:       CLI extension for RabbitVCS
Summary(ja):    RabbitVCS の CLI 拡張
Group:          Development/Tools
Requires:	rabbitvcs-core = %{version}-%{release}
BuildArch:      noarch

%description cli
RabbitVCS is a set of graphical tools written to provide simple and 
straightforward access to the version control systems you use. This is the 
extension for command line interface.


%prep
%setup -q

%build
%{__python} setup.py build


%install
%{__rm} -rf ${RPM_BUILD_ROOT}
%{__python} setup.py install --skip-build --root ${RPM_BUILD_ROOT}


# install nautilus client
%if %{?_dist_release} == "vl6"
%{__install} -d -m755 ${RPM_BUILD_ROOT}/%{_libdir}/nautilus/extensions-2.0/python/
%{__install} -m644 clients/nautilus/RabbitVCS.py ${RPM_BUILD_ROOT}/%{_libdir}/nautilus/extensions-2.0/python/
%else
%{__install} -d -m755 ${RPM_BUILD_ROOT}/%{_datadir}/nautilus-python/extensions/
%{__install} -m644 clients/nautilus-3.0/RabbitVCS.py ${RPM_BUILD_ROOT}/%{_datadir}/nautilus-python/extensions/
%endif

# Installing Thunar Extension
mkdir -p $RPM_BUILD_ROOT%{_libdir}/thunarx-2/python/
cp clients/thunar/%{title}.py $RPM_BUILD_ROOT%{_libdir}/thunarx-2/python/%{title}.py

# Installing Gedit Extension
%if %{?_dist_release} == "vl6"
mkdir -p $RPM_BUILD_ROOT%{_libdir}/gedit-2/plugins/
cp clients/gedit/%{name}-plugin.py $RPM_BUILD_ROOT%{_libdir}/gedit-2/plugins/%{name}-plugin.py
cp clients/gedit/%{name}-gedit2.gedit-plugin $RPM_BUILD_ROOT%{_libdir}/gedit-2/plugins/%{name}-gedit2.gedit-plugin
%else
mkdir -p $RPM_BUILD_ROOT%{_libdir}/gedit/plugins/
cp clients/gedit/%{name}-plugin.py $RPM_BUILD_ROOT%{_libdir}/gedit/plugins/%{name}-plugin.py
cp clients/gedit/%{name}-gedit3.plugin $RPM_BUILD_ROOT%{_libdir}/gedit/plugins/%{name}-gedit3.plugin
%endif

# Installing CLI Extension
mkdir -p $RPM_BUILD_ROOT%{_bindir}
cp clients/cli/%{name} $RPM_BUILD_ROOT%{_bindir}/%{name}

# install updated japanese translation
msgfmt %{SOURCE1} -o ${RPM_BUILD_ROOT}/%{_localedir}/ja/LC_MESSAGES/RabbitVCS.mo

%clean
%{__rm} -rf ${RPM_BUILD_ROOT}


%post
touch --no-create %{_datadir}/icons/hicolor
if [ -x /usr/bin/gtk-update-icon-cache ]; then
  /usr/bin/gtk-update-icon-cache --quiet %{_datadir}/icons/hicolor ||:
fi

%postun
touch --no-create %{_datadir}/icons/hicolor
if [ -x /usr/bin/gtk-update-icon-cache ]; then
  /usr/bin/gtk-update-icon-cache --quiet %{_datadir}/icons/hicolor ||:
fi

%files core
%defattr(-, root, root, -)
%doc %{_datadir}/doc/%{name}/
%{python_sitelib}/%{name}/
%{python_sitelib}/%{name}-%{version}-py?.?.egg-info
%{_datadir}/icons/hicolor/16x16/actions/
%{_datadir}/icons/hicolor/scalable/actions/
%{_datadir}/icons/hicolor/scalable/apps/%{name}.svg
%{_datadir}/icons/hicolor/scalable/apps/%{name}-small.svg
%{_datadir}/icons/hicolor/scalable/emblems/
%{_datadir}/locale/
%{_datadir}/%{name}/configspec.ini
# only usefull for ubuntu (and debian??)
#%exclude %{_datadir}/%{name}/do-rabbitvcs-restart-nautilus
#%exclude %{_datadir}/%{name}/rabbitvcs-restart-required.update-notifier

%files nautilus
%defattr(-, root, root, -)
%doc clients/nautilus/README
%if %{?_dist_release} == "vl6"
%{_libdir}/nautilus/extensions-2.0/python/RabbitVCS.py
%else
%{_datadir}/nautilus-python/extensions/RabbitVCS.py
%endif

%files thunar
%defattr(-, root, root,-)
%{_libdir}/thunarx-2/python/%{title}.py*

%files gedit
%defattr(-, root, root,-)
%if %{?_dist_release} == "vl6"
%{_libdir}/gedit-2/plugins/%{name}-plugin.py*
%{_libdir}/gedit-2/plugins/%{name}-gedit2.gedit-plugin
%else
%{_libdir}/gedit/plugins/%{name}-plugin.py*
%{_libdir}/gedit/plugins/%{name}-gedit3.plugin
%endif

%files cli
%defattr(-, root, root,-)
%{_bindir}/%{name}

%changelog
* Sun Nov 11 2012 Toshiharu Kudoh <toshi.kd2@gmail.com> 0.15.2-3
- updated japanese translation (Source1)

* Sun Oct 21 2012 Toshiharu Kudoh <toshi.kd2@gmail.com> 0.15.2-2
- updated japanese translation (Source1)

* Sun Oct 14 2012 Toshiharu Kudoh <toshi.kd2@gmail.com> 0.15.2-1
- new upstream release
- deleted conditional branch and macro for Vine 5
- updated japanese translation (Source1)
- set contitional branch for stable release and VineSeed for -gedit package

* Tue Feb 21 2012 Toshiharu Kudoh <toshi.kd2@gmail.com> 0.15.0.5-2
- rebuilt with python-2.7

* Wed Feb 08 2012 Toshiharu Kudoh <toshi.kd2@gmail.com> 0.15.0.5-1
- new upstream release
- reorganized rabbitvcs-core, rabbitvcs-nautilus, rabbitvcs-thunar, 
  rabbitvcs-gedit, rabbitvcs-cli
- set contitional branch for stable release and VineSeed
- added Require packages for rabbitvcs-core
  - added meld, pygobject, python-dulwich

* Sun May 29 2011 Kazutaka HARADA <kazutaka@vinelinux.org> 0.14.2.1-1
- new upstream release
- drop BuildArch: noarch to change installation path for RabbitVCS.py
  (need to locate under /usr/lib64 on x86_64)
- add updated japanese translation (Source1)

* Mon Jan 24 2011 Kazutaka HARADA <kazutaka@vinelinux.org> 0.14.1.1-2
- fix installation path of RabbitVCS.py
- drop unnecessary Requires: glade2

* Sun Jan 23 2011 Kazutaka HARADA <kazutaka@vinelinux.org> 0.14.1.1-1
- new upstream release
- add Requires: python-simplejson
- add Patch1 to avoid error when gtk+ < 2.18 (only for Vine 5)

* Fri Jul 23 2010 Kazutaka HARADA <kazutaka@vinelinux.org> 0.13.3-1
- new upstream release
- merge rabbitvcs-nautilus package again (upstream source change)
- requires nautilus-python >= 0.7.0 for rabbitvcs-nautilus

* Sun Feb 14 2010 Kazutaka HARADA <kazutaka@vinelinux.org> 0.13-1
- new upstream release
- now front-end for nautilus is provided separetely
  (as rabbitvcs-nautilus package)

* Wed Oct 07 2009 Kazutaka HARADA <kazutaka@dc4.so-net.ne.jp> 0.12-1
- new upstream release with new name
- add Obsoletes: nautilussvn
- drop source1 (japanese translation)
- update description

* Fri Jun 05 2009 Kazutaka HARADA <kazutaka@dc4.so-net.ne.jp> 0.12-3.beta1.2
- update japanese translation

* Sat May 23 2009 Kazutaka HARADA <kazutaka@dc4.so-net.ne.jp> 0.12-2.beta1.2
- add japanese translation as Source1
- add BuildRequires: gettext

* Sat May 23 2009 Kazutaka HARADA <kazutaka@dc4.so-net.ne.jp> 0.12-1.beta1.2
- initial build for Vine Linux
