%define name emacsen-common
%define origname emacsen-common
%define version 0.5
%define prereq_ge()  %(LC_ALL="C" rpm -q --queryformat 'Requires(post):%%{NAME} >= %%{VERSION}' %1| grep -v "is not")
%define _libdir %{_prefix}/lib

Summary: Common facilities for all emacsen.
Name: %{name}
Version: %{version}
Release: 1%{?_dist_release}
License: GPL
Group: Development/Languages
# archive created from git-svn local repos.
# git archive --format=tar --prefix=emacsen-common-0.5/ HEAD |\
#   xz > ~/rpm/SOURCES/emacsen-common/emacsen-common-0.5.tar.xz
Source0: %{origname}-%{version}.tar.xz

Distribution: Vine Liunx
Vendor: Project Vine
Packager: daisuke

URL: http://trac.vinelinux.org/browser/projects/emacsen-common
BuildRoot: %{_tmppath}/%{name}-root
BuildArch: noarch
Requires: rpm
Requires: gzip
Requires: ruby
%prereq_ge alternatives
BuildRequires: alternatives

%description
This package contains code that is needed by all the (x)emacs packages.



%prep

%setup -q


%build


%install
%__rm -rf $RPM_BUILD_ROOT

%__mkdir_p $RPM_BUILD_ROOT/%{_sysconfdir}/emacs
%__mkdir_p $RPM_BUILD_ROOT/%{_var}/lib/%{origname}
%__mkdir_p $RPM_BUILD_ROOT/%{_libdir}/%{origname}/packages/remove
%__mkdir_p $RPM_BUILD_ROOT/%{_libdir}/%{origname}/packages/install
%__mkdir_p $RPM_BUILD_ROOT/%{_datadir}/%{origname}/site-list
%__mkdir_p $RPM_BUILD_ROOT/%{_var}/lib/emacs

echo "/usr/bin/b2m
/usr/bin/ctags
/usr/bin/ebrowse
/usr/bin/emacsclient
/usr/bin/etags
/usr/bin/gctags
/usr/bin/gnuclient
/usr/bin/grep-changelog
/usr/bin/ootags
/usr/bin/rcs-checkin
/usr/share/icons/hicolor/scalable/apps/emacs.svg
/usr/share/icons/hicolor/scalable/mimetypes/emacs-document.svg" > $RPM_BUILD_ROOT%{_var}/lib/emacs/alternative-filelist

%__cp show-vine-default.sh $RPM_BUILD_ROOT/%{_libdir}/%{origname}/

%__cp scripts/emacs-install.rb $RPM_BUILD_ROOT/%{_libdir}/%{origname}/.
%__cp scripts/emacs-package-install.rb $RPM_BUILD_ROOT/%{_libdir}/%{origname}/.
%__cp scripts/generate-package-list.rb $RPM_BUILD_ROOT/%{_libdir}/%{origname}/.
%__cp scripts/installed-flavors $RPM_BUILD_ROOT/%{_var}/lib/emacsen-common/installed-flavors
%__cp scripts/installed-elisp $RPM_BUILD_ROOT/%{_var}/lib/emacsen-common/installed-elisp

%__cp scripts/change-default-flavors.rb  $RPM_BUILD_ROOT/%{_libdir}/%{origname}/.

%__ln_s -f emacs-package-install.rb  $RPM_BUILD_ROOT/%{_libdir}/%{origname}/emacs-package-install

%__ln_s -f emacs-package-install.rb  $RPM_BUILD_ROOT/%{_libdir}/%{origname}/emacs-package-remove

%__ln_s -f emacs-install.rb  $RPM_BUILD_ROOT/%{_libdir}/%{origname}/emacs-install

%__ln_s -f emacs-install.rb  $RPM_BUILD_ROOT/%{_libdir}/%{origname}/emacs-remove


%__ln_s -f generate-package-list.rb  $RPM_BUILD_ROOT/%{_libdir}/%{origname}/generate-package-list

%__ln_s -f generate-package-list.rb  $RPM_BUILD_ROOT/%{_libdir}/%{origname}/remove-package-list

%__ln_s -f generate-package-list.rb  $RPM_BUILD_ROOT/%{_libdir}/%{origname}/generate-flavors-list

%__ln_s -f generate-package-list.rb  $RPM_BUILD_ROOT/%{_libdir}/%{origname}/remove-flavors-list

#%__ln_s -f change-default-flavors.rb  $RPM_BUILD_ROOT/%{_libdir}/%{origname}/change-default-flavor

#%__ln_s -f change-default-flavors.rb  $RPM_BUILD_ROOT/%{_libdir}/%{origname}/reverse-default-flavor

#%__ln_s -f change-default-flavors.rb  $RPM_BUILD_ROOT/%{_libdir}/%{origname}/change-temporary-flavor  



#%__make install prefix=$RPM_BUILD_ROOT/%{_prefix}



 


%clean
%__rm -rf ${RPM_BUILD_ROOT}

%triggerpostun -- emacs < 20.7-0vl7.3

if [ -f %{_var}/lib/emacsen-common/doinstaflavor-emacs ]; then

NEWFLAVOR=$(cat %{_var}/lib/emacsen-common/doinstaflavor-emacs)

%_addflavorslist $NEWFLAVOR

export PRIORITY=10

%_installemacs $NEWFLAVOR

unset PRIORITY

%__rm -rf %{_var}/lib/emacsen-common/doinstaflavor-emacs

fi

%triggerpostun -- xemacs < 21.1.14-0vl6

if [ -f %{_var}/lib/emacsen-common/doinstaflavor-xemacs ]; then

NEWFLAVOR=$(cat %{_var}/lib/emacsen-common/doinstaflavor-xemacs)

%_addflavorslist $NEWFLAVOR

export PRIORITY=15

%_installemacs $NEWFLAVOR

unset PRIORITY

%__rm -rf %{_var}/lib/emacsen-common/doinstaflavor-xemacs

fi

%files 
%defattr(-, root, root)
%attr(755,root,root) %{_libdir}/emacsen-common/show-vine-default.sh
%attr(755,root,root) %{_libdir}/emacsen-common/emacs-*
%attr(755,root,root) %{_libdir}/emacsen-common/generate-*
%attr(755,root,root) %{_libdir}/emacsen-common/remove-*
%dir %{_libdir}/emacsen-common/packages/remove
%dir %{_libdir}/emacsen-common/packages/install
%dir %{_sysconfdir}/emacs
%dir %{_libdir}/emacsen-common
%dir %{_var}/lib/emacs
%{_var}/lib/emacs/alternative-filelist
%config(noreplace) %{_var}/lib/emacsen-common/installed-flavors
%config(noreplace) %{_var}/lib/emacsen-common/installed-elisp


%changelog 
* Sat Dec 15 2012 Daisuke SUZUKI <daisuke@linux.or.jp> 0.5-1
- import emacsen-common to vine svn repository
- support ruby-1.9.3

* Sun Mar 03 2011 Munehiro Yamamoto <munepi@vinelinux.org> 0.4-6
- fixed show-vine-default.sh

* Sat Jan 29 2011 Munehiro Yamamoto <munepi@vinelinux.org> 0.4-5
- added grep-changelog, emacs{,-document}.svg to emacs's slave

* Sun Dec 05 2010 Munehiro Yamamoto <munepi@vinelinux.org> 0.4-4
- added show-vine-default.sh

* Sun Apr 26 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 0.4-3
- created %%{_sysconfdir}/emacs for vine-default
- added in %%files section: 
  - %%dir %%{_sysconfdir}/emacs
  - %%dir %%{_libdir}/emacsen-common
  - %%dir %%{_var}/lib/emacs

* Sat Aug 16 2008 Shu KONNO <owa@bg.wakwak.com> 0.4-2vl5
- added %%define _libdir %%{_prefix}/lib

* Fri Aug 15 2008 Shu KONNO <owa@bg.wakwak.com> 0.4-1vl5
- applied new versioning policy

* Thu Mar 23 2006 Daisuke SUZUKI <daisuke@linux.or.jp> 0.4-0vl23
- use %%{_var}/lib instead of %%{_localstatedir}

* Wed Jul 28 2004 Daisuke SUZUKI <daisuke@linux.or.jp> 0.4-0vl22
- add b2m, gnuclient, ootags to emacs's slave

* Wed Jul 28 2004 Daisuke SUZUKI <daisuke@linux.or.jp> 0.4-0vl21
- fix emacsen-install to add emacsclient as emacs's slave

* Thu Mar  4 2004 Daisuke SUZUKI <daisuke@linux.or.jp> 0.4-0vl20
- add PreReq: gzip

* Wed Apr  3 2002 Jun Nishii <jun@vinelinux.org> 0.4-0vl19
- fix typo in xemacs handling of emacs-install

* Sat Mar 23 2002 Kazuhisa TAKEI <takei@vinelinux.org> 0.4-0vl18
- fixed emacs-install.rb
  ( don't  remove  xemacs-alternatives)   

* Sat Mar 23 2002 Kazuhisa TAKEI <takei@vinelinux.org> 0.4-0vl17
- add /usr/bin/xemacs to alternatives.

* Thu Mar  7 2002 Kazuhisa TAKEI <takei@vinelinux.org> 0.4-0vl16
- %triggerin -> %triggerpostun 

* Wed Mar  6 2002 Daisuke SUZUKI <daisuke@linux.or.jp> 0.4-0vl15
- add prereq rpm >= 3.0.6-0vl16 for emacsen macros

* Thu Dec  6 2001 Kazuhisa TAKEI <takei@vinelinux.org> 0.4-0vl14
- fixed %triggerin  

* Thu Nov  8 2001 Kazuhisa TAKEI <takei@vinelinux.org> 0.4-0vl13
- move /tmp -> /var/lib/emacsen-common (IP(package)C file)
- add %triggerin xemacs

* Sat Oct  6 2001 Kazuhisa TAKEI <takei@vinelinux.org> 0.4-0vl1
- fixed emacs-install.rb ( lacking run update-alternatives when emacsen install)  
* Sun Aug 12 2001 Kazuhisa TAKEI <takei@vinelinux.org> 0.2-0vl1
- add routine when install and remove .

* Wed Jul 18 2001 Kazuhisa TAKEI <takei@vinelinux.org> 0.1-0vl1
- initial package



