summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--Makefile.am43
-rwxr-xr-xmake-directive-index.py12
-rwxr-xr-xmake-man-index.py16
-rw-r--r--make-man-rules.py4
-rw-r--r--man/.gitignore2
-rw-r--r--man/systemd.unit.xml13
-rw-r--r--xml_helper.py40
8 files changed, 91 insertions, 41 deletions
diff --git a/.gitignore b/.gitignore
index c3bb81b1f7..58a5000211 100644
--- a/.gitignore
+++ b/.gitignore
@@ -139,6 +139,8 @@
*.lo
*.o
*.stamp
+*.pyc
+__pycache__/
*~
.deps/
.dirstamp
diff --git a/Makefile.am b/Makefile.am
index d5b319e2cb..92bd542767 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -97,6 +97,7 @@ rootbindir=$(rootprefix)/bin
rootlibexecdir=$(rootprefix)/lib/systemd
CLEANFILES = $(BUILT_SOURCES)
+DISTCLEANFILES =
EXTRA_DIST =
BUILT_SOURCES =
INSTALL_EXEC_HOOKS =
@@ -556,9 +557,10 @@ noinst_DATA += \
CLEANFILES += \
man/index.html
+XML_GLOB = $(wildcard $(top_srcdir)/man/*.xml)
NON_INDEX_XML_FILES = $(filter-out man/systemd.index.xml,$(XML_FILES))
+SOURCE_XML_FILES = $(filter-out man/systemd.directives.xml,$(NON_INDEX_XML_FILES))
-XML_GLOB = $(wildcard $(top_srcdir)/man/*.xml)
update-man-list: make-man-rules.py $(XML_GLOB)
$(AM_V_GEN)$(PYTHON) $^ > $(top_srcdir)/Makefile-man.tmp
$(AM_V_at)mv $(top_srcdir)/Makefile-man.tmp $(top_srcdir)/Makefile-man.am
@@ -566,11 +568,11 @@ update-man-list: make-man-rules.py $(XML_GLOB)
man/systemd.index.xml: make-man-index.py $(NON_INDEX_XML_FILES)
$(AM_V_at)$(MKDIR_P) $(dir $@)
- $(AM_V_GEN)$(PYTHON) $^ > $@
+ $(AM_V_GEN)$(PYTHON) $< $@ $(filter-out $<,$^)
-man/systemd.directives.xml: make-directive-index.py $(filter-out man/systemd.directives.xml,$(NON_INDEX_XML_FILES))
+man/systemd.directives.xml: make-directive-index.py $(SOURCE_XML_FILES)
$(AM_V_at)$(MKDIR_P) $(dir $@)
- $(AM_V_GEN)$(PYTHON) $^ > $@
+ $(AM_V_GEN)$(PYTHON) $< $@ $(filter-out $<,$^)
EXTRA_DIST += \
man/systemd.index.xml \
@@ -591,7 +593,8 @@ EXTRA_DIST += \
$(HTML_ALIAS) \
$(dist_MANS) \
make-man-index.py \
- make-directive-index.py
+ make-directive-index.py \
+ xml_helper.py
# ------------------------------------------------------------------------------
noinst_LTLIBRARIES += \
@@ -3819,38 +3822,46 @@ CLEANFILES += \
# ------------------------------------------------------------------------------
if ENABLE_MANPAGES
+man/custom-entities.ent: Makefile
+ $(AM_V_GEN)$(MKDIR_P) $(dir $@)
+ $(AM_V_GEN)(echo '<?xml version="1.0" encoding="utf-8" ?>' && \
+ echo '$(subst '|,<!ENTITY ,$(subst =, ",$(subst |',">,$(substitutions))))') \
+ > $@ # '
+
+DISTCLEANFILES += \
+ man/custom-entities.ent
+
XSLTPROC_FLAGS = \
--nonet \
--stringparam man.output.quietly 1 \
--stringparam funcsynopsis.style ansi \
--stringparam man.authors.section.enabled 0 \
--stringparam man.copyright.section.enabled 0 \
- --stringparam systemd.version $(VERSION)
+ --stringparam systemd.version $(VERSION) \
+ --path '$(builddir)/man:$(srcdir)/man'
XSLTPROC_PROCESS_MAN = \
- $(AM_V_XSLT)$(MKDIR_P) $(dir $@) && \
- $(XSLTPROC) -o $@ $(XSLTPROC_FLAGS) $(srcdir)/man/custom-man.xsl $<
+ $(AM_V_XSLT)$(XSLTPROC) -o $@ $(XSLTPROC_FLAGS) $(srcdir)/man/custom-man.xsl $<
XSLTPROC_PROCESS_HTML = \
- $(AM_V_XSLT)$(MKDIR_P) $(dir $@) && \
- $(XSLTPROC) -o $@ $(XSLTPROC_FLAGS) $(srcdir)/man/custom-html.xsl $<
+ $(AM_V_XSLT)$(XSLTPROC) -o $@ $(XSLTPROC_FLAGS) $(srcdir)/man/custom-html.xsl $<
-man/%.1: man/%.xml man/custom-man.xsl
+man/%.1: man/%.xml man/custom-man.xsl man/custom-entities.ent
$(XSLTPROC_PROCESS_MAN)
-man/%.3: man/%.xml man/custom-man.xsl
+man/%.3: man/%.xml man/custom-man.xsl man/custom-entities.ent
$(XSLTPROC_PROCESS_MAN)
-man/%.5: man/%.xml man/custom-man.xsl
+man/%.5: man/%.xml man/custom-man.xsl man/custom-entities.ent
$(XSLTPROC_PROCESS_MAN)
-man/%.7: man/%.xml man/custom-man.xsl
+man/%.7: man/%.xml man/custom-man.xsl man/custom-entities.ent
$(XSLTPROC_PROCESS_MAN)
-man/%.8: man/%.xml man/custom-man.xsl
+man/%.8: man/%.xml man/custom-man.xsl man/custom-entities.ent
$(XSLTPROC_PROCESS_MAN)
-man/%.html: man/%.xml man/custom-html.xsl
+man/%.html: man/%.xml man/custom-html.xsl man/custom-entities.ent
$(XSLTPROC_PROCESS_HTML)
define html-alias
diff --git a/make-directive-index.py b/make-directive-index.py
index 039efaa434..99e7bfaf28 100755
--- a/make-directive-index.py
+++ b/make-directive-index.py
@@ -19,13 +19,8 @@
import sys
import collections
-try:
- from lxml import etree as tree
- PRETTY = dict(pretty_print=True)
-except ImportError:
- import xml.etree.ElementTree as tree
- PRETTY = {}
import re
+from xml_helper import *
TEMPLATE = '''\
<refentry id="systemd.directives" conditional="HAVE_PYTHON">
@@ -173,7 +168,7 @@ referring to {pages} individual manual pages.
'''
def _extract_directives(directive_groups, formatting, page):
- t = tree.parse(page)
+ t = xml_parse(page)
section = t.find('./refmeta/manvolnum').text
pagename = t.find('./refmeta/refentrytitle').text
@@ -282,4 +277,5 @@ def make_page(*xml_files):
return _make_page(template, directive_groups, formatting)
if __name__ == '__main__':
- tree.dump(make_page(*sys.argv[1:]), **PRETTY)
+ with open(sys.argv[1], 'wb') as f:
+ f.write(xml_print(make_page(*sys.argv[2:])))
diff --git a/make-man-index.py b/make-man-index.py
index d9ab5cc752..74a47b821a 100755
--- a/make-man-index.py
+++ b/make-man-index.py
@@ -19,14 +19,10 @@
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
import collections
-try:
- from lxml import etree as tree
- PRETTY = dict(pretty_print=True)
-except ImportError:
- import xml.etree.ElementTree as tree
- PRETTY = {}
import sys
import re
+from xml_helper import *
+
MDASH = ' — ' if sys.version_info.major >= 3 else ' -- '
TEMPLATE = '''\
@@ -72,6 +68,7 @@ SUMMARY = '''\
COUNTS = '\
This index contains {count} entries, referring to {pages} individual manual pages.'
+
def check_id(page, t):
id = t.getroot().get('id')
if not re.search('/' + id + '[.]', page):
@@ -80,7 +77,7 @@ def check_id(page, t):
def make_index(pages):
index = collections.defaultdict(list)
for p in pages:
- t = tree.parse(p)
+ t = xml_parse(p)
check_id(p, t)
section = t.find('./refmeta/manvolnum').text
refname = t.find('./refnamediv/refname').text
@@ -123,7 +120,7 @@ def add_summary(template, indexpages):
para = template.find(".//para[@id='counts']")
para.text = COUNTS.format(count=count, pages=len(pages))
-def make_page(xml_files):
+def make_page(*xml_files):
template = tree.fromstring(TEMPLATE)
index = make_index(xml_files)
@@ -135,4 +132,5 @@ def make_page(xml_files):
return template
if __name__ == '__main__':
- tree.dump(make_page(sys.argv[1:]), **PRETTY)
+ with open(sys.argv[1], 'wb') as f:
+ f.write(xml_print(make_page(*sys.argv[2:])))
diff --git a/make-man-rules.py b/make-man-rules.py
index 46a586374f..ad601f874f 100644
--- a/make-man-rules.py
+++ b/make-man-rules.py
@@ -18,9 +18,9 @@
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
-import xml.etree.ElementTree as tree
import collections
import sys
+from xml_helper import *
SECTION = '''\
MANPAGES += \\
@@ -54,7 +54,7 @@ def man(page, number):
return 'man/{}.{}'.format(page, number)
def add_rules(rules, name):
- xml = tree.parse(name)
+ xml = xml_parse(name)
# print('parsing {}'.format(name), file=sys.stderr)
conditional = xml.getroot().get('conditional') or ''
rulegroup = rules[conditional]
diff --git a/man/.gitignore b/man/.gitignore
index 3798c75f1d..bf5eeab938 100644
--- a/man/.gitignore
+++ b/man/.gitignore
@@ -1,4 +1,4 @@
/systemd.directives.xml
/systemd.index.xml
/*.[13578]
-/python-systemd/
+/custom-entities.ent
diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml
index 2196e73bb3..47c50315ae 100644
--- a/man/systemd.unit.xml
+++ b/man/systemd.unit.xml
@@ -1,6 +1,9 @@
<?xml version='1.0'?> <!--*-nxml-*-->
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
- "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
+ "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
+<!ENTITY % entities SYSTEM "custom-entities.ent" >
+%entities;
+]>
<!--
This file is part of systemd.
@@ -278,7 +281,7 @@
<entry>Generated units</entry>
</row>
<row>
- <entry><filename>@SYSTEM_CONFIG_UNIT_PATH@</filename></entry>
+ <entry><filename>&SYSTEM_CONFIG_UNIT_PATH;</filename></entry>
<entry morerows='1'>Local configuration</entry>
</row>
<row>
@@ -297,7 +300,7 @@
<entry>Units for local packages</entry>
</row>
<row>
- <entry><filename>@systemunitdir@</filename></entry>
+ <entry><filename>&systemunitdir;</filename></entry>
<entry>Systemd package configuration</entry>
</row>
<row>
@@ -335,7 +338,7 @@
<entry>Generated units</entry>
</row>
<row>
- <entry><filename>@USER_CONFIG_UNIT_PATH@</filename></entry>
+ <entry><filename>&USER_CONFIG_UNIT_PATH;</filename></entry>
<entry morerows='1'>Local configuration</entry>
</row>
<row>
@@ -357,7 +360,7 @@
<entry><filename>/usr/local/share/systemd/user</filename></entry>
</row>
<row>
- <entry><filename>@userunitdir@</filename></entry>
+ <entry><filename>&userunitdir;</filename></entry>
<entry>Systemd package configuration</entry>
</row>
<row>
diff --git a/xml_helper.py b/xml_helper.py
new file mode 100644
index 0000000000..a484beac19
--- /dev/null
+++ b/xml_helper.py
@@ -0,0 +1,40 @@
+# -*- Mode: python; coding: utf-8; indent-tabs-mode: nil -*- */
+#
+# This file is part of systemd.
+#
+# Copyright 2012-2013 Zbigniew Jędrzejewski-Szmek
+#
+# systemd is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+#
+# systemd is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with systemd; If not, see <http://www.gnu.org/licenses/>.
+
+try:
+ from lxml import etree as tree
+
+ class CustomResolver(tree.Resolver):
+ def resolve(self, url, id, context):
+ if 'custom-entities.ent' in url:
+ return self.resolve_filename('man/custom-entities.ent', context)
+
+ _parser = tree.XMLParser()
+ _parser.resolvers.add(CustomResolver())
+ xml_parse = lambda page: tree.parse(page, _parser)
+ xml_print = lambda xml: tree.tostring(xml, pretty_print=True)
+except ImportError:
+ import xml.etree.ElementTree as tree
+ import re as _re
+ import io as _io
+
+ def xml_parse(page):
+ s = _re.sub(b'&[a-zA-Z0-9_]+;', b'', open(page, 'rb').read())
+ return tree.parse(_io.BytesIO(s))
+ xml_print = tree.tostring