%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 auto-install
%define origver  0.1.24

Summary:      Auto install elisp file
Name:         %{origname}
Version:      %{origver}
Release:      2%{?_dist_release}

Source0:      http://www.emacswiki.org/emacs/download/auto-install.el
Source1:      %{origname}-install.sh
Source2:      %{origname}-remove.sh
Source3:      vine-default-%{origname}.el
Source4:      %{origname}-init.el
Source5:      http://www.gnu.org/licenses/gpl-3.0.txt

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

Requires:     emacsen
PreReq:       emacsen
Conflicts:    flim < 1.14.9-2
%prereq_ge    emacsen-common

Distribution: Vine Linux
Vendor:       Project Vine
Packager:     iwaim

%description
Auto install elisp file

%prep

%setup -q -T -c %{origname}-%{origver}
%{__cp} -a %{SOURCE5} .

%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 %{SOURCE0} %{SOURCE3} %{SOURCE4} %{buildroot}%{_datadir}/emacs/site-lisp/%{origname}


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

%_installemacsenscript %{origname} %{SOURCE1}

%_removeemacsenscript  %{origname} %{SOURCE2}


%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-3.0.txt
%{_datadir}/emacs/site-lisp/%{origname}
%{emacsen_pkgdir}/install/%{origname}
%{emacsen_pkgdir}/remove/%{origname}


%changelog
* Sun Mar  7 2010 IWAI, Masaharu <iwai@alib.jp> 0.1.24-2
- update Conflicts flim version

* Tue Feb 23 2010 IWAI, Masaharu <iwai@alib.jp> 0.1.24-1
- first release for Vine Linux
