source: BLFS/xsl/process-install.xsl@ 426e40b

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

add the desktop-file-utils case for non install instructions in blfs tools

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