Author: pierre Date: Tue Aug 13 08:03:39 2019 New Revision: 4114 Log: Refactoring the output of installation instructions:
Create a template which processes the instruction tree fragment (only header for now, the content is bogus), and call it from main sheet. Added: jhalfs/trunk/BLFS/xsl/process-install.xsl Deleted: jhalfs/trunk/BLFS/xsl/gen-install.xsl Modified: jhalfs/trunk/BLFS/xsl/scripts.xsl Added: jhalfs/trunk/BLFS/xsl/process-install.xsl ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ jhalfs/trunk/BLFS/xsl/process-install.xsl Tue Aug 13 08:03:39 2019 (r4114) @@ -0,0 +1,277 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> + +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + version="1.0"> + +<!-- $Id: gen-install.xsl 4107 2019-06-15 15:26:23Z pierre $ --> + + <xsl:template name="process-install"> + <xsl:param name="instruction-tree"/> + <xsl:param name="want-stats"/> + <xsl:param name="root-seen"/> + <xsl:param name="install-seen"/> + <xsl:param name="test-seen"/> + <xsl:param name="doc-seen"/> + +<!-- "nature" variables: + - 'non-root': executable as user + - 'config': execute as root, with no special formatting + - 'install': execute as root, with PKG_DEST or escape instructions + - 'none': does not exist (for preceding of following uniquely) +--> + <xsl:variable name="my-nature"> + <xsl:choose> + <xsl:when test="not(@role)"> + <xsl:text>non-root</xsl:text> + </xsl:when> + <xsl:when test="contains(string(),'useradd') or + contains(string(),'groupadd') or + contains(string(),'usermod') or + contains(string(),'icon-cache') or + contains(string(),'desktop-database') or + contains(string(),'compile-schemas') or + contains(string(),'query-loaders') or + contains(string(),'pam.d') or + contains(string(),'query-immodules')"> + <xsl:text>config</xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:text>install</xsl:text> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable + name="prec-screen" + select="preceding::screen[not(@role='nodump') and ./userinput][1] + [ancestor::sect2 = current()/ancestor::sect2]"/> + + <xsl:variable + name="prec-string" + select="string($prec-screen)"/> + +<!-- + <xsl:message> + <xsl:text> +============================== +List of preceding siblings for "</xsl:text> + <xsl:value-of select="./userinput"/> + <xsl:text>": +</xsl:text> + <xsl:for-each select="preceding-sibling::screen[not(@role='nodump') and + ./userinput] | + preceding-sibling::para/command"> + <xsl:copy-of select=".//text()"/> + <xsl:text> +=== +</xsl:text> + </xsl:for-each> + </xsl:message> +--> + <xsl:variable name="prec-nature"> + <xsl:choose> + <xsl:when + test="$prec-string='' or + (preceding::screen[not(@role='nodump') and + ./userinput] | + preceding::command[contains(text(),'check') or + contains(text(),'test')] + )[last()][self::command]"> + <xsl:text>none</xsl:text> + </xsl:when> + <xsl:when test="$prec-screen[not(@role)]"> + <xsl:text>non-root</xsl:text> + </xsl:when> + <xsl:when test="contains($prec-string,'useradd') or + contains($prec-string,'groupadd') or + contains($prec-string,'usermod') or + contains($prec-string,'icon-cache') or + contains($prec-string,'desktop-database') or + contains($prec-string,'compile-schemas') or + contains($prec-string,'query-loaders') or + contains($prec-string,'pam.d') or + contains($prec-string,'query-immodules')"> + <xsl:text>config</xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:text>install</xsl:text> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable + name="follow-screen" + select="following::screen[not(@role='nodump') and ./userinput][1] + [ancestor::sect2 = current()/ancestor::sect2]"/> + + <xsl:variable + name="follow-string" + select="string($follow-screen)"/> + + <xsl:variable name="follow-nature"> + <xsl:choose> + <xsl:when + test="$follow-string='' or + (following::screen[not(@role='nodump') and + ./userinput] | + following::command[contains(text(),'check') or + contains(text(),'test')] + )[1][self::command]"> + <xsl:text>none</xsl:text> + </xsl:when> + <xsl:when test="$follow-screen[not(@role)]"> + <xsl:text>non-root</xsl:text> + </xsl:when> + <xsl:when test="contains($follow-string,'useradd') or + contains($follow-string,'groupadd') or + contains($follow-string,'usermod') or + contains($follow-string,'icon-cache') or + contains($follow-string,'desktop-database') or + contains($follow-string,'compile-schemas') or + contains($follow-string,'query-loaders') or + contains($follow-string,'pam.d') or + contains($follow-string,'query-immodules')"> + <xsl:text>config</xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:text>install</xsl:text> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:choose> + <xsl:when test="$my-nature='non-root'"> + <xsl:if test="$prec-nature='install'"> + <xsl:call-template name="end-install"/> + <xsl:call-template name="end-root"/> + </xsl:if> + <xsl:if test="$prec-nature='config'"> + <xsl:call-template name="end-root"/> + </xsl:if> + <xsl:apply-templates/> + </xsl:when> + + <xsl:when test="$my-nature='config'"> + <xsl:if test="$prec-nature='none' or $prec-nature='non-root'"> + <xsl:call-template name="begin-root"/> + </xsl:if> + <xsl:if test="$prec-nature='install'"> + <xsl:call-template name="end-install"/> + </xsl:if> + <xsl:apply-templates mode="root"/> + <xsl:if test="$follow-nature='none'"> + <xsl:call-template name="end-root"/> + </xsl:if> + </xsl:when> + + <xsl:when test="$my-nature='install'"> + <xsl:if test="$prec-nature='none' or $prec-nature='non-root'"> + <xsl:if test="$want-stats"> + <xsl:call-template name="output-destdir"/> + </xsl:if> + <xsl:call-template name="begin-root"/> + <xsl:call-template name="begin-install"/> + </xsl:if> + <xsl:if test="$prec-nature='config'"> + <xsl:if test="$want-stats"> + <xsl:call-template name="end-root"/> + <xsl:call-template name="output-destdir"/> + <xsl:call-template name="begin-root"/> + </xsl:if> + <xsl:call-template name="begin-install"/> + </xsl:if> + <xsl:apply-templates mode="install"/> + <xsl:if test="$follow-nature='none'"> + <xsl:call-template name="end-install"/> + <xsl:call-template name="end-root"/> + </xsl:if> + </xsl:when> + + </xsl:choose> + </xsl:template> + + <xsl:template name="begin-root"> + <xsl:if test="$sudo='y'"> + <xsl:text> +sudo -E sh << ROOT_EOF</xsl:text> + </xsl:if> + </xsl:template> + + <xsl:template name="begin-install"> + <xsl:if test="$wrap-install = 'y'"> + <xsl:text> +if [ -r "$JH_PACK_INSTALL" ]; then + source $JH_PACK_INSTALL + export -f wrapInstall + export -f packInstall +fi +wrapInstall '</xsl:text> + </xsl:if> + </xsl:template> + + <xsl:template name="end-root"> + <xsl:if test="$sudo='y'"> + <xsl:text> +ROOT_EOF</xsl:text> + </xsl:if> + </xsl:template> + + <xsl:template name="end-install"> + <xsl:if test="$del-la-files = 'y'"> + <xsl:call-template name="output-root"> + <xsl:with-param name="out-string" select="$la-files-instr"/> + </xsl:call-template> + </xsl:if> + <xsl:if test="$wrap-install = 'y'"> + <xsl:text>'
packInstall</xsl:text> + </xsl:if> + </xsl:template> + + <xsl:template match="userinput" mode="install"> + <xsl:text> +</xsl:text> + <xsl:call-template name="output-install"> + <xsl:with-param name="out-string" select="string()"/> + </xsl:call-template> + </xsl:template> + + <xsl:template name="output-install"> + <xsl:param name="out-string" select="''"/> + <xsl:choose> + <xsl:when test="starts-with($out-string, 'make ') or + contains($out-string,' make ') or + contains($out-string,'
make')"> + <xsl:call-template name="output-install"> + <xsl:with-param + name="out-string" + select="substring-before($out-string,'make ')"/> + </xsl:call-template> + <xsl:text>make -j1 </xsl:text> + <xsl:call-template name="output-install"> + <xsl:with-param + name="out-string" + select="substring-after($out-string,'make ')"/> + </xsl:call-template> + </xsl:when> + <xsl:when test="contains($out-string,string($APOS)) + and $wrap-install = 'y'"> + <xsl:call-template name="output-root"> + <xsl:with-param + name="out-string" + select="substring-before($out-string,string($APOS))"/> + </xsl:call-template> + <xsl:text>'\''</xsl:text> + <xsl:call-template name="output-install"> + <xsl:with-param name="out-string" + select="substring-after($out-string,string($APOS))"/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="output-root"> + <xsl:with-param name="out-string" select="$out-string"/> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + +</xsl:stylesheet> Modified: jhalfs/trunk/BLFS/xsl/scripts.xsl ============================================================================== --- jhalfs/trunk/BLFS/xsl/scripts.xsl Mon Jul 15 13:06:35 2019 (r4113) +++ jhalfs/trunk/BLFS/xsl/scripts.xsl Tue Aug 13 08:03:39 2019 (r4114) @@ -89,8 +89,9 @@ <!-- end parameters and global variables --> -<!-- include the templates for the screen children of role="install" sect2 --> - <xsl:include href="gen-install.xsl"/> +<!-- include the template for processing screen children of + role="install" sect2 --> + <xsl:include href="process-install.xsl"/> <!--=================== Begin processing ========================--> @@ -275,13 +276,18 @@ </xsl:text> </xsl:if> - <xsl:apply-templates - mode="installation" + <xsl:call-template name="process-install"> + <xsl:with-param + name="instruction-tree" select=".//screen[not(@role = 'nodump') and ./userinput] | .//para/command[contains(text(),'check') or - contains(text(),'test')]"> + contains(text(),'test')]"/> <xsl:with-param name="want-stats" select="$want-stats"/> - </xsl:apply-templates> + <xsl:with-param name="root-seen" select="boolean(0)"/> + <xsl:with-param name="install-seen" select="boolean(0)"/> + <xsl:with-param name="test-seen" select="boolean(0)"/> + <xsl:with-param name="doc-seen" select="boolean(0)"/> + </xsl:call-template> <xsl:text> </xsl:text> <xsl:if test="$sudo = 'y'"> -- http://lists.linuxfromscratch.org/listinfo/alfs-log Unsubscribe: See the above information page