source: BLFS/xsl/process-install.xsl@ 3da8c49

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

BLFS/xsl/Process-install: detect config instruction in QtWebEngine page

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