[systemd-commits] 2 commits - Makefile.am man/journalctl.xml man/less-variables.xml man/localectl.xml man/loginctl.xml man/machinectl.xml man/systemctl.xml man/systemd-analyze.xml man/timedatectl.xml src/shared tools/xml_helper.py

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Tue Feb 11 22:13:04 PST 2014


 Makefile.am             |    3 ++-
 man/journalctl.xml      |   19 +++----------------
 man/less-variables.xml  |   29 +++++++++++++++++++++++++++++
 man/localectl.xml       |   19 +++----------------
 man/loginctl.xml        |   19 +++----------------
 man/machinectl.xml      |   19 +++----------------
 man/systemctl.xml       |   21 +++------------------
 man/systemd-analyze.xml |   21 +++------------------
 man/timedatectl.xml     |   19 +++----------------
 src/shared/pager.c      |    9 ++++++---
 tools/xml_helper.py     |   22 +++++++++++++---------
 11 files changed, 71 insertions(+), 129 deletions(-)

New commits:
commit 21ac6ff143cc8bebfbd1818af28e8c6f82cd5265
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Wed Feb 12 00:55:38 2014 -0500

    man: use xinclude to de-deduplicate common text
    
    I only tested with python-lxml. I'm not sure if xml.etree should be
    deprecated.

diff --git a/Makefile.am b/Makefile.am
index 6a3fd48..09547d3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4645,7 +4645,7 @@ if ENABLE_MANPAGES
 man/custom-entities.ent:
 	$(AM_V_GEN)$(MKDIR_P) $(dir $@)
 	$(AM_V_GEN)(echo '<?xml version="1.0" encoding="utf-8" ?>' && \
-	 echo '$(subst '|,<!ENTITY ,$(subst =, ",$(subst |',">,$(substitutions))))') \
+	 printf '$(subst '|,<!ENTITY ,$(subst =, ",$(subst |',">\n,$(substitutions))))') \
 	 > $@ # '
 
 DISTCLEANFILES += \
@@ -4653,6 +4653,7 @@ DISTCLEANFILES += \
 
 XSLTPROC_FLAGS = \
 	--nonet \
+	--xinclude \
 	--stringparam man.output.quietly 1 \
 	--stringparam funcsynopsis.style ansi \
 	--stringparam man.authors.section.enabled 0 \
diff --git a/man/journalctl.xml b/man/journalctl.xml
index 18a1b9e..8890c64 100644
--- a/man/journalctl.xml
+++ b/man/journalctl.xml
@@ -21,7 +21,8 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 -->
 
-<refentry id="journalctl">
+<refentry id="journalctl"
+          xmlns:xi="http://www.w3.org/2001/XInclude">
 
         <refentryinfo>
                 <title>journalctl</title>
@@ -875,25 +876,7 @@
                 failure code is returned.</para>
         </refsect1>
 
-        <refsect1>
-                <title>Environment</title>
-
-                <variablelist class='environment-variables'>
-                        <varlistentry>
-                                <term><varname>$SYSTEMD_PAGER</varname></term>
-                                <listitem><para>Pager to use when
-                                <option>--no-pager</option> is not given;
-                                overrides <varname>$PAGER</varname>.  Setting
-                                this to an empty string or the value
-                                <literal>cat</literal> is equivalent to passing
-                                <option>--no-pager</option>.</para></listitem>
-				<term><varname>$SYSTEMD_LESS</varname></term>
-				<listitem><para><varname>$SYSTEMD_LESS</varname> overrides the
-				default options passed to <literal>less</literal>
-				(<literal>FRSXMK</literal>).</para></listitem>
-                        </varlistentry>
-                </variablelist>
-        </refsect1>
+        <xi:include href="less-variables.xml" />
 
         <refsect1>
                 <title>Examples</title>
diff --git a/man/less-variables.xml b/man/less-variables.xml
new file mode 100644
index 0000000..09cbd42
--- /dev/null
+++ b/man/less-variables.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+                 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+
+<refsect1>
+        <title>Environment</title>
+
+        <variablelist class='environment-variables'>
+                <varlistentry>
+                        <term><varname>$SYSTEMD_PAGER</varname></term>
+
+                        <listitem><para>Pager to use when
+                        <option>--no-pager</option> is not given;
+                        overrides <varname>$PAGER</varname>.  Setting
+                        this to an empty string or the value
+                        <literal>cat</literal> is equivalent to passing
+                        <option>--no-pager</option>.</para></listitem>
+                </varlistentry>
+
+                <varlistentry>
+                        <term><varname>$SYSTEMD_LESS</varname></term>
+
+                        <listitem><para>Override the default
+                        options passed to
+                        <command>less</command>
+                        (<literal>FRSXMK</literal>).</para></listitem>
+                </varlistentry>
+        </variablelist>
+</refsect1>
diff --git a/man/localectl.xml b/man/localectl.xml
index 238757c..09e8d41 100644
--- a/man/localectl.xml
+++ b/man/localectl.xml
@@ -21,7 +21,8 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 -->
 
-<refentry id="localectl" conditional='ENABLE_LOCALED'>
+<refentry id="localectl" conditional='ENABLE_LOCALED'
+          xmlns:xi="http://www.w3.org/2001/XInclude">
 
         <refentryinfo>
                 <title>localectl</title>
@@ -253,25 +254,7 @@
                 code otherwise.</para>
         </refsect1>
 
-        <refsect1>
-                <title>Environment</title>
-
-                <variablelist class='environment-variables'>
-                        <varlistentry>
-                                <term><varname>$SYSTEMD_PAGER</varname></term>
-                                <listitem><para>Pager to use when
-                                <option>--no-pager</option> is not given;
-                                overrides <varname>$PAGER</varname>.  Setting
-                                this to an empty string or the value
-                                <literal>cat</literal> is equivalent to passing
-                                <option>--no-pager</option>.</para></listitem>
-				<term><varname>$SYSTEMD_LESS</varname></term>
-				<listitem><para><varname>$SYSTEMD_LESS</varname> overrides the
-				default options passed to <literal>less</literal>
-				(<literal>FRSXMK</literal>).</para></listitem>
-                        </varlistentry>
-                </variablelist>
-        </refsect1>
+        <xi:include href="less-variables.xml" />
 
         <refsect1>
                 <title>See Also</title>
diff --git a/man/loginctl.xml b/man/loginctl.xml
index ede869f..38f099e 100644
--- a/man/loginctl.xml
+++ b/man/loginctl.xml
@@ -21,7 +21,8 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 -->
 
-<refentry id="loginctl" conditional='ENABLE_LOGIND'>
+<refentry id="loginctl" conditional='ENABLE_LOGIND'
+          xmlns:xi="http://www.w3.org/2001/XInclude">
 
         <refentryinfo>
                 <title>loginctl</title>
@@ -474,25 +475,7 @@
                 code otherwise.</para>
         </refsect1>
 
-        <refsect1>
-                <title>Environment</title>
-
-                <variablelist class='environment-variables'>
-                        <varlistentry>
-                                <term><varname>$SYSTEMD_PAGER</varname></term>
-                                <listitem><para>Pager to use when
-                                <option>--no-pager</option> is not given;
-                                overrides <varname>$PAGER</varname>.  Setting
-                                this to an empty string or the value
-                                <literal>cat</literal> is equivalent to passing
-                                <option>--no-pager</option>.</para></listitem>
-				<term><varname>$SYSTEMD_LESS</varname></term>
-				<listitem><para><varname>$SYSTEMD_LESS</varname> overrides the
-				default options passed to <literal>less</literal>
-				(<literal>FRSXMK</literal>).</para></listitem>
-                        </varlistentry>
-                </variablelist>
-        </refsect1>
+        <xi:include href="less-variables.xml" />
 
         <refsect1>
                 <title>See Also</title>
diff --git a/man/machinectl.xml b/man/machinectl.xml
index 2e7fa3b..5c30c44 100644
--- a/man/machinectl.xml
+++ b/man/machinectl.xml
@@ -21,7 +21,8 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 -->
 
-<refentry id="machinectl" conditional='ENABLE_MACHINED'>
+<refentry id="machinectl" conditional='ENABLE_MACHINED'
+          xmlns:xi="http://www.w3.org/2001/XInclude">
 
         <refentryinfo>
                 <title>machinectl</title>
@@ -299,25 +300,7 @@
                 code otherwise.</para>
         </refsect1>
 
-        <refsect1>
-                <title>Environment</title>
-
-                <variablelist class='environment-variables'>
-                        <varlistentry>
-                                <term><varname>$SYSTEMD_PAGER</varname></term>
-                                <listitem><para>Pager to use when
-                                <option>--no-pager</option> is not given;
-                                overrides <varname>$PAGER</varname>.  Setting
-                                this to an empty string or the value
-                                <literal>cat</literal> is equivalent to passing
-                                <option>--no-pager</option>.</para></listitem>
-				<term><varname>$SYSTEMD_LESS</varname></term>
-				<listitem><para><varname>$SYSTEMD_LESS</varname> overrides the
-				default options passed to <literal>less</literal>
-				(<literal>FRSXMK</literal>).</para></listitem>
-                        </varlistentry>
-                </variablelist>
-        </refsect1>
+        <xi:include href="less-variables.xml" />
 
         <refsect1>
                 <title>See Also</title>
diff --git a/man/systemctl.xml b/man/systemctl.xml
index 1b0f8e5..906399c 100644
--- a/man/systemctl.xml
+++ b/man/systemctl.xml
@@ -21,7 +21,8 @@ You should have received a copy of the GNU Lesser General Public License
 along with systemd; If not, see <http://www.gnu.org/licenses/>.
 -->
 
-<refentry id="systemctl">
+<refentry id="systemctl"
+          xmlns:xi="http://www.w3.org/2001/XInclude">
 
   <refentryinfo>
     <title>systemctl</title>
@@ -1465,27 +1466,7 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
     code otherwise.</para>
   </refsect1>
 
-  <refsect1>
-    <title>Environment</title>
-
-    <variablelist class='environment-variables'>
-      <varlistentry>
-        <term><varname>$SYSTEMD_PAGER</varname></term>
-
-        <listitem>
-          <para>Pager to use when <option>--no-pager</option> is not
-          given; overrides <varname>$PAGER</varname>.  Setting this to
-          an empty string or the value <literal>cat</literal> is
-          equivalent to passing
-          <option>--no-pager</option>.</para>
-        </listitem>
-	<term><varname>$SYSTEMD_LESS</varname></term>
-	<listitem><para><varname>$SYSTEMD_LESS</varname> overrides the
-	default options passed to <literal>less</literal>
-	(<literal>FRSXMK</literal>).</para></listitem> 
-      </varlistentry>
-    </variablelist>
-  </refsect1>
+  <xi:include href="less-variables.xml" />
 
   <refsect1>
     <title>See Also</title>
diff --git a/man/systemd-analyze.xml b/man/systemd-analyze.xml
index 54479e4..de6c2be 100644
--- a/man/systemd-analyze.xml
+++ b/man/systemd-analyze.xml
@@ -21,7 +21,8 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 -->
 
-<refentry id="systemd-analyze">
+<refentry id="systemd-analyze"
+          xmlns:xi="http://www.w3.org/2001/XInclude">
 
         <refentryinfo>
                 <title>systemd-analyze</title>
@@ -321,27 +322,7 @@ $ eog targets.svg</programlisting>
 
         </refsect1>
 
-        <refsect1>
-                <title>Environment</title>
-
-                <variablelist class='environment-variables'>
-                        <varlistentry>
-                                <term><varname>$SYSTEMD_PAGER</varname></term>
-
-                                <listitem>
-                                        <para>Pager to use when <option>--no-pager</option> is not
-                                        given; overrides <varname>$PAGER</varname>.  Setting this to
-                                        an empty string or the value <literal>cat</literal> is
-                                        equivalent to passing
-                                        <option>--no-pager</option>.</para>
-                                </listitem>
-				<term><varname>$SYSTEMD_LESS</varname></term>
-				<listitem><para><varname>$SYSTEMD_LESS</varname> overrides the
-				default options passed to <literal>less</literal>
-				(<literal>FRSXMK</literal>).</para></listitem>
-                        </varlistentry>
-                </variablelist>
-        </refsect1>
+        <xi:include href="less-variables.xml" />
 
         <refsect1>
                 <title>See Also</title>
diff --git a/man/timedatectl.xml b/man/timedatectl.xml
index be66993..6bf277d 100644
--- a/man/timedatectl.xml
+++ b/man/timedatectl.xml
@@ -21,7 +21,8 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 -->
 
-<refentry id="timedatectl" conditional='ENABLE_TIMEDATED'>
+<refentry id="timedatectl" conditional='ENABLE_TIMEDATED'
+        xmlns:xi="http://www.w3.org/2001/XInclude">
 
         <refentryinfo>
                 <title>timedatectl</title>
@@ -227,25 +228,7 @@
                 code otherwise.</para>
         </refsect1>
 
-        <refsect1>
-                <title>Environment</title>
-
-                <variablelist class='environment-variables'>
-                        <varlistentry>
-                                <term><varname>$SYSTEMD_PAGER</varname></term>
-                                <listitem><para>Pager to use when
-                                <option>--no-pager</option> is not given;
-                                overrides <varname>$PAGER</varname>.  Setting
-                                this to an empty string or the value
-                                <literal>cat</literal> is equivalent to passing
-                                <option>--no-pager</option>.</para></listitem>
-				<term><varname>$SYSTEMD_LESS</varname></term>
-				<listitem><para><varname>$SYSTEMD_LESS</varname> overrides the
-				default options passed to <literal>less</literal>
-				(<literal>FRSXMK</literal>).</para></listitem>
-                        </varlistentry>
-                </variablelist>
-        </refsect1>
+        <xi:include href="less-variables.xml" />
 
         <refsect1>
                 <title>Examples</title>
diff --git a/tools/xml_helper.py b/tools/xml_helper.py
index 08e226f..0d91a17 100644
--- a/tools/xml_helper.py
+++ b/tools/xml_helper.py
@@ -17,19 +17,23 @@
 #  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
+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)
+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)
 
+try:
     _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,
-                                          encoding='utf-8')
+    def xml_parse(page):
+        doc = tree.parse(page, _parser)
+        doc.xinclude()
+        return doc
+    def xml_print(xml):
+        return tree.tostring(xml, pretty_print=True, encoding='utf-8')
+
 except ImportError:
     import xml.etree.ElementTree as tree
     import re as _re

commit f366d58dc1fe51b300167446597750d29687c3c5
Author: Jason A. Donenfeld <Jason at zx2c4.com>
Date:   Wed Feb 12 03:30:10 2014 +0100

    pager: support SYSTEMD_LESS environment variable
    
    This allows customization of the arguments used by less. The main
    motivation is that some folks might not like having --no-init on every
    invocation of less.

diff --git a/man/journalctl.xml b/man/journalctl.xml
index 3b05e80..18a1b9e 100644
--- a/man/journalctl.xml
+++ b/man/journalctl.xml
@@ -887,6 +887,10 @@
                                 this to an empty string or the value
                                 <literal>cat</literal> is equivalent to passing
                                 <option>--no-pager</option>.</para></listitem>
+				<term><varname>$SYSTEMD_LESS</varname></term>
+				<listitem><para><varname>$SYSTEMD_LESS</varname> overrides the
+				default options passed to <literal>less</literal>
+				(<literal>FRSXMK</literal>).</para></listitem>
                         </varlistentry>
                 </variablelist>
         </refsect1>
diff --git a/man/localectl.xml b/man/localectl.xml
index 0950cce..238757c 100644
--- a/man/localectl.xml
+++ b/man/localectl.xml
@@ -265,6 +265,10 @@
                                 this to an empty string or the value
                                 <literal>cat</literal> is equivalent to passing
                                 <option>--no-pager</option>.</para></listitem>
+				<term><varname>$SYSTEMD_LESS</varname></term>
+				<listitem><para><varname>$SYSTEMD_LESS</varname> overrides the
+				default options passed to <literal>less</literal>
+				(<literal>FRSXMK</literal>).</para></listitem>
                         </varlistentry>
                 </variablelist>
         </refsect1>
diff --git a/man/loginctl.xml b/man/loginctl.xml
index 13105d4..ede869f 100644
--- a/man/loginctl.xml
+++ b/man/loginctl.xml
@@ -486,6 +486,10 @@
                                 this to an empty string or the value
                                 <literal>cat</literal> is equivalent to passing
                                 <option>--no-pager</option>.</para></listitem>
+				<term><varname>$SYSTEMD_LESS</varname></term>
+				<listitem><para><varname>$SYSTEMD_LESS</varname> overrides the
+				default options passed to <literal>less</literal>
+				(<literal>FRSXMK</literal>).</para></listitem>
                         </varlistentry>
                 </variablelist>
         </refsect1>
diff --git a/man/machinectl.xml b/man/machinectl.xml
index cabdbac..2e7fa3b 100644
--- a/man/machinectl.xml
+++ b/man/machinectl.xml
@@ -311,6 +311,10 @@
                                 this to an empty string or the value
                                 <literal>cat</literal> is equivalent to passing
                                 <option>--no-pager</option>.</para></listitem>
+				<term><varname>$SYSTEMD_LESS</varname></term>
+				<listitem><para><varname>$SYSTEMD_LESS</varname> overrides the
+				default options passed to <literal>less</literal>
+				(<literal>FRSXMK</literal>).</para></listitem>
                         </varlistentry>
                 </variablelist>
         </refsect1>
diff --git a/man/systemctl.xml b/man/systemctl.xml
index ed1bf48..1b0f8e5 100644
--- a/man/systemctl.xml
+++ b/man/systemctl.xml
@@ -1479,6 +1479,10 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
           equivalent to passing
           <option>--no-pager</option>.</para>
         </listitem>
+	<term><varname>$SYSTEMD_LESS</varname></term>
+	<listitem><para><varname>$SYSTEMD_LESS</varname> overrides the
+	default options passed to <literal>less</literal>
+	(<literal>FRSXMK</literal>).</para></listitem> 
       </varlistentry>
     </variablelist>
   </refsect1>
diff --git a/man/systemd-analyze.xml b/man/systemd-analyze.xml
index cbf59e0..54479e4 100644
--- a/man/systemd-analyze.xml
+++ b/man/systemd-analyze.xml
@@ -335,6 +335,10 @@ $ eog targets.svg</programlisting>
                                         equivalent to passing
                                         <option>--no-pager</option>.</para>
                                 </listitem>
+				<term><varname>$SYSTEMD_LESS</varname></term>
+				<listitem><para><varname>$SYSTEMD_LESS</varname> overrides the
+				default options passed to <literal>less</literal>
+				(<literal>FRSXMK</literal>).</para></listitem>
                         </varlistentry>
                 </variablelist>
         </refsect1>
diff --git a/man/timedatectl.xml b/man/timedatectl.xml
index beda304..be66993 100644
--- a/man/timedatectl.xml
+++ b/man/timedatectl.xml
@@ -239,6 +239,10 @@
                                 this to an empty string or the value
                                 <literal>cat</literal> is equivalent to passing
                                 <option>--no-pager</option>.</para></listitem>
+				<term><varname>$SYSTEMD_LESS</varname></term>
+				<listitem><para><varname>$SYSTEMD_LESS</varname> overrides the
+				default options passed to <literal>less</literal>
+				(<literal>FRSXMK</literal>).</para></listitem>
                         </varlistentry>
                 </variablelist>
         </refsect1>
diff --git a/src/shared/pager.c b/src/shared/pager.c
index 72a29f2..55b13d6 100644
--- a/src/shared/pager.c
+++ b/src/shared/pager.c
@@ -84,14 +84,17 @@ int pager_open(bool jump_to_end) {
 
         /* In the child start the pager */
         if (pager_pid == 0) {
+                const char* less_opts;
 
                 dup2(fd[0], STDIN_FILENO);
                 close_pipe(fd);
 
+                less_opts = getenv("SYSTEMD_LESS");
+                if (!less_opts)
+                        less_opts = "FRSXMK";
                 if (jump_to_end)
-                        setenv("LESS", "FRSXMK+G", 1);
-                else
-                        setenv("LESS", "FRSXMK", 1);
+                        less_opts = strappenda(less_opts, " +G");
+                setenv("LESS", less_opts, 1);
 
                 /* Make sure the pager goes away when the parent dies */
                 if (prctl(PR_SET_PDEATHSIG, SIGTERM) < 0)



More information about the systemd-commits mailing list