%define Name docbook-style-dsssl
%define Version 1.64

Name        	: %{Name}
Version     	: %{Version}
Release     	: 3
Group       	: Textprocessing/Tools

Summary     	: Norman Walsh's DSSSL modular style sheets for DocBook.

Copyright   	: 1997-2000 Norman Walsh; distributable
Packager    	: Eric Bischoff <eric@caldera.de>, Mark Galassi <rosalia@galassi.org>
URL         	: http://www.nwalsh.com/docbook/dsssl/

Requires	: jade >= 1.2.1
Requires	: docbook-dtd-sgml
Prereq		: sgml-common
Prereq		: jade

BuildRoot   	: /tmp/%{Name}-%{Version}

BuildArch	: noarch
Source0		: http://www.nwalsh.com/docbook/dsssl/db164.zip
Source1		: %{Name}-%{Version}.Makefile


%Description
These DSSSL stylesheets allow to convert any DocBook document to another
printed (for example, RTF or TeX) or online (for example, HTML) format.
They are highly customizable.


%Prep
%setup -c -T
unzip %{SOURCE0}
if [ `id -u` -eq 0 ]; then
  chown -R root.root .
  chmod -R a+rX,g-w,o-w .
fi
cp %{SOURCE1} docbook/Makefile


%Build


%Install
DESTDIR=$RPM_BUILD_ROOT
cd docbook
make install BINDIR=$DESTDIR/usr/bin DESTDIR=$DESTDIR/usr/share/sgml/docbook/dsssl-stylesheets-%{Version}
cd ..


%Clean
DESTDIR=$RPM_BUILD_ROOT
rm -rf $DESTDIR


%Files
%defattr (-,root,root)
%doc docbook/BUGS docbook/TODO docbook/README docbook/ChangeLog docbook/WhatsNew
/usr/bin/collateindex.pl
/usr/share/sgml/docbook/dsssl-stylesheets-%{Version}/catalog
/usr/share/sgml/docbook/dsssl-stylesheets-%{Version}/dtds/decls/docbook.dcl
/usr/share/sgml/docbook/dsssl-stylesheets-%{Version}/lib/dblib.dsl
/usr/share/sgml/docbook/dsssl-stylesheets-%{Version}/VERSION
/usr/share/sgml/docbook/dsssl-stylesheets-%{Version}/common/*
/usr/share/sgml/docbook/dsssl-stylesheets-%{Version}/html/*
/usr/share/sgml/docbook/dsssl-stylesheets-%{Version}/print/*
/usr/share/sgml/docbook/dsssl-stylesheets-%{Version}/test/*
/usr/share/sgml/docbook/dsssl-stylesheets-%{Version}/images/*


%Post
for centralized in /etc/sgml/*-docbook-*.cat; do
  if [ $1 -le 1 ]; then
    /usr/bin/install-catalog --add $centralized /usr/share/sgml/jade-1.2.1/catalog
  fi
  if [ $1 -le 1 -o `grep --count dsssl-stylesheets-%{Version} $centralized` -eq 0 ]; then
    /usr/bin/install-catalog --add $centralized /usr/share/sgml/docbook/dsssl-stylesheets-%{Version}/catalog
  fi
done


%Postun
for centralized in /etc/sgml/*-docbook-*.cat; do
  if [ $1 -le 0 ]; then
    /usr/bin/install-catalog --remove $centralized /usr/share/sgml/jade-1.2.1/catalog
  fi
  if [ $1 -le 0 -o `grep --count dsssl-stylesheets $centralized` -gt 1 ]; then
     /usr/bin/install-catalog --remove $centralized /usr/share/sgml/docbook/dsssl-stylesheets-%{Version}/catalog
  fi
done
