%define emacsen_pkgdir /usr/lib/emacsen-common/packages
Summary: Handles the switching of various initialization files of emacsen
Name: initz
Version: 0.0.9
Release: 1%{?_dist_release}
License: GPL
Group: Applications/Editors
Source: http://www.koka-in.org/~bg66/%{name}-%{version}.tar.gz
Source1: %{name}-install.sh
Source2: %{name}-remove.sh
URL: http://www.koka-in.org/~bg66/index.cgi?cmd=view;name=Initz
Prefix: /usr
BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildArch: noarch
PreReq: emacsen, emacsen-common >= 0.1

%description
Initz handles the switching of various startup initialization files of
emacsen provided for various environment. According to the environment
(maybe emacs version, OS type or OS versions) Initz reads appropriate init
files provided by the user in several directories, one for one environment.

%prep

%setup -q

%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

(cd lisp && \
 install -m 644 *.el ${RPM_BUILD_ROOT}/%{_datadir}/emacs/site-lisp/%{name})

%_installemacsenscript %{name} %{SOURCE1} 

%_removeemacsenscript  %{name} %{SOURCE2}

%post
if [ "$1" = 2 ]; then
  %_emacsenPackageRemove initz

fi

%_addemacsenlist initz

%_emacsenPackageInstall initz

%preun
if [ "$1" = 0 ]; then
  %_emacsenPackageRemove initz

  %_removeemacsenlist initz

fi



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

%files
%defattr(-, root, root)
%{_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}
%doc AUTHORS
%doc COPYING
%doc ChangeLog
%doc NEWS
%doc README
%doc TODO
%doc sample

%changelog
* Sun Sep 28 2008 Shu KONNO <owa@bg.wakwak.com> 0.0.9-1vl5
- applied new versioning policy, spec in utf-8
- added macro %%emacsen_pkgdir

* Mon Feb 04 2002 akira yamada <akira@vinelinux.org> 0.0.9-0vl1
- new upstream version.
- putted emacsen-common into PreReq.

* Thu Dec 06 2001 akira yamada <akira@vinelinux.org> 0.0.2-0vl1
- Initial packaging.
