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

%define        tgnusver 6_15_4-09

Summary:       T-gnus - a branch of Gnus (SEMI compatible) for FSF Emacs 20.x
Summary(ja):   T-gnus - SEMI 対応の Gnus (Emacs20 用)
Name:          t-gnus
Version:       6.15.4.09
Release:       0vl2
License:       GPL
Source0:       ftp://ftp.jpl.org/pub/elisp/t-gnus-6.14/snapshots/t-gnus-%{tgnusver}-quimby.tar.gz
Source1:       t-gnus-install.sh
Source2:       t-gnus-remove.sh
Patch0:        t-gnus-%{tgnusver}-info.patch
Group:         Applications/Editors/Emacs
BuildRoot:     %{_tmppath}/%{name}-%{version}-root
BuildArch:     noarch

PreReq:        emacsen
%prereq_ge     emacsen-common
%prereq_ge     semi
BuildRequires: emacsen-common, semi
Obsoletes:     t-gnus-xemacs

Vendor:        Project Vine
Distribution:  Vine Linux
Packager:      MATSUBAYASHI 'Shaolin' Kohji <shaolin@vinelinux.org>


%description
T-gnus is a variation of Gnus and SEMI-capable.
It is a replacement for Gnus with gnus-mime combination.

Install t-gnus package if you want to use T-gnus on Emacs 20.x.

%description -l ja
T-gnus は SEMI 対応の Gnus の1つです．
gnus-mime と Gnus の組合せを置き換えるものです．


%prep
%setup -q -n t-gnus-%{tgnusver}-quimby
%patch0 -p1

cd texi

# change info filename to avoid conflict with Gnus of emacs-20.4
#
sed -e 's/@c @direntry/@direntry/' \
    -e 's/@c \* Emacs MIME/\* Emacs MIME/' \
    -e 's/@c @end direntry/@end direntry/' \
    emacs-mime.texi > emacs-mime-new.texi
mv emacs-mime-new.texi emacs-mime.texi

sed -e 's/@c @direntry/@direntry/' \
    -e 's/@c \* Gnus-ja/\* Gnus-ja/' \
    -e 's/@c @end direntry/@end direntry/' \
    -e 's/@setfilename gnus-ja/@setfilename t-gnus-ja/' \
    -e 's/Gnus-ja: (gnus-ja)/T-Gnus-ja: (t-gnus-ja)/' \
    gnus-ja.texi > t-gnus-ja.texi

sed -e 's/@c @direntry/@direntry/' \
    -e 's/@c \* Gnus/\* Gnus/' \
    -e 's/@c @end direntry/@end direntry/' \
    -e 's/@setfilename gnus/@setfilename t-gnus/' \
    -e 's/Gnus: (gnus)/T-Gnus: (t-gnus)/' \
    gnus.texi > t-gnus.texi

sed -e 's/@c @direntry/@direntry/' \
    -e 's/@c \* Message/\* Message/' \
    -e 's/@c @end direntry/@end direntry/' \
    -e 's/@setfilename message-ja/@setfilename t-gnus-message-ja/' \
    -e 's/Message-ja: (message-ja)/T-Gnus-Message-ja: (t-gnus-message-ja)/' \
    message-ja.texi > t-gnus-message-ja.texi

sed -e 's/@c @direntry/@direntry/' \
    -e 's/@c \* Message/\* Message/' \
    -e 's/@c @end direntry/@end direntry/' \
    -e 's/@setfilename message/@setfilename t-gnus-message/' \
    -e 's/Message: (message)/T-Gnus-Message: (t-gnus-message)/' \
    message.texi > t-gnus-message.texi


%build

./configure
make clean


%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


#
# install el files
#

cp -a Makefile* aclocal.m4 config* etc install-sh lisp mkinstalldirs texi \
	${RPM_BUILD_ROOT}%{_datadir}/emacs/site-lisp/%{name}


#
# format info files and install them
#

mkdir -p ${RPM_BUILD_ROOT}%{_infodir}

( cd texi;
  make all-info ja-info
  install -m 644 *.info* ${RPM_BUILD_ROOT}%{_infodir}/.
)


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

%_installemacsenscript %{name} %{SOURCE1}

%_removeemacsenscript %{name} %{SOURCE2}


%post

#
# bytecompile and install
#

if [ "$1" = 2 ] ; then

%_emacsenPackageRemove %{name}

fi

%_addemacsenlist %{name}

%_emacsenPackageInstall %{name}


/sbin/install-info %{_infodir}/emacs-mime.info.gz %{_infodir}/dir \
	--section="MIME Interface"
/sbin/install-info %{_infodir}/sieve.info.gz %{_infodir}/dir \
	--section="Newsreader"
/sbin/install-info %{_infodir}/t-gnus.info.gz %{_infodir}/dir \
	--section="Newsreader"
/sbin/install-info %{_infodir}/t-gnus-ja.info.gz %{_infodir}/dir \
	--section="Newsreader"
/sbin/install-info %{_infodir}/t-gnus-message.info.gz %{_infodir}/dir \
	--section="Newsreader"
/sbin/install-info %{_infodir}/t-gnus-message-ja.info.gz %{_infodir}/dir \
	--section="Newsreader"


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

%_emacsenPackageRemove %{name}

%_removeemacsenlist %{name}

   /sbin/install-info --delete %{_infodir}/emacs-mime.info.gz %{_infodir}/dir
   /sbin/install-info --delete %{_infodir}/sieve.info.gz %{_infodir}/dir
   /sbin/install-info --delete %{_infodir}/t-gnus.info.gz %{_infodir}/dir
   /sbin/install-info --delete %{_infodir}/t-gnus-ja.info.gz %{_infodir}/dir
   /sbin/install-info --delete %{_infodir}/t-gnus-message.info.gz \
	%{_infodir}/dir
   /sbin/install-info --delete %{_infodir}/t-gnus-message-ja.info.gz \
	%{_infodir}/dir
fi


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


%files
%defattr(-,root,root)
%doc ChangeLog* GNUS-NEWS Mule23@1934*
%doc README* TODO* contrib sample.lpath.el todo

%{_infodir}/*
%{_datadir}/emacs/site-lisp/%{name}/
%{_libdir}/emacsen-common/packages/install/%{name}
%{_libdir}/emacsen-common/packages/remove/%{name}


%changelog
* Tue Sep 12 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 6.15.4.09-0vl2
- changed Group to Appliations/Editors/Emacs <BTS:VineLinux:163>
- s/Copyright/License/

* Fri Dec 28 2001 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 6.15.4.09-0vl1
- now emacsen-common aware
- updated to new upstream release

* Thu Jul 12 2001 Tomoya TAKA <tomoya@olive.plala.or.jp>
- 6.15.3.02-0vl1
- update to 6_14_5-02
- fix t-gnus-info.patch, and modify building function of info for emacs

* Wed Jul 11 2001 MATSUBAYASHI 'Shaolin' Kohji <shaolin@vinelinux.org>
- 6.14.5.04-0vl2
- rebuilt with apel-10.3, flim-1.14.3, semi-1.14.3

* Mon Sep 25 2000 MATSUBAYASHI 'Shaolin' Kohji
- 6.14.5.04-0vl1
- updated to 6_14_5-04 snapshot release
- now both emacs/xemacs packages are merged into one srpm
- modified for brp-redhat

* Wed May 10 2000 MATSUBAYASHI 'Shaolin' Kohji
- 6.14.1.01-1vl1
- rebuild with apel-10.2

* Fri Jan 07 2000 MATSUBAYASHI 'Shaolin' Kohji
- 6.14.1.01-1
- updated to 6.14.1.01

* Tue Dec 28 1999 MATSUBAYASHI 'Shaolin' Kohji
- 6.14.0.14-1
- updated to 6.14.0.14

* Sat Dec  4 1999 MATSUBAYASHI 'Shaolin' Kohji
- 6.13.4.01-1
- updated to 6.13.4.01

* Sat Nov 27 1999 MATSUBAYASHI 'Shaolin' Kohji
- 6.13.3.06-1
- updated to 6.13.3.06 for semi-1.13.7

* Sat Nov 27 1999 MATSUBAYASHI 'Shaolin' Kohji
- 6.12.0-2
- now info file is converted into EUC format
- %post and %preun section fixed

* Tue Sep 21 1999 MATSUBAYASHI 'Shaolin' Kohji
- 6.12.0-1
- first rpm package for Vine 1.9
- changed info filename from gnus-* to t-gnus-*
  (to avoid conflicts with Gnus info that comes with emacs-20.4)
