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)
This commit is contained in:
Pierre Labastie 2019-08-17 08:30:36 +00:00
parent 96d7e44922
commit 0a0b60984c
4 changed files with 232 additions and 120 deletions

View file

@ -102,13 +102,16 @@
</xsl:call-template>
</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"
select="substring-before(concat($list,' '),'-pass1 ')"/>
<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>
<xsl:when test="not(id($list)[self::sect1 or self::sect2 or self::para or self::bridgehead])">
<xsl:apply-templates
@ -192,6 +195,90 @@
</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>
<xsl:otherwise>
<xsl:copy-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="processing-instruction()" mode="pass1">
<xsl:variable name="pi-full" select="string()"/>
<xsl:variable name="pi-value"

View file

@ -17,6 +17,7 @@
<xsl:variable name="current-instr" select="$instruction-tree[1]"/>
<xsl:choose>
<!--============================================================-->
<!-- First, if we have an empty tree, close everything and exit -->
<xsl:when test="not($current-instr)">
<xsl:if test="$install-seen">
@ -35,7 +36,8 @@
<xsl:with-param name="want-stats" select="$want-stats"/>
</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">
<xsl:call-template name="end-install"/>
@ -54,15 +56,15 @@
</xsl:call-template>
</xsl:if>
<xsl:call-template name="begin-root"/>
<xsl:choose>
<xsl:when test="$want-stats">
<!-- 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:when>
<xsl:otherwise>
<xsl:apply-templates select="$current-instr"
mode="root-comment-out"/>
</xsl:otherwise>
</xsl:choose>
</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
name="instruction-tree"
@ -73,7 +75,8 @@
<xsl:with-param name="test-seen" select="boolean(1)"/>
<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">
<xsl:call-template name="end-test">
@ -91,8 +94,15 @@
<xsl:if test="not($install-seen)">
<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
that -->
@ -108,9 +118,14 @@
<xsl:with-param name="test-seen" select="boolean(0)"/>
<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
contains(string($current-instr),'usermod') or
@ -148,6 +163,7 @@
<xsl:with-param name="doc-seen" select="boolean(0)"/>
</xsl:call-template>
</xsl:when><!-- end config as root -->
<!--____________________________________________________________ -->
<xsl:otherwise><!-- we have a true install instruction -->
<xsl:if test="$test-seen">
<xsl:call-template name="end-test">
@ -195,8 +211,10 @@ echo Size after install: $(sudo du -skx --exclude home /) >> $INFOLOG
<xsl:with-param name="doc-seen" select="boolean(0)"/>
</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">
<xsl:if test="$install-seen">
@ -220,14 +238,15 @@ echo Size after install: $(sudo du -skx --exclude home /) >> $INFOLOG
<xsl:with-param name="want-stats" select="$want-stats"/>
</xsl:call-template>
</xsl:if>
<xsl:choose>
<xsl:when test="$want-stats">
<!-- We first apply normal templates, and save the result in a variable -->
<xsl:variable name="processed-instr">
<xsl:apply-templates select="$current-instr"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="$current-instr" mode="comment-out"/>
</xsl:otherwise>
</xsl:choose>
</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
name="instruction-tree"
@ -238,7 +257,8 @@ echo Size after install: $(sudo du -skx --exclude home /) >> $INFOLOG
<xsl:with-param name="test-seen" select="boolean(1)"/>
<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">
<xsl:call-template name="end-install"/>
@ -261,14 +281,15 @@ echo Size after install: $(sudo du -skx --exclude home /) >> $INFOLOG
<xsl:with-param name="want-stats" select="$want-stats"/>
</xsl:call-template>
</xsl:if>
<xsl:choose>
<xsl:when test="$want-stats">
<!-- We first apply normal templates, and save the result in a variable -->
<xsl:variable name="processed-instr">
<xsl:apply-templates select="$current-instr"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="$current-instr" mode="comment-out"/>
</xsl:otherwise>
</xsl:choose>
</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
name="instruction-tree"
@ -280,6 +301,7 @@ echo Size after install: $(sudo du -skx --exclude home /) >> $INFOLOG
<xsl:with-param name="doc-seen" select="boolean(1)"/>
</xsl:call-template>
</xsl:when><!-- no role, remap="doc" -->
<!--============================================================-->
<xsl:otherwise><!-- no role no remap -->
<xsl:if test="$install-seen">
<xsl:call-template name="end-install"/>
@ -309,36 +331,10 @@ echo Size after install: $(sudo du -skx --exclude home /) >> $INFOLOG
<xsl:with-param name="doc-seen" select="boolean(0)"/>
</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>
<xsl:template match="userinput" mode="install">
<xsl:text>
</xsl:text>
@ -347,76 +343,104 @@ echo Size after install: $(sudo du -skx --exclude home /) >> $INFOLOG
</xsl:call-template>
</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;')">
<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;')
)"/>
<!-- 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="$process='root'">
<xsl:call-template name="output-root">
<xsl:with-param
name="out-string"
select="concat('# ',
substring-before($out-string,'&#xA;')
)"/>
<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:call-template name="remove-ampersand">
<xsl:with-param
name="out-string"
select="concat('# ',
substring-before($out-string,'&#xA;')
)"/>
<xsl:if test="not($want-stats)">
<xsl:text>#</xsl:text>
</xsl:if>
<xsl:choose>
<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: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"
<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:with-param name="process" select="$process"/>
</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>
</xsl:template>

View file

@ -189,7 +189,8 @@ cd $SRC_DIR</xsl:text>
<xsl:apply-templates select=".//screen[./userinput]"/>
</xsl:when>
<xsl:when test="@role = 'installation'">
<xsl:when test="@role = 'installation' and
not(preceding-sibling::sect2[@role = 'installation'])">
<xsl:text>
cd $BUILD_DIR
find . -maxdepth 1 -mindepth 1 -type d | xargs </xsl:text>

View file

@ -116,7 +116,7 @@ PACKAGE=${PACKAGE,,}
# name is not normalized, several hacks are necessary (now in function
# extract_version)...
VERSION=$(extract_version $PCKGVRS)
porg -lp ${PACKAGE}-${VERSION} sh << PORG_EOF
porg -+ -lp ${PACKAGE}-${VERSION} sh << PORG_EOF
$*
PORG_EOF
}