source: common/chroot.xsl@ 35094ed

ablfs-more trunk
Last change on this file since 35094ed was 1b02a9a, checked in by Xi Ruoyao <xry111@…>, 9 months ago
Replace $(nproc
echo 1) and $(nproc)
  • Property mode set to 100644
File size: 3.7 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2
3<xsl:stylesheet
4 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5 xmlns:exsl="http://exslt.org/common"
6 extension-element-prefixes="exsl"
7 version="1.0">
8
9 <xsl:param name="jobs_2" select="1"/>
10
11 <xsl:template match="/">
12 <xsl:apply-templates select="//sect1"/>
13 </xsl:template>
14
15 <xsl:template match="sect1">
16 <xsl:if
17 test="descendant::screen/userinput[contains(string(),'&#xA;chroot') or
18 starts-with(string(),'chroot')]">
19 <!-- The file names -->
20 <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
21 <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
22 <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
23 <!-- The build order -->
24 <xsl:variable name="position" select="position()"/>
25 <xsl:variable name="order">
26 <xsl:choose>
27 <xsl:when test="string-length($position) = 1">
28 <xsl:text>00</xsl:text>
29 <xsl:value-of select="$position"/>
30 </xsl:when>
31 <xsl:when test="string-length($position) = 2">
32 <xsl:text>0</xsl:text>
33 <xsl:value-of select="$position"/>
34 </xsl:when>
35 <xsl:otherwise>
36 <xsl:value-of select="$position"/>
37 </xsl:otherwise>
38 </xsl:choose>
39 </xsl:variable>
40 <!-- Creating dirs and files -->
41 <exsl:document href="{$order}-{$filename}" method="text">
42 <xsl:text>#!/bin/bash&#xA;</xsl:text>
43 <xsl:apply-templates
44 select=".//userinput[contains(string(),'&#xA;chroot') or
45 starts-with(string(),'chroot')]"/>
46 <xsl:text>exit&#xA;</xsl:text>
47 </exsl:document>
48 </xsl:if>
49 </xsl:template>
50
51 <xsl:template match="userinput">
52 <xsl:call-template name="extract-chroot">
53 <xsl:with-param name="instructions" select="string()"/>
54 </xsl:call-template>
55 </xsl:template>
56
57 <xsl:template name="extract-chroot">
58 <xsl:param name="instructions" select="''"/>
59 <xsl:choose>
60 <xsl:when test="contains($instructions, '$(nproc || echo 1)')">
61 <xsl:call-template name="extract-chroot">
62 <xsl:with-param
63 name="instructions"
64 select="concat(substring-before($instructions, '$(nproc || echo 1)'), $jobs_2, substring-after($instructions, '$(nproc || echo 1)'))"/>
65 </xsl:call-template>
66 </xsl:when>
67 <xsl:when test="not(starts-with($instructions,'&#xA;chroot')) and
68 contains($instructions, '&#xA;chroot')">
69 <xsl:call-template name="extract-chroot">
70 <xsl:with-param name="instructions"
71 select="substring(substring-after($instructions,
72 substring-before($instructions,
73 '&#xA;chroot')),2)"/>
74 </xsl:call-template>
75 </xsl:when>
76 <xsl:when test="contains($instructions,'\&#xA;')">
77 <xsl:copy-of select="substring-before($instructions,'\&#xA;')"/>
78 <xsl:text>\
79</xsl:text>
80 <xsl:call-template name="extract-chroot">
81 <xsl:with-param name="instructions"
82 select="substring-after($instructions,'\&#xA;')"/>
83 </xsl:call-template>
84 </xsl:when>
85 <xsl:when test="contains($instructions,'&#xA;')">
86 <xsl:copy-of select="substring-before($instructions,'&#xA;')"/>
87 <xsl:text>
88</xsl:text>
89 </xsl:when>
90 <xsl:otherwise>
91 <xsl:copy-of select="$instructions"/>
92 <xsl:text>
93</xsl:text>
94 </xsl:otherwise>
95 </xsl:choose>
96 </xsl:template>
97</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.