source: LFS/lfs.xsl@ 945ccaa

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

Merge the new_features branch (manully, thanks to svn)

  • Property mode set to 100644
File size: 38.6 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>'
262packInstall
263</xsl:text>
264 </xsl:when>
265 <xsl:otherwise>
266 <xsl:if test="../@id = 'ch-system-man-pages'">
267<!-- these files are provided by the shadow package -->
268 <xsl:text>rm -fv $PKG_DEST/usr/share/man/{man3/getspnam.3,man5/passwd.5}
269</xsl:text>
270 </xsl:if>
271<!-- Attr man/man2 pages are already installed by man-pages. As of
272 March 2013, they are the same pages.
273 November 2015: now they are more accurate
274 in man-pages, and the man5 section is also in man-pages... -->
275 <xsl:if test="../@id = 'ch-system-attr'">
276 <xsl:text>rm -fv $PKG_DEST/usr/share/man/man2/*
277rm -fv $PKG_DEST/usr/share/man/man5/*
278</xsl:text>
279 </xsl:if>
280<!-- nologin is installed by util-linux. remove it from shadow -->
281 <xsl:if test="../@id = 'ch-system-shadow'">
282 <xsl:text>rm -fv $PKG_DEST/usr/share/man/man8/nologin.8
283rm -fv $PKG_DEST/sbin/nologin
284</xsl:text>
285 </xsl:if>
286 <xsl:text>rm -fv $PKG_DEST/{,usr/}lib64
287rm -fv $PKG_DEST/usr/{man,doc,info}
288for dir in $PKG_DEST/usr/share/man/man{1..8}; do
289 [[ -z $(ls $dir) ]] &amp;&amp; rmdir -v $dir
290done
291for dir in $PKG_DEST/usr/share/{doc,info,man}; do
292 [[ -z $(ls $dir) ]] &amp;&amp; rmdir -v $dir
293done
294for dir in $PKG_DEST/usr/{lib,bin,sbin,include}; do
295 [[ -z $(ls $dir) ]] &amp;&amp; rmdir -v $dir
296done
297for dir in $PKG_DEST/{boot,etc,lib,bin,sbin}; do
298 [[ -z $(ls $dir) ]] &amp;&amp; rmdir -v $dir
299done
300packInstall
301rm -rf $PKG_DEST
302</xsl:text>
303 </xsl:otherwise>
304 </xsl:choose>
305 </xsl:if>
306 <xsl:if test="$testsuite='3' and
307 ../@id='ch-tools-glibc' and
308 @role='installation'">
309 <xsl:copy-of select="//userinput[@remap='locale-test']"/>
310 <xsl:text>&#xA;</xsl:text>
311 </xsl:if>
312 <xsl:if test="../@id='ch-system-glibc' and @role='installation'">
313 <xsl:choose>
314 <xsl:when test="$full-locale='y'">
315 <xsl:copy-of select="//userinput[@remap='locale-full']"/>
316 <xsl:text>&#xA;</xsl:text>
317 </xsl:when>
318 <xsl:otherwise>
319 <xsl:copy-of select="//userinput[@remap='locale-test']"/>
320 <xsl:text>&#xA;</xsl:text>
321 <xsl:if test="not(contains(string(//userinput[@remap='locale-test']),$lang)) and $lang!='C' and $lang!='POSIX'">
322 <xsl:text>if LOCALE=`grep "</xsl:text>
323 <xsl:value-of select="$lang"/>
324 <xsl:text>/" $PKGDIR/localedata/SUPPORTED`; then
325 CHARMAP=`echo $LOCALE | sed 's,[^/]*/\([^ ]*\) [\],\1,'`
326 INPUT=`echo $LOCALE | sed 's,[/.].*,,'`
327 LOCALE=`echo $LOCALE | sed 's,/.*,,'`
328 localedef -i $INPUT -f $CHARMAP $LOCALE
329fi
330</xsl:text>
331 </xsl:if>
332 </xsl:otherwise>
333 </xsl:choose>
334 </xsl:if>
335 <xsl:apply-templates
336 select=".//screen[
337 (not(@role) or
338 @role != 'nodump') and
339 (not(@revision) or
340 @revision=$revision)
341 ]/userinput[
342 not(@remap) or
343 @remap='adjust' or
344 @remap='test' and current()/../@id='ch-tools-dejagnu' or
345 @remap='test' and current()/../@id='ch-system-systemd'
346 ]"/>
347 </xsl:template>
348
349 <xsl:template match="sect1" mode="pkgmngt">
350 <xsl:param name="dirname" select="chapter05"/>
351 <!-- The build order -->
352 <xsl:param name="order" select="062"/>
353<!-- The file names -->
354 <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
355 <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
356 <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
357 <!-- Creating dirs and files -->
358 <xsl:if test="count(descendant::screen/userinput) &gt; 0 and
359 count(descendant::screen/userinput) &gt;
360 count(descendant::screen[@role='nodump'])">
361 <exsl:document href="{$dirname}/{$order}-{position()}-{$filename}"
362 method="text">
363 <xsl:text>#!/bin/bash
364set +h
365set -e
366
367cd $PKGDIR
368</xsl:text>
369 <xsl:apply-templates
370 select=".//screen[not(@role) or
371 @role != 'nodump']/userinput[@remap != 'adjust']"
372 mode="pkgmngt"/>
373 <xsl:if test="$dirname = 'chapter06'">
374 <xsl:text>packInstall
375rm -rf "$PKG_DEST"
376</xsl:text>
377 </xsl:if>
378 <xsl:apply-templates
379 select=".//screen[not(@role) or
380 @role != 'nodump'
381 ]/userinput[not(@remap) or
382 @remap='adjust'
383 ]"
384 mode="pkgmngt"/>
385 <xsl:text>
386echo -e "\n\nTotalseconds: $SECONDS\n"
387exit
388</xsl:text>
389 </exsl:document>
390 </xsl:if>
391 </xsl:template>
392
393 <xsl:template match="userinput" mode="pkgmngt">
394 <xsl:apply-templates/>
395 <xsl:text>&#xA;</xsl:text>
396 </xsl:template>
397
398 <xsl:template match="userinput">
399 <xsl:choose>
400 <!-- Copying the kernel config file -->
401 <xsl:when test="string() = 'make mrproper'">
402 <xsl:text>make mrproper&#xA;</xsl:text>
403 <xsl:if test="ancestor::sect1[@id='ch-bootable-kernel']">
404 <xsl:text>cp -v ../kernel-config .config&#xA;</xsl:text>
405 </xsl:if>
406 </xsl:when>
407<!-- test instructions -->
408 <xsl:when test="@remap = 'test'">
409 <xsl:choose>
410 <xsl:when test="$testsuite = '0'"/>
411 <xsl:when test="$testsuite = '1' and
412 not(ancestor::sect1[@id='ch-system-gcc']) and
413 not(ancestor::sect1[@id='ch-system-glibc']) and
414 not(ancestor::sect1[@id='ch-system-gmp']) and
415 not(ancestor::sect1[@id='ch-system-mpfr']) and
416 not(ancestor::sect1[@id='ch-system-binutils'])"/>
417 <xsl:when test="$testsuite = '2' and
418 ancestor::chapter[@id='chapter-temporary-tools']"/>
419 <xsl:otherwise>
420 <xsl:choose>
421 <xsl:when test="$bomb-testsuite = 'n'">
422 <xsl:choose>
423 <!-- special case for glibc -->
424 <xsl:when test="contains(string(), 'glibc-check-log')">
425 <xsl:value-of
426 select="substring-before(string(),'2&gt;&amp;1')"/>
427 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
428 </xsl:when>
429 <!-- special case for procps-ng -->
430 <xsl:when test="contains(string(), 'pushd')">
431 <xsl:text>{ </xsl:text>
432 <xsl:apply-templates/>
433 <xsl:text>; } &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
434 </xsl:when>
435 <xsl:when test="contains(string(), 'make -k')">
436 <xsl:apply-templates/>
437 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
438 </xsl:when>
439 <xsl:when test="contains(string(), 'make')">
440 <xsl:value-of select="substring-before(string(),'make')"/>
441 <xsl:text>make -k</xsl:text>
442 <xsl:value-of select="substring-after(string(),'make')"/>
443 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
444 </xsl:when>
445 <xsl:otherwise>
446 <xsl:apply-templates/>
447 <xsl:if test="not(contains(string(), '&gt;&gt;'))">
448 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
449 </xsl:if>
450 <xsl:text>&#xA;</xsl:text>
451 </xsl:otherwise>
452 </xsl:choose>
453 </xsl:when>
454 <xsl:otherwise>
455 <!-- bomb-testsuite != 'n'-->
456 <xsl:choose>
457 <!-- special case for glibc -->
458 <xsl:when test="contains(string(), 'glibc-check-log')">
459 <xsl:value-of
460 select="substring-before(string(),'2&gt;&amp;1')"/>
461 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
462 </xsl:when>
463 <!-- special case for gmp -->
464 <xsl:when test="contains(string(), 'tee gmp-check-log')">
465 <xsl:text>(</xsl:text>
466 <xsl:apply-templates/>
467 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 &amp;&amp; exit $PIPESTATUS)&#xA;</xsl:text>
468 </xsl:when>
469 <!-- special case for procps-ng -->
470 <xsl:when test="contains(string(), 'pushd')">
471 <xsl:text>{ </xsl:text>
472 <xsl:apply-templates/>
473 <xsl:text>; } &gt;&gt; $TEST_LOG 2&gt;&amp;1&#xA;</xsl:text>
474 </xsl:when>
475 <xsl:when test="contains(string(), 'make -k')">
476 <xsl:apply-templates/>
477 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
478 </xsl:when>
479 <xsl:otherwise>
480 <xsl:apply-templates/>
481 <xsl:if test="not(contains(string(), '&gt;&gt;'))">
482 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
483 </xsl:if>
484 <xsl:text>&#xA;</xsl:text>
485 </xsl:otherwise>
486 </xsl:choose>
487 </xsl:otherwise>
488 </xsl:choose>
489 </xsl:otherwise>
490 </xsl:choose>
491 </xsl:when>
492<!-- End of test instructions -->
493 <!-- Don't stop on strip run -->
494 <xsl:when test="contains(string(),'strip ')">
495 <xsl:apply-templates/>
496 <xsl:text> || true&#xA;</xsl:text>
497 </xsl:when>
498<!-- Package management -->
499<!-- Add $PKG_DEST to installation commands -->
500 <xsl:when test="@remap='install' and
501 not(ancestor::chapter[
502 @id='chapter-temporary-tools'
503 ])">
504 <xsl:choose>
505 <xsl:when test="$pkgmngt='n'">
506 <xsl:choose>
507 <xsl:when test="contains(string(),'firmware,udev')">
508 <xsl:text>if [[ ! -d /lib/udev/devices ]] ; then&#xA;</xsl:text>
509 <xsl:apply-templates/>
510 <xsl:text>&#xA;fi&#xA;</xsl:text>
511 </xsl:when>
512 <xsl:otherwise>
513 <xsl:apply-templates/>
514 <xsl:text>&#xA;</xsl:text>
515 </xsl:otherwise>
516 </xsl:choose>
517 </xsl:when>
518 <xsl:when test="$wrap-install='y'">
519 <xsl:choose>
520 <xsl:when test="./literal">
521 <xsl:call-template name="output-wrap">
522 <xsl:with-param name="commands" select="text()[1]"/>
523 </xsl:call-template>
524 <xsl:apply-templates select="literal"/>
525 <xsl:call-template name="output-wrap">
526 <xsl:with-param name="commands" select="text()[2]"/>
527 </xsl:call-template>
528 </xsl:when>
529 <xsl:otherwise>
530 <xsl:call-template name="output-wrap">
531 <xsl:with-param name="commands" select="string()"/>
532 </xsl:call-template>
533 </xsl:otherwise>
534 </xsl:choose>
535 <xsl:text>&#xA;</xsl:text>
536 </xsl:when>
537 <xsl:otherwise><!--pkgmngt = 'y' and wrap-install='n'-->
538 <xsl:choose>
539 <xsl:when test="./literal">
540 <xsl:call-template name="outputpkgdest">
541 <xsl:with-param name="outputstring" select="text()[1]"/>
542 </xsl:call-template>
543 <xsl:apply-templates select="literal"/>
544 <xsl:call-template name="outputpkgdest">
545 <xsl:with-param name="outputstring" select="text()[2]"/>
546 </xsl:call-template>
547 </xsl:when>
548 <xsl:otherwise>
549 <xsl:call-template name="outputpkgdest">
550 <xsl:with-param name="outputstring" select="string()"/>
551 </xsl:call-template>
552 </xsl:otherwise>
553 </xsl:choose>
554 </xsl:otherwise>
555 </xsl:choose>
556 </xsl:when>
557 <!-- if package management, we should make an independant package for
558 tzdata. -->
559 <xsl:when test="contains(string(),'tzdata') and $pkgmngt='y'">
560 <xsl:text>
561OLD_PKG_DEST="$PKG_DEST"
562OLD_PKGDIR=$PKGDIR
563PKG_DEST=$(dirname $OLD_PKG_DEST)/001-tzdata
564PKGDIR=$(dirname $PKGDIR)/tzdata-</xsl:text>
565 <xsl:copy-of select="substring-before(
566 substring-after(string(),'tzdata'),
567 '.tar')"/>
568 <xsl:text>
569</xsl:text>
570 <xsl:choose>
571 <xsl:when test="$wrap-install='n'">
572 <xsl:copy-of select="substring-before(string(),'ZONEINFO=')"/>
573 <xsl:text>ZONEINFO=$PKG_DEST</xsl:text>
574 <xsl:copy-of select="substring-after(string(),'ZONEINFO=')"/>
575 <xsl:text>
576packInstall
577rm -rf $PKG_DEST
578</xsl:text>
579 </xsl:when>
580 <xsl:otherwise><!-- wrap-install='y' -->
581 <xsl:copy-of select="substring-before(string(),'ZONEINFO=')"/>
582 <xsl:text>
583wrapInstall '
584ZONEINFO=</xsl:text>
585 <xsl:copy-of select="substring-after(string(),'ZONEINFO=')"/>
586 <xsl:text>'
587packInstall
588</xsl:text>
589 </xsl:otherwise>
590 </xsl:choose>
591 <xsl:text>
592PKG_DEST=$OLD_PKG_DEST
593unset OLD_PKG_DEST
594PKGDIR=$OLD_PKGDIR
595unset OLD_PKGDIR
596</xsl:text>
597 </xsl:when><!-- addition for tzdata + package management -->
598 <!-- End addition for package management -->
599 <!-- The rest of commands -->
600 <xsl:otherwise>
601 <xsl:apply-templates/>
602 <xsl:text>&#xA;</xsl:text>
603 </xsl:otherwise>
604 </xsl:choose>
605 </xsl:template>
606
607 <xsl:template match="replaceable">
608 <xsl:choose>
609 <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
610 <xsl:value-of select="$timezone"/>
611 </xsl:when>
612 <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
613 <xsl:value-of select="$page"/>
614 </xsl:when>
615 <xsl:when test="contains(string(.),'&lt;ll&gt;_&lt;CC&gt;')">
616 <xsl:value-of select="$lang"/>
617 </xsl:when>
618 <xsl:when test="contains(string(.),'Domain')">
619 <xsl:value-of select="$domain"/>
620 </xsl:when>
621 <xsl:when test="contains(string(.),'primary')">
622 <xsl:value-of select="$nameserver1"/>
623 </xsl:when>
624 <xsl:when test="contains(string(.),'secondary')">
625 <xsl:value-of select="$nameserver2"/>
626 </xsl:when>
627 <xsl:when test="contains(string(.),'192.168.1.1')">
628 <xsl:value-of select="$ip"/>
629 </xsl:when>
630 <xsl:when test="contains(string(.),'192.168.0.2')">
631 <xsl:value-of select="$ip"/>
632 </xsl:when>
633<!-- Only adapted to LFS-20170310 and later -->
634 <xsl:when test="contains(string(.),'HOSTNAME')">
635 <xsl:value-of select="$hostname"/>
636 </xsl:when>
637 <xsl:when test="contains(string(.),'FQDN')">
638 <xsl:value-of select="$hostname"/>
639 <xsl:text>.</xsl:text>
640 <xsl:value-of select="$domain"/>
641 </xsl:when>
642 <xsl:when test="contains(string(.),'alias')"/>
643 <xsl:when test="contains(string(.),'&lt;lfs&gt;')">
644 <xsl:value-of select="$hostname"/>
645 </xsl:when>
646 <xsl:otherwise>
647 <xsl:text>**EDITME</xsl:text>
648 <xsl:apply-templates/>
649 <xsl:text>EDITME**</xsl:text>
650 </xsl:otherwise>
651 </xsl:choose>
652 </xsl:template>
653
654 <xsl:template match="literal">
655 <xsl:choose>
656 <xsl:when test="contains(string(),'ONBOOT')">
657 <xsl:call-template name="outputnet">
658 <xsl:with-param name="netstring" select="string()"/>
659 </xsl:call-template>
660 </xsl:when>
661 <xsl:when test="contains(string(),'[Match]')">
662 <xsl:call-template name="outputsysdnet">
663 <xsl:with-param name="netstring" select="string()"/>
664 </xsl:call-template>
665 </xsl:when>
666 <xsl:otherwise>
667 <xsl:apply-templates/>
668 </xsl:otherwise>
669 </xsl:choose>
670 </xsl:template>
671
672 <xsl:template name="outputnet">
673 <xsl:param name="netstring" select="''"/>
674 <!-- We suppose that book example has the following values:
675 - interface: eth0
676 - ip: 192.168.1.2
677 - gateway: 192.168.1.1
678 - prefix: 24
679 - broadcast: 192.168.1.255
680 Change below if book changes -->
681 <xsl:choose>
682 <xsl:when test="contains($netstring,'eth0')">
683 <xsl:call-template name="outputnet">
684 <xsl:with-param name="netstring"
685 select="substring-before($netstring,'eth0')"/>
686 </xsl:call-template>
687 <xsl:value-of select="$interface"/>
688 <xsl:call-template name="outputnet">
689 <xsl:with-param name="netstring"
690 select="substring-after($netstring,'eth0')"/>
691 </xsl:call-template>
692 </xsl:when>
693 <xsl:when test="contains($netstring,'192.168.1.1')">
694 <xsl:call-template name="outputnet">
695 <xsl:with-param name="netstring"
696 select="substring-before($netstring,'192.168.1.1')"/>
697 </xsl:call-template>
698 <xsl:value-of select="$gateway"/>
699 <xsl:call-template name="outputnet">
700 <xsl:with-param name="netstring"
701 select="substring-after($netstring,'192.168.1.1')"/>
702 </xsl:call-template>
703 </xsl:when>
704 <!-- must test this before the following, because 192.168.1.255 contains
705 192.168.1.2! -->
706 <xsl:when test="contains($netstring,'192.168.1.255')">
707 <xsl:call-template name="outputnet">
708 <xsl:with-param name="netstring"
709 select="substring-before($netstring,'192.168.1.255')"/>
710 </xsl:call-template>
711 <xsl:value-of select="$broadcast"/>
712 <xsl:call-template name="outputnet">
713 <xsl:with-param name="netstring"
714 select="substring-after($netstring,'192.168.1.255')"/>
715 </xsl:call-template>
716 </xsl:when>
717 <xsl:when test="contains($netstring,'192.168.1.2')">
718 <xsl:call-template name="outputnet">
719 <xsl:with-param name="netstring"
720 select="substring-before($netstring,'192.168.1.2')"/>
721 </xsl:call-template>
722 <xsl:value-of select="$ip"/>
723 <xsl:call-template name="outputnet">
724 <xsl:with-param name="netstring"
725 select="substring-after($netstring,'192.168.1.2')"/>
726 </xsl:call-template>
727 </xsl:when>
728 <xsl:when test="contains($netstring,'24')">
729 <xsl:call-template name="outputnet">
730 <xsl:with-param name="netstring"
731 select="substring-before($netstring,'24')"/>
732 </xsl:call-template>
733 <xsl:value-of select="$prefix"/>
734 <xsl:call-template name="outputnet">
735 <xsl:with-param name="netstring"
736 select="substring-after($netstring,'24')"/>
737 </xsl:call-template>
738 </xsl:when>
739 <xsl:otherwise>
740 <xsl:value-of select="$netstring"/>
741 </xsl:otherwise>
742 </xsl:choose>
743 </xsl:template>
744
745 <xsl:template name="outputsysdnet">
746 <xsl:param name="netstring" select="''"/>
747 <!-- We suppose that book example has the following values:
748 - interface: eth0
749 - ip: 192.168.0.2
750 - gateway: 192.168.0.1
751 - prefix: 24
752 - DNS: 192.168.0.1
753 - Domain: <Your Domain Name>
754 and gateway comes before DNS. Change below if book changes -->
755 <xsl:choose>
756 <xsl:when test="contains($netstring,'eth0')">
757 <xsl:call-template name="outputsysdnet">
758 <xsl:with-param name="netstring"
759 select="substring-before($netstring,'eth0')"/>
760 </xsl:call-template>
761 <xsl:value-of select="$interface"/>
762 <xsl:call-template name="outputsysdnet">
763 <xsl:with-param name="netstring"
764 select="substring-after($netstring,'eth0')"/>
765 </xsl:call-template>
766 </xsl:when>
767 <xsl:when test="contains($netstring,'192.168.0.1') and
768 contains($netstring,'Gateway')">
769 <xsl:call-template name="outputsysdnet">
770 <xsl:with-param name="netstring"
771 select="substring-before($netstring,'192.168.0.1')"/>
772 </xsl:call-template>
773 <xsl:value-of select="$gateway"/>
774 <xsl:call-template name="outputsysdnet">
775 <xsl:with-param name="netstring"
776 select="substring-after($netstring,'192.168.0.1')"/>
777 </xsl:call-template>
778 </xsl:when>
779 <xsl:when test="contains($netstring,'192.168.0.1') and
780 not(contains($netstring,'Gateway'))">
781 <xsl:call-template name="outputsysdnet">
782 <xsl:with-param name="netstring"
783 select="substring-before($netstring,'192.168.0.1')"/>
784 </xsl:call-template>
785 <xsl:value-of select="$nameserver1"/>
786 <xsl:text>
787DNS=</xsl:text>
788 <xsl:value-of select="$nameserver2"/>
789 <xsl:call-template name="outputsysdnet">
790 <xsl:with-param name="netstring"
791 select="substring-after($netstring,'192.168.0.1')"/>
792 </xsl:call-template>
793 </xsl:when>
794 <xsl:when test="contains($netstring,'192.168.0.2')">
795 <xsl:call-template name="outputsysdnet">
796 <xsl:with-param name="netstring"
797 select="substring-before($netstring,'192.168.0.2')"/>
798 </xsl:call-template>
799 <xsl:value-of select="$ip"/>
800 <xsl:call-template name="outputsysdnet">
801 <xsl:with-param name="netstring"
802 select="substring-after($netstring,'192.168.0.2')"/>
803 </xsl:call-template>
804 </xsl:when>
805 <xsl:when test="contains($netstring,'24')">
806 <xsl:call-template name="outputsysdnet">
807 <xsl:with-param name="netstring"
808 select="substring-before($netstring,'24')"/>
809 </xsl:call-template>
810 <xsl:value-of select="$prefix"/>
811 <xsl:call-template name="outputsysdnet">
812 <xsl:with-param name="netstring"
813 select="substring-after($netstring,'24')"/>
814 </xsl:call-template>
815 </xsl:when>
816 <xsl:when test="contains($netstring,'&lt;Your Domain Name&gt;')">
817 <xsl:call-template name="outputsysdnet">
818 <xsl:with-param name="netstring"
819 select="substring-before($netstring,'&lt;Your Domain Name&gt;')"/>
820 </xsl:call-template>
821 <xsl:value-of select="$domain"/>
822 <xsl:call-template name="outputsysdnet">
823 <xsl:with-param name="netstring"
824 select="substring-after($netstring,'&lt;Your Domain Name&gt;')"/>
825 </xsl:call-template>
826 </xsl:when>
827 <xsl:otherwise>
828 <xsl:value-of select="$netstring"/>
829 </xsl:otherwise>
830 </xsl:choose>
831 </xsl:template>
832
833 <xsl:template name="outputpkgdest">
834 <xsl:param name="outputstring" select="foo"/>
835 <xsl:choose>
836 <xsl:when test="contains($outputstring,'make ')">
837 <xsl:choose>
838 <xsl:when test="not(starts-with($outputstring,'make'))">
839 <xsl:call-template name="outputpkgdest">
840 <xsl:with-param name="outputstring"
841 select="substring-before($outputstring,'make')"/>
842 </xsl:call-template>
843 <xsl:call-template name="outputpkgdest">
844 <xsl:with-param
845 name="outputstring"
846 select="substring-after($outputstring,
847 substring-before($outputstring,'make'))"/>
848 </xsl:call-template>
849 </xsl:when>
850 <xsl:otherwise>
851 <xsl:choose>
852<!-- special cases (no DESTDIR) here -->
853 <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
854 <xsl:text>make install_root=$PKG_DEST -j1</xsl:text>
855 <xsl:value-of
856 select="substring-before(substring-after(string(),'make'),
857 'install')"/>
858 <xsl:text>install&#xA;</xsl:text>
859 </xsl:when>
860 <xsl:when test="ancestor::sect1[@id='ch-system-bzip2']">
861 <xsl:text>make PREFIX=$PKG_DEST/usr install&#xA;</xsl:text>
862 </xsl:when>
863 <xsl:when test="ancestor::sect1[@id='ch-system-sysklogd']">
864 <xsl:text>make BINDIR=$PKG_DEST/sbin prefix=$PKG_DEST install&#xA;</xsl:text>
865 </xsl:when>
866 <xsl:when test="ancestor::sect1[@id='ch-system-iproute2']">
867 <xsl:text>make DESTDIR=$PKG_DEST DOCDIR=</xsl:text>
868 <xsl:value-of
869 select="substring-before(substring-after(string(),'DOCDIR='),
870 'install')"/>
871 <xsl:text>install&#xA;</xsl:text>
872 </xsl:when>
873 <xsl:when test="ancestor::sect1[@id='ch-system-sysvinit']">
874 <xsl:text>make ROOT=$PKG_DEST</xsl:text>
875 <xsl:value-of
876 select="substring-before(substring-after(string(),'make'),
877 'install')"/>
878 <xsl:text>install&#xA;</xsl:text>
879 </xsl:when>
880 <xsl:when test="ancestor::sect1[@id='ch-bootable-kernel']">
881 <xsl:text>make INSTALL_MOD_PATH=$PKG_DEST</xsl:text>
882 <xsl:value-of
883 select="substring-before(substring-after(string(),'make'),
884 'install')"/>
885 <xsl:text>install&#xA;</xsl:text>
886 </xsl:when>
887 <xsl:when test="ancestor::sect1[@id='ch-system-attr']">
888 <xsl:text>DIST_ROOT=$PKG_DEST make</xsl:text>
889 <xsl:call-template name="outputpkgdest">
890 <xsl:with-param name="outputstring"
891 select="substring-after($outputstring,'make')"/>
892 </xsl:call-template>
893 </xsl:when>
894 <xsl:otherwise>
895 <xsl:text>make DESTDIR=$PKG_DEST</xsl:text>
896 <xsl:call-template name="outputpkgdest">
897 <xsl:with-param
898 name="outputstring"
899 select="substring-after($outputstring,'make')"/>
900 </xsl:call-template>
901 </xsl:otherwise>
902 </xsl:choose>
903 </xsl:otherwise>
904 </xsl:choose>
905 </xsl:when>
906 <xsl:otherwise> <!-- no make in this string -->
907 <xsl:choose>
908 <xsl:when test="contains($outputstring,'&gt;/') and
909 not(contains(substring-before($outputstring,'&gt;/'),' /'))">
910 <xsl:value-of select="substring-before($outputstring,'&gt;/')"/>
911 <xsl:text>&gt;$PKG_DEST/</xsl:text>
912 <xsl:call-template name="outputpkgdest">
913 <xsl:with-param name="outputstring" select="substring-after($outputstring,'&gt;/')"/>
914 </xsl:call-template>
915 </xsl:when>
916 <xsl:when test="contains($outputstring,' /')">
917 <xsl:value-of select="substring-before($outputstring,' /')"/>
918 <xsl:text> $PKG_DEST/</xsl:text>
919 <xsl:call-template name="outputpkgdest">
920 <xsl:with-param name="outputstring" select="substring-after($outputstring,' /')"/>
921 </xsl:call-template>
922 </xsl:when>
923 <xsl:otherwise>
924 <xsl:value-of select="$outputstring"/>
925 <xsl:text>&#xA;</xsl:text>
926 </xsl:otherwise>
927 </xsl:choose>
928 </xsl:otherwise>
929 </xsl:choose>
930 </xsl:template>
931
932 <xsl:variable name="APOS">'</xsl:variable>
933 <xsl:template name="output-wrap">
934 <xsl:param name="commands" select="''"/>
935 <xsl:choose>
936 <xsl:when test="contains($commands,string($APOS))">
937 <xsl:call-template name="output-wrap">
938 <xsl:with-param name="commands"
939 select="substring-before($commands,string($APOS))"/>
940 </xsl:call-template>
941 <xsl:text>'\''</xsl:text>
942 <xsl:call-template name="output-wrap">
943 <xsl:with-param name="commands"
944 select="substring-after($commands,string($APOS))"/>
945 </xsl:call-template>
946 </xsl:when>
947 <xsl:otherwise>
948 <xsl:value-of select="$commands"/>
949 </xsl:otherwise>
950 </xsl:choose>
951 </xsl:template>
952
953</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.