Index: BLFS/xsl/make_book.xsl
===================================================================
--- BLFS/xsl/make_book.xsl	(revision 96d7e449228ad04eabe40d267d9737e49fe84db9)
+++ BLFS/xsl/make_book.xsl	(revision 0a0b60984cc91f5c7b9da6f45120e55b13f5e080)
@@ -103,5 +103,5 @@
             </xsl:when>
             <xsl:when test="contains(concat($list,' '),'-pass1 ')">
-<!-- Let's do it only for sect1, hopefully -->
+<!-- We need to do it only for sect1 and sect2, because of libva -->
               <xsl:variable
                    name="real-id"
@@ -109,4 +109,7 @@
               <xsl:if test="id($real-id)[self::sect1]">
                 <xsl:apply-templates select="id($real-id)" mode="pass1"/>
+              </xsl:if>
+              <xsl:if test="id($real-id)[self::sect2]">
+                <xsl:apply-templates select="id($real-id)" mode="pass1-sect2"/>
               </xsl:if>
             </xsl:when>
@@ -185,4 +188,88 @@
           </xsl:for-each>
           <xsl:apply-templates mode="pass1"/>
+        </xsl:element>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:copy-of select="."/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
+  <xsl:template match="*" mode="pass1-sect2">
+    <xsl:choose>
+      <xsl:when test="self::sect2">
+        <xsl:element name="sect1">
+          <xsl:attribute name="id"><xsl:value-of select="@id"/>-pass1</xsl:attribute>
+          <xsl:attribute name="xreflabel"><xsl:value-of select="@xreflabel"/></xsl:attribute>
+          <xsl:processing-instruction name="dbhtml">filename="<xsl:value-of
+                          select="@id"/>-pass1.html"</xsl:processing-instruction>
+          <xsl:apply-templates mode="pass1-sect2"/>
+        </xsl:element>
+      </xsl:when>
+      <xsl:when test="self::sect3">
+        <xsl:element name="sect2">
+          <xsl:attribute name="role">
+            <xsl:value-of select="@role"/>
+          </xsl:attribute>
+          <xsl:apply-templates mode="pass1-sect2"/>
+        </xsl:element>
+      </xsl:when>
+      <xsl:when test="self::bridgehead">
+        <xsl:element name="bridgehead">
+          <xsl:attribute name="renderas">
+            <xsl:if test="@renderas='sect4'">sect3</xsl:if>
+            <xsl:if test="@renderas='sect5'">sect4</xsl:if>
+          </xsl:attribute>
+          <xsl:value-of select='.'/>
+        </xsl:element>
+      </xsl:when>
+      <xsl:when test="self::xref">
+        <xsl:choose>
+          <xsl:when test="contains(concat(' ',normalize-space($list),' '),
+                                   concat(' ',@linkend,' '))">
+            <xsl:choose>
+              <xsl:when test="@linkend='x-window-system' or @linkend='xorg7'">
+                <xref linkend="xorg7-server"/>
+              </xsl:when>
+              <xsl:when test="@linkend='server-mail'">
+                <xref linkend="{$MTA}"/>
+              </xsl:when>
+              <xsl:otherwise>
+                <xsl:copy-of select="."/>
+              </xsl:otherwise>
+            </xsl:choose>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:choose>
+              <xsl:when test="@linkend='bootscripts' or
+                              @linkend='systemd-units'">
+                <xsl:copy-of select="."/>
+              </xsl:when>
+              <xsl:otherwise>
+                <xsl:value-of select="@linkend"/> (in full book)
+              </xsl:otherwise>
+            </xsl:choose>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:when>
+      <xsl:when test="@id">
+        <xsl:element name="{name()}">
+          <xsl:for-each select="attribute::*">
+            <xsl:attribute name="{name()}">
+              <xsl:value-of select="."/>
+              <xsl:if test="name() = 'id'">-pass1</xsl:if>
+            </xsl:attribute>
+          </xsl:for-each>
+          <xsl:apply-templates mode="pass1-sect2"/>
+        </xsl:element>
+      </xsl:when>
+      <xsl:when test=".//xref | .//@id">
+        <xsl:element name="{name()}">
+          <xsl:for-each select="attribute::*">
+            <xsl:attribute name="{name()}">
+              <xsl:value-of select="."/>
+            </xsl:attribute>
+          </xsl:for-each>
+          <xsl:apply-templates mode="pass1-sect2"/>
         </xsl:element>
       </xsl:when>
Index: BLFS/xsl/process-install.xsl
===================================================================
--- BLFS/xsl/process-install.xsl	(revision 96d7e449228ad04eabe40d267d9737e49fe84db9)
+++ BLFS/xsl/process-install.xsl	(revision 0a0b60984cc91f5c7b9da6f45120e55b13f5e080)
@@ -18,4 +18,5 @@
 
     <xsl:choose>
+<!--============================================================-->
 <!-- First, if we have an empty tree, close everything and exit -->
       <xsl:when test="not($current-instr)">
@@ -36,5 +37,6 @@
           </xsl:call-template>
         </xsl:if>
-      </xsl:when><!-- empty tree -->
+      </xsl:when><!-- end empty tree -->
+<!--============================================================-->
       <xsl:when test="$current-instr[@role='root' and @remap='test']">
         <xsl:if test="$install-seen">
@@ -55,13 +57,13 @@
         </xsl:if>
         <xsl:call-template name="begin-root"/>
-        <xsl:choose>
-          <xsl:when test="$want-stats">
-            <xsl:apply-templates select="$current-instr" mode="root"/>
-          </xsl:when>
-          <xsl:otherwise>
-            <xsl:apply-templates select="$current-instr"
-                                 mode="root-comment-out"/>
-          </xsl:otherwise>
-        </xsl:choose>
+<!-- We first apply mode="root" templates, and save the result in a variable -->
+        <xsl:variable name="processed-instr">
+          <xsl:apply-templates select="$current-instr" mode="root"/>
+        </xsl:variable>
+<!-- We then process as a test instruction -->
+        <xsl:call-template name="process-test">
+          <xsl:with-param name="test-instr" select="$processed-instr"/>
+          <xsl:with-param name="want-stats" select="$want-stats"/>
+        </xsl:call-template>
         <xsl:call-template name="process-install">
           <xsl:with-param
@@ -74,5 +76,6 @@
           <xsl:with-param name="doc-seen" select="boolean(0)"/>
         </xsl:call-template>
-      </xsl:when><!-- role="root" and remap="test" -->
+      </xsl:when><!-- end role="root" and remap="test" -->
+<!--============================================================-->
       <xsl:when test="$current-instr[@role='root' and @remap='doc']">
         <xsl:if test="$test-seen">
@@ -92,6 +95,13 @@
           <xsl:call-template name="begin-install"/>
         </xsl:if>
-        <xsl:apply-templates select="$current-instr"
-                             mode="install-comment-out"/>
+<!-- We first apply mode="install" templates, and save the result in a
+     variable -->
+        <xsl:variable name="processed-instr">
+          <xsl:apply-templates select="$current-instr" mode="install"/>
+        </xsl:variable>
+<!-- Then comment it out -->
+        <xsl:call-template name="output-comment-out">
+          <xsl:with-param name="out-string" select="$processed-instr"/>
+        </xsl:call-template>
 <!-- The above template ends with a commented line, so that if end-install
      adds a closing single quote, it will not be seen. Add a CR to prevent
@@ -109,7 +119,12 @@
           <xsl:with-param name="doc-seen" select="boolean(1)"/>
         </xsl:call-template>
-      </xsl:when><!--role="root" and remap="doc" -->
+      </xsl:when><!-- end role="root" and remap="doc" -->
+<!--============================================================-->
       <xsl:when test="$current-instr[@role='root']">
+<!-- We have two cases, depending on the content: either a config instruction,
+     that we do not recorrd with porg (first case belaow), or a true install
+     instruction (otherwise below) -->
         <xsl:choose>
+<!--____________________________________________________________ -->
           <xsl:when test="contains(string($current-instr),'useradd') or
                           contains(string($current-instr),'groupadd') or
@@ -149,4 +164,5 @@
             </xsl:call-template>
           </xsl:when><!-- end config as root -->
+<!--____________________________________________________________ -->
           <xsl:otherwise><!-- we have a true install instruction -->
             <xsl:if test="$test-seen">
@@ -196,6 +212,8 @@
             </xsl:call-template>
           </xsl:otherwise><!-- end true install instruction -->
+<!--____________________________________________________________ -->
         </xsl:choose>
       </xsl:when><!-- role="root" and no remap -->
+<!--============================================================-->
       <xsl:when test="$current-instr[@remap='test'] or
                       $current-instr/self::command">
@@ -221,12 +239,13 @@
           </xsl:call-template>
         </xsl:if>
-        <xsl:choose>
-          <xsl:when test="$want-stats">
-            <xsl:apply-templates select="$current-instr"/>
-          </xsl:when>
-          <xsl:otherwise>
-            <xsl:apply-templates select="$current-instr" mode="comment-out"/>
-          </xsl:otherwise>
-        </xsl:choose>
+<!-- We first apply normal templates, and save the result in a variable -->
+        <xsl:variable name="processed-instr">
+          <xsl:apply-templates select="$current-instr"/>
+        </xsl:variable>
+<!-- We then process as a test instruction -->
+        <xsl:call-template name="process-test">
+          <xsl:with-param name="test-instr" select="$processed-instr"/>
+          <xsl:with-param name="want-stats" select="$want-stats"/>
+        </xsl:call-template>
         <xsl:call-template name="process-install">
           <xsl:with-param
@@ -239,5 +258,6 @@
           <xsl:with-param name="doc-seen" select="boolean(0)"/>
         </xsl:call-template>
-      </xsl:when><!-- no role, remap=test -->
+      </xsl:when><!-- end no role, remap=test -->
+<!--============================================================-->
       <xsl:when test="$current-instr[@remap='doc']">
         <xsl:if test="$install-seen">
@@ -262,12 +282,13 @@
           </xsl:call-template>
         </xsl:if>
-        <xsl:choose>
-          <xsl:when test="$want-stats">
-            <xsl:apply-templates select="$current-instr"/>
-          </xsl:when>
-          <xsl:otherwise>
-            <xsl:apply-templates select="$current-instr" mode="comment-out"/>
-          </xsl:otherwise>
-        </xsl:choose>
+<!-- We first apply normal templates, and save the result in a variable -->
+        <xsl:variable name="processed-instr">
+          <xsl:apply-templates select="$current-instr"/>
+        </xsl:variable>
+<!-- We then process as a doc instruction -->
+        <xsl:call-template name="process-doc">
+          <xsl:with-param name="doc-instr" select="$processed-instr"/>
+          <xsl:with-param name="want-stats" select="$want-stats"/>
+        </xsl:call-template>
         <xsl:call-template name="process-install">
           <xsl:with-param
@@ -281,4 +302,5 @@
         </xsl:call-template>
       </xsl:when><!-- no role, remap="doc" -->
+<!--============================================================-->
       <xsl:otherwise><!-- no role no remap -->
         <xsl:if test="$install-seen">
@@ -310,32 +332,6 @@
         </xsl:call-template>
       </xsl:otherwise><!-- no role, no remap -->
+<!--============================================================-->
     </xsl:choose>
-  </xsl:template>
-
-  <xsl:template match="userinput" mode="install-comment-out">
-    <xsl:text>
-</xsl:text>
-    <xsl:call-template name="output-comment-out">
-      <xsl:with-param name="out-string" select="string()"/>
-      <xsl:with-param name="process" select="'install'"/>
-    </xsl:call-template>
-  </xsl:template>
-
-  <xsl:template match="userinput|command" mode="root-comment-out">
-    <xsl:text>
-</xsl:text>
-    <xsl:call-template name="output-comment-out">
-      <xsl:with-param name="out-string" select="string()"/>
-      <xsl:with-param name="process" select="'root'"/>
-    </xsl:call-template>
-  </xsl:template>
-
-  <xsl:template match="userinput|command" mode="comment-out">
-    <xsl:text>
-</xsl:text>
-    <xsl:call-template name="output-comment-out">
-      <xsl:with-param name="out-string" select="string()"/>
-      <xsl:with-param name="process" select="'none'"/>
-    </xsl:call-template>
   </xsl:template>
 
@@ -348,74 +344,102 @@
   </xsl:template>
 
-  <xsl:template name="output-comment-out">
-<!-- Output instructions with each line commented out. The "process"
-     parameter is:
-        none: only output commented-out and remove ampersand
-        root: output commented out and remove ampersand,
-              with escaping of \, $, and `
-        install: same + escape ' -->
-    <xsl:param name="out-string"/>
-    <xsl:param name="process"/>
+<!-- userinput templates for mode="root" and normal are in scripts.xsl -->
+
+  <xsl:template name="process-test">
+    <xsl:param name="test-instr"/>
+    <xsl:param name="want-stats"/>
     <xsl:choose>
-      <xsl:when test="contains($out-string,'&#xA;')">
+      <!-- the string may begin with a linefeed -->
+      <xsl:when test="substring($test-instr,1,1)='&#xA;'">
+        <xsl:text>
+</xsl:text>
+        <xsl:call-template name="process-test">
+          <xsl:with-param name="test-instr"
+                          select="substring-after($test-instr,'&#xA;')"/>
+          <xsl:with-param name="want-stats" select="$want-stats"/>
+        </xsl:call-template>
+      </xsl:when>
+      <xsl:when test="contains($test-instr,'&#xA;')">
+        <xsl:call-template name="process-test">
+          <xsl:with-param name="test-instr"
+                          select="substring-before($test-instr,'&#xA;')"/>
+          <xsl:with-param name="want-stats" select="$want-stats"/>
+        </xsl:call-template>
+        <xsl:text>
+</xsl:text>
+        <xsl:call-template name="process-test">
+          <xsl:with-param name="test-instr"
+                          select="substring-after($test-instr,'&#xA;')"/>
+          <xsl:with-param name="want-stats" select="$want-stats"/>
+        </xsl:call-template>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:if test="not($want-stats)">
+          <xsl:text>#</xsl:text>
+        </xsl:if>
         <xsl:choose>
-          <xsl:when test="$process='install'">
-            <xsl:call-template name="output-install">
-              <xsl:with-param
-                        name="out-string"
-                        select="concat('# ',
-                                        substring-before($out-string,'&#xA;')
-                                      )"/>
-            </xsl:call-template>
-          </xsl:when>
-          <xsl:when test="$process='root'">
-            <xsl:call-template name="output-root">
-              <xsl:with-param
-                        name="out-string"
-                        select="concat('# ',
-                                        substring-before($out-string,'&#xA;')
-                                      )"/>
-            </xsl:call-template>
+          <xsl:when test="contains($test-instr,'make')
+                  and not(contains($test-instr,'make -k'))">
+            <xsl:copy-of select="substring-before($test-instr,'make')"/>
+            <xsl:text>make -k</xsl:text>
+            <xsl:copy-of select="substring-after($test-instr,'make')"/>
           </xsl:when>
           <xsl:otherwise>
-            <xsl:call-template name="remove-ampersand">
-              <xsl:with-param
-                        name="out-string"
-                        select="concat('# ',
-                                        substring-before($out-string,'&#xA;')
-                                      )"/>
-            </xsl:call-template>
+            <xsl:copy-of select="$test-instr"/>
           </xsl:otherwise>
         </xsl:choose>
+        <xsl:if test="substring($test-instr,
+                                string-length($test-instr),
+                                1)!='\'">
+          <xsl:if test="$want-stats">
+            <xsl:text> &gt;&gt; $TESTLOG 2>&amp;1</xsl:text>
+          </xsl:if>
+          <xsl:text> || true</xsl:text>
+        </xsl:if>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
+  <xsl:template name="process-doc">
+    <xsl:param name="doc-instr"/>
+    <xsl:param name="want-stats"/>
+    <xsl:choose>
+      <xsl:when test="$want-stats">
+        <xsl:copy-of select="$doc-instr"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:call-template name="output-comment-out">
+          <xsl:with-param name="out-string" select="$doc-instr"/>
+        </xsl:call-template>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
+  <xsl:template name="output-comment-out">
+<!-- Output instructions with each line commented out. -->
+    <xsl:param name="out-string"/>
+    <xsl:choose>
+      <!-- the string may begin with a linefeed -->
+      <xsl:when test="substring($out-string,1,1)='&#xA;'">
         <xsl:text>
 </xsl:text>
         <xsl:call-template name="output-comment-out">
-          <xsl:with-param
-                    name="out-string"
-                    select="substring-after($out-string,'&#xA;')"/>
-          <xsl:with-param name="process" select="$process"/>
+          <xsl:with-param name="out-string"
+                          select="substring-after($out-string,'&#xA;')"/>
+        </xsl:call-template>
+      </xsl:when>
+      <xsl:when test="contains($out-string,'&#xA;')">
+        <xsl:text>#</xsl:text>
+        <xsl:copy-of select="substring-before($out-string,'&#xA;')"/>
+        <xsl:text>
+</xsl:text>
+        <xsl:call-template name="output-comment-out">
+          <xsl:with-param name="out-string"
+                          select="substring-after($out-string,'&#xA;')"/>
         </xsl:call-template>
       </xsl:when>
       <xsl:otherwise>
-        <xsl:choose>
-          <xsl:when test="$process='install'">
-            <xsl:call-template name="output-install">
-              <xsl:with-param name="out-string"
-                              select="concat('# ',$out-string)"/>
-            </xsl:call-template>
-          </xsl:when>
-          <xsl:when test="$process='root'">
-            <xsl:call-template name="output-root">
-              <xsl:with-param name="out-string"
-                              select="concat('# ',$out-string)"/>
-            </xsl:call-template>
-          </xsl:when>
-          <xsl:otherwise>
-            <xsl:call-template name="remove-ampersand">
-              <xsl:with-param name="out-string"
-                              select="concat('# ',$out-string)"/>
-            </xsl:call-template>
-          </xsl:otherwise>
-        </xsl:choose>
+        <xsl:text>#</xsl:text>
+        <xsl:copy-of select="$out-string"/>
       </xsl:otherwise>
     </xsl:choose>
Index: BLFS/xsl/scripts.xsl
===================================================================
--- BLFS/xsl/scripts.xsl	(revision 96d7e449228ad04eabe40d267d9737e49fe84db9)
+++ BLFS/xsl/scripts.xsl	(revision 0a0b60984cc91f5c7b9da6f45120e55b13f5e080)
@@ -190,5 +190,6 @@
       </xsl:when>
 
-      <xsl:when test="@role = 'installation'">
+      <xsl:when test="@role = 'installation' and
+                      not(preceding-sibling::sect2[@role = 'installation'])">
         <xsl:text>
 cd $BUILD_DIR
