Changeset 0a0b609 for BLFS/xsl


Ignore:
Timestamp:
08/17/2019 08:30:36 AM (5 years ago)
Author:
Pierre Labastie <pierre@…>
Branches:
ablfs-more, legacy, trunk
Children:
30732c6a
Parents:
96d7e44
Message:

Several things:

  • refactor again process-install. Allows for better generation of test instructions
  • only output the instructions of the first sect2 with role="installation". this will miss the vaapi intel driver, the installation of help files in GIMP, and the second method for which
  • always run porg logging in "append" mode
  • allows pass1 in sect2 (libva again)
Location:
BLFS/xsl
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • BLFS/xsl/make_book.xsl

    r96d7e44 r0a0b609  
    103103            </xsl:when>
    104104            <xsl:when test="contains(concat($list,' '),'-pass1 ')">
    105 <!-- Let's do it only for sect1, hopefully -->
     105<!-- We need to do it only for sect1 and sect2, because of libva -->
    106106              <xsl:variable
    107107                   name="real-id"
     
    109109              <xsl:if test="id($real-id)[self::sect1]">
    110110                <xsl:apply-templates select="id($real-id)" mode="pass1"/>
     111              </xsl:if>
     112              <xsl:if test="id($real-id)[self::sect2]">
     113                <xsl:apply-templates select="id($real-id)" mode="pass1-sect2"/>
    111114              </xsl:if>
    112115            </xsl:when>
     
    185188          </xsl:for-each>
    186189          <xsl:apply-templates mode="pass1"/>
     190        </xsl:element>
     191      </xsl:when>
     192      <xsl:otherwise>
     193        <xsl:copy-of select="."/>
     194      </xsl:otherwise>
     195    </xsl:choose>
     196  </xsl:template>
     197
     198  <xsl:template match="*" mode="pass1-sect2">
     199    <xsl:choose>
     200      <xsl:when test="self::sect2">
     201        <xsl:element name="sect1">
     202          <xsl:attribute name="id"><xsl:value-of select="@id"/>-pass1</xsl:attribute>
     203          <xsl:attribute name="xreflabel"><xsl:value-of select="@xreflabel"/></xsl:attribute>
     204          <xsl:processing-instruction name="dbhtml">filename="<xsl:value-of
     205                          select="@id"/>-pass1.html"</xsl:processing-instruction>
     206          <xsl:apply-templates mode="pass1-sect2"/>
     207        </xsl:element>
     208      </xsl:when>
     209      <xsl:when test="self::sect3">
     210        <xsl:element name="sect2">
     211          <xsl:attribute name="role">
     212            <xsl:value-of select="@role"/>
     213          </xsl:attribute>
     214          <xsl:apply-templates mode="pass1-sect2"/>
     215        </xsl:element>
     216      </xsl:when>
     217      <xsl:when test="self::bridgehead">
     218        <xsl:element name="bridgehead">
     219          <xsl:attribute name="renderas">
     220            <xsl:if test="@renderas='sect4'">sect3</xsl:if>
     221            <xsl:if test="@renderas='sect5'">sect4</xsl:if>
     222          </xsl:attribute>
     223          <xsl:value-of select='.'/>
     224        </xsl:element>
     225      </xsl:when>
     226      <xsl:when test="self::xref">
     227        <xsl:choose>
     228          <xsl:when test="contains(concat(' ',normalize-space($list),' '),
     229                                   concat(' ',@linkend,' '))">
     230            <xsl:choose>
     231              <xsl:when test="@linkend='x-window-system' or @linkend='xorg7'">
     232                <xref linkend="xorg7-server"/>
     233              </xsl:when>
     234              <xsl:when test="@linkend='server-mail'">
     235                <xref linkend="{$MTA}"/>
     236              </xsl:when>
     237              <xsl:otherwise>
     238                <xsl:copy-of select="."/>
     239              </xsl:otherwise>
     240            </xsl:choose>
     241          </xsl:when>
     242          <xsl:otherwise>
     243            <xsl:choose>
     244              <xsl:when test="@linkend='bootscripts' or
     245                              @linkend='systemd-units'">
     246                <xsl:copy-of select="."/>
     247              </xsl:when>
     248              <xsl:otherwise>
     249                <xsl:value-of select="@linkend"/> (in full book)
     250              </xsl:otherwise>
     251            </xsl:choose>
     252          </xsl:otherwise>
     253        </xsl:choose>
     254      </xsl:when>
     255      <xsl:when test="@id">
     256        <xsl:element name="{name()}">
     257          <xsl:for-each select="attribute::*">
     258            <xsl:attribute name="{name()}">
     259              <xsl:value-of select="."/>
     260              <xsl:if test="name() = 'id'">-pass1</xsl:if>
     261            </xsl:attribute>
     262          </xsl:for-each>
     263          <xsl:apply-templates mode="pass1-sect2"/>
     264        </xsl:element>
     265      </xsl:when>
     266      <xsl:when test=".//xref | .//@id">
     267        <xsl:element name="{name()}">
     268          <xsl:for-each select="attribute::*">
     269            <xsl:attribute name="{name()}">
     270              <xsl:value-of select="."/>
     271            </xsl:attribute>
     272          </xsl:for-each>
     273          <xsl:apply-templates mode="pass1-sect2"/>
    187274        </xsl:element>
    188275      </xsl:when>
  • BLFS/xsl/process-install.xsl

    r96d7e44 r0a0b609  
    1818
    1919    <xsl:choose>
     20<!--============================================================-->
    2021<!-- First, if we have an empty tree, close everything and exit -->
    2122      <xsl:when test="not($current-instr)">
     
    3637          </xsl:call-template>
    3738        </xsl:if>
    38       </xsl:when><!-- empty tree -->
     39      </xsl:when><!-- end empty tree -->
     40<!--============================================================-->
    3941      <xsl:when test="$current-instr[@role='root' and @remap='test']">
    4042        <xsl:if test="$install-seen">
     
    5557        </xsl:if>
    5658        <xsl:call-template name="begin-root"/>
    57         <xsl:choose>
    58           <xsl:when test="$want-stats">
    59             <xsl:apply-templates select="$current-instr" mode="root"/>
    60           </xsl:when>
    61           <xsl:otherwise>
    62             <xsl:apply-templates select="$current-instr"
    63                                  mode="root-comment-out"/>
    64           </xsl:otherwise>
    65         </xsl:choose>
     59<!-- We first apply mode="root" templates, and save the result in a variable -->
     60        <xsl:variable name="processed-instr">
     61          <xsl:apply-templates select="$current-instr" mode="root"/>
     62        </xsl:variable>
     63<!-- We then process as a test instruction -->
     64        <xsl:call-template name="process-test">
     65          <xsl:with-param name="test-instr" select="$processed-instr"/>
     66          <xsl:with-param name="want-stats" select="$want-stats"/>
     67        </xsl:call-template>
    6668        <xsl:call-template name="process-install">
    6769          <xsl:with-param
     
    7476          <xsl:with-param name="doc-seen" select="boolean(0)"/>
    7577        </xsl:call-template>
    76       </xsl:when><!-- role="root" and remap="test" -->
     78      </xsl:when><!-- end role="root" and remap="test" -->
     79<!--============================================================-->
    7780      <xsl:when test="$current-instr[@role='root' and @remap='doc']">
    7881        <xsl:if test="$test-seen">
     
    9295          <xsl:call-template name="begin-install"/>
    9396        </xsl:if>
    94         <xsl:apply-templates select="$current-instr"
    95                              mode="install-comment-out"/>
     97<!-- We first apply mode="install" templates, and save the result in a
     98     variable -->
     99        <xsl:variable name="processed-instr">
     100          <xsl:apply-templates select="$current-instr" mode="install"/>
     101        </xsl:variable>
     102<!-- Then comment it out -->
     103        <xsl:call-template name="output-comment-out">
     104          <xsl:with-param name="out-string" select="$processed-instr"/>
     105        </xsl:call-template>
    96106<!-- The above template ends with a commented line, so that if end-install
    97107     adds a closing single quote, it will not be seen. Add a CR to prevent
     
    109119          <xsl:with-param name="doc-seen" select="boolean(1)"/>
    110120        </xsl:call-template>
    111       </xsl:when><!--role="root" and remap="doc" -->
     121      </xsl:when><!-- end role="root" and remap="doc" -->
     122<!--============================================================-->
    112123      <xsl:when test="$current-instr[@role='root']">
     124<!-- We have two cases, depending on the content: either a config instruction,
     125     that we do not recorrd with porg (first case belaow), or a true install
     126     instruction (otherwise below) -->
    113127        <xsl:choose>
     128<!--____________________________________________________________ -->
    114129          <xsl:when test="contains(string($current-instr),'useradd') or
    115130                          contains(string($current-instr),'groupadd') or
     
    149164            </xsl:call-template>
    150165          </xsl:when><!-- end config as root -->
     166<!--____________________________________________________________ -->
    151167          <xsl:otherwise><!-- we have a true install instruction -->
    152168            <xsl:if test="$test-seen">
     
    196212            </xsl:call-template>
    197213          </xsl:otherwise><!-- end true install instruction -->
     214<!--____________________________________________________________ -->
    198215        </xsl:choose>
    199216      </xsl:when><!-- role="root" and no remap -->
     217<!--============================================================-->
    200218      <xsl:when test="$current-instr[@remap='test'] or
    201219                      $current-instr/self::command">
     
    221239          </xsl:call-template>
    222240        </xsl:if>
    223         <xsl:choose>
    224           <xsl:when test="$want-stats">
    225             <xsl:apply-templates select="$current-instr"/>
    226           </xsl:when>
    227           <xsl:otherwise>
    228             <xsl:apply-templates select="$current-instr" mode="comment-out"/>
    229           </xsl:otherwise>
    230         </xsl:choose>
     241<!-- We first apply normal templates, and save the result in a variable -->
     242        <xsl:variable name="processed-instr">
     243          <xsl:apply-templates select="$current-instr"/>
     244        </xsl:variable>
     245<!-- We then process as a test instruction -->
     246        <xsl:call-template name="process-test">
     247          <xsl:with-param name="test-instr" select="$processed-instr"/>
     248          <xsl:with-param name="want-stats" select="$want-stats"/>
     249        </xsl:call-template>
    231250        <xsl:call-template name="process-install">
    232251          <xsl:with-param
     
    239258          <xsl:with-param name="doc-seen" select="boolean(0)"/>
    240259        </xsl:call-template>
    241       </xsl:when><!-- no role, remap=test -->
     260      </xsl:when><!-- end no role, remap=test -->
     261<!--============================================================-->
    242262      <xsl:when test="$current-instr[@remap='doc']">
    243263        <xsl:if test="$install-seen">
     
    262282          </xsl:call-template>
    263283        </xsl:if>
    264         <xsl:choose>
    265           <xsl:when test="$want-stats">
    266             <xsl:apply-templates select="$current-instr"/>
    267           </xsl:when>
    268           <xsl:otherwise>
    269             <xsl:apply-templates select="$current-instr" mode="comment-out"/>
    270           </xsl:otherwise>
    271         </xsl:choose>
     284<!-- We first apply normal templates, and save the result in a variable -->
     285        <xsl:variable name="processed-instr">
     286          <xsl:apply-templates select="$current-instr"/>
     287        </xsl:variable>
     288<!-- We then process as a doc instruction -->
     289        <xsl:call-template name="process-doc">
     290          <xsl:with-param name="doc-instr" select="$processed-instr"/>
     291          <xsl:with-param name="want-stats" select="$want-stats"/>
     292        </xsl:call-template>
    272293        <xsl:call-template name="process-install">
    273294          <xsl:with-param
     
    281302        </xsl:call-template>
    282303      </xsl:when><!-- no role, remap="doc" -->
     304<!--============================================================-->
    283305      <xsl:otherwise><!-- no role no remap -->
    284306        <xsl:if test="$install-seen">
     
    310332        </xsl:call-template>
    311333      </xsl:otherwise><!-- no role, no remap -->
     334<!--============================================================-->
    312335    </xsl:choose>
    313   </xsl:template>
    314 
    315   <xsl:template match="userinput" mode="install-comment-out">
    316     <xsl:text>
    317 </xsl:text>
    318     <xsl:call-template name="output-comment-out">
    319       <xsl:with-param name="out-string" select="string()"/>
    320       <xsl:with-param name="process" select="'install'"/>
    321     </xsl:call-template>
    322   </xsl:template>
    323 
    324   <xsl:template match="userinput|command" mode="root-comment-out">
    325     <xsl:text>
    326 </xsl:text>
    327     <xsl:call-template name="output-comment-out">
    328       <xsl:with-param name="out-string" select="string()"/>
    329       <xsl:with-param name="process" select="'root'"/>
    330     </xsl:call-template>
    331   </xsl:template>
    332 
    333   <xsl:template match="userinput|command" mode="comment-out">
    334     <xsl:text>
    335 </xsl:text>
    336     <xsl:call-template name="output-comment-out">
    337       <xsl:with-param name="out-string" select="string()"/>
    338       <xsl:with-param name="process" select="'none'"/>
    339     </xsl:call-template>
    340336  </xsl:template>
    341337
     
    348344  </xsl:template>
    349345
    350   <xsl:template name="output-comment-out">
    351 <!-- Output instructions with each line commented out. The "process"
    352      parameter is:
    353         none: only output commented-out and remove ampersand
    354         root: output commented out and remove ampersand,
    355               with escaping of \, $, and `
    356         install: same + escape ' -->
    357     <xsl:param name="out-string"/>
    358     <xsl:param name="process"/>
     346<!-- userinput templates for mode="root" and normal are in scripts.xsl -->
     347
     348  <xsl:template name="process-test">
     349    <xsl:param name="test-instr"/>
     350    <xsl:param name="want-stats"/>
    359351    <xsl:choose>
    360       <xsl:when test="contains($out-string,'&#xA;')">
     352      <!-- the string may begin with a linefeed -->
     353      <xsl:when test="substring($test-instr,1,1)='&#xA;'">
     354        <xsl:text>
     355</xsl:text>
     356        <xsl:call-template name="process-test">
     357          <xsl:with-param name="test-instr"
     358                          select="substring-after($test-instr,'&#xA;')"/>
     359          <xsl:with-param name="want-stats" select="$want-stats"/>
     360        </xsl:call-template>
     361      </xsl:when>
     362      <xsl:when test="contains($test-instr,'&#xA;')">
     363        <xsl:call-template name="process-test">
     364          <xsl:with-param name="test-instr"
     365                          select="substring-before($test-instr,'&#xA;')"/>
     366          <xsl:with-param name="want-stats" select="$want-stats"/>
     367        </xsl:call-template>
     368        <xsl:text>
     369</xsl:text>
     370        <xsl:call-template name="process-test">
     371          <xsl:with-param name="test-instr"
     372                          select="substring-after($test-instr,'&#xA;')"/>
     373          <xsl:with-param name="want-stats" select="$want-stats"/>
     374        </xsl:call-template>
     375      </xsl:when>
     376      <xsl:otherwise>
     377        <xsl:if test="not($want-stats)">
     378          <xsl:text>#</xsl:text>
     379        </xsl:if>
    361380        <xsl:choose>
    362           <xsl:when test="$process='install'">
    363             <xsl:call-template name="output-install">
    364               <xsl:with-param
    365                         name="out-string"
    366                         select="concat('# ',
    367                                         substring-before($out-string,'&#xA;')
    368                                       )"/>
    369             </xsl:call-template>
    370           </xsl:when>
    371           <xsl:when test="$process='root'">
    372             <xsl:call-template name="output-root">
    373               <xsl:with-param
    374                         name="out-string"
    375                         select="concat('# ',
    376                                         substring-before($out-string,'&#xA;')
    377                                       )"/>
    378             </xsl:call-template>
     381          <xsl:when test="contains($test-instr,'make')
     382                  and not(contains($test-instr,'make -k'))">
     383            <xsl:copy-of select="substring-before($test-instr,'make')"/>
     384            <xsl:text>make -k</xsl:text>
     385            <xsl:copy-of select="substring-after($test-instr,'make')"/>
    379386          </xsl:when>
    380387          <xsl:otherwise>
    381             <xsl:call-template name="remove-ampersand">
    382               <xsl:with-param
    383                         name="out-string"
    384                         select="concat('# ',
    385                                         substring-before($out-string,'&#xA;')
    386                                       )"/>
    387             </xsl:call-template>
     388            <xsl:copy-of select="$test-instr"/>
    388389          </xsl:otherwise>
    389390        </xsl:choose>
     391        <xsl:if test="substring($test-instr,
     392                                string-length($test-instr),
     393                                1)!='\'">
     394          <xsl:if test="$want-stats">
     395            <xsl:text> &gt;&gt; $TESTLOG 2>&amp;1</xsl:text>
     396          </xsl:if>
     397          <xsl:text> || true</xsl:text>
     398        </xsl:if>
     399      </xsl:otherwise>
     400    </xsl:choose>
     401  </xsl:template>
     402
     403  <xsl:template name="process-doc">
     404    <xsl:param name="doc-instr"/>
     405    <xsl:param name="want-stats"/>
     406    <xsl:choose>
     407      <xsl:when test="$want-stats">
     408        <xsl:copy-of select="$doc-instr"/>
     409      </xsl:when>
     410      <xsl:otherwise>
     411        <xsl:call-template name="output-comment-out">
     412          <xsl:with-param name="out-string" select="$doc-instr"/>
     413        </xsl:call-template>
     414      </xsl:otherwise>
     415    </xsl:choose>
     416  </xsl:template>
     417
     418  <xsl:template name="output-comment-out">
     419<!-- Output instructions with each line commented out. -->
     420    <xsl:param name="out-string"/>
     421    <xsl:choose>
     422      <!-- the string may begin with a linefeed -->
     423      <xsl:when test="substring($out-string,1,1)='&#xA;'">
    390424        <xsl:text>
    391425</xsl:text>
    392426        <xsl:call-template name="output-comment-out">
    393           <xsl:with-param
    394                     name="out-string"
    395                     select="substring-after($out-string,'&#xA;')"/>
    396           <xsl:with-param name="process" select="$process"/>
     427          <xsl:with-param name="out-string"
     428                          select="substring-after($out-string,'&#xA;')"/>
     429        </xsl:call-template>
     430      </xsl:when>
     431      <xsl:when test="contains($out-string,'&#xA;')">
     432        <xsl:text>#</xsl:text>
     433        <xsl:copy-of select="substring-before($out-string,'&#xA;')"/>
     434        <xsl:text>
     435</xsl:text>
     436        <xsl:call-template name="output-comment-out">
     437          <xsl:with-param name="out-string"
     438                          select="substring-after($out-string,'&#xA;')"/>
    397439        </xsl:call-template>
    398440      </xsl:when>
    399441      <xsl:otherwise>
    400         <xsl:choose>
    401           <xsl:when test="$process='install'">
    402             <xsl:call-template name="output-install">
    403               <xsl:with-param name="out-string"
    404                               select="concat('# ',$out-string)"/>
    405             </xsl:call-template>
    406           </xsl:when>
    407           <xsl:when test="$process='root'">
    408             <xsl:call-template name="output-root">
    409               <xsl:with-param name="out-string"
    410                               select="concat('# ',$out-string)"/>
    411             </xsl:call-template>
    412           </xsl:when>
    413           <xsl:otherwise>
    414             <xsl:call-template name="remove-ampersand">
    415               <xsl:with-param name="out-string"
    416                               select="concat('# ',$out-string)"/>
    417             </xsl:call-template>
    418           </xsl:otherwise>
    419         </xsl:choose>
     442        <xsl:text>#</xsl:text>
     443        <xsl:copy-of select="$out-string"/>
    420444      </xsl:otherwise>
    421445    </xsl:choose>
  • BLFS/xsl/scripts.xsl

    r96d7e44 r0a0b609  
    190190      </xsl:when>
    191191
    192       <xsl:when test="@role = 'installation'">
     192      <xsl:when test="@role = 'installation' and
     193                      not(preceding-sibling::sect2[@role = 'installation'])">
    193194        <xsl:text>
    194195cd $BUILD_DIR
Note: See TracChangeset for help on using the changeset viewer.