source: BLFS/xsl/process-install.xsl@ 974fe35

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

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