Skip to content

Commit

Permalink
First attempt to fix XML catalog generation (#424)
Browse files Browse the repository at this point in the history
Simplify XML catalog generation by using templates

* additionally, switching to catalog.d/ and update-xml-catalog for SUSE
  • Loading branch information
tomschr authored and fsundermeyer committed Aug 7, 2018
1 parent 5a980e3 commit 659713a
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 194 deletions.
83 changes: 25 additions & 58 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ DAPSROOT := $(abs_top_srcdir)
#
BUILD_ROOT := build
FIRSTBUILD := $(BUILD_ROOT)/.firstbuild
DAPS_CATALOG := $(BUILD_ROOT)/for-catalog-$(PACKAGE).xml

#------------------------
# Catalog
#
DAPS_CATALOG_DIR := $(BUILD_ROOT)/catalog.d
DAPS_CATALOG := $(DAPS_CATALOG_DIR)/$(PACKAGE).xml

#------------------------
# fop config / jing wrapper
Expand All @@ -48,7 +53,9 @@ FOP_CONFIG := etc/fop/fop-daps.xml
FOP_CONFIG_DEFAULT := etc/fop/fop-daps.generic
JING_WRAPPER := libexec/daps-jing
JING_WRAPPER_DEFAULT := libexec/daps-jing.generic

if !DIST_DEBIAN
DAPS_CATALOG_TEMPLATE := etc/catalog.generic
endif
if DIST_SUSE
FOP_CONFIG_SRC := etc/fop/fop-daps.suse
endif
Expand All @@ -60,7 +67,7 @@ if DIST_REDHAT
endif
if DIST_DEBIAN
JING_WRAPPER_SRC := libexec/daps-jing.debian
DAPS_CATALOG_TEMPLATE := inst_files/debian_catalog_template
DAPS_CATALOG_TEMPLATE := etc/catalog.debian
endif

# stylesheets
Expand All @@ -78,13 +85,13 @@ MAN_PAGES := daps.1 ccecho.1 daps-init.1 daps-autobuild.1
MAN_BUILD_PATH := $(srcdir)/man/build/$(MAN_PAGE_DIR)/man/

# Manuals
DC_USERGUIDE = $(srcdir)/doc/DC-daps-user
DC_QUICKSTART = $(srcdir)/doc/DC-daps-quick
USERGUIDE_NAME = daps-user
QUICKSTART_NAME = daps-quick
USERGUIDE = $(srcdir)/doc/build/$(USERGUIDE_NAME)/single-html/$(USERGUIDE_NAME)/$(USERGUIDE_NAME).html
QUICKSTART = $(srcdir)/doc/build/$(QUICKSTART_NAME)/single-html/$(QUICKSTART_NAME)/$(QUICKSTART_NAME).html
MANUALS = $(dir $(USERGUIDE)) $(dir $(QUICKSTART))
DC_USERGUIDE := $(srcdir)/doc/DC-daps-user
DC_QUICKSTART := $(srcdir)/doc/DC-daps-quick
USERGUIDE_NAME := daps-user
QUICKSTART_NAME := daps-quick
USERGUIDE := $(srcdir)/doc/build/$(USERGUIDE_NAME)/single-html/$(USERGUIDE_NAME)/$(USERGUIDE_NAME).html
QUICKSTART := $(srcdir)/doc/build/$(QUICKSTART_NAME)/single-html/$(QUICKSTART_NAME)/$(QUICKSTART_NAME).html
MANUALS := $(dir $(USERGUIDE)) $(dir $(QUICKSTART))


#------------------------
Expand All @@ -95,7 +102,7 @@ fopconfdir = $(dapsconfdir)/fop
xepconfdir = $(dapsconfdir)/xep
hyphendir = $(xepconfdir)/hyphen

catalogdir = @sysconfdir@/xml
catalogdir = @sysconfdir@/xml/catalog.d

dapslibdir = $(pkgdatadir)/lib
dapslibexecdir = $(pkgdatadir)/libexec
Expand Down Expand Up @@ -226,7 +233,7 @@ endif
#-----------------------------CLEAN--------------------------------------------

clean-local:
rm -rf build/ man/build/ doc/build/
rm -rf build/ man/build/ doc/build/ $(DAPS_CATALOG_DIR)
(cd autobuild && ln -sf daps-autobuild.in daps-autobuild)
(cd bin && (ln -sf daps.in daps; ln -sf daps-xmlformat.in daps-xmlformat))
(cd bin && ln -sf daps-xmlformat.in daps-xmlformat)
Expand All @@ -237,53 +244,13 @@ clean-local:

#-----------------------------DAPS--------------------------------------------

# The DAPS_CATALOG generation has been replaced by a static file
# inst_files/daps_catalog_snippet to circumvent a bug in xmlformat
# in Debian-based distributions
#
# Use the local catalogs (etc/catalog.generic, etc/catalog.debian) to generate
# system catalogs

$(DAPS_CATALOG): $(BUILD_ROOT)
$(DAPS_CATALOG): DAPS_PROFDIR := $(pkgdatadir)/daps-xslt/profiling
if !DIST_DEBIAN
# On Debian and Ubuntu "xmlcatalog --add" is buggy and therefore cannot
# be used to generate the catalog file. It will be generated from a template
# instead (see else).
#
# create temporary DAPS catalog entries file
$(DAPS_CATALOG): URN_SUSE := urn:x-suse:xslt:profiling
$(DAPS_CATALOG): URN_DAPS := urn:x-daps:xslt:profiling
$(DAPS_CATALOG): DB_VERSIONS := 41 42 43 44 45 50 51
$(DAPS_CATALOG):
$(Q)test -z "$(dir $@)" || $(MKDIR_P) $(dir $@)
$(Q)$(XMLCATALOG) --noout --create $@
$(Q)for VERS in $(DB_VERSIONS); do \
$(XMLCATALOG) --noout --add \
"system" "$(URN_DAPS):docbook$${VERS}-profile.xsl" \
"file://$(DAPS_PROFDIR)/docbook$${VERS}-profile.xsl" $@; \
$(XMLCATALOG) --noout --add \
"system" "$(URN_SUSE):docbook$${VERS}-profile.xsl" \
"file://$(DAPS_PROFDIR)/docbook$${VERS}-profile.xsl" $@; \
done
$(Q)$(XMLCATALOG) --noout --add \
"system" "$(URN_DAPS):novdoc-profile.xsl" \
"file://$(DAPS_PROFDIR)/novdoc-profile.xsl" $@
$(Q)$(XMLCATALOG) --noout --add \
"system" "$(URN_SUSE):novdoc-profile.xsl" \
"file://$(DAPS_PROFDIR)/novdoc-profile.xsl" $@
$(Q)$(XMLCATALOG) --noout --add "rewriteSystem" \
"http://daps.sourceforge.net/release/daps-xsl/current/" \
"file://$(pkgdatadir)/daps-xslt/" $@
$(Q)$(XMLCATALOG) --noout --add "rewriteSystem" \
"https://opensuse.github.io/daps/release/daps-xsl/current/" \
"file://$(pkgdatadir)/daps-xslt/" $@
$(Q)$(SED) -i '/^<!DOCTYPE .*>$$/d' $@
$(Q)$(SED) -i '/<catalog/a\ <group id="$(PACKAGE)">' $@
$(Q)$(SED) -i '/<\/catalog/i\ </group>' $@
$(Q)$(srcdir)/bin/ccecho "result" "Created $@"
else
$(DAPS_CATALOG):
$(REPL_PATH) $(DAPS_CATALOG_TEMPLATE) > $@
endif

$(DAPS_CATALOG): $(DAPS_CATALOG_TEMPLATE) $(BUILD_ROOT) $(DAPS_CATALOG_DIR)
sed 's_\(xml:base\)=".."_\1="file:///usr/share/daps/daps-xslt/"_g' $< > $@


# the sources contain links bin/daps, etc/config and $(FOP_CONFIG)
Expand Down Expand Up @@ -350,7 +317,7 @@ $(dist_man1_MANS):
--docconfig=$(DAPSROOT)/man/$(DC_MANPAGES) man --nogzip
+$(Q)$(srcdir)/bin/ccecho "result" "Created man pages $@"

$(INSTALLDIRS) $(BUILD_ROOT):
$(INSTALLDIRS) $(BUILD_ROOT) $(DAPS_CATALOG_DIR):
test -z "$@" || $(MKDIR_P) $@

.PHONY: debian ubuntu redhat
Expand Down
80 changes: 25 additions & 55 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ am__can_run_installinfo = \
man1dir = $(mandir)/man1
NROFF = nroff
MANS = $(dist_man1_MANS)
am__dist_catalog_DATA_DIST = $(BUILD_ROOT)/for-catalog-$(PACKAGE).xml
am__dist_catalog_DATA_DIST = $(DAPS_CATALOG_DIR)/$(PACKAGE).xml
DATA = $(dist_bashcompletion_DATA) $(dist_catalog_DATA) \
$(dist_dapsconf_DATA) $(dist_dapslib_DATA) \
$(dist_dapsmake_DATA) $(dist_doc_DATA) $(dist_emacssite_DATA) \
Expand Down Expand Up @@ -302,7 +302,7 @@ EPUBCHECK = @EPUBCHECK@
EXIFTOOL = @EXIFTOOL@
GREP = @GREP@
GS = @GS@
HAVE_PYMOD_XML = @HAVE_PYMOD_XML@
HAVE_PYMOD_LXML = @HAVE_PYMOD_LXML@
INKSCAPE = @INKSCAPE@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
Expand Down Expand Up @@ -424,7 +424,12 @@ DAPSROOT := $(abs_top_srcdir)
#
BUILD_ROOT := build
FIRSTBUILD := $(BUILD_ROOT)/.firstbuild
DAPS_CATALOG := $(BUILD_ROOT)/for-catalog-$(PACKAGE).xml

#------------------------
# Catalog
#
DAPS_CATALOG_DIR := $(BUILD_ROOT)/catalog.d
DAPS_CATALOG := $(DAPS_CATALOG_DIR)/$(PACKAGE).xml

#------------------------
# fop config / jing wrapper
Expand All @@ -433,11 +438,12 @@ FOP_CONFIG := etc/fop/fop-daps.xml
FOP_CONFIG_DEFAULT := etc/fop/fop-daps.generic
JING_WRAPPER := libexec/daps-jing
JING_WRAPPER_DEFAULT := libexec/daps-jing.generic
@DIST_DEBIAN_FALSE@DAPS_CATALOG_TEMPLATE := etc/catalog.generic
@DIST_DEBIAN_TRUE@DAPS_CATALOG_TEMPLATE := etc/catalog.debian
@DIST_REDHAT_TRUE@FOP_CONFIG_SRC := etc/fop/fop-daps.redhat
@DIST_SUSEBS_TRUE@FOP_CONFIG_SRC := etc/fop/fop-daps.suse
@DIST_SUSE_TRUE@FOP_CONFIG_SRC := etc/fop/fop-daps.suse
@DIST_DEBIAN_TRUE@JING_WRAPPER_SRC := libexec/daps-jing.debian
@DIST_DEBIAN_TRUE@DAPS_CATALOG_TEMPLATE := inst_files/debian_catalog_template
@HAS_DAPS_XSL_FALSE@STYLEROOT := $(patsubst //%,%,$(patsubst file:%,%,$(shell $(XMLCATALOG) $(root_catalog) $(db4_xslt_url))))

# stylesheets
Expand All @@ -450,13 +456,13 @@ MAN_PAGES := daps.1 ccecho.1 daps-init.1 daps-autobuild.1
MAN_BUILD_PATH := $(srcdir)/man/build/$(MAN_PAGE_DIR)/man/

# Manuals
DC_USERGUIDE = $(srcdir)/doc/DC-daps-user
DC_QUICKSTART = $(srcdir)/doc/DC-daps-quick
USERGUIDE_NAME = daps-user
QUICKSTART_NAME = daps-quick
USERGUIDE = $(srcdir)/doc/build/$(USERGUIDE_NAME)/single-html/$(USERGUIDE_NAME)/$(USERGUIDE_NAME).html
QUICKSTART = $(srcdir)/doc/build/$(QUICKSTART_NAME)/single-html/$(QUICKSTART_NAME)/$(QUICKSTART_NAME).html
MANUALS = $(dir $(USERGUIDE)) $(dir $(QUICKSTART))
DC_USERGUIDE := $(srcdir)/doc/DC-daps-user
DC_QUICKSTART := $(srcdir)/doc/DC-daps-quick
USERGUIDE_NAME := daps-user
QUICKSTART_NAME := daps-quick
USERGUIDE := $(srcdir)/doc/build/$(USERGUIDE_NAME)/single-html/$(USERGUIDE_NAME)/$(USERGUIDE_NAME).html
QUICKSTART := $(srcdir)/doc/build/$(QUICKSTART_NAME)/single-html/$(QUICKSTART_NAME)/$(QUICKSTART_NAME).html
MANUALS := $(dir $(USERGUIDE)) $(dir $(QUICKSTART))

#------------------------
# Installation hooks
Expand All @@ -465,7 +471,7 @@ dapsconfdir = @sysconfdir@/daps
fopconfdir = $(dapsconfdir)/fop
xepconfdir = $(dapsconfdir)/xep
hyphendir = $(xepconfdir)/hyphen
catalogdir = @sysconfdir@/xml
catalogdir = @sysconfdir@/xml/catalog.d
dapslibdir = $(pkgdatadir)/lib
dapslibexecdir = $(pkgdatadir)/libexec
dapsmakedir = $(pkgdatadir)/make
Expand Down Expand Up @@ -1759,7 +1765,7 @@ install-data-local:
#-----------------------------CLEAN--------------------------------------------

clean-local:
rm -rf build/ man/build/ doc/build/
rm -rf build/ man/build/ doc/build/ $(DAPS_CATALOG_DIR)
(cd autobuild && ln -sf daps-autobuild.in daps-autobuild)
(cd bin && (ln -sf daps.in daps; ln -sf daps-xmlformat.in daps-xmlformat))
(cd bin && ln -sf daps-xmlformat.in daps-xmlformat)
Expand All @@ -1770,49 +1776,13 @@ clean-local:

#-----------------------------DAPS--------------------------------------------

# The DAPS_CATALOG generation has been replaced by a static file
# inst_files/daps_catalog_snippet to circumvent a bug in xmlformat
# in Debian-based distributions
#
# Use the local catalogs (etc/catalog.generic, etc/catalog.debian) to generate
# system catalogs

$(DAPS_CATALOG): $(BUILD_ROOT)
$(DAPS_CATALOG): DAPS_PROFDIR := $(pkgdatadir)/daps-xslt/profiling
@DIST_DEBIAN_FALSE@ # On Debian and Ubuntu "xmlcatalog --add" is buggy and therefore cannot
@DIST_DEBIAN_FALSE@ # be used to generate the catalog file. It will be generated from a template
@DIST_DEBIAN_FALSE@ # instead (see else).
@DIST_DEBIAN_FALSE@ #
@DIST_DEBIAN_FALSE@ # create temporary DAPS catalog entries file
@DIST_DEBIAN_FALSE@ $(DAPS_CATALOG): URN_SUSE := urn:x-suse:xslt:profiling
@DIST_DEBIAN_FALSE@ $(DAPS_CATALOG): URN_DAPS := urn:x-daps:xslt:profiling
@DIST_DEBIAN_FALSE@ $(DAPS_CATALOG): DB_VERSIONS := 41 42 43 44 45 50 51
@DIST_DEBIAN_FALSE@ $(DAPS_CATALOG):
@DIST_DEBIAN_FALSE@ $(Q)test -z "$(dir $@)" || $(MKDIR_P) $(dir $@)
@DIST_DEBIAN_FALSE@ $(Q)$(XMLCATALOG) --noout --create $@
@DIST_DEBIAN_FALSE@ $(Q)for VERS in $(DB_VERSIONS); do \
@DIST_DEBIAN_FALSE@ $(XMLCATALOG) --noout --add \
@DIST_DEBIAN_FALSE@ "system" "$(URN_DAPS):docbook$${VERS}-profile.xsl" \
@DIST_DEBIAN_FALSE@ "file://$(DAPS_PROFDIR)/docbook$${VERS}-profile.xsl" $@; \
@DIST_DEBIAN_FALSE@ $(XMLCATALOG) --noout --add \
@DIST_DEBIAN_FALSE@ "system" "$(URN_SUSE):docbook$${VERS}-profile.xsl" \
@DIST_DEBIAN_FALSE@ "file://$(DAPS_PROFDIR)/docbook$${VERS}-profile.xsl" $@; \
@DIST_DEBIAN_FALSE@ done
@DIST_DEBIAN_FALSE@ $(Q)$(XMLCATALOG) --noout --add \
@DIST_DEBIAN_FALSE@ "system" "$(URN_DAPS):novdoc-profile.xsl" \
@DIST_DEBIAN_FALSE@ "file://$(DAPS_PROFDIR)/novdoc-profile.xsl" $@
@DIST_DEBIAN_FALSE@ $(Q)$(XMLCATALOG) --noout --add \
@DIST_DEBIAN_FALSE@ "system" "$(URN_SUSE):novdoc-profile.xsl" \
@DIST_DEBIAN_FALSE@ "file://$(DAPS_PROFDIR)/novdoc-profile.xsl" $@
@DIST_DEBIAN_FALSE@ $(Q)$(XMLCATALOG) --noout --add "rewriteSystem" \
@DIST_DEBIAN_FALSE@ "http://daps.sourceforge.net/release/daps-xsl/current/" \
@DIST_DEBIAN_FALSE@ "file://$(pkgdatadir)/daps-xslt/" $@
@DIST_DEBIAN_FALSE@ $(Q)$(XMLCATALOG) --noout --add "rewriteSystem" \
@DIST_DEBIAN_FALSE@ "https://opensuse.github.io/daps/release/daps-xsl/current/" \
@DIST_DEBIAN_FALSE@ "file://$(pkgdatadir)/daps-xslt/" $@
@DIST_DEBIAN_FALSE@ $(Q)$(SED) -i '/^<!DOCTYPE .*>$$/d' $@
@DIST_DEBIAN_FALSE@ $(Q)$(SED) -i '/<catalog/a\ <group id="$(PACKAGE)">' $@
@DIST_DEBIAN_FALSE@ $(Q)$(SED) -i '/<\/catalog/i\ </group>' $@
@DIST_DEBIAN_FALSE@ $(Q)$(srcdir)/bin/ccecho "result" "Created $@"
@DIST_DEBIAN_TRUE@ $(DAPS_CATALOG):
@DIST_DEBIAN_TRUE@ $(REPL_PATH) $(DAPS_CATALOG_TEMPLATE) > $@
$(DAPS_CATALOG): $(DAPS_CATALOG_TEMPLATE) $(BUILD_ROOT) $(DAPS_CATALOG_DIR)
sed 's_\(xml:base\)=".."_\1="file:///usr/share/daps/daps-xslt/"_g' $< > $@

# the sources contain links bin/daps, etc/config and $(FOP_CONFIG)
# These need to be replaced by real files/different links created by
Expand Down Expand Up @@ -1878,7 +1848,7 @@ $(dist_man1_MANS):
--docconfig=$(DAPSROOT)/man/$(DC_MANPAGES) man --nogzip
+$(Q)$(srcdir)/bin/ccecho "result" "Created man pages $@"

$(INSTALLDIRS) $(BUILD_ROOT):
$(INSTALLDIRS) $(BUILD_ROOT) $(DAPS_CATALOG_DIR):
test -z "$@" || $(MKDIR_P) $@

.PHONY: debian ubuntu redhat
Expand Down
15 changes: 7 additions & 8 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ DIST_REDHAT_TRUE
HAS_DAPS_XSL_FALSE
HAS_DAPS_XSL_TRUE
db5_version
HAVE_PYMOD_XML
HAVE_PYMOD_LXML
pkgpyexecdir
pyexecdir
pkgpythondir
Expand Down Expand Up @@ -3832,30 +3832,29 @@ $as_echo "$am_cv_python_pyexecdir" >&6; }
PYTHON="python"
fi
PYTHON_NAME=`basename $PYTHON`
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $PYTHON_NAME module: xml" >&5
$as_echo_n "checking $PYTHON_NAME module: xml... " >&6; }
$PYTHON -c "import xml" 2>/dev/null
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $PYTHON_NAME module: lxml" >&5
$as_echo_n "checking $PYTHON_NAME module: lxml... " >&6; }
$PYTHON -c "import lxml" 2>/dev/null
if test $? -eq 0;
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
eval HAVE_PYMOD_XML=yes
eval HAVE_PYMOD_LXML=yes
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
eval HAVE_PYMOD_XML=no
eval HAVE_PYMOD_LXML=no
#
if test -n "fatal"
then
as_fn_error $? "failed to find required python module xml" "$LINENO" 5
as_fn_error $? "failed to find required python module lxml" "$LINENO" 5
exit 1
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: ===== Checking for DocBook 4.x..." >&5
$as_echo "$as_me: ===== Checking for DocBook 4.x..." >&6;}
Expand Down
7 changes: 2 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,8 @@ AM_PATH_PYTHON([3.4])
dnl AM_PATH_PYTHON([2.6])

dnl Variables HAVE_PYMOD_* are filled with "yes" or "no"
AC_PYTHON_MODULE([xml], [fatal])
AC_SUBST(HAVE_PYMOD_XML)

dnl AC_PYTHON_MODULE([lxml], [fatal])
dnl AC_SUBST(HAVE_PYMOD_LXML)
AC_PYTHON_MODULE([lxml], [fatal])
AC_SUBST(HAVE_PYMOD_LXML)


dnl --------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions etc/catalog.debian
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<group xml:base="../daps-xslt/">
<group id="daps" xml:base="../daps-xslt/">
<system systemId="urn:x-suse:xslt:profiling:docbook41-profile.xsl"
uri="profiling/docbook41-profile.xsl"/>
<uri name="urn:x-suse:xslt:profiling:docbook41-profile.xsl"
Expand Down Expand Up @@ -85,7 +85,7 @@
uri="profiling/novdoc-profile.xsl"/>

<system systemId="http://www.oasis-open.org/docbook/xml/4.5/dbcentx.mod"
uri="/usr/share/xml/docbook/schema/dtd/4.5/dbcentx.mod"/>
uri="file:///usr/share/xml/docbook/schema/dtd/4.5/dbcentx.mod"/>
</group>

<!-- Make sure the standard catalog is found as well -->
Expand Down
Loading

0 comments on commit 659713a

Please sign in to comment.