Index: general/sysutils/systemd.xml.next
===================================================================
--- general/sysutils/systemd.xml.next	(revision b7205fdb9da2abfb5e5d6236c40dbc898bc33ab4)
+++ general/sysutils/systemd.xml.next	(revision b7205fdb9da2abfb5e5d6236c40dbc898bc33ab4)
@@ -0,0 +1,351 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+   "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+  <!ENTITY % general-entities SYSTEM "../../general.ent">
+  %general-entities;
+
+  <!ENTITY systemd-download-http       "http://www.freedesktop.org/software/systemd/">
+  <!ENTITY systemd-patch-download-http "http://www.linuxfromscratch.org/patches/downloads/systemd/">
+]>
+
+<sect1 id="systemd" xreflabel="Systemd">
+  <?dbhtml filename="systemd.html"?>
+
+  <sect1info>
+    <othername>$LastChangedBy$</othername>
+    <date>$Date$</date>
+  </sect1info>
+
+  <title>Systemd</title>
+
+  <indexterm zone="systemd">
+    <primary sortas="a-systemd">systemd</primary>
+  </indexterm>
+
+  <sect2 role="package">
+    <title>Introduction to systemd</title>
+
+    <para>
+      Even though <application>systemd</application> was built in
+      LFS, there are some features provided by the package that
+      some BLFS packages need, but their dependencies didn't fit
+      into LFS.
+    </para>
+
+    <para>
+      There are two reasons why <application>systemd</application>
+      needs to be rebuilt. Some packages require GUdev library to
+      be present in order to compile while others expect working
+      <command>systemd-logind</command> service in order to work
+      properly. To build the GUdev library, make sure that you have
+      installed first set of required dependencies. In order to get
+      <command>systemd-logind</command> to work properly, make sure
+      that you have installed second set of required dependencies.
+    </para>
+
+    <para>
+      Unlike other packages in BLFS, there is no set version of
+      <application>systemd</application> in this page's title and
+      no set version specified for download. Version updates to
+      <application>systemd</application> make it possible that the
+      user's system may have a <application>systemd</application>
+      version different from the one in the current LFS book.
+      Therefore, users should use the version of
+      <application>systemd</application> that is currently
+      installed on their system.
+    </para>
+
+    <bridgehead renderas="sect3">Package Information</bridgehead>
+    <itemizedlist spacing="compact">
+      <listitem>
+        <para>Systemd Download (HTTP): <ulink url="&systemd-download-http;"/></para>
+      </listitem>
+      <listitem>
+        <para>Systemd Patch Download (HTTP): <ulink url="&systemd-patch-download-http;"/></para>
+      </listitem>
+    </itemizedlist>
+
+    <para>
+      Make sure you download the "compat" patch whose version matches
+      the <application>systemd</application> version you are building.
+    </para>
+
+    <note>
+      <para>
+        If you are unsure which version needs to be downloaded, issue
+        <command>systemctl --version</command> in order to find out.
+        Some of the commands below might need the version information.
+        Issue the following command to store the
+        <application>systemd</application> version number into an
+        environment variable:
+      </para>
+
+<screen><userinput>export SYSTEMD_VERSION=$(systemctl --version | head -n1 | awk '{print $2}')</userinput></screen>
+    </note>
+
+    <bridgehead renderas="sect3">systemd Dependencies</bridgehead>
+
+    <bridgehead renderas="sect4">Required (GUdev)</bridgehead>
+    <para role="required">
+      <xref linkend="glib2"/> and
+      <xref linkend="gobject-introspection"/>
+    </para>
+
+    <bridgehead renderas="sect4">Required (Logind)</bridgehead>
+    <para role="required">
+      <xref linkend="linux-pam"/>
+    </para>
+
+    <bridgehead renderas="sect4">Recommended Runtime Dependency</bridgehead>
+    <para role="recommended">
+      <xref linkend="polkit"/>
+    </para>
+
+    <bridgehead renderas="sect4">Optional</bridgehead>
+    <para role="optional">
+      <xref linkend="curl"/>,
+      <xref linkend="elfutils"/>,
+      <xref linkend="gnutls"/>,
+      <xref linkend="gtk-doc"/>,
+      <xref linkend="libgcrypt"/>,
+      <xref linkend="libidn"/>,
+      <xref linkend="python3"/>,
+      <ulink url="https://code.google.com/p/cryptsetup/">cryptsetup</ulink>,
+      <ulink url="https://www.gnu.org/software/libmicrohttpd/">libmicrohttpd</ulink>,
+      <ulink url="http://fukuchi.org/works/qrencode/">libqrencode</ulink>,
+      <ulink url="http://sourceforge.net/projects/libseccomp/">libseccomp</ulink>,
+      <ulink url="http://lxml.de/">lxml</ulink> (Python Module), and
+      <ulink url="https://code.google.com/p/lz4/">lz4</ulink>
+    </para>
+
+    <note>
+      <para>
+        In order to build the <application>systemd</application>
+        <application>Python</application> module, lxml package
+        needs to be installed for the corresponding
+        <application>Python</application> version (2 or 3).
+        Note that <command>configure</command> defaults to
+        <application>Python 2</application>. In order to build
+        the module for <application>Python 3</application>,
+        make sure you pass the <envar>PYTHON=python3</envar>
+        environment variable to the <command>configure</command>
+        command below.
+      </para>
+    </note>
+
+    <bridgehead renderas="sect4">Optional (for rebuilding manual pages)</bridgehead>
+    <para role="optional">
+      <xref linkend="libxslt"/>,
+      <xref linkend="DocBook"/>, and
+      <xref linkend="docbook-xsl"/>
+    </para>
+
+    <para condition="html" role="usernotes">User Notes:
+      <ulink url="&blfs-wiki;/systemd"/>
+    </para>
+  </sect2>
+
+  <sect2 role="installation">
+    <title>Installation of systemd</title>
+
+    <para>
+      First, apply the required patch:
+    </para>
+
+<screen><userinput>patch -Np1 -i ../systemd-${SYSTEMD_VERSION}-compat-1.patch</userinput></screen>
+
+    <para>
+      Rebuild <application>systemd</application> by running the
+      following commands:
+    </para>
+
+<screen><userinput>cc_cv_CFLAGS__flto=no              \
+./configure --prefix=/usr          \
+            --sysconfdir=/etc      \
+            --localstatedir=/var   \
+            --with-rootprefix=     \
+            --with-rootlibdir=/lib \
+            --enable-split-usr     \
+            --disable-ldconfig     \
+            --docdir=/usr/share/doc/systemd-${SYSTEMD_VERSION} &amp;&amp;
+make</userinput></screen>
+
+    <note>
+      <para>
+        For the best results, make sure you run the testsuite from
+        a system that is booted by the same
+        <application>systemd</application> version you are rebuilding.
+      </para>
+    </note>
+
+    <para>
+      To test the results, issue: <command>make -k check</command>.
+    </para>
+
+    <warning>
+      <para>
+        Installing the package will override all files installed by
+        <application>systemd</application> in LFS. It is critical that
+        nothing uses either <application>systemd</application> or
+        <application>Udev</application> libraries or programs during
+        the installation phrase. Best way to achieve that is to do the
+        installation in the rescue mode. To switch to the rescue mode,
+        issue the following command as the
+        <systemitem class="username">root</systemitem> user from a TTY:
+      </para>
+
+<screen role="root"><userinput>systemctl start rescue.target</userinput></screen>
+    </warning>
+
+   <para>
+     Now, as the <systemitem class="username">root</systemitem> user:
+   </para>
+
+<screen role="root"><userinput>make install</userinput></screen>
+
+    <para>
+      Prevent systemd units that are not needed on a LFS system from
+      running by running the following command as the <systemitem
+      class="username">root</systemitem> user:
+    </para>
+
+<screen role="root"><userinput>rm -fv /lib/systemd/system/sysinit.target.wants/systemd-{firstboot,sysusers,update-done}.service</userinput></screen>
+
+    <para>
+      Move NSS libraries to <filename class="directory">/lib</filename>
+      by running the following command as the <systemitem
+      class="username">root</systemitem> user:
+    </para>
+
+<screen role="root"><userinput>mv -v /usr/lib/libnss_{myhostname,mymachines,resolve}.so.2 /lib</userinput></screen>
+
+    <para>
+      Remove an unnecessary directory by running the following command
+      as the <systemitem class="username">root</systemitem> user:
+    </para>
+
+<screen role="root"><userinput>rm -rfv /usr/lib/rpm</userinput></screen>
+
+    <para>
+      Remove a reference to a non-existent group by running the following
+      command as the <systemitem class="username">root</systemitem> user:
+    </para>
+
+<screen role="root"><userinput>sed -i "s:0775 root lock:0755 root root:g" /usr/lib/tmpfiles.d/legacy.conf</userinput></screen>
+
+  </sect2>
+
+  <sect2 role="configuration">
+    <title>Configuring systemd</title>
+
+    <para>
+      If the <application>systemd</application> PAM module was built,
+      the <filename>/etc/pam.d/system-sesion</filename> file needs to
+      be modified and a new file needs to be created in order for
+      <command>systemd-logind</command> to work correctly. To accomplish
+      that, run the following commands as the <systemitem
+     class="username">root</systemitem> user:
+    </para>
+
+<screen role="root"><userinput>cat &gt;&gt; /etc/pam.d/system-session &lt;&lt; "EOF"
+<literal># Begin Systemd addition
+    
+session   required    pam_loginuid.so
+-session   optional    pam_systemd.so
+
+# End Systemd addition</literal>
+EOF
+
+cat &gt; /etc/pam.d/systemd-user &lt;&lt; "EOF"
+<literal># Begin /etc/pam.d/systemd-user
+
+account  required pam_access.so
+account  include  system-account
+
+session  required pam_env.so
+session  required pam_limits.so
+session  include  system-session
+
+auth     required pam_deny.so
+password required pam_deny.so
+
+# End /etc/pam.d/systemd-user</literal>
+EOF</userinput></screen>
+
+    <para>
+      At this point it would be a nice idea to reboot to
+      test if the reinstallation was sucessful.
+    </para>
+
+  </sect2>
+
+  <sect2 role="content">
+    <title>Contents</title>
+
+      <para>
+        A list of the installed files, along with their short
+        descriptions can be found at
+        <ulink url="http://www.linuxfromscratch.org/lfs/view/systemd/chapter06/systemd.html#contents-systemd"/>.
+      </para>
+
+      <para>
+        Below are listed newly installed libraries and directories
+        along with short descriptions.
+      </para>
+
+    <segmentedlist>
+      <segtitle>Installed Programs</segtitle>
+      <segtitle>Installed Libraries</segtitle>
+      <segtitle>Installed Directories</segtitle>
+
+      <seglistitem>
+        <seg>
+          None
+        </seg>
+        <seg>
+          libgudev-1.0.so and pam_systemd.so
+          (in <filename class="directory">/lib/security</filename>)
+        </seg>
+        <seg>
+          /usr/include/gudev-1.0 and
+          /usr/share/gtk-doc/html/gudev
+        </seg>
+      </seglistitem>
+    </segmentedlist>
+
+    <variablelist>
+      <bridgehead renderas="sect3">Short Descriptions</bridgehead>
+      <?dbfo list-presentation="list"?>
+      <?dbhtml list-presentation="table"?>
+
+      <varlistentry id="libgudev-1.0">
+        <term><filename class="libraryfile">libgudev-1.0.so</filename></term>
+        <listitem>
+          <para>
+            is a GObject-based wrapper library for libudev.
+          </para>
+          <indexterm zone="systemd libgudev-1.0">
+            <primary sortas="c-libgudev-1.0">libgudev-1.0.so</primary>
+          </indexterm>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry id="pam_systemd">
+        <term><filename class="libraryfile">pam_systemd.so</filename></term>
+        <listitem>
+          <para>
+            is a PAM module used to register user sessions with the
+            <application>systemd</application> login manager,
+            <command>systemd-logind</command>.
+          </para>
+          <indexterm zone="systemd pam_systemd">
+            <primary sortas="c-pam_systemd">pam_systemd.so</primary>
+          </indexterm>
+        </listitem>
+      </varlistentry>
+
+    </variablelist>
+
+  </sect2>
+
+</sect1>
