%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

Summary:      module to provide MIME feature for RMAIL
Summary(ja):  RMAIL に MIME の機能を提供するライブラリ
Name:         rmail-mime
Version:      1.13.0
Release:      1%{?_dist_release}

Source0:      ftp://ftp.m17n.org/pub/mule/semi/rmail-mime-1.13/%{name}-%{version}.tar.gz
Source1:      %{name}-install.sh
Source2:      %{name}-remove.sh

Patch10:      RMAIL-MIME-CFG.patch

License:      Freely Distributable
Group:        Applications/Editors/Emacs
BuildRoot:    %{_tmppath}/%{name}-%{version}-root
BuildArch:    noarch

PreReq:       emacsen
BuildPreReq:  emacsen-common, semi
%prereq_ge    emacsen-common
%prereq_ge    semi

Vendor:       Project Vine
Distribution: Vine Linux
Packager:     MATSUBAYASHI 'Shaolin' Kohji <shaolin@vinelinux.org>


%description
RMAIL-MIME is a module to provide MIME feature using SEMI required
by RMAIL included in emacsen.

Note: in order to rebuild this SRPM package, you need emacsen,
emacsen-common and semi installed.


%description -l ja
RMAIL-MIME は SEMI を使って rmail に MIME 機能を提供するものです．

注意：この SRPM パッケージを rebuild するには、emacsen と emacsen-common，
そして semi がインストールされている必要があります．


%prep
%setup

%patch10 -p1


%build


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

mkdir -p $RPM_BUILD_ROOT/%{_datadir}/emacs/site-lisp/%{name}
#mkdir -p $RPM_BUILD_ROOT/%{_libdir}/emacsen-common/packages/install
#mkdir -p $RPM_BUILD_ROOT/%{_libdir}/emacsen-common/packages/remove
mkdir -p $RPM_BUILD_ROOT/%{emacsen_pkgdir}/install
mkdir -p $RPM_BUILD_ROOT/%{emacsen_pkgdir}/remove

#
# install el files
# 

cp Makefile RMAIL-MIME-* *.el \
   ${RPM_BUILD_ROOT}%{_datadir}/emacs/site-lisp/%{name}

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

%_installemacsenscript %{name} %{SOURCE1} 

%_removeemacsenscript  %{name} %{SOURCE2}


%post 

#
# bytecompile and install 
#

if [ "$1" = 2 ]; then

%_emacsenPackageRemove %{name}

fi


%_addemacsenlist %{name}

%_emacsenPackageInstall %{name}


%preun

if [ "$1" = 0 ]; then

%_emacsenPackageRemove %{name}

%_removeemacsenlist %{name}

fi


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


%files
%defattr(-,root,root)
%doc ChangeLog README*
%{_datadir}/emacs/site-lisp/%{name}/
#%{_libdir}/emacsen-common/packages/install/%{name}
#%{_libdir}/emacsen-common/packages/remove/%{name}
%{emacsen_pkgdir}/install/%{name}
%{emacsen_pkgdir}/remove/%{name}
 

%changelog
* Fri Oct 10 2008 Shu KONNO <owa@bg.wakwak.com> 1.13.0-1vl5
- applied new versioning policy, spec in utf-8
- added macro %%emacsen_pkgdir

* Wed Sep 13 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.13.0-0vl3
- changed Group to Appliations/Editors/Emacs <BTS:VineLinux:163>

* Tue Feb 19 2002 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 1.13.0-0vl2
- Oops the remove script was incorrect. Fixed.

- first (seperated) rmail-mime package with emacsen-common capability
* Mon Dec 31 2001 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 1.13.0-0vl1
- first (seperated) rmail-mime package with emacsen-common capability
