source: BLFS/xsl/gen-install.xsl@ a4af6811

ablfs-more legacy trunk
Last change on this file since a4af6811 was 619b313, checked in by Pierre Labastie <pierre@…>, 5 years ago

Various fixes and improvements coming from github:

  • the case for "pax" in packInstall.sh.prog
  • an error in packageManager.xml.porg (comment before <?xml?> tag)
  • a non-working $Id in Makefile
  • some fixes for using the sect1info in lfs (in BLFS tools)
  • a big rewrite for generating scripts with more consistent line spacing, opening the way to manage remap="test" and remap="doc" attributes
  • Property mode set to 100644
File size: 9.4 KB
RevLine 
[c048987]1<?xml version="1.0" encoding="ISO-8859-1"?>
2
3<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 version="1.0">
5
6<!-- $Id$ -->
7
8 <xsl:template match="screen" mode="installation">
[619b313]9 <xsl:param name="want-stats" select="false"/>
[c048987]10<!-- "nature" variables:
11 - 'non-root': executable as user
12 - 'config': execute as root, with no special formatting
13 - 'install': execute as root, with PKG_DEST or escape instructions
14 - 'none': does not exist (for preceding of following uniquely)
15-->
16 <xsl:variable name="my-nature">
17 <xsl:choose>
18 <xsl:when test="not(@role)">
19 <xsl:text>non-root</xsl:text>
20 </xsl:when>
21 <xsl:when test="contains(string(),'useradd') or
22 contains(string(),'groupadd') or
23 contains(string(),'usermod') or
24 contains(string(),'icon-cache') or
25 contains(string(),'desktop-database') or
26 contains(string(),'compile-schemas') or
27 contains(string(),'query-loaders') or
28 contains(string(),'pam.d') or
29 contains(string(),'query-immodules')">
30 <xsl:text>config</xsl:text>
31 </xsl:when>
32 <xsl:otherwise>
33 <xsl:text>install</xsl:text>
34 </xsl:otherwise>
35 </xsl:choose>
36 </xsl:variable>
37
[619b313]38 <xsl:variable
39 name="prec-screen"
40 select="preceding::screen[not(@role='nodump') and ./userinput][1]
41 [ancestor::sect2 = current()/ancestor::sect2]"/>
42
[c048987]43 <xsl:variable
44 name="prec-string"
[619b313]45 select="string($prec-screen)"/>
46
[c048987]47<!--
48 <xsl:message>
49 <xsl:text>
50==============================
51List of preceding siblings for "</xsl:text>
52 <xsl:value-of select="./userinput"/>
53 <xsl:text>":
54</xsl:text>
55 <xsl:for-each select="preceding-sibling::screen[not(@role='nodump') and
56 ./userinput] |
57 preceding-sibling::para/command">
58 <xsl:copy-of select=".//text()"/>
59 <xsl:text>
60===
61</xsl:text>
62 </xsl:for-each>
63 </xsl:message>
64-->
65 <xsl:variable name="prec-nature">
66 <xsl:choose>
67 <xsl:when
68 test="$prec-string='' or
[619b313]69 (preceding::screen[not(@role='nodump') and
70 ./userinput] |
71 preceding::command[contains(text(),'check') or
72 contains(text(),'test')]
[c048987]73 )[last()][self::command]">
74 <xsl:text>none</xsl:text>
75 </xsl:when>
[619b313]76 <xsl:when test="$prec-screen[not(@role)]">
[c048987]77 <xsl:text>non-root</xsl:text>
78 </xsl:when>
79 <xsl:when test="contains($prec-string,'useradd') or
80 contains($prec-string,'groupadd') or
81 contains($prec-string,'usermod') or
82 contains($prec-string,'icon-cache') or
83 contains($prec-string,'desktop-database') or
84 contains($prec-string,'compile-schemas') or
85 contains($prec-string,'query-loaders') or
86 contains($prec-string,'pam.d') or
87 contains($prec-string,'query-immodules')">
88 <xsl:text>config</xsl:text>
89 </xsl:when>
90 <xsl:otherwise>
91 <xsl:text>install</xsl:text>
92 </xsl:otherwise>
93 </xsl:choose>
94 </xsl:variable>
95
[619b313]96 <xsl:variable
97 name="follow-screen"
98 select="following::screen[not(@role='nodump') and ./userinput][1]
99 [ancestor::sect2 = current()/ancestor::sect2]"/>
100
[c048987]101 <xsl:variable
102 name="follow-string"
[619b313]103 select="string($follow-screen)"/>
[c048987]104
105 <xsl:variable name="follow-nature">
106 <xsl:choose>
107 <xsl:when
108 test="$follow-string='' or
[619b313]109 (following::screen[not(@role='nodump') and
110 ./userinput] |
111 following::command[contains(text(),'check') or
112 contains(text(),'test')]
[c048987]113 )[1][self::command]">
114 <xsl:text>none</xsl:text>
115 </xsl:when>
[619b313]116 <xsl:when test="$follow-screen[not(@role)]">
[c048987]117 <xsl:text>non-root</xsl:text>
118 </xsl:when>
119 <xsl:when test="contains($follow-string,'useradd') or
120 contains($follow-string,'groupadd') or
121 contains($follow-string,'usermod') or
122 contains($follow-string,'icon-cache') or
123 contains($follow-string,'desktop-database') or
124 contains($follow-string,'compile-schemas') or
125 contains($follow-string,'query-loaders') or
126 contains($follow-string,'pam.d') or
127 contains($follow-string,'query-immodules')">
128 <xsl:text>config</xsl:text>
129 </xsl:when>
130 <xsl:otherwise>
131 <xsl:text>install</xsl:text>
132 </xsl:otherwise>
133 </xsl:choose>
134 </xsl:variable>
135
136 <xsl:choose>
137 <xsl:when test="$my-nature='non-root'">
138 <xsl:if test="$prec-nature='install'">
139 <xsl:call-template name="end-install"/>
140 <xsl:call-template name="end-root"/>
141 </xsl:if>
142 <xsl:if test="$prec-nature='config'">
143 <xsl:call-template name="end-root"/>
144 </xsl:if>
145 <xsl:apply-templates/>
146 </xsl:when>
147
148 <xsl:when test="$my-nature='config'">
149 <xsl:if test="$prec-nature='none' or $prec-nature='non-root'">
150 <xsl:call-template name="begin-root"/>
151 </xsl:if>
152 <xsl:if test="$prec-nature='install'">
153 <xsl:call-template name="end-install"/>
154 </xsl:if>
155 <xsl:apply-templates mode="root"/>
156 <xsl:if test="$follow-nature='none'">
157 <xsl:call-template name="end-root"/>
158 </xsl:if>
159 </xsl:when>
160
161 <xsl:when test="$my-nature='install'">
162 <xsl:if test="$prec-nature='none' or $prec-nature='non-root'">
[619b313]163 <xsl:if test="$want-stats">
[c048987]164 <xsl:call-template name="output-destdir"/>
165 </xsl:if>
166 <xsl:call-template name="begin-root"/>
167 <xsl:call-template name="begin-install"/>
168 </xsl:if>
169 <xsl:if test="$prec-nature='config'">
[619b313]170 <xsl:if test="$want-stats">
[c048987]171 <xsl:call-template name="end-root"/>
172 <xsl:call-template name="output-destdir"/>
173 <xsl:call-template name="begin-root"/>
174 </xsl:if>
175 <xsl:call-template name="begin-install"/>
176 </xsl:if>
177 <xsl:apply-templates mode="install"/>
178 <xsl:if test="$follow-nature='none'">
179 <xsl:call-template name="end-install"/>
180 <xsl:call-template name="end-root"/>
181 </xsl:if>
182 </xsl:when>
183
184 </xsl:choose>
185 </xsl:template>
186
187 <xsl:template name="begin-root">
188 <xsl:if test="$sudo='y'">
[619b313]189 <xsl:text>
190sudo -E sh &lt;&lt; ROOT_EOF</xsl:text>
[c048987]191 </xsl:if>
192 </xsl:template>
193
194 <xsl:template name="begin-install">
195 <xsl:if test="$wrap-install = 'y'">
[619b313]196 <xsl:text>
197if [ -r "$JH_PACK_INSTALL" ]; then
[c048987]198 source $JH_PACK_INSTALL
199 export -f wrapInstall
200 export -f packInstall
201fi
[619b313]202wrapInstall '</xsl:text>
[c048987]203 </xsl:if>
204 </xsl:template>
205
206 <xsl:template name="end-root">
207 <xsl:if test="$sudo='y'">
[619b313]208 <xsl:text>
209ROOT_EOF</xsl:text>
[c048987]210 </xsl:if>
211 </xsl:template>
212
213 <xsl:template name="end-install">
214 <xsl:if test="$del-la-files = 'y'">
215 <xsl:call-template name="output-root">
216 <xsl:with-param name="out-string" select="$la-files-instr"/>
217 </xsl:call-template>
218 </xsl:if>
219 <xsl:if test="$wrap-install = 'y'">
[619b313]220 <xsl:text>'&#xA;packInstall</xsl:text>
[c048987]221 </xsl:if>
222 </xsl:template>
223
[619b313]224 <xsl:template match="userinput" mode="install">
225 <xsl:text>
226</xsl:text>
[c048987]227 <xsl:call-template name="output-install">
[619b313]228 <xsl:with-param name="out-string" select="string()"/>
[c048987]229 </xsl:call-template>
230 </xsl:template>
231
232 <xsl:template name="output-install">
233 <xsl:param name="out-string" select="''"/>
234 <xsl:choose>
[619b313]235 <xsl:when test="starts-with($out-string, 'make ') or
236 contains($out-string,' make ') or
237 contains($out-string,'&#xA;make')">
238 <xsl:call-template name="output-install">
239 <xsl:with-param
240 name="out-string"
241 select="substring-before($out-string,'make ')"/>
242 </xsl:call-template>
243 <xsl:text>make -j1 </xsl:text>
244 <xsl:call-template name="output-install">
245 <xsl:with-param
246 name="out-string"
247 select="substring-after($out-string,'make ')"/>
248 </xsl:call-template>
249 </xsl:when>
[c048987]250 <xsl:when test="contains($out-string,string($APOS))
251 and $wrap-install = 'y'">
252 <xsl:call-template name="output-root">
253 <xsl:with-param
254 name="out-string"
255 select="substring-before($out-string,string($APOS))"/>
256 </xsl:call-template>
257 <xsl:text>'\''</xsl:text>
258 <xsl:call-template name="output-install">
259 <xsl:with-param name="out-string"
260 select="substring-after($out-string,string($APOS))"/>
261 </xsl:call-template>
262 </xsl:when>
263 <xsl:otherwise>
264 <xsl:call-template name="output-root">
[aeb8539]265 <xsl:with-param name="out-string" select="$out-string"/>
[c048987]266 </xsl:call-template>
267 </xsl:otherwise>
268 </xsl:choose>
269 </xsl:template>
270
271</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.