SHA256
1
0
forked from pool/docbook_5
docbook_5/docbook_5.spec

325 lines
10 KiB
RPMSpec

#
# spec file for package docbook_5
#
# 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/
#
Name: docbook_5
Summary: DocBook Schemas (DTD, RELAX NG, W3C Schema) for Version 5.x
License: SUSE-Oasis-Specification-Notice
Group: Productivity/Publishing/DocBook
Version: 5.1CR3
Release: 0
# Requires: libxml2
BuildRequires: fdupes
BuildRequires: sgml-skel
PreReq: /usr/bin/xmlcatalog sgml-skel
PreReq: sed grep awk
Source2: docbook_5-README.SUSE
# DocBook Specifications:
Source3: docbook-5.0-spec-cd-01.pdf
Source4: docbook-5.0-spec-cd-01.html
Source5: docbook-5.0-spec-cd-01.xml
# DB 5.0
Source500: docbook-5.0.tar.bz2
# DB 5.1CR3
Source510: docbook-5.1CR3.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildArch: noarch
Url: http://www.oasis-open.org/docbook/
%define schemaversions 5.0 5.1
%define lastschemaversion 5.1
%description
The version 5.0 release is a complete rewrite of DocBook in RELAX NG.
The intent of this rewrite is to produce a schema that is true to the
spirit of DocBook while simultaneously removing inconsistencies that
have arisen as a natural consequence of DocBook's long, slow evolution.
%define INSTALL install -m755 -s
%define INSTALL_DIR install -d -m755
%define INSTALL_DATA install -m644
%define INSTALL_SCRIPT install -m755
%define xml_dir %{_datadir}/xml
%define xml_docbook_dir %{xml_dir}/docbook
%define xml_schema_dir %{xml_dir}/docbook/schema
%define xml_docbook_dtd_dir %{xml_schema_dir}/dtd
%define xml_docbook_rng_dir %{xml_schema_dir}/rng
%define xml_docbook_sch_dir %{xml_schema_dir}/sch
%define xml_docbook_xsd_dir %{xml_schema_dir}/xsd
%define xml_docbook_custom_dir %{xml_docbook_dir}/custom
%define xml_docbook_style_dir %{xml_docbook_dir}/stylesheet
%define xml_config_dir /var/lib/xml
%define xml_sysconf_dir %{_sysconfdir}/xml
%prep
%setup -n %{name} -c -T
# Copy README
cp -p %{S:2} .
# Copy the DocBook Specifications:
cp %{S:3} %{S:4} %{S:5} .
tar -xjf %{S:500}
tar -xjf %{S:510}
mv docbook-%{version} docbook-%{lastschemaversion}
chmod -R a+rX,g-w,o-w .
find . -type f | xargs chmod a-x
%build
# # build root catalog fragment
xmlcatbin=/usr/bin/xmlcatalog
CATALOG=%{name}.xml
$xmlcatbin --create --noout $CATALOG
# Iterate over all versions...
for v in %{schemaversions}; do
docbookdir=%{xml_docbook_dtd_dir}/${v}
$xmlcatbin --noout --add "public" \
"-//OASIS//DTD DocBook XML ${v}//EN" \
"file://%{xml_docbook_dtd_dir}/${v}/docbook.dtd" ${CATALOG}
# We need to create lots of URIs...
for http in "http://www.oasis-open.org/docbook/xml" \
"http://www.docbook.org/xml" \
"http://docbook.org/xml" ; do
# DTDs
$xmlcatbin --noout --add "rewriteSystem" \
"${http}/${v}" \
"file://$docbookdir" $CATALOG
$xmlcatbin --noout --add "rewriteURI" \
"${http}/${v}" \
"file://$docbookdir" $CATALOG
# RNG, RNG+XInclude
$xmlcatbin --noout --add "rewriteSystem" \
"${http}/${v}/rng/" \
"file://%{xml_docbook_rng_dir}/${v}/" ${CATALOG}
$xmlcatbin --noout --add "rewriteURI" \
"${http}/${v}/rng/" \
"file://%{xml_docbook_rng_dir}/${v}/" ${CATALOG}
# XSD, XSD+XInclude
$xmlcatbin --noout --add "rewriteSystem" \
"${http}/${v}/xsd/" \
"file://%{xml_docbook_xsd_dir}/${v}/" ${CATALOG}
$xmlcatbin --noout --add "rewriteURI" \
"${http}/${v}/xsd/" \
"file://%{xml_docbook_xsd_dir}/${v}/" ${CATALOG}
# Schematron
$xmlcatbin --noout --add "rewriteSystem" \
"${http}/${v}/sch/" \
"file://%{xml_docbook_sch_dir}/${v}/" ${CATALOG}
$xmlcatbin --noout --add "rewriteURI" \
"${http}/${v}/sch/" \
"file://%{xml_docbook_sch_dir}/${v}/" ${CATALOG}
done
done
# ---------------------
# Build XML catalog files for each Schema
for v in %{schemaversions}; do
for s in dtd rng sch xsd; do
cat=docbook-${v}/${s}/catalog.xml
$xmlcatbin --noout --create ${cat}
$xmlcatbin --noout --add "public" \
"-//OASIS//DTD DocBook XML ${v}//EN" \
"docbook.dtd" ${cat}
for http in "http://www.oasis-open.org/docbook/xml" \
"http://www.docbook.org/xml" \
"http://docbook.org/xml" ; do
case ${s} in
dtd)
$xmlcatbin --noout --add "system" \
"${http}/${v}/dtd/docbook.dtd" \
"docbook.dtd" ${cat}
;;
rng)
for ff in docbook.rng docbook.rnc \
"docbookxi.${s}" docbookxi.rnc \
assembly.rng assembly.rnc \
dbits.rng dbits.rnc; do
$xmlcatbin --noout --add "system" \
"${http}/${v}/${s}/${ff}" \
"${ff}" ${cat}
$xmlcatbin --noout --add "uri" \
"${http}/${v}/${s}/${ff}" \
"${ff}" ${cat}
done
;;
sch)
$xmlcatbin --noout --add "system" \
"${http}/${v}/${s}/docbook.${s}" \
"docbook.${s}" ${cat}
$xmlcatbin --noout --add "uri" \
"${http}/${v}/${s}/docbook.${s}" \
"docbook.${s}" ${cat}
;;
xsd)
for ff in "docbook.${s}" "docbookxi.${s}" xlink.xsd xml.xsd; do
$xmlcatbin --noout --add "system" \
"${http}/${v}/${s}/${ff}" \
"${ff}" ${cat}
$xmlcatbin --noout --add "uri" \
"${http}/${v}/${s}/${ff}" \
"${ff}" ${cat}
done
;;
esac
done
done
done
%define FOR_ROOT_CAT for-catalog-%{name}-%{version}.xml
CATALOG=etc/xml/$CATALOG
rm -f %{FOR_ROOT_CAT}.tmp
$xmlcatbin --noout --create %{FOR_ROOT_CAT}.tmp
for v in %{schemaversions}; do
cat=%{xml_docbook_dtd_dir}/${v}/catalog.xml
# DTDs
$xmlcatbin --noout --add "delegatePublic" \
"-//OASIS//DTD DocBook XML ${v}//EN" \
"file://%{xml_docbook_dtd_dir}/${v}/catalog.xml" \
%{FOR_ROOT_CAT}.tmp
for http in "http://www.oasis-open.org/docbook/xml" \
"http://www.docbook.org/xml" \
"http://docbook.org/xml" ; do
$xmlcatbin --noout --add "delegateSystem" \
"${http}/${v}/dtd/" \
"file://%{xml_docbook_dtd_dir}/${v}/catalog.xml" \
%{FOR_ROOT_CAT}.tmp
$xmlcatbin --noout --add "delegateSystem" \
"${http}/${v}/rng/" \
"file://%{xml_docbook_rng_dir}/${v}/catalog.xml" \
%{FOR_ROOT_CAT}.tmp
$xmlcatbin --noout --add "delegateSystem" \
"${http}/${v}/xsd/" \
"file://%{xml_docbook_xsd_dir}/${v}/catalog.xml" \
%{FOR_ROOT_CAT}.tmp
$xmlcatbin --noout --add "delegateSystem" \
"${http}/${v}/sch/" \
"file://%{xml_docbook_sch_dir}/${v}/catalog.xml" \
%{FOR_ROOT_CAT}.tmp
done
done
# Create tag
sed '/<catalog/a\
<group id="%{name}-%{version}">
/<\/catalog/i\
</group>' \
%{FOR_ROOT_CAT}.tmp > %{FOR_ROOT_CAT}
%install
# Create installation structure
%{INSTALL_DIR} $RPM_BUILD_ROOT%{xml_config_dir} \
$RPM_BUILD_ROOT%{_bindir} \
$RPM_BUILD_ROOT%{xml_docbook_style_dir}/upgrade
cat_dir=%{buildroot}/etc/xml
%{INSTALL_DIR} $cat_dir
%{INSTALL_DATA} %{FOR_ROOT_CAT} %{name}.xml $cat_dir
for v in %{schemaversions}; do
# Create directories
mkdir -p $RPM_BUILD_ROOT%{xml_docbook_dtd_dir}/$v \
$RPM_BUILD_ROOT%{xml_docbook_rng_dir}/$v \
$RPM_BUILD_ROOT%{xml_docbook_sch_dir}/$v \
$RPM_BUILD_ROOT%{xml_docbook_xsd_dir}/$v
#
%{INSTALL_DATA} docbook-$v/dtd/* $RPM_BUILD_ROOT%{xml_docbook_dtd_dir}/$v
%{INSTALL_DATA} docbook-$v/rng/* $RPM_BUILD_ROOT%{xml_docbook_rng_dir}/$v
%{INSTALL_DATA} docbook-$v/sch/* $RPM_BUILD_ROOT%{xml_docbook_sch_dir}/$v
%{INSTALL_DATA} docbook-$v/xsd/* $RPM_BUILD_ROOT%{xml_docbook_xsd_dir}/$v
done
# Use the latest version. If not found, fall back to 5.0
if [ ! -e docbook-$v/tools/db4-entities.pl ] ; then
v=5.0
fi
%{INSTALL_SCRIPT} docbook-$v/tools/db4-entities.pl $RPM_BUILD_ROOT%{_bindir}
%{INSTALL_DATA} docbook-$v/tools/db4-upgrade.xsl \
$RPM_BUILD_ROOT%{xml_docbook_style_dir}/upgrade
# Install NDVL file(s)
#for v in %%{version}; do
# %%{INSTALL_DATA} docbook-$v/docbook.nvdl $RPM_BUILD_ROOT%%{xml_docbook_rng_dir}/$v
#done
# cleanup
%fdupes $RPM_BUILD_ROOT
%post
# in case of an update, remove old
if [ "2" = "$1" ]; then
/usr/bin/edit-xml-catalog --group --catalog /etc/xml/suse-catalog.xml \
--del %{name}-%{version} || true
fi
/usr/bin/edit-xml-catalog --group --catalog /etc/xml/suse-catalog.xml \
--add /etc/xml/%{FOR_ROOT_CAT}
%postun
# remove entries only on removal of file
if [ "0" = "$1" -a ! -f %{xml_sysconf_dir}/%{FOR_ROOT_CAT} ] ; then
/usr/bin/edit-xml-catalog --group --catalog /etc/xml/suse-catalog.xml \
--del %{name}-%{version}
fi
%files
%defattr(-, root, root)
%config %{xml_sysconf_dir}/docbook_5.xml
%config %{xml_sysconf_dir}/%{FOR_ROOT_CAT}
%doc *README*
%doc docbook-5.0-spec-cd-01.{pdf,html,xml}
# Use the last version of DocBook:
%doc docbook-5.0/docs/* docbook-%{lastschemaversion}/docbook.nvdl
#%%{sgml_dir}/CATALOG.*
%dir %{xml_docbook_dir}/schema
%dir %{xml_docbook_dtd_dir}
%dir %{xml_docbook_rng_dir}
%dir %{xml_docbook_sch_dir}
%dir %{xml_docbook_xsd_dir}
%dir %{xml_docbook_style_dir}
# 5.0
%{xml_docbook_dtd_dir}/5.0
%{xml_docbook_rng_dir}/5.0
%{xml_docbook_sch_dir}/5.0
%{xml_docbook_xsd_dir}/5.0
%{xml_docbook_style_dir}/upgrade
# 5.1CR3
%{xml_docbook_dtd_dir}/%{lastschemaversion}
%{xml_docbook_rng_dir}/%{lastschemaversion}
%{xml_docbook_sch_dir}/%{lastschemaversion}
%{xml_docbook_xsd_dir}/%{lastschemaversion}
%{_bindir}/db4-entities.pl
%changelog