File docbook-xsl-stylesheets.spec of Package docbook-xsl-stylesheets

#
# spec file for package docbook-xsl-stylesheets
#
# Copyright (c) 2015 SUSE LINUX 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/
#


%define realversion            1.78.1

%define dbstyle_dir            %{_datadir}/xml/docbook/stylesheet/nwalsh
%define dbstyle_catalog        %{name}.xml
%define suse_catalog           %{_sysconfdir}/xml/suse-catalog.xml
%define xmlcatalog             %{_bindir}/xmlcatalog
%define dbstyle_catalog_entry  for-catalog-%{name}-%{realversion}.xml

Name:           docbook-xsl-stylesheets
Summary:        XSL Stylesheets for DocBook 4
License:        MPL-1.1 and MIT
Group:          Productivity/Publishing/DocBook
BuildRequires:  fdupes
BuildRequires:  sgml-skel
BuildRequires:  unzip
# BuildRequires:  dos2unix
BuildArch:      noarch
Requires:       docbook_4
Requires:       xmlcharent
PreReq:         sgml-skel %{_bindir}/xmlcatalog
Version:        1.78.1+svn9743
Release:        0
Source0:        http://switch.dl.sourceforge.net/sourceforge/docbook/docbook-xsl-%{realversion}.tar.bz2
Source1:        http://switch.dl.sourceforge.net/sourceforge/docbook/docbook-xsl-doc-%{realversion}.tar.bz2
Source10:       dbxslt-install.sh

## PATCH-FIX-OPENSUSE docbook-xsl-stylesheets-dbtoepub.patch Fixed dirname
Patch0:         %{name}-dbtoepub.patch

## PATCH-FIX-OPENSUSE docbook-xsl-stylesheets-epub3-base.dir-r9742.patch Fix for base.dir parameter
Patch10:        %{name}-epub3-base.dir.patch

## PATCH-FIX-OPENSUSE docbook-xsl-stylesheets-manpages-other-r9847.patch Fixed upstream bug #1313
Patch11:        %{name}-manpages-other-r9847.patch

BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Url:            http://sourceforge.net/projects/docbook/

#--------------------------------------------------------------------------
%description
These are the XSL stylesheets for DocBook XML and "Simplified" DocBook
DTDs. Use these stylesheets for documents based on DocBook 4 and
earlier; they are not aware of the namespace feature.

The stylesheets transform DocBook documents into HTML, XHTML, Manpages,
XSL-FO (for PDF), and a few other formats.

XSL is a standard W3C stylesheet language for both print and online
rendering. For more information about XSL, see the XSL page at the W3C:
http://www.w3.org/Style/XSL/


# Package
%package        scripts 
# License:       MPL-1.1 and MIT 
Summary:        Script to create Indices for FOP
Group:          Productivity/Publishing/XML
Requires:       ImageMagick
Requires:       perl
Requires:       ruby

%description scripts

Contains several scripts:

* pdf2index:    Create indices for FOP
* db2epub:      Create EPUB2 output
* callout-gen:  Create callout icons using ImageMagick

This package may be obsolete in the future.

#--------------------------------------------------------------------------
%prep
%setup -q -n docbook-xsl-%{realversion} -b1
%patch0 -p1
%patch10 -p0
%patch11 -p0

cp %{S:10} .

#--------------------------------------------------------------------------
%build
# 
#
find slides -regex ".*\.\(xml\|htc\|\|hu\|js\|svg\|css\|html\.*\|txt\|rnc\|xhtml\)" \
   -exec sed -i 's/\r//' {} \;

# Fix wrong end-of-line encoding
sed -i 's/\r//' params/*

#
find -type f -exec chmod 644 {} \;
find -type d -exec chmod 755 {} \;
chmod 755 extensions/xslt.py

#--------------------------------------------------------------------------
%install

sh ./dbxslt-install.sh --package-version="%{realversion}" --buildroot=%{buildroot}

# fixing permission errors from sources

# create current link
# but not for snapshots
#
if ! echo %{S:0} | grep -q snapshot; then
   pushd %{buildroot}%{dbstyle_dir} >/dev/null
    ln -sf %{realversion} current
   popd >/dev/null
fi

# the docs come last
%__tar c -C doc . | (cd %{buildroot}%{_defaultdocdir}/%{name}/html; %__tar xp);

%fdupes -s %{buildroot}

#--------------------------------------------------------------------------
%post
#
# XML Catalog entries
#
# remove existing entries first (if existing) - needed for
# zypper in, since it does not call postun
#
# in case of an update, remove old
if [ "2" = "$1" ]; then
  %{_bindir}/edit-xml-catalog --group --catalog %{suse_catalog} --del %{name}
fi
# ... and (re)add it again
%{_bindir}/edit-xml-catalog --group --catalog %{suse_catalog} \
  --add %{_sysconfdir}/xml/%{dbstyle_catalog_entry}

exit 0

#--------------------------------------------------------------------------
%postun
#
# delete catalog entry
# only run if package is really uninstalled ($1 = 0) and not
# in case of an update
#
if [ "0" = "$1" ]; then
   %{_bindir}/edit-xml-catalog --group --catalog %{suse_catalog} --del %{name}
fi

exit 0

#--------------------------------------------------------------------------
%files
%defattr(-, root, root)
%config %{_sysconfdir}/xml/*.xml
%doc BUGS NEWS README RELEASE-NOTES.txt TODO
%dir %{_datadir}/xml/docbook/stylesheet
%dir %{_datadir}/xml/docbook/stylesheet/nwalsh
%dir %{dbstyle_dir}/%{realversion}

%exclude %{dbstyle_dir}/%{realversion}/slides/slidy/.htaccess
%exclude %{dbstyle_dir}/%{realversion}/slides/slidy/*/.htaccess
# %%exclude %%{dbstyle_dir}/svn-commit.tmp
# %%exclude %%{dbstyle_dir}/%%{realversion}/*/*.xsl.orig

%{dbstyle_dir}/current
%{dbstyle_dir}/%{realversion}/*

%files scripts
%defattr(-, root, root)
%{_bindir}/callout-gen
%{_bindir}/dbtoepub
%{_bindir}/pdf2index

%changelog