%define _prefix	/usr

Name:			bleachbit
Version:		0.8.7
Release:		1%{?_dist_release}
Summary:		Tool for remove unnecessary files, free space, and maintain privacy
Summary(ja):		不要ファイルの削除、スペースの解放、プライバシーの保全のためのツール
Group:                  Applications/System
License:		GPLv3
URL:			http://bleachbit.sourceforge.net/
Source0:		%{name}-%{version}.tar.bz2
Patch0:		        no_update.patch

BuildRoot:	%{_tmppath}/%{name}-%{version}-root
BuildArch:	noarch
BuildRequires:	python-devel
BuildRequires:	desktop-file-utils
BuildRequires:	gettext

Requires:       gnome-python
Requires:	python
Requires:	python-simplejson
Requires:	pygtk2 >= 2.6
Requires:       usermode

%description
Delete traces of your activities and other junk files to free disk
space and maintain privacy.  BleachBit identifies and erases
broken menu entries, cache, cookies, localizations, recent document
lists, and temporary files in Firefox, OpenOffice.org, Bash, and 50
other applications.

%description -l ja
あなたの活動の形跡及びその他不要なファイルを
ディスクスペース確保とプライバシー保護のために削除します。
BleachBit は壊れたメニューエントリ・キャッシュ・クッキー・
ローカライゼーション・最近使用したドキュメントのリスト・
Firefox・OpenOffice.org・bash、その他50のアプリケーションの
一時ファイルを検出し、削除します。

%prep
%setup -q
%patch0 -p1

%build
make -C po local
%{__python} setup.py build

cp %{name}.desktop %{name}-root.desktop
sed -i -e 's/Name=BleachBit$/Name=BleachBit as Administrator/g' %{name}-root.desktop

cat > bleachbit.pam <<EOF
#%PAM-1.0
auth		include		config-util
account		include		config-util
session		include		config-util
EOF

cat > bleachbit.console <<EOF
USER=root
PROGRAM=/usr/bin/bleachbit
SESSION=true
EOF

# remove Windows-specific cleaners
grep -l os=.windows. cleaners/*xml | xargs rm -f
# remove Windows-specific modules
rm -f bleachbit/Windows.py

%install
rm -rf $RPM_BUILD_ROOT

make install DESTDIR=$RPM_BUILD_ROOT prefix=%{_prefix}

desktop-file-validate %{buildroot}/%{_datadir}/applications/%{name}.desktop

sed -i -e 's/Exec=bleachbit$/Exec=bleachbit-root/g' %{name}-root.desktop

desktop-file-install \
	--dir=%{buildroot}/%{_datadir}/applications/ \
	--vendor="" %{name}-root.desktop

# consolehelper and userhelper
ln -s consolehelper %{buildroot}/%{_bindir}/%{name}-root
mkdir -p %{buildroot}/%{_sbindir}
ln -s ../..%{_datadir}/%{name}/GUI.py %{buildroot}/%{_sbindir}/%{name}-root
mkdir -p %{buildroot}%{_sysconfdir}/pam.d
install -m 644 %{name}.pam %{buildroot}%{_sysconfdir}/pam.d/%{name}-root
mkdir -p %{buildroot}%{_sysconfdir}/security/console.apps
install -m 644 %{name}.console %{buildroot}%{_sysconfdir}/security/console.apps/%{name}-root

make -C po install DESTDIR=$RPM_BUILD_ROOT

%find_lang %{name}

%__rm %{buildroot}%{_datadir}/%{name}/*.py[co]

%clean
rm -rf $RPM_BUILD_ROOT

%post
update-desktop-database &> /dev/null ||:

%postun
update-desktop-database &> /dev/null ||:

%files -f %{name}.lang
%defattr(-,root,root)
%doc COPYING
%config(noreplace) %{_sysconfdir}/pam.d/%{name}-root
%config(noreplace) %{_sysconfdir}/security/console.apps/%{name}-root
%{_bindir}/%{name}-root
%{_sbindir}/%{name}-root
%{_bindir}/%{name}
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/*
%{_datadir}/pixmaps/*.png
%{_datadir}/applications/*.desktop

%changelog
* Wed Feb 16 2011 Toshiharu Kudoh <toshi.kd2@gmail.com> - 0.8.7-1
- new upstream release

* Mon Jan 17 2011 Toshiharu Kudoh <toshi.kd2@gmail.com> - 0.8.6-1
- new upstream release

* Sun Jan 2 2011 Toshiharu Kudoh <toshi.kd2@gmail.com> - 0.8.5-1
- new upstream release
- added Requires: python-simplejson

* Sat Dec 18 2010 Toshiharu Kudoh <toshi.kd2@gmail.com> - 0.8.4-1
- new upstream release

* Mon Dec 13 2010 Toshiharu Kudoh <toshi.kd2@gmail.com> - 0.8.3-1
- new upstream release

* Tue Nov 16 2010 Toshiharu Kudoh <toshi.kd2@gmail.com> - 0.8.2-1
- new upstream release

* Wed Oct 6 2010 Toshiharu Kudoh <toshi.kd2@gmail.com> - 0.8.1-1
- new upstream release

* Sat Jun 5 2010 Toshiharu Kudoh <toshi.kd2@gmail.com> - 0.8.0-1
- new upstream release

* Tue May 4 2010 Toshiharu Kudoh <toshi.kd2@gmail.com> - 0.7.4-1
- new upstream release
- fixed Japanese description

* Sun Feb 21 2010 Toshiharu Kudoh <toshi.kd2@gmail.com> - 0.7.3-1
- new upstream release

* Sat Feb 6 2010 Toshiharu Kudoh <toshi.kd2@gmail.com> - 0.7.2-2
- rebuilt with python-2.6.4

* Tue Dec 1 2009 Toshiharu Kudoh <toshi.kd2@gmail.com> - 0.7.2-1
- new upstream release

* Tue Nov 10 2009 Toshiharu Kudoh <toshi.kd2@gmail.com> - 0.7.1-1
- new upstream release

* Fri Oct 23 2009 Toshiharu Kudoh <toshi.kd2@gmail.com> - 0.7.0-1
- new upstream release
- added Patch0 from Debian to disable update check

* Sun Oct 4 2009 Toshiharu Kudoh <toshi.kd2@gmail.com> - 0.6.5-1
- new upstream release

* Thu Sep 24 2009 Toshiharu Kudoh <toshi.kd2@gmail.com> - 0.6.4-2
- added BuildRequires: gettext
- added Requires: gnome-python
- changed Requires: pygtk2 >= 2.6
- changed description/ -l ja
- deleted Windows-specific cleaners and modules
- changed program path in root

* Thu Sep 17 2009 Toshiharu Kudoh <toshi.kd2@gmail.com> - 0.6.4-1
- new upstream release

* Thu Sep 3 2009 Toshiharu Kudoh <toshi.kd2@gmail.com> - 0.6.3-1
- new upstream release

* Wed Aug 19 2009 Toshiharu Kudoh <toshi.kd2@gmail.com> - 0.6.1-1
- new upstream release

* Tue Aug 4 2009 Toshiharu Kudoh <toshi.kd2@gmail.com> - 0.6.0-1
- new upstream release

* Fri Jul 17 2009 Toshiharu Kudoh <toshi.kd2@gmail.com> - 0.5.4-1
- new upstream release

* Thu Jul 2 2009 Toshiharu Kudoh <toshi.kd2@gmail.com> - 0.5.3-1
- new upstream release

* Tue Jun 23 2009 Toshiharu Kudoh <toshi.kd2@gmail.com> - 0.5.2-1
- new upstream release

* Fri Jun 12 2009 Toshiharu Kudoh <toshi.kd2@gmail.com> - 0.5.1-1
- new upstream release

* Sun Jun 7 2009 Toshiharu Kudoh <toshi.kd2@gmail.com> - 0.5.0-1
- new upstream release

* Fri May 15 2009 Toshiharu Kudoh <toshi.kd2@gmail.com> - 0.4.2-1
- initial build for VineSeed

