%define _noVersionedDependencies	1
%define prereq_ge()  %(LC_ALL="C" rpm -q --queryformat 'PreReq:%%{NAME} >= %%{VERSION}' %1| grep -v "is not")
%define emacsen_pkgdir /usr/lib/emacsen-common/packages
%define	origname text-translator
%define origver  0.7.1

Summary:      translates the character string on Emacs
Name:         %{origname}
Version:      %{origver}
Release:      1%{?_dist_release}

Source0:      text-translator.el
Source1:      text-translator-vars.el
Source2:      text-translator-load.el
Source3:      http://www.gnu.org/licenses/gpl-2.0.txt

Source11:     %{origname}-install.sh
Source12:     %{origname}-remove.sh
Source13:     vine-default-%{origname}.el
Source14:     %{origname}-init.el

License:      GPLv2+
Group:        Applications/Editors/Emacs
URL:          http://www.emacswiki.org/emacs/TextTranslator
BuildRoot:    %{_tmppath}/%{name}-%{version}-root
BuildArch:    noarch

Requires:     emacsen
PreReq:       emacsen
%prereq_ge    emacsen-common

Distribution: Vine Linux
Vendor:       Project Vine
Packager:     iwaim

%description
translates the character string on Emacs. this packages use the text 
translation service that exists on the Internet.

%prep

%setup -T -c %{origname}-%{origver}
%{__cp} %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} .

%build

%install
[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}
[ "%{buildroot}" != "/" ] && mkdir -p %{buildroot}

mkdir -p %{buildroot}%{_datadir}/emacs/site-lisp/%{origname}/packages
mkdir -p %{buildroot}%{emacsen_pkgdir}/install
mkdir -p %{buildroot}%{emacsen_pkgdir}/remove

#
# install el files
#

cp -p *.el %{SOURCE13} %{SOURCE14} %{buildroot}%{_datadir}/emacs/site-lisp/%{origname}


#
# install script (bytecompile el and install elc , remove)
#

%_installemacsenscript %{origname} %{SOURCE11}

%_removeemacsenscript  %{origname} %{SOURCE12}


%clean
[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}

%post
#
# bytecompile and install
#
if [ "$1" = 2 ]; then

%_emacsenPackageRemove %{origname}

fi

%_addemacsenlist %{origname}

%_emacsenPackageInstall %{origname}


%preun
if [ "$1" = 0 ]; then

%_emacsenPackageRemove %{origname}

%_removeemacsenlist %{origname}

fi


%files
%defattr(-,root,root)
%doc gpl-2.0.txt
%{_datadir}/emacs/site-lisp/%{origname}
%{emacsen_pkgdir}/install/%{origname}
%{emacsen_pkgdir}/remove/%{origname}

%changelog
* Sun Mar 07 2010 IWAI, Masaharu <iwai@alib.jp> 0.7.1-1
- first release for Vine Linux
