source: BLFS/xsl/process-install.xsl@ 240d928

ablfs-more legacy trunk
Last change on this file since 240d928 was 59a1e1a, checked in by Pierre Labastie <pierre.labastie@…>, 3 years ago

Add gtweak to non-install commands

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