Ignore:
Timestamp:
04/22/2019 09:38:44 AM (5 years ago)
Author:
Pierre Labastie <pierre@…>
Branches:
ablfs-more, legacy, trunk
Children:
72e9e68
Parents:
dfc023a
Message:

Fix generation of install instructions, and remove those pesky && as much as
possible

File:
1 edited

Legend:

Unmodified
Added
Removed
  • BLFS/xsl/scripts.xsl

    rdfc023a raeb8539  
    541541<!-- instructions run as root (configuration mainly) -->
    542542      <xsl:when test="@role = 'root'">
     543<!-- templates begin/end-root are in gen-install.xsl -->
    543544        <xsl:if test="not(preceding-sibling::screen[1][@role='root'])">
    544           <xsl:if test="$sudo = 'y'">
    545             <xsl:text>sudo -E sh &lt;&lt; ROOT_EOF&#xA;</xsl:text>
    546           </xsl:if>
     545          <xsl:call-template name="begin-root"/>
    547546        </xsl:if>
    548547        <xsl:apply-templates mode="root"/>
     548        <xsl:text>&#xA;</xsl:text>
    549549        <xsl:if test="not(following-sibling::screen[1][@role='root'])">
    550           <xsl:if test="$sudo = 'y'">
    551             <xsl:text>&#xA;ROOT_EOF</xsl:text>
    552           </xsl:if>
     550          <xsl:call-template name="end-root"/>
    553551        </xsl:if>
    554552      </xsl:when>
     
    556554      <xsl:otherwise>
    557555        <xsl:apply-templates select="userinput"/>
    558       </xsl:otherwise>
    559     </xsl:choose>
    560     <xsl:text>&#xA;</xsl:text>
     556        <xsl:text>&#xA;</xsl:text>
     557      </xsl:otherwise>
     558    </xsl:choose>
    561559  </xsl:template>
    562560
     
    603601  <xsl:template match="screen" mode="config">
    604602    <xsl:if test="preceding-sibling::para[1]/xref[@linkend='bootscripts']">
     603<!-- if the preceding "screen" tag is role="root", and we are role="root"
     604     the end-root has not been called. So do it -->
     605      <xsl:if test="preceding-sibling::screen[1][@role='root'] and
     606                    @role='root'">
     607        <xsl:call-template name="end-root"/>
     608      </xsl:if>
    605609      <xsl:call-template name="set-bootpkg-dir">
    606610        <xsl:with-param name="bootpkg" select="'bootscripts'"/>
     
    608612                        select="id('bootscripts')//itemizedlist//ulink/@url"/>
    609613      </xsl:call-template>
     614<!-- if the preceding "screen" tag is role="root", and we are role="root"
     615     the begin-root will not be called. So do it -->
     616      <xsl:if test="preceding-sibling::screen[1][@role='root'] and
     617                    @role='root'">
     618        <xsl:call-template name="begin-root"/>
     619      </xsl:if>
    610620    </xsl:if>
    611621    <xsl:if test="preceding-sibling::para[1]/xref[@linkend='systemd-units']">
     622<!-- if the preceding "screen" tag is role="root", and we are role="root"
     623     the end-root has not been called. So do it -->
     624      <xsl:if test="preceding-sibling::screen[1][@role='root'] and
     625                    @role='root'">
     626        <xsl:call-template name="end-root"/>
     627      </xsl:if>
    612628      <xsl:call-template name="set-bootpkg-dir">
    613629        <xsl:with-param name="bootpkg" select="'systemd-units'"/>
     
    615631                        select="id('systemd-units')//itemizedlist//ulink/@url"/>
    616632      </xsl:call-template>
     633<!-- if the preceding "screen" tag is role="root", and we are role="root"
     634     the begin-root will not be called. So do it -->
     635      <xsl:if test="preceding-sibling::screen[1][@role='root'] and
     636                    @role='root'">
     637        <xsl:call-template name="begin-root"/>
     638      </xsl:if>
    617639    </xsl:if>
    618640    <xsl:apply-templates select='.'/>
    619641    <xsl:if test="preceding-sibling::para[1]/xref[@linkend='bootscripts' or
    620642                                                  @linkend='systemd-units']">
    621       <xsl:text>
    622 popd</xsl:text>
     643<!-- if the next "screen" tag is role="root", and we are role="root"
     644     the end-root has not been called. So do it -->
     645      <xsl:if test="following-sibling::screen[1][@role='root'] and
     646                    @role='root'">
     647        <xsl:call-template name="end-root"/>
     648      </xsl:if>
     649      <xsl:text>popd
     650</xsl:text>
     651<!-- if the next "screen" tag is role="root", and we are role="root"
     652     the begin-root will not be called. So do it -->
     653      <xsl:if test="following-sibling::screen[1][@role='root'] and
     654                    @role='root'">
     655        <xsl:call-template name="begin-root"/>
     656      </xsl:if>
    623657    </xsl:if>
    624     <xsl:text>&#xA;</xsl:text>
    625658  </xsl:template>
    626659
     
    686719  </xsl:template>
    687720
     721  <xsl:template match="text()">
     722    <xsl:call-template name="remove-ampersand">
     723      <xsl:with-param name="out-string" select="string()"/>
     724    </xsl:call-template>
     725  </xsl:template>
     726
    688727  <xsl:template match="text()" mode="root">
    689728    <xsl:call-template name="output-root">
     
    740779      </xsl:when>
    741780      <xsl:otherwise>
    742         <xsl:value-of select="$out-string"/>
     781        <xsl:call-template name="remove-ampersand">
     782          <xsl:with-param name="out-string" select="$out-string"/>
     783        </xsl:call-template>
     784<!--        <xsl:value-of select="$out-string"/> -->
    743785      </xsl:otherwise>
    744786    </xsl:choose>
     
    890932          <xsl:when test="contains($outputstring,'&gt;/') and
    891933                                 not(contains(substring-before($outputstring,'&gt;/'),' /'))">
    892             <xsl:value-of select="substring-before($outputstring,'&gt;/')"/>
     934            <xsl:call-template name="remove-ampersand">
     935              <xsl:with-param name="out-string"
     936                   select="substring-before($outputstring,'&gt;/')"/>
     937            </xsl:call-template>
     938<!--            <xsl:value-of select="substring-before($outputstring,'&gt;/')"/>-->
    893939            <xsl:text>&gt;$PKG_DEST/</xsl:text>
    894940            <xsl:call-template name="outputpkgdest">
     
    897943          </xsl:when>
    898944          <xsl:when test="contains($outputstring,' /')">
    899             <xsl:value-of select="substring-before($outputstring,' /')"/>
     945            <xsl:call-template name="remove-ampersand">
     946              <xsl:with-param name="out-string"
     947                   select="substring-before($outputstring,' /')"/>
     948            </xsl:call-template>
     949<!--            <xsl:value-of select="substring-before($outputstring,' /')"/>-->
    900950            <xsl:text> $PKG_DEST/</xsl:text>
    901951            <xsl:call-template name="outputpkgdest">
     
    904954          </xsl:when>
    905955          <xsl:otherwise>
    906             <xsl:value-of select="$outputstring"/>
     956            <xsl:call-template name="remove-ampersand">
     957              <xsl:with-param name="out-string" select="$outputstring"/>
     958            </xsl:call-template>
     959<!--            <xsl:value-of select="$outputstring"/>-->
    907960          </xsl:otherwise>
    908961        </xsl:choose>
     
    911964  </xsl:template>
    912965
     966  <xsl:template name="remove-ampersand">
     967    <xsl:param name="out-string" select="''"/>
     968    <xsl:choose>
     969      <xsl:when test="contains($out-string,'&amp;&amp;&#xA;')">
     970        <xsl:variable name="instruction-before">
     971          <xsl:call-template name="last-line">
     972            <xsl:with-param
     973                 name="instructions"
     974                 select="substring-before($out-string,'&amp;&amp;&#xA;')"/>
     975          </xsl:call-template>
     976        </xsl:variable>
     977        <xsl:call-template name="remove-end-space">
     978              <xsl:with-param
     979                 name="instructions"
     980                 select="substring-before($out-string,'&amp;&amp;&#xA;')"/>
     981        </xsl:call-template>
     982        <xsl:if test="contains($instruction-before,' ]') or
     983                      contains($instruction-before,'test ') or
     984                      contains($instruction-before,'pgrep -l')">
     985          <xsl:text> &amp;&amp;</xsl:text>
     986        </xsl:if>
     987        <xsl:text>&#xA;</xsl:text>
     988        <xsl:call-template name="remove-ampersand">
     989          <xsl:with-param name="out-string"
     990                          select="substring-after($out-string,
     991                                                  '&amp;&amp;&#xA;')"/>
     992        </xsl:call-template>
     993      </xsl:when>
     994      <xsl:otherwise>
     995        <xsl:copy-of select="$out-string"/>
     996      </xsl:otherwise>
     997    </xsl:choose>
     998  </xsl:template>
     999
     1000  <xsl:template name="last-line">
     1001    <xsl:param name="instructions" select="''"/>
     1002    <xsl:choose>
     1003      <xsl:when test="contains($instructions,'&#xA;')">
     1004        <xsl:call-template name="last-line">
     1005          <xsl:with-param
     1006               name="instructions"
     1007               select="substring-after($instructions,'&#xA;')"/>
     1008        </xsl:call-template>
     1009      </xsl:when>
     1010      <xsl:otherwise>
     1011        <xsl:copy-of select="normalize-space($instructions)"/>
     1012      </xsl:otherwise>
     1013    </xsl:choose>
     1014  </xsl:template>
     1015
     1016  <xsl:template name="remove-end-space">
     1017    <xsl:param name="instructions" select="''"/>
     1018    <xsl:choose>
     1019      <xsl:when test="contains($instructions,'&#xA;')">
     1020        <xsl:copy-of select="substring-before($instructions,'&#xA;')"/>
     1021        <xsl:text>&#xA;</xsl:text>
     1022        <xsl:call-template name="remove-end-space">
     1023          <xsl:with-param
     1024               name="instructions"
     1025               select="substring-after($instructions,'&#xA;')"/>
     1026        </xsl:call-template>
     1027      </xsl:when>
     1028      <xsl:otherwise>
     1029        <xsl:copy-of select="normalize-space($instructions)"/>
     1030      </xsl:otherwise>
     1031    </xsl:choose>
     1032  </xsl:template>
     1033
    9131034</xsl:stylesheet>
Note: See TracChangeset for help on using the changeset viewer.