%define		_noVersionedDependencies        1
%define		prereq_ge()  %(LC_ALL="C" rpm -q --queryformat 'PreReq:%%{NAME} >= %%{VERSION}' %1| grep -v "is not")

%define		emacsver	%(rpm -q emacs | cut -d - -f 2)
%define		Version		2.0.0
%define		Name		navi2ch
%define		origver		%{Version}
%define		origname	%{Name}

Summary:	2ch client on Emacsen
Summary(ja):	(X)Emacsで動く2ちゃんねるクライアントです
Name:		%{Name}
Version:	%{Version}
Release:	1%{?_dist_release}
License:	GPL
Group:		Applications/Editors/Emacs
#Source:	http://prdownloads.sourceforge.net/%{Name}/%{Name}-%{Version}.tar.gz
Source:		http://prdownloads.sourceforge.net/%{Name}/%{Name}-20080929.tar.gz
Source1:	navi2ch-install.sh
Source2:	navi2ch-remove.sh
Source3:	navi2ch-init.el
Patch10:	navi2ch-1.7.5-emacs22.patch
BuildRoot:	%{_tmppath}/%{Name}-%{Version}-root
URL:		http://navi2ch.sourceforge.net/
BuildArch:	noarch

PreReq:		emacsen make gzip texinfo
%prereq_ge	emacsen-common
Provides:	%{origname} = %{origver}

%description
2ch client on Emacsen.

%description -l ja
(X)Emacsで動く2ちゃんねるクライアントです。 

navi2chの特徴
・(X)Emacsで動く。:-) 
・データファイルを直接読み込むのでブラウザで見るより速い。 
・その他(募集中)。 

キーバインドについては、info を参照して下さい。


Emacs/XEmacs 起動時に以下の設定ファイルを読み込みます。
M-x navi2ch で起動します。

/etc/emacs-??.?/site-start.d/90navi2ch-init.el
/etc/xemacs-??.?.??/site-start.d/90navi2ch-init.e

ユーザー単位で設定ファイルに変更を加えたい場合は、上記設定ファイルを
~/ へコピーして ~/.emacs.my.el から読み込む等してください。

monafont を使いたい場合は、~/.navi2ch/init.el に、
(setq navi2ch-mona-enable t)
を記述して下さい。

%prep
#%setup -q -n %{Name}-%{Version}
%setup -q -n %{Name}
#%patch10 -p1

%build

%install
#rm -rf $RPM_BUILD_ROOT
#make lispdir=$RPM_BUILD_ROOT%{_datadir}/emacs/site-lisp/navi2ch 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/%{origname}
mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/emacsen-common/packages/install
mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/emacsen-common/packages/remove

#
# install el files
#

#cp Makefile *.el ${RPM_BUILD_ROOT}/usr/share/emacs/site-lisp/%{origname}
cp -a * %{SOURCE3} ${RPM_BUILD_ROOT}/usr/share/emacs/site-lisp/%{origname}

#
# install  script( bytecompile el and install elc , remove )
#

%_installemacsenscript %{origname} %{SOURCE1}

%_removeemacsenscript  %{origname} %{SOURCE2}

#
# install info file
#

cd doc
# makeinfo navi2ch.texi
emacs -q -batch -l ./batch-texi2info.el -f batch-texi2info navi2ch.texi
gzip navi2ch.info
cd ..
mkdir -p ${RPM_BUILD_ROOT}%{_infodir}
install -m 644 doc/*.info*  ${RPM_BUILD_ROOT}%{_infodir}

%post

#
# bytecompile and install
#

if [ "$1" = 2 ]; then

%_emacsenPackageRemove %{origname}

fi

%_addemacsenlist %{origname}

%_emacsenPackageInstall %{origname}

/sbin/install-info %{_infodir}/navi2ch.info.gz %{_infodir}/dir \
    --entry="* Navi2ch:(navi2ch) .  2ch Client On Emacsen" --section="Navi2ch"

%preun

if [ "$1" = 0 ]; then

%_emacsenPackageRemove %{origname}

%_removeemacsenlist %{origname}

/sbin/install-info --delete %{_infodir}/navi2ch.info.gz %{_infodir}/dir \
    --entry="* Navi2ch: (navi2ch).  2ch Client On Emacsen" --section="Navi2ch"

fi


%clean
#rm -rf $RPM_BUILD_ROOT

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

rm -rf ${RPM_BUILD_DIR}/%{Name}-%{Version}



%files
%defattr(-, root, root)
%doc AUTHORS COPYING ChangeLog INSTALL NEWS README TODO
#%{_datadir}/emacs/site-lisp/navi2ch
/usr/share/emacs/site-lisp/%{origname}/
/usr/lib/emacsen-common/packages/install/%{origname}
/usr/lib/emacsen-common/packages/remove/%{origname}
%{_infodir}/navi2ch.info*


%changelog
* Tue Sep 29 2008 Hiroaki Irokawa <irorinrin @ terra.dti.ne.jp> 2.0.0-1vl5
- Sync with cvs trunk(20080929)

* Sat Aug 16 2008 Shu KONNO <owa@bg.wakwak.com> 1.7.5-1vl5
- applied new versioning policy, spec in utf-8
- changed %%{_libdir} to %%{_prefix}/lib

* Tue Jul 24 2007 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.7.5-0vl8
- Sync with CVS Snapshot(20070724)
- rebuilt for VineSeed

* Tue Jul 24 2007 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.7.5-0vl7
- Sync with CVS Snapshot(20070724)

* Tue Apr 24 2007 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.7.5-0vl6
- rebuilt for VineSeed

* Tue Apr 24 2007 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.7.5-0vl5
- Sync with CVS Snapshot(20070424)
- Add Compile for emacs-21

* Tue Sep 12 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.7.5-0vl4
- changed Group to Appliations/Editors/Emacs <BTS:VineLinux:163>

* Tue Jun  6 2006 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.7.5-0vl3
- Sync with CVS Snapshot(20060529) because not work on XEmacs.
- Not Support for emacs-20,21(compile error)

* Tue Sep 20 2005 Daisuke SUZUKI <daisuke@linux.or.jp> 1.7.5-0vl2
- add Patch10 to use assoc-string instead of assoc-ignore-case for emacs22.

* Sun Oct 17 2004 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.7.5-0vl1
- update

* Tue Aug 31 2004 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.7.4-0vl1
- update
- Copyright -> License

* Fri May  7 2004 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.7.3-0vl1
- update

* Mon Apr  5 2004 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.7.2-0vl1
- update

* Mon Sep 29 2003 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.7.1-0vl1
- update

* Tue Jul 22 2003 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.7-0vl1
- update
- include %SOURCE3

* Thu Mar  6 2003 Hiroaki Irokawa <irorin@terra.dti.ne.jp>
- navi2ch-1.6.1-0vl4.
- rebuilt.

* Mon Dec 16 2002 Hiroaki Irokawa <irorin@terra.dti.ne.jp>
- navi2ch-1.6.1-0vl1.
- update.

* Sun Jul 28 2002 Hiroaki Irokawa <irorin@terra.dti.ne.jp>
- navi2ch-1.6.0-0vl1.
- update.

* Sun Jun 16 2002 Hiroaki Irokawa <irorin@terra.dti.ne.jp>
- navi2ch-1.5.2-0vl1.
- update.

* Sat Jan 26 2002 Hiroaki Irokawa <irorin@terra.dti.ne.jp>
- navi2ch-1.5.1-0vl1.
- update.
* Sat Jan 12 2002 Hiroaki Irokawa <irorin@terra.dti.ne.jp>
 - navi2ch-1.4-0vl1.
 - update.
* Mon Dec 24 2001 Hiroaki Irokawa <irorin@terra.dti.ne.jp>
 - 01.11.28-1vl2.
 - emacsenized.
* Mon Dec 24 2001 Hiroaki Irokawa <irorin@terra.dti.ne.jp>
 - 01.11.28-1vl1.
