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

Summary:      RPM spec file editing commands for Emacs/XEmacs
Name:         %{origname}
Version:      %{origver}
Release:      2%{?_dist_release}

Source0:      http://www.tihlde.org/~stigb/rpm-spec-mode.el
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://www.emacswiki.org/emacs/RpmSpecMode
BuildRoot:    %{_tmppath}/%{name}-%{version}-root
BuildArch:    noarch

Requires:     emacsen
%prereq_ge    emacsen-common

Distribution: Vine Linux
Vendor:       Project Vine
Packager:     iwaim

%description
RPM spec file editing commands for Emacs/XEmacs

%prep

%setup -T -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 %{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)
%{_datadir}/emacs/site-lisp/%{origname}
%{emacsen_pkgdir}/install/%{origname}
%{emacsen_pkgdir}/remove/%{origname}


%changelog
* Thu Feb  9 2012 Munehiro Yamamoto <munepi@vinelinux.org> 0.12-2
- updated rpm-spec-mode-init.el

* Thu Sep 02 2010 IWAI, Masaharu <iwai@alib.jp> 0.12-1
- first release for Vine Linux
