source: BLFS/xsl/process-install.xsl@ 3930460

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

BLFS/xsl/process-install: make an entity for config instruction conditions
and add a condition for /opt/rustc creation

  • Property mode set to 100644
File size: 22.9 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE stylesheet [
3<!ENTITY detect-config "contains(string($current-instr),'useradd') or
4 contains(string($current-instr),'groupadd') or
5 contains(string($current-instr),'usermod') or
6 contains(string($current-instr),'icon-cache') or
7 contains(string($current-instr),'desktop-database') or
8 contains(string($current-instr),'compile-schemas') or
9 contains(string($current-instr),'query-loaders') or
10 contains(string($current-instr),'pam.d') or
11 contains(string($current-instr),'/opt/rustc') or
12 contains(string($current-instr),'query-immodules')">
13]>
14
15<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
16 version="1.0">
17
18<!-- $Id$ -->
19
20 <xsl:template name="process-install">
21 <xsl:param name="instruction-tree"/>
22 <xsl:param name="want-stats"/>
23 <xsl:param name="root-seen"/>
24 <xsl:param name="install-seen"/>
25 <xsl:param name="test-seen"/>
26 <xsl:param name="doc-seen"/>
27
28<!-- Isolate the current instruction -->
29 <xsl:variable name="current-instr" select="$instruction-tree[1]"/>
30
31 <xsl:choose>
32<!--============================================================-->
33<!-- First, if we have an empty tree, close everything and exit -->
34 <xsl:when test="not($current-instr)">
35 <xsl:if test="$install-seen">
36 <xsl:call-template name="end-install"/>
37 </xsl:if>
38 <xsl:if test="$root-seen">
39 <xsl:call-template name="end-root"/>
40 </xsl:if>
41 <xsl:if test="$doc-seen and not($root-seen)">
42 <xsl:call-template name="end-doc">
43 <xsl:with-param name="want-stats" select="$want-stats"/>
44 </xsl:call-template>
45 </xsl:if>
46 <xsl:if test="$test-seen">
47 <xsl:call-template name="end-test">
48 <xsl:with-param name="want-stats" select="$want-stats"/>
49 </xsl:call-template>
50 </xsl:if>
51 </xsl:when><!-- end empty tree -->
52<!--============================================================-->
53 <xsl:when test="$current-instr[@role='root' and @remap='test']">
54 <xsl:if test="$install-seen">
55 <xsl:call-template name="end-install"/>
56 </xsl:if>
57 <xsl:if test="$root-seen">
58 <xsl:call-template name="end-root"/>
59 </xsl:if>
60 <xsl:if test="$doc-seen and not($root-seen)">
61 <xsl:call-template name="end-doc">
62 <xsl:with-param name="want-stats" select="$want-stats"/>
63 </xsl:call-template>
64 </xsl:if>
65 <xsl:if test="not($test-seen)">
66 <xsl:call-template name="begin-test">
67 <xsl:with-param name="want-stats" select="$want-stats"/>
68 </xsl:call-template>
69 </xsl:if>
70 <xsl:call-template name="begin-root"/>
71<!-- We first apply mode="root" templates, and save the result in a variable -->
72 <xsl:variable name="processed-instr">
73 <xsl:apply-templates select="$current-instr" mode="root"/>
74 </xsl:variable>
75<!-- We then process as a test instruction -->
76 <xsl:call-template name="process-test">
77 <xsl:with-param name="test-instr" select="$processed-instr"/>
78 <xsl:with-param name="want-stats" select="$want-stats"/>
79 </xsl:call-template>
80 <xsl:call-template name="process-install">
81 <xsl:with-param
82 name="instruction-tree"
83 select="$instruction-tree[position()>1]"/>
84 <xsl:with-param name="want-stats" select="$want-stats"/>
85 <xsl:with-param name="root-seen" select="boolean(1)"/>
86 <xsl:with-param name="install-seen" select="boolean(0)"/>
87 <xsl:with-param name="test-seen" select="boolean(1)"/>
88 <xsl:with-param name="doc-seen" select="boolean(0)"/>
89 </xsl:call-template>
90 </xsl:when><!-- end role="root" and remap="test" -->
91<!--============================================================-->
92 <xsl:when test="$current-instr[@role='root' and @remap='doc']">
93 <xsl:if test="$test-seen">
94 <xsl:call-template name="end-test">
95 <xsl:with-param name="want-stats" select="$want-stats"/>
96 </xsl:call-template>
97 </xsl:if>
98 <xsl:if test="$doc-seen and not($root-seen)">
99 <xsl:call-template name="end-doc">
100 <xsl:with-param name="want-stats" select="$want-stats"/>
101 </xsl:call-template>
102 </xsl:if>
103 <xsl:if test="not($root-seen)">
104 <xsl:call-template name="begin-root"/>
105 </xsl:if>
106 <xsl:if test="not($install-seen)">
107 <xsl:call-template name="begin-install"/>
108 </xsl:if>
109<!-- We first apply mode="install" templates, and save the result in a
110 variable -->
111 <xsl:variable name="processed-instr">
112 <xsl:apply-templates select="$current-instr" mode="install"/>
113 </xsl:variable>
114<!-- Then comment it out -->
115 <xsl:call-template name="output-comment-out">
116 <xsl:with-param name="out-string" select="$processed-instr"/>
117 </xsl:call-template>
118<!-- The above template ends with a commented line, so that if end-install
119 adds a closing single quote, it will not be seen. Add a CR to prevent
120 that -->
121 <xsl:text>
122</xsl:text>
123 <xsl:call-template name="process-install">
124 <xsl:with-param
125 name="instruction-tree"
126 select="$instruction-tree[position()>1]"/>
127 <xsl:with-param name="want-stats" select="$want-stats"/>
128 <xsl:with-param name="root-seen" select="boolean(1)"/>
129 <xsl:with-param name="install-seen" select="boolean(1)"/>
130 <xsl:with-param name="test-seen" select="boolean(0)"/>
131 <xsl:with-param name="doc-seen" select="boolean(1)"/>
132 </xsl:call-template>
133 </xsl:when><!-- end role="root" and remap="doc" -->
134<!--============================================================-->
135 <xsl:when test="$current-instr[@role='root']">
136<!-- We have two cases, depending on the content: either a config instruction,
137 that we do not record with porg (first case below), or a true install
138 instruction (otherwise below) -->
139 <xsl:choose>
140<!--____________________________________________________________ -->
141 <xsl:when test="&detect-config;">
142 <xsl:if test="$install-seen">
143 <xsl:call-template name="end-install"/>
144 </xsl:if>
145 <xsl:if test="$test-seen">
146 <xsl:call-template name="end-test">
147 <xsl:with-param name="want-stats" select="$want-stats"/>
148 </xsl:call-template>
149 </xsl:if>
150 <xsl:if test="$doc-seen and not($root-seen)">
151 <xsl:call-template name="end-doc">
152 <xsl:with-param name="want-stats" select="$want-stats"/>
153 </xsl:call-template>
154 </xsl:if>
155 <xsl:if test="not($root-seen)">
156 <xsl:call-template name="begin-root"/>
157 </xsl:if>
158 <xsl:apply-templates select="$current-instr" mode="root"/>
159 <xsl:call-template name="process-install">
160 <xsl:with-param
161 name="instruction-tree"
162 select="$instruction-tree[position()>1]"/>
163 <xsl:with-param name="want-stats" select="$want-stats"/>
164 <xsl:with-param name="root-seen" select="boolean(1)"/>
165 <xsl:with-param name="install-seen" select="boolean(0)"/>
166 <xsl:with-param name="test-seen" select="boolean(0)"/>
167 <xsl:with-param name="doc-seen" select="boolean(0)"/>
168 </xsl:call-template>
169 </xsl:when><!-- end config as root -->
170<!--____________________________________________________________ -->
171 <xsl:otherwise><!-- we have a true install instruction -->
172 <xsl:if test="$test-seen">
173 <xsl:call-template name="end-test">
174 <xsl:with-param name="want-stats" select="$want-stats"/>
175 </xsl:call-template>
176 </xsl:if>
177 <xsl:if test="$doc-seen and not($root-seen)">
178 <xsl:call-template name="end-doc">
179 <xsl:with-param name="want-stats" select="$want-stats"/>
180 </xsl:call-template>
181 </xsl:if>
182 <xsl:if test="$want-stats and not($install-seen)">
183 <xsl:if test="$root-seen">
184 <xsl:call-template name="end-root"/>
185 </xsl:if>
186 <xsl:text>
187echo Time before install: ${SECONDS} >> $INFOLOG</xsl:text>
188 <xsl:apply-templates
189 select="$instruction-tree[@role='root']/userinput"
190 mode="destdir"/>
191 <xsl:text>
192
193echo Time after install: ${SECONDS} >> $INFOLOG
194echo Size after install: $(sudo du -skx --exclude home /) >> $INFOLOG
195</xsl:text>
196 <xsl:if test="$root-seen">
197 <xsl:call-template name="begin-root"/>
198 </xsl:if>
199 </xsl:if>
200 <xsl:if test="not($root-seen)">
201 <xsl:call-template name="begin-root"/>
202 </xsl:if>
203 <xsl:if test="not($install-seen)">
204 <xsl:call-template name="begin-install"/>
205 </xsl:if>
206 <xsl:apply-templates select="$current-instr" mode="install"/>
207 <xsl:call-template name="process-install">
208 <xsl:with-param
209 name="instruction-tree"
210 select="$instruction-tree[position()>1]"/>
211 <xsl:with-param name="want-stats" select="$want-stats"/>
212 <xsl:with-param name="root-seen" select="boolean(1)"/>
213 <xsl:with-param name="install-seen" select="boolean(1)"/>
214 <xsl:with-param name="test-seen" select="boolean(0)"/>
215 <xsl:with-param name="doc-seen" select="boolean(0)"/>
216 </xsl:call-template>
217 </xsl:otherwise><!-- end true install instruction -->
218<!--____________________________________________________________ -->
219 </xsl:choose>
220 </xsl:when><!-- role="root" and no remap -->
221<!--============================================================-->
222 <xsl:when test="$current-instr[@remap='test'] or
223 $current-instr/self::command">
224 <xsl:if test="$install-seen">
225 <xsl:call-template name="end-install"/>
226 </xsl:if>
227 <xsl:if test="$root-seen">
228 <xsl:call-template name="end-root"/>
229 </xsl:if>
230 <xsl:if test="$doc-seen and not($root-seen)">
231 <xsl:call-template name="end-doc">
232 <xsl:with-param name="want-stats" select="$want-stats"/>
233 </xsl:call-template>
234 </xsl:if>
235 <xsl:if test="not($test-seen)">
236 <xsl:if test="not($doc-seen)">
237 <xsl:call-template name="end-make">
238 <xsl:with-param name="want-stats" select="$want-stats"/>
239 </xsl:call-template>
240 </xsl:if>
241 <xsl:call-template name="begin-test">
242 <xsl:with-param name="want-stats" select="$want-stats"/>
243 </xsl:call-template>
244 </xsl:if>
245<!-- We first apply normal templates, and save the result in a variable -->
246 <xsl:variable name="processed-instr">
247 <xsl:apply-templates select="$current-instr"/>
248 </xsl:variable>
249<!-- We then process as a test instruction -->
250 <xsl:call-template name="process-test">
251 <xsl:with-param name="test-instr" select="$processed-instr"/>
252 <xsl:with-param name="want-stats" select="$want-stats"/>
253 </xsl:call-template>
254 <xsl:call-template name="process-install">
255 <xsl:with-param
256 name="instruction-tree"
257 select="$instruction-tree[position()>1]"/>
258 <xsl:with-param name="want-stats" select="$want-stats"/>
259 <xsl:with-param name="root-seen" select="boolean(0)"/>
260 <xsl:with-param name="install-seen" select="boolean(0)"/>
261 <xsl:with-param name="test-seen" select="boolean(1)"/>
262 <xsl:with-param name="doc-seen" select="boolean(0)"/>
263 </xsl:call-template>
264 </xsl:when><!-- end no role, remap=test -->
265<!--============================================================-->
266 <xsl:when test="$current-instr[@remap='doc']">
267 <xsl:if test="$install-seen">
268 <xsl:call-template name="end-install"/>
269 </xsl:if>
270 <xsl:if test="$root-seen">
271 <xsl:call-template name="end-root"/>
272 </xsl:if>
273 <xsl:if test="$test-seen">
274 <xsl:call-template name="end-test">
275 <xsl:with-param name="want-stats" select="$want-stats"/>
276 </xsl:call-template>
277 </xsl:if>
278 <xsl:if test="not($doc-seen) or $root-seen">
279 <xsl:if test="not($test-seen) and not($root-seen)">
280 <xsl:call-template name="end-make">
281 <xsl:with-param name="want-stats" select="$want-stats"/>
282 </xsl:call-template>
283 </xsl:if>
284 <xsl:call-template name="begin-doc">
285 <xsl:with-param name="want-stats" select="$want-stats"/>
286 </xsl:call-template>
287 </xsl:if>
288<!-- We first apply normal templates, and save the result in a variable -->
289 <xsl:variable name="processed-instr">
290 <xsl:apply-templates select="$current-instr"/>
291 </xsl:variable>
292<!-- We then process as a doc instruction -->
293 <xsl:call-template name="process-doc">
294 <xsl:with-param name="doc-instr" select="$processed-instr"/>
295 <xsl:with-param name="want-stats" select="$want-stats"/>
296 </xsl:call-template>
297 <xsl:call-template name="process-install">
298 <xsl:with-param
299 name="instruction-tree"
300 select="$instruction-tree[position()>1]"/>
301 <xsl:with-param name="want-stats" select="$want-stats"/>
302 <xsl:with-param name="root-seen" select="boolean(0)"/>
303 <xsl:with-param name="install-seen" select="boolean(0)"/>
304 <xsl:with-param name="test-seen" select="boolean(0)"/>
305 <xsl:with-param name="doc-seen" select="boolean(1)"/>
306 </xsl:call-template>
307 </xsl:when><!-- no role, remap="doc" -->
308<!--============================================================-->
309 <xsl:otherwise><!-- no role no remap -->
310 <xsl:if test="$install-seen">
311 <xsl:call-template name="end-install"/>
312 </xsl:if>
313 <xsl:if test="$root-seen">
314 <xsl:call-template name="end-root"/>
315 </xsl:if>
316 <xsl:if test="$doc-seen and not($root-seen)">
317 <xsl:call-template name="end-doc">
318 <xsl:with-param name="want-stats" select="$want-stats"/>
319 </xsl:call-template>
320 </xsl:if>
321 <xsl:if test="$test-seen">
322 <xsl:call-template name="end-test">
323 <xsl:with-param name="want-stats" select="$want-stats"/>
324 </xsl:call-template>
325 </xsl:if>
326 <xsl:apply-templates select="$current-instr"/>
327 <xsl:call-template name="process-install">
328 <xsl:with-param
329 name="instruction-tree"
330 select="$instruction-tree[position()>1]"/>
331 <xsl:with-param name="want-stats" select="$want-stats"/>
332 <xsl:with-param name="root-seen" select="boolean(0)"/>
333 <xsl:with-param name="install-seen" select="boolean(0)"/>
334 <xsl:with-param name="test-seen" select="boolean(0)"/>
335 <xsl:with-param name="doc-seen" select="boolean(0)"/>
336 </xsl:call-template>
337 </xsl:otherwise><!-- no role, no remap -->
338<!--============================================================-->
339 </xsl:choose>
340 </xsl:template>
341
342 <xsl:template match="userinput" mode="install">
343 <xsl:text>
344</xsl:text>
345 <xsl:call-template name="output-install">
346 <xsl:with-param name="out-string" select="string()"/>
347 </xsl:call-template>
348 </xsl:template>
349
350<!-- userinput templates for mode="root" and normal are in scripts.xsl -->
351
352 <xsl:template name="process-test">
353 <xsl:param name="test-instr"/>
354 <xsl:param name="want-stats"/>
355 <xsl:choose>
356 <!-- the string may begin with a linefeed -->
357 <xsl:when test="substring($test-instr,1,1)='&#xA;'">
358 <xsl:text>
359</xsl:text>
360 <xsl:call-template name="process-test">
361 <xsl:with-param name="test-instr"
362 select="substring-after($test-instr,'&#xA;')"/>
363 <xsl:with-param name="want-stats" select="$want-stats"/>
364 </xsl:call-template>
365 </xsl:when>
366 <xsl:when test="contains($test-instr,'&#xA;')">
367 <xsl:call-template name="process-test">
368 <xsl:with-param name="test-instr"
369 select="substring-before($test-instr,'&#xA;')"/>
370 <xsl:with-param name="want-stats" select="$want-stats"/>
371 </xsl:call-template>
372 <xsl:text>
373</xsl:text>
374 <xsl:call-template name="process-test">
375 <xsl:with-param name="test-instr"
376 select="substring-after($test-instr,'&#xA;')"/>
377 <xsl:with-param name="want-stats" select="$want-stats"/>
378 </xsl:call-template>
379 </xsl:when>
380 <xsl:otherwise>
381 <xsl:if test="not($want-stats)">
382 <xsl:text>#</xsl:text>
383 </xsl:if>
384 <xsl:choose>
385 <xsl:when test="contains($test-instr,'make')
386 and not(contains($test-instr,'make -k'))">
387 <xsl:copy-of select="substring-before($test-instr,'make')"/>
388 <xsl:text>make -k</xsl:text>
389 <xsl:copy-of select="substring-after($test-instr,'make')"/>
390 </xsl:when>
391 <xsl:otherwise>
392 <xsl:copy-of select="$test-instr"/>
393 </xsl:otherwise>
394 </xsl:choose>
395 <xsl:if test="substring($test-instr,
396 string-length($test-instr),
397 1)!='\'">
398 <xsl:if test="$want-stats">
399 <xsl:text> &gt;&gt; $TESTLOG 2>&amp;1</xsl:text>
400 </xsl:if>
401 <xsl:text> || true</xsl:text>
402 </xsl:if>
403 </xsl:otherwise>
404 </xsl:choose>
405 </xsl:template>
406
407 <xsl:template name="process-doc">
408 <xsl:param name="doc-instr"/>
409 <xsl:param name="want-stats"/>
410 <xsl:choose>
411 <xsl:when test="$want-stats">
412 <xsl:copy-of select="$doc-instr"/>
413 </xsl:when>
414 <xsl:otherwise>
415 <xsl:call-template name="output-comment-out">
416 <xsl:with-param name="out-string" select="$doc-instr"/>
417 </xsl:call-template>
418 </xsl:otherwise>
419 </xsl:choose>
420 </xsl:template>
421
422 <xsl:template name="output-comment-out">
423<!-- Output instructions with each line commented out. -->
424 <xsl:param name="out-string"/>
425 <xsl:choose>
426 <!-- the string may begin with a linefeed -->
427 <xsl:when test="substring($out-string,1,1)='&#xA;'">
428 <xsl:text>
429</xsl:text>
430 <xsl:call-template name="output-comment-out">
431 <xsl:with-param name="out-string"
432 select="substring-after($out-string,'&#xA;')"/>
433 </xsl:call-template>
434 </xsl:when>
435 <xsl:when test="contains($out-string,'&#xA;')">
436 <xsl:text>#</xsl:text>
437 <xsl:copy-of select="substring-before($out-string,'&#xA;')"/>
438 <xsl:text>
439</xsl:text>
440 <xsl:call-template name="output-comment-out">
441 <xsl:with-param name="out-string"
442 select="substring-after($out-string,'&#xA;')"/>
443 </xsl:call-template>
444 </xsl:when>
445 <xsl:otherwise>
446 <xsl:text>#</xsl:text>
447 <xsl:copy-of select="$out-string"/>
448 </xsl:otherwise>
449 </xsl:choose>
450 </xsl:template>
451
452 <xsl:template name="end-make">
453 <xsl:param name="want-stats"/>
454 <xsl:if test="$want-stats">
455 <xsl:text>
456
457echo Time after make: ${SECONDS} >> $INFOLOG
458echo Size after make: $(sudo du -skx --exclude home /) >> $INFOLOG</xsl:text>
459 </xsl:if>
460 </xsl:template>
461
462 <xsl:template name="begin-doc">
463 <xsl:param name="want-stats"/>
464 <xsl:if test="$want-stats">
465 <xsl:text>
466echo Time before doc: ${SECONDS} >> $INFOLOG
467</xsl:text>
468 </xsl:if>
469 </xsl:template>
470
471 <xsl:template name="begin-test">
472 <xsl:param name="want-stats"/>
473 <xsl:if test="$want-stats">
474 <xsl:text>
475echo Time before test: ${SECONDS} >> $INFOLOG
476</xsl:text>
477 </xsl:if>
478 </xsl:template>
479
480 <xsl:template name="begin-root">
481 <xsl:if test="$sudo='y'">
482 <xsl:text>
483sudo -E sh &lt;&lt; ROOT_EOF</xsl:text>
484 </xsl:if>
485 </xsl:template>
486
487 <xsl:template name="begin-install">
488 <xsl:if test="$wrap-install = 'y'">
489 <xsl:text>
490if [ -r "$JH_PACK_INSTALL" ]; then
491 source $JH_PACK_INSTALL
492 export -f wrapInstall
493 export -f packInstall
494fi
495wrapInstall '</xsl:text>
496 </xsl:if>
497 </xsl:template>
498
499 <xsl:template name="end-doc">
500 <xsl:param name="want-stats"/>
501 <xsl:if test="$want-stats">
502 <xsl:text>
503
504echo Time after doc: ${SECONDS} >> $INFOLOG
505echo Size after doc: $(sudo du -skx --exclude home /) >> $INFOLOG</xsl:text>
506 </xsl:if>
507 </xsl:template>
508
509 <xsl:template name="end-test">
510 <xsl:param name="want-stats"/>
511 <xsl:if test="$want-stats">
512 <xsl:text>
513
514echo Time after test: ${SECONDS} >> $INFOLOG
515echo Size after test: $(sudo du -skx --exclude home /) >> $INFOLOG</xsl:text>
516 </xsl:if>
517 </xsl:template>
518
519 <xsl:template name="end-root">
520 <xsl:if test="$sudo='y'">
521 <xsl:text>
522ROOT_EOF</xsl:text>
523 </xsl:if>
524 </xsl:template>
525
526 <xsl:template name="end-install">
527 <xsl:if test="$del-la-files = 'y'">
528 <xsl:call-template name="output-root">
529 <xsl:with-param name="out-string" select="$la-files-instr"/>
530 </xsl:call-template>
531 </xsl:if>
532 <xsl:if test="$wrap-install = 'y'">
533 <xsl:text>'&#xA;packInstall</xsl:text>
534 </xsl:if>
535 </xsl:template>
536
537 <xsl:template name="output-install">
538 <xsl:param name="out-string" select="''"/>
539 <xsl:choose>
540 <xsl:when test="starts-with($out-string, 'make ') or
541 contains($out-string,' make ') or
542 contains($out-string,'&#xA;make')">
543 <xsl:call-template name="output-install">
544 <xsl:with-param
545 name="out-string"
546 select="substring-before($out-string,'make ')"/>
547 </xsl:call-template>
548 <xsl:text>make -j1 </xsl:text>
549 <xsl:call-template name="output-install">
550 <xsl:with-param
551 name="out-string"
552 select="substring-after($out-string,'make ')"/>
553 </xsl:call-template>
554 </xsl:when>
555 <xsl:when test="contains($out-string,string($APOS))
556 and $wrap-install = 'y'">
557 <xsl:call-template name="output-root">
558 <xsl:with-param
559 name="out-string"
560 select="substring-before($out-string,string($APOS))"/>
561 </xsl:call-template>
562 <xsl:text>'\''</xsl:text>
563 <xsl:call-template name="output-install">
564 <xsl:with-param name="out-string"
565 select="substring-after($out-string,string($APOS))"/>
566 </xsl:call-template>
567 </xsl:when>
568 <xsl:otherwise>
569 <xsl:call-template name="output-root">
570 <xsl:with-param name="out-string" select="$out-string"/>
571 </xsl:call-template>
572 </xsl:otherwise>
573 </xsl:choose>
574 </xsl:template>
575
576</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.