Name:         docbook-style-xsl
Version:      1.79.2
Release:      11
Summary:      XSLT 1.0 Stylesheets for DocBook 
License:      MIT
URL:          https://github.com/docbook/xslt10-stylesheets
Source0:      https://github.com/docbook/xslt10-stylesheets/releases/download/release%2F1.79.2/docbook-xsl-doc-1.79.2.tar.bz2
Source1:      https://github.com/docbook/xslt10-stylesheets/releases/download/release%2F1.79.2/docbook-xsl-nons-1.79.2.tar.bz2
Source2:      %{name}.Makefile
BuildArch:    noarch

Requires:docbook-dtd-xml xml-common >= 0.6.3-8
Requires(post): libxml2 >= 2.4.8
Requires(postun): libxml2 >= 2.4.8
Conflicts: passivetex < 1.21

Provides:docbook-xsl = %{version}

Patch1:  docbook-xsl-pagesetup.patch
Patch2:  docbook-xsl-marginleft.patch
Patch3:  docbook-xsl-newmethods.patch
Patch4:  docbook-xsl-non-constant-expressions.patch
Patch5:  docbook-xsl-list-item-body.patch
Patch6:  docbook-xsl-mandir.patch
Patch7:  docbook-style-xsl-non-recursive-string-subst.patch
Patch8:  docbook-style-xsl-1.79.2-fix-gtk-doc-multilib.patch

%description
These are XSL stylesheets for transforming DocBook XML document
instances into various output formats.

%prep
%setup -c -T -n docbook-xsl-%{version} 
tar -jx -f %{SOURCE1} --strip-components 1
cd ..
tar -jx -f %{SOURCE0} 
cd -
cp -p %{SOURCE2} Makefile
%patch1 -p1 -b .pagesetup
%patch2 -p1 -b .marginleft
%patch3 -p1 -b .newmethods
%patch4 -p1 -b .nonconstant
%patch5 -p1 -b .listitembody
%patch6 -p1 -b .mandir
%patch7 -p1 -b .non-recursive-subst
%patch8 -p1 -b .gtk-doc-multilib

for fhtml in $(find ./doc -name '*.html' -type f)
do
  iconv -f ISO-8859-1 -t UTF-8 "$fhtml" -o "$fhtml".tmp
  mv -f "$fhtml".tmp "$fhtml"
  sed -i 's/charset=ISO-8859-1/charset=UTF-8/' "$fhtml"
done

%build

%install
make install DESTDIR=%{buildroot}%{_datadir}/sgml/docbook/xsl-stylesheets-%{version}
cp -a VERSION.xsl %{buildroot}%{_datadir}/sgml/docbook/xsl-stylesheets-%{version}/VERSION.xsl
ln -s xsl-stylesheets-%{version} %{buildroot}%{_datadir}/sgml/docbook/xsl-stylesheets
rm -rf %{buildroot}%{_datadir}/sgml/docbook/xsl-stylesheets/extensions/*

%pre

%preun

%post
CATALOG=%{_sysconfdir}/xml/catalog
%{_bindir}/xmlcatalog --noout --add "rewriteSystem" \
 "http://cdn.docbook.org/release/xsl-nons/%{version}" \
 "file://%{_datadir}/sgml/docbook/xsl-stylesheets-%{version}" $CATALOG
%{_bindir}/xmlcatalog --noout --add "rewriteURI" \
 "http://cdn.docbook.org/release/xsl-nons/%{version}" \
 "file://%{_datadir}/sgml/docbook/xsl-stylesheets-%{version}" $CATALOG
%{_bindir}/xmlcatalog --noout --add "rewriteSystem" \
 "http://cdn.docbook.org/release/xsl-nons/current/" \
 "file://%{_datadir}/sgml/docbook/xsl-stylesheets-%{version}" $CATALOG
%{_bindir}/xmlcatalog --noout --add "rewriteURI" \
 "http://cdn.docbook.org/release/xsl-nons/current/" \
 "file://%{_datadir}/sgml/docbook/xsl-stylesheets-%{version}" $CATALOG
%{_bindir}/xmlcatalog --noout --add "rewriteSystem" \
 "http://docbook.sourceforge.net/release/xsl/current" \
 "file://%{_datadir}/sgml/docbook/xsl-stylesheets-%{version}" $CATALOG
%{_bindir}/xmlcatalog --noout --add "rewriteURI" \
 "http://docbook.sourceforge.net/release/xsl/current" \
 "file://%{_datadir}/sgml/docbook/xsl-stylesheets-%{version}" $CATALOG

%postun
if [ "$1" = 0 ]; then
  CATALOG=%{_sysconfdir}/xml/catalog
  %{_bindir}/xmlcatalog --noout --del \
   "file://%{_datadir}/sgml/docbook/xsl-stylesheets-%{version}" $CATALOG
fi

%files
%defattr(-,root,root)
%doc BUGS README TODO doc/
%{_datadir}/sgml/docbook/xsl-stylesheets*

%changelog
* Mon Jun 20 2022 liukuo <liukuo@kylinos.cn> - 1.79.2-11
- License compliance rectification

* Fri Jun 17 2022 dillon chen <dillon.chen@gmail.com> - 1.79.2-10
- add patch8

* Fri Sep 20 2019 openEuler Buildteam <buildteam@openeuler.org> - 1.79.2-9 
- Package init
