%define name thailatex
%define version @VERSION@
%define release 1
%define manifest %{_builddir}/%{name}-%{version}-%{release}.manifest

Summary: Thai extension for LaTeX
Name: %{name}
Version: %{version}
Release: %{release}
Copyright: freely distributable
Group: Applications/Publishing
Source: %{name}-%{version}.tar.gz
BuildArch: noarch
BuildRoot: /var/tmp/%{name}-%{version}
Vendor: Surapant Meknavin <surapan@nectec.or.th>, Theppitak Karoonboonyanan <thep@links.nectec.or.th>, NECTEC
Packager: Theppitak Karoonboonyanan <thep@links.nectec.or.th>
Distribution: Linux TLE, Thai Linux Working Group
Requires: tetex >= 0.9, tetex-dvips >= 0.9
BuildRequires: tetex >= 0.9, tetex-afm >= 0.9

%description

Thai fonts, style, etc. for publishing Thai documents with LaTeX.
Thai word segmentation filter which inserts "\wbr " command as Thai word
delimitor, such as "swath", is recommended to be used as a preprocessor.

%prep
%setup

%build
./configure --prefix=/usr
make

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT

# __os_install_post is implicitly expanded after the
# install section... do it now, and then disable it,
# so all work is done before building manifest.

%{?__os_install_post}
%define __os_install_post %{nil}

# build the file list automagically into %{manifest}

cd $RPM_BUILD_ROOT
rm -f %{manifest}
find . -type d \
        | sed '1,2d;s,^\.,\%attr(-\,root\,root) \%dir ,' >> %{manifest}
find . -type f \
        | sed '/babel.sty/d;/config.ps/d;/pdftex.cfg/d;/site-start.el/d' \
        | sed 's,^\.,\%attr(-\,root\,root) ,' >> %{manifest}
find . -type l \
        | sed 's,^\.,\%attr(-\,root\,root) ,' >> %{manifest}

%clean
rm -f %{manifest}
rm -rf $RPM_BUILD_ROOT

%post
/usr/sbin/sync-thailatex
/usr/sbin/sync-babel

%triggerin -- tetex
/usr/sbin/sync-thailatex
/usr/sbin/sync-babel

%preun
if [ "$1" = "0" ]; then # last uninstall only, do not run when upgraded
  /usr/sbin/sync-thailatex
  /usr/sbin/sync-babel
fi

%files -f %{manifest}
%defattr(-,root,root)
#%doc README
#%docdir
#%config

%changelog
* Sun Dec 21 2003 Theppitak Karoonboonyanan <thep@linux.thai.net>
  - use argumentless sync scripts

* Thu Mar 06 2003 Theppitak Karoonboonyanan <thep@linux.thai.net>
  - use the split sync-thailatex and sync-babel scripts separately
  - add preun script for unregistering thailatex at last uninstallation

* Tue Mar 04 2003 Theppitak Karoonboonyanan <thep@linux.thai.net>
  - add tetex-dvips to Requires: (as suggested by Vee Sattayamas)

* Tue Jan 28 2003 Poonlap Veerathanabutr <poonlap@linux.thai.net>
  - fix some comment in spec file which cause problems

* Mon Aug 05 2002 Theppitak Karoonboonyanan <thep@links.nectec.or.th>
  - add BuildRequires
  - add %clean script
  - clear RPM build dir before installing

* Tue Jan 08 2002 Theppitak Karoonboonyanan <thep@links.nectec.or.th>
  - update %post and %postun scripts according to new installing method
  - fix upgrading bug by adding %triggerpostun script to do the %post
    job again, after the %postun script of the older version removed
    every patch. (%post is still needed for rpm -i case.. Hmm.. messy)
  - change %postun to %preun, to be safe about the order of %postun
    of the older package and %triggerpostun of the newer package.
  - incorporate babel.sty patching.
  - split scriptlets into sync-thailatex script.
  - add %triggerin to get synchronized with tetex.

* Wed Dec 05 2001 Theppitak Karoonboonyanan <thep@links.nectec.or.th>
  - use manifest

* Wed Jan 03 2001 Theppitak Karoonboonyanan <thep@links.nectec.or.th>
  - thailatex.spec : use variables for sources, path names; use BuildRoot

* Wed Aug 16 2000 Theppitak Karoonboonyanan <thep@links.nectec.or.th>
  - fix "norasi" "Bluevalues" parameter to fix Acrobat Distiller
    rejection, by Anutara

* Thu May 25 2000 Theppitak Karoonboonyanan <thep@links.nectec.or.th>
  - rearrange package and create Makefiles
  - encoding changed from TIS to LTH, according to TeX convention
  - add "norasi" bold and bold-italic font; correct TeXTIS.enc
  - make "norasi" be Thai roman font, "dbttx" Thai sans serif
  - correct some Thai translations
  - release version 0.2

* Mon Jun 21 1999 Surapant Meknavin <surapan@nectec.or.th>
  - create the original Thai LaTeX extension based on babel package
  - two fonts are available : dbtt (n,bx,i,bi) and nf3x (n,i)
  - release version 0.1

