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

349 lines
13 KiB
RPMSpec

#
# spec file for package docbook_5
#
# Copyright (c) 2013 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/
#
Name: docbook_5
Summary: DocBook Schemas (DTD, RELAX NG, W3C Schema) for Version 5.x
License: BSD-3-Clause and MIT
Group: Productivity/Publishing/DocBook
Version: 5.0
Release: 0
Requires: libxml2
BuildRequires: sgml-skel
PreReq: /usr/bin/xmlcatalog sgml-skel
PreReq: sed grep awk
Source2: docbook_5-README.SuSE
# DocBook Specifications:
Source3: docbook-%{version}-spec-cd-01.pdf
Source4: docbook-%{version}-spec-cd-01.html
Source5: docbook-%{version}-spec-cd-01.xml
# DB 5.0
Source500: http://www.docbook.org/xml/%{version}/docbook-%{version}.tar.bz2
#Source504: CATALOG.db50CR1xml
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildArch: noarch
Url: http://www.oasis-open.org/docbook/
%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_docbook_dtd_dir %{xml_docbook_dir}/schema/dtd
%define xml_docbook_rng_dir %{xml_docbook_dir}/schema/rng
%define xml_docbook_sch_dir %{xml_docbook_dir}/schema/sch
%define xml_docbook_xsd_dir %{xml_docbook_dir}/schema/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
cp -p $RPM_SOURCE_DIR/%{name}-README.SuSE README.SuSE
# Copy the DocBook Specifications:
cp %{S:3} %{S:4} %{S:5} .
#
#unzip -q -a %{S:500}
tar -xjf %{S:500}
#
# CATALOG.* files
#cp %{S:504} .
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
for v in %{version}; do
# DTD
$xmlcatbin --noout --add "public" \
"-//OASIS//DTD DocBook XML ${v}//EN" \
"file://%{xml_docbook_dtd_dir}/${v}/docbook.dtd" ${CATALOG}
$xmlcatbin --noout --add "system" \
"http://www.oasis-open.org/docbook/xml/${v}/dtd/docbook.dtd" \
"file://%{xml_docbook_dtd_dir}/${v}/docbook.dtd" ${CATALOG}
$xmlcatbin --noout --add "system" \
"http://docbook.org/xml/${v}/dtd/docbook.dtd" \
"file://%{xml_docbook_dtd_dir}/${v}/docbook.dtd" ${CATALOG}
# RNG
$xmlcatbin --noout --add "uri" \
"http://www.oasis-open.org/docbook/xml/${v}/rng/docbook.rng" \
"file://%{xml_docbook_rng_dir}/${v}/docbook.rng" ${CATALOG}
$xmlcatbin --noout --add "uri" \
"http://docbook.org/xml/${v}/rng/docbook.rng" \
"file://%{xml_docbook_rng_dir}/${v}/docbook.rng" ${CATALOG}
# RNG+XInclude
$xmlcatbin --noout --add "uri" \
"http://www.oasis-open.org/docbook/xml/${v}/rng/docbookxi.rng" \
"file://%{xml_docbook_rng_dir}/${v}/docbookxi.rng" ${CATALOG}
$xmlcatbin --noout --add "uri" \
"http://docbook.org/xml/${v}/rng/docbookxi.rng" \
"file://%{xml_docbook_rng_dir}/${v}/docbookxi.rng" ${CATALOG}
# RNC
$xmlcatbin --noout --add "uri" \
"http://www.oasis-open.org/docbook/xml/${v}/rnc/docbook.rnc" \
"file://%{xml_docbook_rng_dir}/${v}/docbook.rnc" ${CATALOG}
$xmlcatbin --noout --add "uri" \
"http://docbook.org/xml/${v}/rng/docbook.rnc" \
"file://%{xml_docbook_rng_dir}/${v}/docbook.rnc" ${CATALOG}
# RNC+XInclude
$xmlcatbin --noout --add "uri" \
"http://www.oasis-open.org/docbook/xml/${v}/rnc/docbookxi.rnc" \
"file://%{xml_docbook_rng_dir}/${v}/docbookxi.rnc" ${CATALOG}
$xmlcatbin --noout --add "uri" \
"http://docbook.org/xml/${v}/rng/docbookxi.rnc" \
"file://%{xml_docbook_rng_dir}/${v}/docbookxi.rnc" ${CATALOG}
# XSD
$xmlcatbin --noout --add "uri" \
"http://www.oasis-open.org/docbook/xml/${v}/xsd/docbook.xsd" \
"file://%{xml_docbook_xsd_dir}/${v}/docbook.xsd" ${CATALOG}
$xmlcatbin --noout --add "uri" \
"http://docbook.org/xml/${v}/xsd/docbook.xsd" \
"file://%{xml_docbook_xsd_dir}/${v}/docbook.xsd" ${CATALOG}
# XSD + XInclude
$xmlcatbin --noout --add "uri" \
"http://www.oasis-open.org/docbook/xml/${v}/xsd/docbookxi.xsd" \
"file://%{xml_docbook_xsd_dir}/${v}/docbookxi.xsd" ${CATALOG}
$xmlcatbin --noout --add "uri" \
"http://docbook.org/xml/${v}/xsd/docbookxi.xsd" \
"file://%{xml_docbook_xsd_dir}/${v}/docbookxi.xsd" ${CATALOG}
$xmlcatbin --noout --add "uri" \
"http://www.oasis-open.org/docbook/xml/${v}/xsd/xi.xsd" \
"file://%{xml_docbook_xsd_dir}/${v}/xi.xsd" ${CATALOG}
$xmlcatbin --noout --add "uri" \
"http://docbook.org/xml/${v}/xsd/xi.xsd" \
"file://%{xml_docbook_xsd_dir}/${v}/xi.xsd" ${CATALOG}
# XLink + XML
$xmlcatbin --noout --add "uri" \
"http://www.oasis-open.org/docbook/xml/${v}/xsd/xlink.xsd" \
"file://%{xml_docbook_xsd_dir}/${v}/xlink.xsd" ${CATALOG}
$xmlcatbin --noout --add "uri" \
"http://docbook.org/xml/${v}/xsd/xlink.xsd" \
"file://%{xml_docbook_xsd_dir}/${v}/xlink.xsd" ${CATALOG}
$xmlcatbin --noout --add "uri" \
"http://www.oasis-open.org/docbook/xml/${v}/xsd/xml.xsd" \
"file://%{xml_docbook_xsd_dir}/${v}/xml.xsd" ${CATALOG}
$xmlcatbin --noout --add "uri" \
"http://docbook.org/xml/${v}/xsd/xml.xsd" \
"file://%{xml_docbook_xsd_dir}/${v}/xml.xsd" ${CATALOG}
# Schematron
$xmlcatbin --noout --add "uri" \
"http://www.oasis-open.org/docbook/xml/${v}/sch/docbook.sch" \
"file://%{xml_docbook_sch_dir}/${v}/docbook.sch" ${CATALOG}
$xmlcatbin --noout --add "uri" \
"http://docbook.org/xml/${v}/sch/docbook.sch" \
"file://%{xml_docbook_sch_dir}/${v}/docbook.sch" ${CATALOG}
done
# ---------------------
# Build XML catalog files for each Schema
for v in %{version}; do
for s in dtd rng sch xsd; do
cat=docbook-${v}/${s}/catalog.xml
$xmlcatbin --noout --create ${cat}
case $s in
dtd)
$xmlcatbin --noout --add "public" \
"-//OASIS//DTD DocBook XML ${v}//EN" \
"docbook.dtd" ${cat}
$xmlcatbin --noout --add "system" \
"http://www.oasis-open.org/docbook/xml/${v}/dtd/docbook.dtd" \
"docbook.dtd" ${cat}
;;
sch)
$xmlcatbin --noout --add "uri" \
"http://docbook.org/xml/${v}/${s}/docbook.${s}" \
"docbook.${s}" ${cat}
$xmlcatbin --noout --add "uri" \
"http://www.oasis-open.org/docbook/xml/${v}/${s}/docbook.${s}" \
"docbook.${s}" ${cat}
;;
rng)
$xmlcatbin --noout --add "uri" \
"http://docbook.org/xml/${v}/${s}/docbook.${s}" \
"docbook.${s}" ${cat}
$xmlcatbin --noout --add "uri" \
"http://www.oasis-open.org/docbook/xml/${v}/${s}/docbook.${s}" \
"docbook.${s}" ${cat}
#
$xmlcatbin --noout --add "uri" \
"http://docbook.org/xml/${v}/${s}/docbookxi.${s}" \
"docbookxi.${s}" ${cat}
$xmlcatbin --noout --add "uri" \
"http://www.oasis-open.org/docbook/xml/${v}/${s}/docbookxi.${s}" \
"docbookxi.${s}" ${cat}
#
$xmlcatbin --noout --add "uri" \
"http://docbook.org/xml/${v}/${s}/docbook.rnc" \
"docbook.rnc" ${cat}
$xmlcatbin --noout --add "uri" \
"http://www.oasis-open.org/docbook/xml/${v}/${s}/docbook.rnc" \
"docbook.rnc" ${cat}
#
$xmlcatbin --noout --add "uri" \
"http://docbook.org/xml/${v}/${s}/docbookxi.rnc" \
"docbookxi.rnc" ${cat}
$xmlcatbin --noout --add "uri" \
"http://www.oasis-open.org/docbook/xml/${v}/${s}/docbookxi.rnc" \
"docbookxi.rnc" ${cat}
;;
xsd)
# http://www.oasis-open.org/docbook/xml/5.0/xsd/docbookxi.xsd
# http://www.oasis-open.org/docbook/xml/5.0/xsd/xlink.xsd
$xmlcatbin --noout --add "uri" \
"http://docbook.org/xml/${v}/${s}/docbook.${s}" \
"docbook.${s}" ${cat}
$xmlcatbin --noout --add "uri" \
"http://www.oasis-open.org/docbook/xml/${v}/${s}/docbook.${s}" \
"docbook.${s}" ${cat}
#
$xmlcatbin --noout --add "uri" \
"http://docbook.org/xml/${v}/${s}/docbookxi.${s}" \
"docbookxi.${s}" ${cat}
$xmlcatbin --noout --add "uri" \
"http://www.oasis-open.org/docbook/xml/${v}/${s}/docbookxi.${s}" \
"docbookxi.${s}" ${cat}
# XLink + XML:
$xmlcatbin --noout --add "uri" \
"http://docbook.org/xml/${v}/${s}/xlink.xsd" \
"xlink.xsd" ${cat}
$xmlcatbin --noout --add "uri" \
"http://www.oasis-open.org/docbook/xml/${v}/${s}/xlink.xsd" \
"xlink.xsd" ${cat}
$xmlcatbin --noout --add "uri" \
"http://docbook.org/xml/${v}/${s}/xml.xsd" \
"xml.xsd" ${cat}
$xmlcatbin --noout --add "uri" \
"http://www.oasis-open.org/docbook/xml/${v}/${s}/xml.xsd" \
"xml.xsd" ${cat}
;;
esac
done
done
%define FOR_ROOT_CAT %{name}-%{version}.xml
CATALOG=etc/xml/$CATALOG
rm -f %{FOR_ROOT_CAT}.tmp
$xmlcatbin --noout --create %{FOR_ROOT_CAT}.tmp
for v in %{version}; 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
$xmlcatbin --noout --add "delegateSystem" \
"http://docbook.org/xml/${v}/dtd/" \
"file://%{xml_docbook_dtd_dir}/${v}/catalog.xml" \
%{FOR_ROOT_CAT}.tmp
#
$xmlcatbin --noout --add "delegateURI" \
"http://docbook.org/xml/${v}/rng/" \
"file://%{xml_docbook_rng_dir}/${v}/catalog.xml" \
%{FOR_ROOT_CAT}.tmp
$xmlcatbin --noout --add "delegateURI" \
"http://docbook.org/xml/${v}/xsd/" \
"file://%{xml_docbook_xsd_dir}/${v}/catalog.xml" \
%{FOR_ROOT_CAT}.tmp
$xmlcatbin --noout --add "delegateURI" \
"http://docbook.org/xml/${v}/sch/" \
"file://%{xml_docbook_sch_dir}/${v}/catalog.xml" \
%{FOR_ROOT_CAT}.tmp
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
%{INSTALL_DIR} $RPM_BUILD_ROOT%{xml_docbook_dtd_dir}/%{version} \
$RPM_BUILD_ROOT%{xml_docbook_rng_dir}/%{version} \
$RPM_BUILD_ROOT%{xml_docbook_sch_dir}/%{version} \
$RPM_BUILD_ROOT%{xml_docbook_xsd_dir}/%{version}
for v in %{version}; do
%{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 last version
%{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
%post
if [ -x /usr/bin/edit-xml-catalog ]; then
/usr/bin/edit-xml-catalog --group --catalog /etc/xml/suse-catalog.xml \
--add /etc/xml/%{FOR_ROOT_CAT}
/usr/bin/edit-xml-catalog --group --catalog /etc/xml/suse-catalog.xml \
--add /etc/xml/%{name}.xml
fi
%postun
# remove entries only on removal of file
if [ ! -f %{xml_sysconf_dir}/%{FOR_ROOT_CAT} -a -x /usr/bin/edit-xml-catalog ] ; then
/usr/bin/edit-xml-catalog --group --catalog /etc/xml/suse-catalog.xml \
--del %{name}-%{version}
fi
%files
%defattr(-, root, root)
#%config %{sgml_config_dir}/CATALOG.*
%config %{xml_sysconf_dir}/docbook_5.xml
%config %{xml_sysconf_dir}/%{FOR_ROOT_CAT}
%doc README.SuSE
%doc docbook-%{version}-spec-cd-01.{pdf,html,xml}
# Use the last version of DocBook:
%doc docbook-%{version}/docs/* docbook-%{version}/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}/%{version}
%{xml_docbook_rng_dir}/%{version}
%{xml_docbook_sch_dir}/%{version}
%{xml_docbook_xsd_dir}/%{version}
%{xml_docbook_style_dir}/upgrade
%{_bindir}/db4-entities.pl
%changelog