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

Name:            %{origname}
Version:         %{origver}
Release:         1%{?_dist_release}
Summary:         Auto install elisp file
Summary(ja):     Emacs Lisp ファイルを自動的にインストールするツール

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(post):  emacsen
Requires(preun): emacsen
%prereq_ge       emacsen-common
Conflicts:       flim < 1.14.9-2

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
* Fri Apr 17 2015 Ryoichi INAGAKI <ryo1@toki.waseda.jp> 1.58-1
- updated to 1.58

* Tue Feb 14 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.1.24-3
- rebuild with Vine6 environment

* 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
