File susedoc.spec of Package susedoc

#
# spec file for package susedoc (Version MACRO)
#
# Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

# norootforbuild

%define dtdversion     1.0
%define packageversion 4.2
%define dtdname        novdoc
%define docbuilddir    /usr/share/susedoc
%define _version       20081009
%define _name          susedoc

Name:           susedoc
Requires:       libxml2 libxslt inkscape transfig ImageMagick java xml-commons-resolver docbook-xsl-stylesheets svg-dtd freefont xalan-j2 fop >= 0.94 make
#
#%if 0%{?opensuse_bs}
#%else
#Requires:       agfa-fonts
#%endif
#
%if %suse_version >= 1100
Recommends:     agfa-fonts
%endif
%if %suse_version >= 1000
BuildRequires:  sgml-skel unzip
%else
%endif
License:        GPL v2 or later
Group:          Productivity/Publishing/XML
AutoReqProv:    on
Version:        %{packageversion}_%{_version}
Release:        12
Summary:        XML Build Mechanics for Novell, SUSE, and openSUSE Documentation
# Needs to be fixed to openSUSE build server:
Url:            http://www.opensuse.org/Documentation_Team
Source0:        %{_name}-%{packageversion}_%{_version}.tar.bz2
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch
%define regcat /usr/bin/sgml-register-catalog
PreReq:         %{regcat} /usr/bin/xmlcatalog
Obsoletes:      novdoc-schema
Provides:       novdoc-schema
#Recommends:     agfa-fonts ttf-founder unfonts sazanami-fonts

%description
This RPM consists of a set of stylesheets, scripts and makefiles that
are used to create HTML, PDF and Wiki documents from Novdoc/DocBook
XML.

See also http://en.opensuse.org/Documentation_Team and
http://developer.novell.com/wiki/index.php/Lessons_for_Lizards.



Authors:
--------
    Thomas Schraitle <thomas.schraitle@suse.de>
    Berthold Gunreben <bg@suse.de>
    Karl Eichwalder <ke@suse.de>
    Curtis Graham 

%define INSTALL install -m755 -s
%define INSTALL_DIR install -d -m755
%define INSTALL_DATA install -m644
%define INSTALL_SCRIPT install -m755 -o root -g root
%define sgml_dir %{_datadir}/sgml
%define sgml_var_dir /var/lib/sgml
%define sgml_mod_dir %{sgml_dir}/novdoc
%define sgml_mod_dtd_dir %{sgml_mod_dir}/dtd
%define sgml_mod_custom_dir %{sgml_mod_dir}/custom
%define sgml_mod_style_dir %{sgml_mod_dir}/stylesheet
%define xml_dir %{_datadir}/xml
%define xml_mod_dir %{xml_dir}/novdoc/
%define xml_mod_dtd_dir %{xml_mod_dir}/schema/dtd/%{dtdversion}
%define xml_mod_custom_dir %{xml_mod_dir}/custom
%define xml_mod_style_dir %{xml_mod_dir}/stylesheet
%define sgml_config_dir /var/lib/sgml
%define sgml_sysconf_dir %{_sysconfdir}/sgml
%define xml_config_dir /var/lib/xml
%define xml_sysconf_dir %{_sysconfdir}/xml
#----------------------

%build
%define FOR_ROOT_CAT for-catalog-%{dtdname}-%{version}-%{release}.xml
%define FOR_XSLT_CAT for-catalog-%{dtdname}xslt-%{version}-%{release}.xml
xmlcatbin=/usr/bin/xmlcatalog
# build root catalog fragment
rm -f %{FOR_ROOT_CAT}.tmp %{FOR_XSLT_CAT}.tmp
$xmlcatbin --noout --create %{FOR_ROOT_CAT}.tmp
#CATALOG=%{xml_mod_dtd_dir}/catalog.xml
NOVCAT=%{xml_mod_dtd_dir}/catalog.xml
$xmlcatbin --noout --add "delegatePublic" "-//Novell//DTD NovDoc XML" \
    "file://$NOVCAT" %{FOR_ROOT_CAT}.tmp
$xmlcatbin --noout --add "delegateSystem" "novdocx.dtd" \
    "file://$NOVCAT" %{FOR_ROOT_CAT}.tmp
# Create tag
sed '/<catalog/a\
  <group id="%{dtdname}-%{version}-%{release}">
/<\/catalog/i\
  </group>' \
  %{FOR_ROOT_CAT}.tmp > %{FOR_ROOT_CAT}
#
$xmlcatbin --noout --create %{FOR_XSLT_CAT}.tmp
$xmlcatbin --noout --add "system" "urn:x-suse:xslt:profiling:docbook41-profile.xsl" \
  "file://%{docbuilddir}/xslt/profiling/docbook41-profile.xsl" %{FOR_XSLT_CAT}.tmp
$xmlcatbin --noout --add "system" "urn:x-suse:xslt:profiling:docbook42-profile.xsl" \
  "file://%{docbuilddir}/xslt/profiling/docbook42-profile.xsl" %{FOR_XSLT_CAT}.tmp
$xmlcatbin --noout --add "system" "urn:x-suse:xslt:profiling:docbook43-profile.xsl" \
  "file://%{docbuilddir}/xslt/profiling/docbook43-profile.xsl" %{FOR_XSLT_CAT}.tmp
$xmlcatbin --noout --add "system" "urn:x-suse:xslt:profiling:docbook44-profile.xsl" \
  "file://%{docbuilddir}/xslt/profiling/docbook44-profile.xsl" %{FOR_XSLT_CAT}.tmp
$xmlcatbin --noout --add "system" "urn:x-suse:xslt:profiling:novdoc-profile.xsl" \
  "file://%{docbuilddir}/xslt/profiling/novdoc-profile.xsl" %{FOR_XSLT_CAT}.tmp
#$xmlcatbin --noout --add "rewriteSystem" "urn:x-suse:common:" \
#  "file://$NOVCAT" %{FOR_ROOT_CAT}.tmp
sed '/<catalog/a\
  <group id="%{dtdname}xslt-%{version}-%{release}">
/<\/catalog/i\
  </group>' \
  %{FOR_XSLT_CAT}.tmp > %{FOR_XSLT_CAT}
#----------------------

%install
[ "$RPM_BUILD_ROOT" != "/" ] && [ -d $RPM_BUILD_ROOT ] && rm -rf $RPM_BUILD_ROOT;
mkdir -p $RPM_BUILD_ROOT/usr/share \
         $RPM_BUILD_ROOT/%{_bindir} \
         $RPM_BUILD_ROOT/%{xml_dir}/%{dtdname}/schema/{dtd,rng}/%{dtdversion}
tar xjf %{SOURCE0} -C $RPM_BUILD_ROOT/usr/share
mv $RPM_BUILD_ROOT/usr/share/%{name}/schema/{*.dtd,catalog.xml,CATALOG} \
   $RPM_BUILD_ROOT/%{xml_dir}/%{dtdname}/schema/dtd/%{dtdversion}
mv $RPM_BUILD_ROOT/usr/share/%{name}/schema/*.rng \
   $RPM_BUILD_ROOT/%{xml_dir}/%{dtdname}/schema/rng/%{dtdversion}
# Catalog
%{INSTALL_DIR} $RPM_BUILD_ROOT%{sgml_var_dir}
%{INSTALL_DIR} $RPM_BUILD_ROOT%{sgml_dir}
echo "CATALOG \"%{xml_mod_dtd_dir}/CATALOG\"" \
  >$RPM_BUILD_ROOT%{sgml_var_dir}/CATALOG.%{dtdname}-%{dtdversion}
ln -s %{sgml_var_dir}/CATALOG.%{dtdname}-%{dtdversion} \
  $RPM_BUILD_ROOT%{sgml_dir}/CATALOG.%{dtdname}-%{dtdversion}
cat_dir=%{buildroot}/etc/xml
%{INSTALL_DIR} $cat_dir
%{INSTALL_DATA} %{FOR_ROOT_CAT} $cat_dir
%{INSTALL_DATA} %{FOR_XSLT_CAT} $cat_dir
%define all_cat CATALOG.%{dtdname}-%{dtdversion}
%{__mv} $RPM_BUILD_ROOT/%{docbuilddir}/bin/susedoc-new.py  $RPM_BUILD_ROOT/%{_bindir} 
#----------------------

%post
if [ -x %{regcat} ]; then
  for c in  %{all_cat}; do
    %{regcat} -a %{sgml_dir}/$c >/dev/null 2>&1
  done
fi
edit-xml-catalog --group --catalog /etc/xml/suse-catalog.xml \
  --add /etc/xml/%{FOR_ROOT_CAT}
edit-xml-catalog --group --catalog /etc/xml/suse-catalog.xml \
  --add /etc/xml/%{FOR_XSLT_CAT}
exit 0
#----------------------

%postun
if [ "$1" = "0" -a -x %{regcat} ]; then
  for c in  %{all_cat}; do
    %{regcat} -r %{sgml_dir}/$c >/dev/null 2>&1
  done
fi
#now XML catalog
edit-xml-catalog --group --catalog /etc/xml/suse-catalog.xml \
  --del %{dtdname}-%{version}-%{release}
edit-xml-catalog --group --catalog /etc/xml/suse-catalog.xml \
  --del %{dtdname}xslt-%{version}-%{release}
exit 0

%clean
[ "$RPM_BUILD_ROOT" != "/" ] && [ -d $RPM_BUILD_ROOT ] && rm -rf $RPM_BUILD_ROOT;

%files
%defattr(-,root,root)
#%dir %{sgml_dir}
%if %suse_version <= 1020
#%dir %{xml_dir}
%endif
%config %{sgml_var_dir}/*
%config %{xml_sysconf_dir}/%{FOR_ROOT_CAT}
%config %{xml_sysconf_dir}/%{FOR_XSLT_CAT}
%{_bindir}/susedoc-new.py
%{sgml_dir}/CATALOG.%{dtdname}-%{dtdversion}
%{xml_dir}/%{dtdname}/
%{docbuilddir}

# 
%changelog
* Thu Oct 09 2008 toms@suse.de
  Updated to 20081009:
- Novdoc DTD: Allow remark in places where DocBook did it too
- Introduced processing instrucction suse to resolve entities
  in a product independant way
- Makefile: Added new project file which is needed for every
  project. It is autogenerated and saved as PROJECTFILE.<P>
  where P is the placeholder for the product/book
* Wed Jun 18 2008 toms@suse.de
- Makefile changes:
  * Added images/gen directory to the list in mkdir
  * Added mkdir command in .env-profile
- Stylesheet changes:
  * Corrected draft.watermark.image and take into account dtdroot
  parameter
  * Copied draft.png from http://docbook.sourceforge.net/release/images/draft.png
  and optipng'ed (reduced size to 50%%)
  * Changed XEP hyphenation pattern file for Hungarian:
  huhyphn_rx.tex -> huhyph_rx.tex
  See also http://services.renderx.com/lists/xep-support/5551.html
- Other changes:
  * Added missing dependency for make (thanks to Tanja!)
  * Cleaned up SPEC file, corrected version
  * Updated susedoc-new.py script
* Fri Jun 06 2008 toms@suse.de
- Makefile changes:
  * Better separation between generated image formats and untouched ones
  (new directory images/gen)
  * Fixed bugs in Makefiles
  * Added target showvariables
- Stylesheets changes
  * xslt/html/suse-titlepage.xsl: Added title and bookinfo/title in the
  xsl:choose/xsl:when switch
  * xslt/html/navig.header.footer.xsl: Correct header with double titles
* Wed Apr 02 2008 toms@suse.de
- Fixed font handling for Japanese and Korean too
- Fixed broken text in es.xml and ja.xml
- Added warning comment in ~/.susedoc/xep-suse.xml inserted by
  bin/xepchangefontpath.py
* Tue Apr 01 2008 toms@suse.de
- Fixed font handling for Chinese documents
- Corrected xml:base for Chinese fonts in xep-suse.xml
- Added parameter debug.fonts to output debugging information
  about fonts (turned on as default)
* Wed Mar 19 2008 toms@suse.de
- Improved make targets and image building process
- Fixed several bugs in XSLT stylesheets (see Changelog for details)
* Mon Oct 08 2007 toms@suse.de
- Fixed xslt/common/l10n/{zh_cn.xml,zh_tw.xml}: Broken Unicode
- Fixed xslt/flyer/fonts.xsl:
  Using XPath (key('id', $rootid)/@lang | /*/@lang )
  to select the language of the document. Needed for Chinese.
  It seems, language isn't passed on. :-(
- xslt/desktop/docbook.xsl:
  * remove X-DOC-Identifier from .desktop files.
  * Wrong numbers for X-DOC-Weight in Quick Starts
  * resolve all @id@ in stand-alone books
- xslt/misc/svg.color2grayscale.xsl
  Template @fill|@stroke: Added xsl:choose to test, if
  $color.nodes[@name=current()]/@grayvalue is empty.
  Content can be an "rgb(...)" function.
  Problem: It seems, XEP can not handle rgb() functions
  TODO: Convert rgb() into something useful that XEP can handle
- xslt/fo/verbatim.xsl:
  screen: Taking care of processing-instruction inside example.
  Now you have two possible solutions:
  <example>
  <title>...</title>
  <?dbsuse-fo font-size="..."?>
  <screen>...</screen>
  </example>
  or
  <example>
  <title>...</title>
  <screen><?dbsuse-fo font-size="..."?>...</screen>
  </example>
- bin/suse-fop, bin/suse-xep:
  Corrected behavior of checking xml-commons-resolver (actually it is
  provided by two packages: xerces-j2 and xml-commons-resolver)
- etc/system-profile, make/common.mk
  use optipng only if available
* Thu Aug 30 2007 toms@suse.de
- Corrected Requires keywords and added version numbers for openSUSE
  Build Server
- Corrected behavior of checking xml-commons-resolver (actually it is
  provided by two packages: xerces-j2 and xml-commons-resolver)
  Also a bug with JAVACMD in suse-fop, found by Marcus Schäfer
* Thu Aug 30 2007 toms@suse.de
- Fixed xsl:preserve-space for titles (xslt/fo/docbook.xsl)
- Fixed index title in xslt/fo/index.xsl
- Support for optipng
* Fri Aug 17 2007 toms@suse.de
- Corrected FOP font issue (Thanks to Nikolay Derkach!).
  Configuration file of FOP and fo/fonts.xsl contained different
  font names (actually, they are aliases).
  Used common/l10n/*.xml files to insert font configuration for FOP
  and XEP.
* Tue Aug 14 2007 toms@suse.de
- created new release 20070813:
  * Corrected desktop/docbook.xsl
  * Uses LANG=C for dia
  * Improved make clean to remove images
- Release 20070730 (not published):
  * Corrected desktop/docbook.xsl
  * Language corrections from Patrick Tinley and Nikolay Derkach
  * Special appearance for legal text in sect1[@role="legal"]
  * Preparing new index method
* Fri May 25 2007 toms@suse.de
- Corrected dependencies for openSUSE 10.3 (svg-dtd -> svg-schema)
  No source changes
* Wed Mar 21 2007 toms@suse.de
- Created vendor release 20070321
  . xsl/desktop/docbook.xsl: New attempt to creating part directories
  . New stylesheet to convert output from OCF to refentry-
* Thu Mar 08 2007 toms@suse.de
- Corrected list of files
* Tue Mar 06 2007 toms@suse.de
- Created new release 20070306
* Wed Feb 28 2007 toms@suse.de
- Added russian translation (Thanks to Nikolay Derkach)
- Better support for FOP
- Improved design of Makefiles and ENV*files
* Wed Feb 14 2007 toms@suse.de
- Created new release 20070214
- Separated layout from ENV file
- Get rid of unnecessary environment variables
- Fallback behavior for missing profiling stylesheets fixed
- Improved CSS handling
- Support for multiple entity files
- Several improvements for our "internal" stylesheets of
  creating of creating openSUSE manuals (see xslt/ChangeLog for details)
* Wed Jan 17 2007 toms@suse.de
- New package for 10.3
openSUSE Build Service is sponsored by