source: LFS/lfs.xsl@ dd08e14

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

Package management: compute times and sizes without packing times and sizes

  • Property mode set to 100644
File size: 38.8 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2
3<!-- $Id$ -->
4
5<xsl:stylesheet
6 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
7 xmlns:exsl="http://exslt.org/common"
8 extension-element-prefixes="exsl"
9 version="1.0">
10
11<!-- Parameters -->
12
13 <!-- which revision attribute to include: can only be sysv or systemd,
14 but we leave checking to the caller-->
15 <xsl:param name="revision" select="'sysv'"/>
16
17 <!-- use package management ?
18 n = no, original behavior
19 y = yes, add PKG_DEST to scripts in install commands of chapter06-08
20 -->
21 <xsl:param name="pkgmngt" select="'n'"/>
22
23 <!-- Package management with "porg style" ?
24 n = no, same as pkgmngt description above
25 y = yes, wrap install commands of chapter06-08 into a bash function.
26 note that pkgmngt must be 'y' in this case
27 -->
28 <xsl:param name="wrap-install" select='"n"'/>
29
30 <!-- Run test suites?
31 0 = none
32 1 = only chapter06 critical testsuites
33 2 = all chapter06 testsuites
34 3 = all chapter05 and chapter06 testsuites
35 -->
36 <xsl:param name="testsuite" select="1"/>
37
38 <!-- Bomb on test suites failures?
39 n = no, I want to build the full system and review the logs
40 y = yes, bomb at the first test suite failure to can review the build dir
41 -->
42 <xsl:param name="bomb-testsuite" select="'n'"/>
43
44 <!-- Install vim-lang package? OBSOLETE should always be 'n'-->
45 <xsl:param name="vim-lang" select="'n'"/>
46
47 <!-- Time zone -->
48 <xsl:param name="timezone" select="'GMT'"/>
49
50 <!-- Page size -->
51 <xsl:param name="page" select="'letter'"/>
52
53 <!-- Locale settings -->
54 <xsl:param name="lang" select="'C'"/>
55
56 <!-- Install the whole set of locales -->
57 <xsl:param name='full-locale' select='"n"'/>
58
59 <!-- Hostname -->
60 <xsl:param name='hostname' select='"HOSTNAME"'/>
61
62 <!-- Network parameters: interface, ip, gateway, prefix, broadcast, domain
63 and nameservers -->
64 <xsl:param name='interface' select="'eth0'"/>
65 <xsl:param name='ip' select='"10.0.2.9"'/>
66 <xsl:param name='gateway' select='"10.0.2.2"'/>
67 <xsl:param name='prefix' select='24'/>
68 <xsl:param name='broadcast' select='"10.0.2.255"'/>
69 <xsl:param name='domain' select='"lfs.org"'/>
70 <xsl:param name='nameserver1' select='"10.0.2.3"'/>
71 <xsl:param name='nameserver2' select='"8.8.8.8"'/>
72
73<!-- End parameters -->
74
75 <xsl:template match="/">
76 <xsl:apply-templates select="//sect1[not(@revision) or
77 @revision=$revision]"/>
78 </xsl:template>
79
80 <xsl:template match="sect1">
81<!-- Since this xsl:if tag encloses the whole template, it would
82 be much better to transpose this condition to the select part
83 of the "calling" apply-template. But that would change the numbering,
84 so that it would be difficult to compare to previous versions. So for
85 version 2.4, let us keep this -->
86 <xsl:if test="(../@id='chapter-temporary-tools' or
87 ../@id='chapter-building-system' or
88 ../@id='chapter-bootscripts' or
89 ../@id='chapter-bootable') and
90 (sect2[not(@revision) or @revision=$revision]//..|.)/
91 screen[(not(@role) or @role != 'nodump') and
92 (not(@revision) or @revision=$revision)]/
93 userinput[not(starts-with(string(),'chroot'))]">
94<!-- The last condition is a hack to allow previous versions of the
95 book where the chroot commands did not have role="nodump".
96 It only works if the chroot command is the only one on the page -->
97 <!-- The dirs names -->
98 <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
99 <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
100 <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
101 <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
102 <!-- The file names -->
103 <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
104 <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
105 <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
106 <!-- The build order -->
107 <xsl:variable name="position" select="position()"/>
108 <xsl:variable name="order">
109 <xsl:choose>
110 <xsl:when test="string-length($position) = 1">
111 <xsl:text>00</xsl:text>
112 <xsl:value-of select="$position"/>
113 </xsl:when>
114 <xsl:when test="string-length($position) = 2">
115 <xsl:text>0</xsl:text>
116 <xsl:value-of select="$position"/>
117 </xsl:when>
118 <xsl:otherwise>
119 <xsl:value-of select="$position"/>
120 </xsl:otherwise>
121 </xsl:choose>
122 </xsl:variable>
123 <!-- Inclusion of package manager scriptlets -->
124 <xsl:if test="@id='ch-tools-stripping' and $pkgmngt='y'">
125 <xsl:apply-templates
126 select="document('packageManager.xml')//sect1[contains(@id,'ch-tools')]"
127 mode="pkgmngt">
128 <xsl:with-param name="order" select="$order"/>
129 <xsl:with-param name="dirname" select="$dirname"/>
130 </xsl:apply-templates>
131 </xsl:if>
132 <xsl:if test="@id='ch-system-strippingagain' and $pkgmngt='y'">
133 <xsl:apply-templates
134 select="document('packageManager.xml')//sect1[contains(@id,'ch-system')]"
135 mode="pkgmngt">
136 <xsl:with-param name="order" select="$order"/>
137 <xsl:with-param name="dirname" select="$dirname"/>
138 </xsl:apply-templates>
139 </xsl:if>
140 <!-- Creating dirs and files -->
141 <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
142 <xsl:choose>
143 <xsl:when test="@id='ch-system-creatingdirs' or
144 @id='ch-system-createfiles' or
145 @id='ch-system-strippingagain'">
146 <xsl:text>#!/tools/bin/bash&#xA;set +h&#xA;</xsl:text>
147 </xsl:when>
148 <xsl:otherwise>
149 <xsl:text>#!/bin/bash&#xA;set +h&#xA;</xsl:text>
150 </xsl:otherwise>
151 </xsl:choose>
152 <xsl:if test="not(@id='ch-tools-stripping') and
153 not(@id='ch-system-strippingagain')">
154 <xsl:text>set -e&#xA;</xsl:text>
155 </xsl:if>
156 <xsl:text>&#xA;</xsl:text>
157 <xsl:if test="sect2[@role='installation']">
158 <xsl:text>cd $PKGDIR&#xA;</xsl:text>
159 </xsl:if>
160 <xsl:apply-templates select="sect2[not(@revision) or
161 @revision=$revision] |
162 screen[(not(@role) or
163 @role!='nodump') and
164 (not(@revision) or
165 @revision=$revision)]/userinput"/>
166 <xsl:if test="@id='ch-system-creatingdirs' and $pkgmngt='y'">
167 <xsl:apply-templates
168 select="document('packageManager.xml')//sect1[
169 @id='ch-pkgmngt-creatingdirs'
170 ]//userinput"
171 mode="pkgmngt"/>
172 </xsl:if>
173 <xsl:if test="@id='ch-system-createfiles' and $pkgmngt='y'">
174 <xsl:apply-templates
175 select="document('packageManager.xml')//sect1[
176 @id='ch-pkgmngt-createfiles'
177 ]//userinput"
178 mode="pkgmngt"/>
179 </xsl:if>
180 <xsl:text>echo -e "\n\nTotalseconds: $SECONDS\n"&#xA;</xsl:text>
181 <xsl:text>exit&#xA;</xsl:text>
182 </exsl:document>
183 </xsl:if>
184 </xsl:template>
185
186 <xsl:template match="sect2">
187 <xsl:apply-templates
188 select=".//screen[(not(@role) or
189 @role != 'nodump') and
190 (not(@revision) or
191 @revision=$revision)]/userinput[
192 @remap = 'pre' or
193 @remap = 'configure' or
194 @remap = 'make' or
195 @remap = 'test' and
196 not(current()/../@id='ch-tools-dejagnu') and
197 not(current()/../@id='ch-system-systemd')]"/>
198 <xsl:if
199 test="ancestor::chapter[@id != 'chapter-temporary-tools'] and
200 $pkgmngt = 'y' and
201 descendant::screen[not(@role) or
202 @role != 'nodump']/userinput[
203 @remap='install']">
204 <xsl:choose>
205 <xsl:when test="$wrap-install='y'">
206 <xsl:text>wrapInstall '
207</xsl:text>
208 </xsl:when>
209 <xsl:otherwise>
210 <xsl:text>mkdir -pv $PKG_DEST/{boot,etc,lib,bin,sbin}
211mkdir -pv $PKG_DEST/usr/{lib,bin,sbin,include}
212mkdir -pv $PKG_DEST/usr/share/{doc,info,man}
213mkdir -pv $PKG_DEST/usr/share/man/man{1..8}
214ln -sv share/{man,doc,info} $PKG_DEST/usr
215case $(uname -m) in
216 x86_64) ln -sv lib $PKG_DEST/lib64 &amp;&amp; ln -sv lib $PKG_DEST/usr/lib64 ;;
217esac
218</xsl:text>
219 </xsl:otherwise>
220 </xsl:choose>
221 </xsl:if>
222 <xsl:if test="../@id = 'ch-system-glibc' and
223 @role='installation' and
224 $pkgmngt = 'y' and
225 $wrap-install = 'n'">
226 <xsl:text>mkdir -pv $PKG_DEST/usr/include/{rpc,rpcsvc}
227</xsl:text>
228 </xsl:if>
229 <xsl:apply-templates
230 select=".//screen[(not(@role) or
231 @role != 'nodump') and
232 (not(@revision) or
233 @revision=$revision)]/userinput[@remap = 'install']"/>
234 <xsl:if test="ancestor::chapter[@id != 'chapter-temporary-tools'] and
235 $pkgmngt = 'y' and
236 descendant::screen[not(@role) or
237 @role != 'nodump']/userinput[
238 @remap='install']">
239 <xsl:choose>
240 <xsl:when test="$wrap-install='y'">
241 <xsl:if test="../@id = 'ch-system-man-pages'">
242<!-- these files are provided by the shadow package -->
243 <xsl:text>rm -fv /usr/share/man/{man3/getspnam.3,man5/passwd.5}
244</xsl:text>
245 </xsl:if>
246<!-- Attr man/man2 pages are already installed by man-pages. As of
247 March 2013, they are the same pages.
248 November 2015: now they are more accurate
249 in man-pages, and the man5 section is also in man-pages... -->
250 <xsl:if test="../@id = 'ch-system-attr'">
251 <xsl:text>rm -fv /usr/share/man/man2/*
252rm -fv /usr/share/man/man5/*
253</xsl:text>
254 </xsl:if>
255<!-- nologin is installed by util-linux. remove it from shadow -->
256 <xsl:if test="../@id = 'ch-system-shadow'">
257 <xsl:text>rm -fv /usr/share/man/man8/nologin.8
258rm -fv /sbin/nologin
259</xsl:text>
260 </xsl:if>
261 <xsl:text>'
262PREV_SEC=${SECONDS}
263packInstall
264SECONDS=${PREV_SEC}
265</xsl:text>
266 </xsl:when>
267 <xsl:otherwise>
268 <xsl:if test="../@id = 'ch-system-man-pages'">
269<!-- these files are provided by the shadow package -->
270 <xsl:text>rm -fv $PKG_DEST/usr/share/man/{man3/getspnam.3,man5/passwd.5}
271</xsl:text>
272 </xsl:if>
273<!-- Attr man/man2 pages are already installed by man-pages. As of
274 March 2013, they are the same pages.
275 November 2015: now they are more accurate
276 in man-pages, and the man5 section is also in man-pages... -->
277 <xsl:if test="../@id = 'ch-system-attr'">
278 <xsl:text>rm -fv $PKG_DEST/usr/share/man/man2/*
279rm -fv $PKG_DEST/usr/share/man/man5/*
280</xsl:text>
281 </xsl:if>
282<!-- nologin is installed by util-linux. remove it from shadow -->
283 <xsl:if test="../@id = 'ch-system-shadow'">
284 <xsl:text>rm -fv $PKG_DEST/usr/share/man/man8/nologin.8
285rm -fv $PKG_DEST/sbin/nologin
286</xsl:text>
287 </xsl:if>
288 <xsl:text>rm -fv $PKG_DEST/{,usr/}lib64
289rm -fv $PKG_DEST/usr/{man,doc,info}
290for dir in $PKG_DEST/usr/share/man/man{1..8}; do
291 [[ -z $(ls $dir) ]] &amp;&amp; rmdir -v $dir
292done
293for dir in $PKG_DEST/usr/share/{doc,info,man}; do
294 [[ -z $(ls $dir) ]] &amp;&amp; rmdir -v $dir
295done
296for dir in $PKG_DEST/usr/{lib,bin,sbin,include}; do
297 [[ -z $(ls $dir) ]] &amp;&amp; rmdir -v $dir
298done
299for dir in $PKG_DEST/{boot,etc,lib,bin,sbin}; do
300 [[ -z $(ls $dir) ]] &amp;&amp; rmdir -v $dir
301done
302PREV_SEC=${SECONDS}
303packInstall
304SECONDS=${PREV_SEC}
305rm -rf $PKG_DEST
306</xsl:text>
307 </xsl:otherwise>
308 </xsl:choose>
309 </xsl:if>
310 <xsl:if test="$testsuite='3' and
311 ../@id='ch-tools-glibc' and
312 @role='installation'">
313 <xsl:copy-of select="//userinput[@remap='locale-test']"/>
314 <xsl:text>&#xA;</xsl:text>
315 </xsl:if>
316 <xsl:if test="../@id='ch-system-glibc' and @role='installation'">
317 <xsl:choose>
318 <xsl:when test="$full-locale='y'">
319 <xsl:copy-of select="//userinput[@remap='locale-full']"/>
320 <xsl:text>&#xA;</xsl:text>
321 </xsl:when>
322 <xsl:otherwise>
323 <xsl:copy-of select="//userinput[@remap='locale-test']"/>
324 <xsl:text>&#xA;</xsl:text>
325 <xsl:if test="not(contains(string(//userinput[@remap='locale-test']),$lang)) and $lang!='C' and $lang!='POSIX'">
326 <xsl:text>if LOCALE=`grep "</xsl:text>
327 <xsl:value-of select="$lang"/>
328 <xsl:text>/" $PKGDIR/localedata/SUPPORTED`; then
329 CHARMAP=`echo $LOCALE | sed 's,[^/]*/\([^ ]*\) [\],\1,'`
330 INPUT=`echo $LOCALE | sed 's,[/.].*,,'`
331 LOCALE=`echo $LOCALE | sed 's,/.*,,'`
332 localedef -i $INPUT -f $CHARMAP $LOCALE
333fi
334</xsl:text>
335 </xsl:if>
336 </xsl:otherwise>
337 </xsl:choose>
338 </xsl:if>
339 <xsl:apply-templates
340 select=".//screen[
341 (not(@role) or
342 @role != 'nodump') and
343 (not(@revision) or
344 @revision=$revision)
345 ]/userinput[
346 not(@remap) or
347 @remap='adjust' or
348 @remap='test' and current()/../@id='ch-tools-dejagnu' or
349 @remap='test' and current()/../@id='ch-system-systemd'
350 ]"/>
351 </xsl:template>
352
353 <xsl:template match="sect1" mode="pkgmngt">
354 <xsl:param name="dirname" select="chapter05"/>
355 <!-- The build order -->
356 <xsl:param name="order" select="062"/>
357<!-- The file names -->
358 <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
359 <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
360 <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
361 <!-- Creating dirs and files -->
362 <xsl:if test="count(descendant::screen/userinput) &gt; 0 and
363 count(descendant::screen/userinput) &gt;
364 count(descendant::screen[@role='nodump'])">
365 <exsl:document href="{$dirname}/{$order}-{position()}-{$filename}"
366 method="text">
367 <xsl:text>#!/bin/bash
368set +h
369set -e
370
371cd $PKGDIR
372</xsl:text>
373 <xsl:apply-templates
374 select=".//screen[not(@role) or
375 @role != 'nodump']/userinput[@remap != 'adjust']"
376 mode="pkgmngt"/>
377 <xsl:if test="$dirname = 'chapter06'">
378 <xsl:text>PREV_SEC=${SECONDS}
379packInstall
380SECONDS=${PREV_SEC}
381rm -rf "$PKG_DEST"
382</xsl:text>
383 </xsl:if>
384 <xsl:apply-templates
385 select=".//screen[not(@role) or
386 @role != 'nodump'
387 ]/userinput[not(@remap) or
388 @remap='adjust'
389 ]"
390 mode="pkgmngt"/>
391 <xsl:text>
392echo -e "\n\nTotalseconds: $SECONDS\n"
393exit
394</xsl:text>
395 </exsl:document>
396 </xsl:if>
397 </xsl:template>
398
399 <xsl:template match="userinput" mode="pkgmngt">
400 <xsl:apply-templates/>
401 <xsl:text>&#xA;</xsl:text>
402 </xsl:template>
403
404 <xsl:template match="userinput">
405 <xsl:choose>
406 <!-- Copying the kernel config file -->
407 <xsl:when test="string() = 'make mrproper'">
408 <xsl:text>make mrproper&#xA;</xsl:text>
409 <xsl:if test="ancestor::sect1[@id='ch-bootable-kernel']">
410 <xsl:text>cp -v ../kernel-config .config&#xA;</xsl:text>
411 </xsl:if>
412 </xsl:when>
413<!-- test instructions -->
414 <xsl:when test="@remap = 'test'">
415 <xsl:choose>
416 <xsl:when test="$testsuite = '0'"/>
417 <xsl:when test="$testsuite = '1' and
418 not(ancestor::sect1[@id='ch-system-gcc']) and
419 not(ancestor::sect1[@id='ch-system-glibc']) and
420 not(ancestor::sect1[@id='ch-system-gmp']) and
421 not(ancestor::sect1[@id='ch-system-mpfr']) and
422 not(ancestor::sect1[@id='ch-system-binutils'])"/>
423 <xsl:when test="$testsuite = '2' and
424 ancestor::chapter[@id='chapter-temporary-tools']"/>
425 <xsl:otherwise>
426 <xsl:choose>
427 <xsl:when test="$bomb-testsuite = 'n'">
428 <xsl:choose>
429 <!-- special case for glibc -->
430 <xsl:when test="contains(string(), 'glibc-check-log')">
431 <xsl:value-of
432 select="substring-before(string(),'2&gt;&amp;1')"/>
433 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
434 </xsl:when>
435 <!-- special case for procps-ng -->
436 <xsl:when test="contains(string(), 'pushd')">
437 <xsl:text>{ </xsl:text>
438 <xsl:apply-templates/>
439 <xsl:text>; } &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
440 </xsl:when>
441 <xsl:when test="contains(string(), 'make -k')">
442 <xsl:apply-templates/>
443 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
444 </xsl:when>
445 <xsl:when test="contains(string(), 'make')">
446 <xsl:value-of select="substring-before(string(),'make')"/>
447 <xsl:text>make -k</xsl:text>
448 <xsl:value-of select="substring-after(string(),'make')"/>
449 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
450 </xsl:when>
451 <xsl:otherwise>
452 <xsl:apply-templates/>
453 <xsl:if test="not(contains(string(), '&gt;&gt;'))">
454 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
455 </xsl:if>
456 <xsl:text>&#xA;</xsl:text>
457 </xsl:otherwise>
458 </xsl:choose>
459 </xsl:when>
460 <xsl:otherwise>
461 <!-- bomb-testsuite != 'n'-->
462 <xsl:choose>
463 <!-- special case for glibc -->
464 <xsl:when test="contains(string(), 'glibc-check-log')">
465 <xsl:value-of
466 select="substring-before(string(),'2&gt;&amp;1')"/>
467 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
468 </xsl:when>
469 <!-- special case for gmp -->
470 <xsl:when test="contains(string(), 'tee gmp-check-log')">
471 <xsl:text>(</xsl:text>
472 <xsl:apply-templates/>
473 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 &amp;&amp; exit $PIPESTATUS)&#xA;</xsl:text>
474 </xsl:when>
475 <!-- special case for procps-ng -->
476 <xsl:when test="contains(string(), 'pushd')">
477 <xsl:text>{ </xsl:text>
478 <xsl:apply-templates/>
479 <xsl:text>; } &gt;&gt; $TEST_LOG 2&gt;&amp;1&#xA;</xsl:text>
480 </xsl:when>
481 <xsl:when test="contains(string(), 'make -k')">
482 <xsl:apply-templates/>
483 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
484 </xsl:when>
485 <xsl:otherwise>
486 <xsl:apply-templates/>
487 <xsl:if test="not(contains(string(), '&gt;&gt;'))">
488 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
489 </xsl:if>
490 <xsl:text>&#xA;</xsl:text>
491 </xsl:otherwise>
492 </xsl:choose>
493 </xsl:otherwise>
494 </xsl:choose>
495 </xsl:otherwise>
496 </xsl:choose>
497 </xsl:when>
498<!-- End of test instructions -->
499 <!-- Don't stop on strip run -->
500 <xsl:when test="contains(string(),'strip ')">
501 <xsl:apply-templates/>
502 <xsl:text> || true&#xA;</xsl:text>
503 </xsl:when>
504<!-- Package management -->
505<!-- Add $PKG_DEST to installation commands -->
506 <xsl:when test="@remap='install' and
507 not(ancestor::chapter[
508 @id='chapter-temporary-tools'
509 ])">
510 <xsl:choose>
511 <xsl:when test="$pkgmngt='n'">
512 <xsl:choose>
513 <xsl:when test="contains(string(),'firmware,udev')">
514 <xsl:text>if [[ ! -d /lib/udev/devices ]] ; then&#xA;</xsl:text>
515 <xsl:apply-templates/>
516 <xsl:text>&#xA;fi&#xA;</xsl:text>
517 </xsl:when>
518 <xsl:otherwise>
519 <xsl:apply-templates/>
520 <xsl:text>&#xA;</xsl:text>
521 </xsl:otherwise>
522 </xsl:choose>
523 </xsl:when>
524 <xsl:when test="$wrap-install='y'">
525 <xsl:choose>
526 <xsl:when test="./literal">
527 <xsl:call-template name="output-wrap">
528 <xsl:with-param name="commands" select="text()[1]"/>
529 </xsl:call-template>
530 <xsl:apply-templates select="literal"/>
531 <xsl:call-template name="output-wrap">
532 <xsl:with-param name="commands" select="text()[2]"/>
533 </xsl:call-template>
534 </xsl:when>
535 <xsl:otherwise>
536 <xsl:call-template name="output-wrap">
537 <xsl:with-param name="commands" select="string()"/>
538 </xsl:call-template>
539 </xsl:otherwise>
540 </xsl:choose>
541 <xsl:text>&#xA;</xsl:text>
542 </xsl:when>
543 <xsl:otherwise><!--pkgmngt = 'y' and wrap-install='n'-->
544 <xsl:choose>
545 <xsl:when test="./literal">
546 <xsl:call-template name="outputpkgdest">
547 <xsl:with-param name="outputstring" select="text()[1]"/>
548 </xsl:call-template>
549 <xsl:apply-templates select="literal"/>
550 <xsl:call-template name="outputpkgdest">
551 <xsl:with-param name="outputstring" select="text()[2]"/>
552 </xsl:call-template>
553 </xsl:when>
554 <xsl:otherwise>
555 <xsl:call-template name="outputpkgdest">
556 <xsl:with-param name="outputstring" select="string()"/>
557 </xsl:call-template>
558 </xsl:otherwise>
559 </xsl:choose>
560 </xsl:otherwise>
561 </xsl:choose>
562 </xsl:when>
563 <!-- if package management, we should make an independant package for
564 tzdata. -->
565 <xsl:when test="contains(string(),'tzdata') and $pkgmngt='y'">
566 <xsl:text>
567OLD_PKG_DEST="$PKG_DEST"
568OLD_PKGDIR=$PKGDIR
569PKG_DEST=$(dirname $OLD_PKG_DEST)/001-tzdata
570PKGDIR=$(dirname $PKGDIR)/tzdata-</xsl:text>
571 <xsl:copy-of select="substring-before(
572 substring-after(string(),'tzdata'),
573 '.tar')"/>
574 <xsl:text>
575</xsl:text>
576 <xsl:choose>
577 <xsl:when test="$wrap-install='n'">
578 <xsl:copy-of select="substring-before(string(),'ZONEINFO=')"/>
579 <xsl:text>ZONEINFO=$PKG_DEST</xsl:text>
580 <xsl:copy-of select="substring-after(string(),'ZONEINFO=')"/>
581 <xsl:text>
582PREV_SEC=${SECONDS}
583packInstall
584SECONDS=${PREV_SEC}
585rm -rf $PKG_DEST
586</xsl:text>
587 </xsl:when>
588 <xsl:otherwise><!-- wrap-install='y' -->
589 <xsl:copy-of select="substring-before(string(),'ZONEINFO=')"/>
590 <xsl:text>
591wrapInstall '
592ZONEINFO=</xsl:text>
593 <xsl:copy-of select="substring-after(string(),'ZONEINFO=')"/>
594 <xsl:text>'
595PREV_SEC=${SECONDS}
596packInstall
597SECONDS=${PREV_SEC}
598</xsl:text>
599 </xsl:otherwise>
600 </xsl:choose>
601 <xsl:text>
602PKG_DEST=$OLD_PKG_DEST
603unset OLD_PKG_DEST
604PKGDIR=$OLD_PKGDIR
605unset OLD_PKGDIR
606</xsl:text>
607 </xsl:when><!-- addition for tzdata + package management -->
608 <!-- End addition for package management -->
609 <!-- The rest of commands -->
610 <xsl:otherwise>
611 <xsl:apply-templates/>
612 <xsl:text>&#xA;</xsl:text>
613 </xsl:otherwise>
614 </xsl:choose>
615 </xsl:template>
616
617 <xsl:template match="replaceable">
618 <xsl:choose>
619 <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
620 <xsl:value-of select="$timezone"/>
621 </xsl:when>
622 <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
623 <xsl:value-of select="$page"/>
624 </xsl:when>
625 <xsl:when test="contains(string(.),'&lt;ll&gt;_&lt;CC&gt;')">
626 <xsl:value-of select="$lang"/>
627 </xsl:when>
628 <xsl:when test="contains(string(.),'Domain')">
629 <xsl:value-of select="$domain"/>
630 </xsl:when>
631 <xsl:when test="contains(string(.),'primary')">
632 <xsl:value-of select="$nameserver1"/>
633 </xsl:when>
634 <xsl:when test="contains(string(.),'secondary')">
635 <xsl:value-of select="$nameserver2"/>
636 </xsl:when>
637 <xsl:when test="contains(string(.),'192.168.1.1')">
638 <xsl:value-of select="$ip"/>
639 </xsl:when>
640 <xsl:when test="contains(string(.),'192.168.0.2')">
641 <xsl:value-of select="$ip"/>
642 </xsl:when>
643<!-- Only adapted to LFS-20170310 and later -->
644 <xsl:when test="contains(string(.),'HOSTNAME')">
645 <xsl:value-of select="$hostname"/>
646 </xsl:when>
647 <xsl:when test="contains(string(.),'FQDN')">
648 <xsl:value-of select="$hostname"/>
649 <xsl:text>.</xsl:text>
650 <xsl:value-of select="$domain"/>
651 </xsl:when>
652 <xsl:when test="contains(string(.),'alias')"/>
653 <xsl:when test="contains(string(.),'&lt;lfs&gt;')">
654 <xsl:value-of select="$hostname"/>
655 </xsl:when>
656 <xsl:otherwise>
657 <xsl:text>**EDITME</xsl:text>
658 <xsl:apply-templates/>
659 <xsl:text>EDITME**</xsl:text>
660 </xsl:otherwise>
661 </xsl:choose>
662 </xsl:template>
663
664 <xsl:template match="literal">
665 <xsl:choose>
666 <xsl:when test="contains(string(),'ONBOOT')">
667 <xsl:call-template name="outputnet">
668 <xsl:with-param name="netstring" select="string()"/>
669 </xsl:call-template>
670 </xsl:when>
671 <xsl:when test="contains(string(),'[Match]')">
672 <xsl:call-template name="outputsysdnet">
673 <xsl:with-param name="netstring" select="string()"/>
674 </xsl:call-template>
675 </xsl:when>
676 <xsl:otherwise>
677 <xsl:apply-templates/>
678 </xsl:otherwise>
679 </xsl:choose>
680 </xsl:template>
681
682 <xsl:template name="outputnet">
683 <xsl:param name="netstring" select="''"/>
684 <!-- We suppose that book example has the following values:
685 - interface: eth0
686 - ip: 192.168.1.2
687 - gateway: 192.168.1.1
688 - prefix: 24
689 - broadcast: 192.168.1.255
690 Change below if book changes -->
691 <xsl:choose>
692 <xsl:when test="contains($netstring,'eth0')">
693 <xsl:call-template name="outputnet">
694 <xsl:with-param name="netstring"
695 select="substring-before($netstring,'eth0')"/>
696 </xsl:call-template>
697 <xsl:value-of select="$interface"/>
698 <xsl:call-template name="outputnet">
699 <xsl:with-param name="netstring"
700 select="substring-after($netstring,'eth0')"/>
701 </xsl:call-template>
702 </xsl:when>
703 <xsl:when test="contains($netstring,'192.168.1.1')">
704 <xsl:call-template name="outputnet">
705 <xsl:with-param name="netstring"
706 select="substring-before($netstring,'192.168.1.1')"/>
707 </xsl:call-template>
708 <xsl:value-of select="$gateway"/>
709 <xsl:call-template name="outputnet">
710 <xsl:with-param name="netstring"
711 select="substring-after($netstring,'192.168.1.1')"/>
712 </xsl:call-template>
713 </xsl:when>
714 <!-- must test this before the following, because 192.168.1.255 contains
715 192.168.1.2! -->
716 <xsl:when test="contains($netstring,'192.168.1.255')">
717 <xsl:call-template name="outputnet">
718 <xsl:with-param name="netstring"
719 select="substring-before($netstring,'192.168.1.255')"/>
720 </xsl:call-template>
721 <xsl:value-of select="$broadcast"/>
722 <xsl:call-template name="outputnet">
723 <xsl:with-param name="netstring"
724 select="substring-after($netstring,'192.168.1.255')"/>
725 </xsl:call-template>
726 </xsl:when>
727 <xsl:when test="contains($netstring,'192.168.1.2')">
728 <xsl:call-template name="outputnet">
729 <xsl:with-param name="netstring"
730 select="substring-before($netstring,'192.168.1.2')"/>
731 </xsl:call-template>
732 <xsl:value-of select="$ip"/>
733 <xsl:call-template name="outputnet">
734 <xsl:with-param name="netstring"
735 select="substring-after($netstring,'192.168.1.2')"/>
736 </xsl:call-template>
737 </xsl:when>
738 <xsl:when test="contains($netstring,'24')">
739 <xsl:call-template name="outputnet">
740 <xsl:with-param name="netstring"
741 select="substring-before($netstring,'24')"/>
742 </xsl:call-template>
743 <xsl:value-of select="$prefix"/>
744 <xsl:call-template name="outputnet">
745 <xsl:with-param name="netstring"
746 select="substring-after($netstring,'24')"/>
747 </xsl:call-template>
748 </xsl:when>
749 <xsl:otherwise>
750 <xsl:value-of select="$netstring"/>
751 </xsl:otherwise>
752 </xsl:choose>
753 </xsl:template>
754
755 <xsl:template name="outputsysdnet">
756 <xsl:param name="netstring" select="''"/>
757 <!-- We suppose that book example has the following values:
758 - interface: eth0
759 - ip: 192.168.0.2
760 - gateway: 192.168.0.1
761 - prefix: 24
762 - DNS: 192.168.0.1
763 - Domain: <Your Domain Name>
764 and gateway comes before DNS. Change below if book changes -->
765 <xsl:choose>
766 <xsl:when test="contains($netstring,'eth0')">
767 <xsl:call-template name="outputsysdnet">
768 <xsl:with-param name="netstring"
769 select="substring-before($netstring,'eth0')"/>
770 </xsl:call-template>
771 <xsl:value-of select="$interface"/>
772 <xsl:call-template name="outputsysdnet">
773 <xsl:with-param name="netstring"
774 select="substring-after($netstring,'eth0')"/>
775 </xsl:call-template>
776 </xsl:when>
777 <xsl:when test="contains($netstring,'192.168.0.1') and
778 contains($netstring,'Gateway')">
779 <xsl:call-template name="outputsysdnet">
780 <xsl:with-param name="netstring"
781 select="substring-before($netstring,'192.168.0.1')"/>
782 </xsl:call-template>
783 <xsl:value-of select="$gateway"/>
784 <xsl:call-template name="outputsysdnet">
785 <xsl:with-param name="netstring"
786 select="substring-after($netstring,'192.168.0.1')"/>
787 </xsl:call-template>
788 </xsl:when>
789 <xsl:when test="contains($netstring,'192.168.0.1') and
790 not(contains($netstring,'Gateway'))">
791 <xsl:call-template name="outputsysdnet">
792 <xsl:with-param name="netstring"
793 select="substring-before($netstring,'192.168.0.1')"/>
794 </xsl:call-template>
795 <xsl:value-of select="$nameserver1"/>
796 <xsl:text>
797DNS=</xsl:text>
798 <xsl:value-of select="$nameserver2"/>
799 <xsl:call-template name="outputsysdnet">
800 <xsl:with-param name="netstring"
801 select="substring-after($netstring,'192.168.0.1')"/>
802 </xsl:call-template>
803 </xsl:when>
804 <xsl:when test="contains($netstring,'192.168.0.2')">
805 <xsl:call-template name="outputsysdnet">
806 <xsl:with-param name="netstring"
807 select="substring-before($netstring,'192.168.0.2')"/>
808 </xsl:call-template>
809 <xsl:value-of select="$ip"/>
810 <xsl:call-template name="outputsysdnet">
811 <xsl:with-param name="netstring"
812 select="substring-after($netstring,'192.168.0.2')"/>
813 </xsl:call-template>
814 </xsl:when>
815 <xsl:when test="contains($netstring,'24')">
816 <xsl:call-template name="outputsysdnet">
817 <xsl:with-param name="netstring"
818 select="substring-before($netstring,'24')"/>
819 </xsl:call-template>
820 <xsl:value-of select="$prefix"/>
821 <xsl:call-template name="outputsysdnet">
822 <xsl:with-param name="netstring"
823 select="substring-after($netstring,'24')"/>
824 </xsl:call-template>
825 </xsl:when>
826 <xsl:when test="contains($netstring,'&lt;Your Domain Name&gt;')">
827 <xsl:call-template name="outputsysdnet">
828 <xsl:with-param name="netstring"
829 select="substring-before($netstring,'&lt;Your Domain Name&gt;')"/>
830 </xsl:call-template>
831 <xsl:value-of select="$domain"/>
832 <xsl:call-template name="outputsysdnet">
833 <xsl:with-param name="netstring"
834 select="substring-after($netstring,'&lt;Your Domain Name&gt;')"/>
835 </xsl:call-template>
836 </xsl:when>
837 <xsl:otherwise>
838 <xsl:value-of select="$netstring"/>
839 </xsl:otherwise>
840 </xsl:choose>
841 </xsl:template>
842
843 <xsl:template name="outputpkgdest">
844 <xsl:param name="outputstring" select="foo"/>
845 <xsl:choose>
846 <xsl:when test="contains($outputstring,'make ')">
847 <xsl:choose>
848 <xsl:when test="not(starts-with($outputstring,'make'))">
849 <xsl:call-template name="outputpkgdest">
850 <xsl:with-param name="outputstring"
851 select="substring-before($outputstring,'make')"/>
852 </xsl:call-template>
853 <xsl:call-template name="outputpkgdest">
854 <xsl:with-param
855 name="outputstring"
856 select="substring-after($outputstring,
857 substring-before($outputstring,'make'))"/>
858 </xsl:call-template>
859 </xsl:when>
860 <xsl:otherwise>
861 <xsl:choose>
862<!-- special cases (no DESTDIR) here -->
863 <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
864 <xsl:text>make install_root=$PKG_DEST -j1</xsl:text>
865 <xsl:value-of
866 select="substring-before(substring-after(string(),'make'),
867 'install')"/>
868 <xsl:text>install&#xA;</xsl:text>
869 </xsl:when>
870 <xsl:when test="ancestor::sect1[@id='ch-system-bzip2']">
871 <xsl:text>make PREFIX=$PKG_DEST/usr install&#xA;</xsl:text>
872 </xsl:when>
873 <xsl:when test="ancestor::sect1[@id='ch-system-sysklogd']">
874 <xsl:text>make BINDIR=$PKG_DEST/sbin prefix=$PKG_DEST install&#xA;</xsl:text>
875 </xsl:when>
876 <xsl:when test="ancestor::sect1[@id='ch-system-iproute2']">
877 <xsl:text>make DESTDIR=$PKG_DEST DOCDIR=</xsl:text>
878 <xsl:value-of
879 select="substring-before(substring-after(string(),'DOCDIR='),
880 'install')"/>
881 <xsl:text>install&#xA;</xsl:text>
882 </xsl:when>
883 <xsl:when test="ancestor::sect1[@id='ch-system-sysvinit']">
884 <xsl:text>make ROOT=$PKG_DEST</xsl:text>
885 <xsl:value-of
886 select="substring-before(substring-after(string(),'make'),
887 'install')"/>
888 <xsl:text>install&#xA;</xsl:text>
889 </xsl:when>
890 <xsl:when test="ancestor::sect1[@id='ch-bootable-kernel']">
891 <xsl:text>make INSTALL_MOD_PATH=$PKG_DEST</xsl:text>
892 <xsl:value-of
893 select="substring-before(substring-after(string(),'make'),
894 'install')"/>
895 <xsl:text>install&#xA;</xsl:text>
896 </xsl:when>
897 <xsl:when test="ancestor::sect1[@id='ch-system-attr']">
898 <xsl:text>DIST_ROOT=$PKG_DEST make</xsl:text>
899 <xsl:call-template name="outputpkgdest">
900 <xsl:with-param name="outputstring"
901 select="substring-after($outputstring,'make')"/>
902 </xsl:call-template>
903 </xsl:when>
904 <xsl:otherwise>
905 <xsl:text>make DESTDIR=$PKG_DEST</xsl:text>
906 <xsl:call-template name="outputpkgdest">
907 <xsl:with-param
908 name="outputstring"
909 select="substring-after($outputstring,'make')"/>
910 </xsl:call-template>
911 </xsl:otherwise>
912 </xsl:choose>
913 </xsl:otherwise>
914 </xsl:choose>
915 </xsl:when>
916 <xsl:otherwise> <!-- no make in this string -->
917 <xsl:choose>
918 <xsl:when test="contains($outputstring,'&gt;/') and
919 not(contains(substring-before($outputstring,'&gt;/'),' /'))">
920 <xsl:value-of select="substring-before($outputstring,'&gt;/')"/>
921 <xsl:text>&gt;$PKG_DEST/</xsl:text>
922 <xsl:call-template name="outputpkgdest">
923 <xsl:with-param name="outputstring" select="substring-after($outputstring,'&gt;/')"/>
924 </xsl:call-template>
925 </xsl:when>
926 <xsl:when test="contains($outputstring,' /')">
927 <xsl:value-of select="substring-before($outputstring,' /')"/>
928 <xsl:text> $PKG_DEST/</xsl:text>
929 <xsl:call-template name="outputpkgdest">
930 <xsl:with-param name="outputstring" select="substring-after($outputstring,' /')"/>
931 </xsl:call-template>
932 </xsl:when>
933 <xsl:otherwise>
934 <xsl:value-of select="$outputstring"/>
935 <xsl:text>&#xA;</xsl:text>
936 </xsl:otherwise>
937 </xsl:choose>
938 </xsl:otherwise>
939 </xsl:choose>
940 </xsl:template>
941
942 <xsl:variable name="APOS">'</xsl:variable>
943 <xsl:template name="output-wrap">
944 <xsl:param name="commands" select="''"/>
945 <xsl:choose>
946 <xsl:when test="contains($commands,string($APOS))">
947 <xsl:call-template name="output-wrap">
948 <xsl:with-param name="commands"
949 select="substring-before($commands,string($APOS))"/>
950 </xsl:call-template>
951 <xsl:text>'\''</xsl:text>
952 <xsl:call-template name="output-wrap">
953 <xsl:with-param name="commands"
954 select="substring-after($commands,string($APOS))"/>
955 </xsl:call-template>
956 </xsl:when>
957 <xsl:otherwise>
958 <xsl:value-of select="$commands"/>
959 </xsl:otherwise>
960 </xsl:choose>
961 </xsl:template>
962
963</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.