%define _noVersionedDependencies	1
%define prereq_ge()  %(LC_ALL="C" rpm -q --queryformat 'Requires(post):%%{NAME} >= %%{VERSION}' %1| grep -v "is not")
%define	origname lua-mode
%define origver  20140514

Summary:      Emacs major mode for editing Lua code
Summary(ja):  Lua コード編集用 Emacs メジャーモード
Name:         %{origname}
Version:      %{origver}
Release:      1%{?_dist_release}

Source0:      https://github.com/immerrr/lua-mode/archive/v%{version}.tar.gz
Source1:      %{origname}-install.sh
Source2:      %{origname}-remove.sh
Source3:      vine-default-%{origname}.el
Source4:      %{origname}-init.el

License:      GPLv2+
Group:        Applications/Editors/Emacs
URL:          http://immerrr.github.io/lua-mode/
BuildRoot:    %{_tmppath}/%{name}-%{version}-root
BuildArch:    noarch

BuildRequires: unzip

Requires:     emacsen
Requires(post):       emacsen
%prereq_ge    emacsen-common

Distribution: Vine Linux
Vendor:       Project Vine
Packager:     munepi

%description
lua-mode is an Emacs major mode for editing Lua files. 

%description -l ja
lua-mode は Lua ファイルを編集するための Emacs メジャーモードです。

%prep

%setup -q
#-c %{origname}-%{origver}

%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 %{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 NEWS README README.md TODO
%{_datadir}/emacs/site-lisp/%{origname}
%{emacsen_pkgdir}/install/%{origname}
%{emacsen_pkgdir}/remove/%{origname}


%changelog
* Fri Apr 17 2015 Ryoichi INAGAKI <ryo1@toki.waseda.jp> 20140514-1
- new upstream release

* Thu Apr 14 2011 Munehiro Yamamoto <munepi@vinelinux.org> 20110324-1
- first release for Vine Linux
