%define name thaipst1fonts
%define version @VERSION@
%define release 2
%define manifest %{_builddir}/%{name}-%{version}-%{release}.manifest
%define fontdir /usr/share/fonts/th/Type1

Name: %{name}
Version: %{version}
Release: %{release}
License: Public Domain
Group: Extensions/Thai/font
Source: %{name}-%{version}.tar.gz
URL: ftp://ftp.nectec.or.th/pub/thailinux/software/All/fonts/
Distribution: Linux-TLE
Vendor: Deer Book and NECTEC
Packager: Pattara Kiatisevi <ott@nectec.or.th>
Requires: XFree86 > 3.2
Prereq: chkfontpath,type1inst
BuildArch: noarch
BuildRoot: /var/tmp/%{name}-%{version}
Summary: A collection of Thai Postscript Type 1 fonts

%description
The collection of Thai Postscript Type 1 fonts from Internet.
This package currently included DBThaiText and Norasi fonts.

%prep
%setup

%build
%configure --with-fontdir=$RPM_BUILD_ROOT%{fontdir}

%install
%makeinstall

# __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 '/Fontmap/d;/fonts.dir/d;/fonts.scale/d;/type1inst.log/d' \
        | sed 's,^\.,\%attr(-\,root\,root) ,' >> %{manifest}
find . -type l \
        | sed 's,^\.,\%attr(-\,root\,root) ,' >> %{manifest}

%post
cd $RPM_BUILD_ROOT%{fontdir}
type1inst >/dev/null 2>&1
mkfontdir
if (/usr/sbin/chkfontpath --list | grep $RPM_BUILD_ROOT%{fontdir}) ; then
	/usr/sbin/chkfontpath --remove $RPM_BUILD_ROOT%{fontdir}
fi
/usr/sbin/chkfontpath --add $RPM_BUILD_ROOT%{fontdir}

%postun
cd $RPM_BUILD_ROOT%{fontdir}
rm -f type1inst.log Fontmap fonts.scale fonts.dir
type1inst >/dev/null 2>&1
if test -f Fontmap; then
	mkfontdir
	if (/usr/sbin/chkfontpath --list | grep $RPM_BUILD_ROOT%{fontdir}) ; then
		/usr/sbin/chkfontpath --remove $RPM_BUILD_ROOT%{fontdir}
	fi
	/usr/sbin/chkfontpath --add $RPM_BUILD_ROOT%{fontdir}
else
	rm -f type1inst.log Fontmap.bak fonts.scale.bak
	cd $RPM_BUILD_ROOT; rmdir $RPM_BUILD_ROOT%{fontdir}
	/usr/sbin/chkfontpath --remove $RPM_BUILD_ROOT%{fontdir}
fi

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

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

%changelog
* Tue Jan 14 2003 Theppitak Karoonboonyanan <thep@linux.thai.net>
- Fix "%install" mess in comment (rpmbuild oddity)

* Sun Dec 16 2001 Phattanon Duangdara <sf_alpha@yahoo.com>
- Move fontdir to /usr/share/fonts/th/Type1

* Sun Nov 25 2001 Theppitak Karoonboonyanan <thep@links.nectec.or.th>
- Add .spec.in into source tarball
- Use %{fontdir}, $RPM_BUILD_ROOT variable
- Use License: instead of Copyright: tag
- Use manifest
- Add mkfontdir in %post
- Add checking for existing fonts in %postun
- Add chkfontpath

* Thu May 25 2000 Kanokwut Thanadkran <kanokwut@hotmail.com>
- Add Norasi fonts.

* Thu Sep 09 1999 Pattara Kiatisevi <ott@nectec.or.th>
- Start with DB Thai Text fonts.
