source: LFS/lfs.xsl@ 5a8939e

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

Really comment out test instructions+always define TESTLOG since the user
may "uncomment" some tests

  • Property mode set to 100644
File size: 37.9 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:call-template name="comment-test">
416 <xsl:with-param name="instructions" select="string()"/>
417 </xsl:call-template>
418 </xsl:when>
419<!-- End of test instructions -->
420 <!-- Don't stop on strip run -->
421 <xsl:when test="contains(string(),'strip ')">
422 <xsl:apply-templates/>
423 <xsl:text> || true&#xA;</xsl:text>
424 </xsl:when>
425<!-- Package management -->
426<!-- Add $PKG_DEST to installation commands -->
427 <xsl:when test="@remap='install' and
428 not(ancestor::chapter[
429 @id='chapter-temporary-tools'
430 ])">
431 <xsl:choose>
432 <xsl:when test="$pkgmngt='n'">
433 <xsl:choose>
434 <xsl:when test="contains(string(),'firmware,udev')">
435 <xsl:text>if [[ ! -d /lib/udev/devices ]] ; then&#xA;</xsl:text>
436 <xsl:apply-templates/>
437 <xsl:text>&#xA;fi&#xA;</xsl:text>
438 </xsl:when>
439 <xsl:otherwise>
440 <xsl:apply-templates/>
441 <xsl:text>&#xA;</xsl:text>
442 </xsl:otherwise>
443 </xsl:choose>
444 </xsl:when>
445 <xsl:when test="$wrap-install='y'">
446 <xsl:choose>
447 <xsl:when test="./literal">
448 <xsl:call-template name="output-wrap">
449 <xsl:with-param name="commands" select="text()[1]"/>
450 </xsl:call-template>
451 <xsl:apply-templates select="literal"/>
452 <xsl:call-template name="output-wrap">
453 <xsl:with-param name="commands" select="text()[2]"/>
454 </xsl:call-template>
455 </xsl:when>
456 <xsl:otherwise>
457 <xsl:call-template name="output-wrap">
458 <xsl:with-param name="commands" select="string()"/>
459 </xsl:call-template>
460 </xsl:otherwise>
461 </xsl:choose>
462 <xsl:text>&#xA;</xsl:text>
463 </xsl:when>
464 <xsl:otherwise><!--pkgmngt = 'y' and wrap-install='n'-->
465 <xsl:choose>
466 <xsl:when test="./literal">
467 <xsl:call-template name="outputpkgdest">
468 <xsl:with-param name="outputstring" select="text()[1]"/>
469 </xsl:call-template>
470 <xsl:apply-templates select="literal"/>
471 <xsl:call-template name="outputpkgdest">
472 <xsl:with-param name="outputstring" select="text()[2]"/>
473 </xsl:call-template>
474 </xsl:when>
475 <xsl:otherwise>
476 <xsl:call-template name="outputpkgdest">
477 <xsl:with-param name="outputstring" select="string()"/>
478 </xsl:call-template>
479 </xsl:otherwise>
480 </xsl:choose>
481 </xsl:otherwise>
482 </xsl:choose>
483 </xsl:when>
484 <!-- if package management, we should make an independant package for
485 tzdata. -->
486 <xsl:when test="contains(string(),'tzdata') and $pkgmngt='y'">
487 <xsl:text>
488OLD_PKG_DEST="$PKG_DEST"
489OLD_PKGDIR=$PKGDIR
490PKG_DEST=$(dirname $OLD_PKG_DEST)/001-tzdata
491PKGDIR=$(dirname $PKGDIR)/tzdata-</xsl:text>
492 <xsl:copy-of select="substring-before(
493 substring-after(string(),'tzdata'),
494 '.tar')"/>
495 <xsl:text>
496</xsl:text>
497 <xsl:choose>
498 <xsl:when test="$wrap-install='n'">
499 <xsl:copy-of select="substring-before(string(),'ZONEINFO=')"/>
500 <xsl:text>ZONEINFO=$PKG_DEST</xsl:text>
501 <xsl:copy-of select="substring-after(string(),'ZONEINFO=')"/>
502 <xsl:text>
503PREV_SEC=${SECONDS}
504packInstall
505SECONDS=${PREV_SEC}
506rm -rf $PKG_DEST
507</xsl:text>
508 </xsl:when>
509 <xsl:otherwise><!-- wrap-install='y' -->
510 <xsl:copy-of select="substring-before(string(),'ZONEINFO=')"/>
511 <xsl:text>
512wrapInstall '
513ZONEINFO=</xsl:text>
514 <xsl:copy-of select="substring-after(string(),'ZONEINFO=')"/>
515 <xsl:text>'
516PREV_SEC=${SECONDS}
517packInstall
518SECONDS=${PREV_SEC}
519</xsl:text>
520 </xsl:otherwise>
521 </xsl:choose>
522 <xsl:text>
523PKG_DEST=$OLD_PKG_DEST
524unset OLD_PKG_DEST
525PKGDIR=$OLD_PKGDIR
526unset OLD_PKGDIR
527</xsl:text>
528 </xsl:when><!-- addition for tzdata + package management -->
529 <!-- End addition for package management -->
530 <!-- The rest of commands -->
531 <xsl:otherwise>
532 <xsl:apply-templates/>
533 <xsl:text>&#xA;</xsl:text>
534 </xsl:otherwise>
535 </xsl:choose>
536 </xsl:template>
537
538 <xsl:template match="replaceable">
539 <xsl:choose>
540 <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
541 <xsl:value-of select="$timezone"/>
542 </xsl:when>
543 <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
544 <xsl:value-of select="$page"/>
545 </xsl:when>
546 <xsl:when test="contains(string(.),'&lt;ll&gt;_&lt;CC&gt;')">
547 <xsl:value-of select="$lang"/>
548 </xsl:when>
549 <xsl:when test="contains(string(.),'Domain')">
550 <xsl:value-of select="$domain"/>
551 </xsl:when>
552 <xsl:when test="contains(string(.),'primary')">
553 <xsl:value-of select="$nameserver1"/>
554 </xsl:when>
555 <xsl:when test="contains(string(.),'secondary')">
556 <xsl:value-of select="$nameserver2"/>
557 </xsl:when>
558 <xsl:when test="contains(string(.),'192.168.1.1')">
559 <xsl:value-of select="$ip"/>
560 </xsl:when>
561 <xsl:when test="contains(string(.),'192.168.0.2')">
562 <xsl:value-of select="$ip"/>
563 </xsl:when>
564<!-- Only adapted to LFS-20170310 and later -->
565 <xsl:when test="contains(string(.),'HOSTNAME')">
566 <xsl:value-of select="$hostname"/>
567 </xsl:when>
568 <xsl:when test="contains(string(.),'FQDN')">
569 <xsl:value-of select="$hostname"/>
570 <xsl:text>.</xsl:text>
571 <xsl:value-of select="$domain"/>
572 </xsl:when>
573 <xsl:when test="contains(string(.),'alias')"/>
574 <xsl:when test="contains(string(.),'&lt;lfs&gt;')">
575 <xsl:value-of select="$hostname"/>
576 </xsl:when>
577 <xsl:otherwise>
578 <xsl:text>**EDITME</xsl:text>
579 <xsl:apply-templates/>
580 <xsl:text>EDITME**</xsl:text>
581 </xsl:otherwise>
582 </xsl:choose>
583 </xsl:template>
584
585 <xsl:template match="literal">
586 <xsl:choose>
587 <xsl:when test="contains(string(),'ONBOOT')">
588 <xsl:call-template name="outputnet">
589 <xsl:with-param name="netstring" select="string()"/>
590 </xsl:call-template>
591 </xsl:when>
592 <xsl:when test="contains(string(),'[Match]')">
593 <xsl:call-template name="outputsysdnet">
594 <xsl:with-param name="netstring" select="string()"/>
595 </xsl:call-template>
596 </xsl:when>
597 <xsl:otherwise>
598 <xsl:apply-templates/>
599 </xsl:otherwise>
600 </xsl:choose>
601 </xsl:template>
602
603 <xsl:template name="outputnet">
604 <xsl:param name="netstring" select="''"/>
605 <!-- We suppose that book example has the following values:
606 - interface: eth0
607 - ip: 192.168.1.2
608 - gateway: 192.168.1.1
609 - prefix: 24
610 - broadcast: 192.168.1.255
611 Change below if book changes -->
612 <xsl:choose>
613 <xsl:when test="contains($netstring,'eth0')">
614 <xsl:call-template name="outputnet">
615 <xsl:with-param name="netstring"
616 select="substring-before($netstring,'eth0')"/>
617 </xsl:call-template>
618 <xsl:value-of select="$interface"/>
619 <xsl:call-template name="outputnet">
620 <xsl:with-param name="netstring"
621 select="substring-after($netstring,'eth0')"/>
622 </xsl:call-template>
623 </xsl:when>
624 <xsl:when test="contains($netstring,'192.168.1.1')">
625 <xsl:call-template name="outputnet">
626 <xsl:with-param name="netstring"
627 select="substring-before($netstring,'192.168.1.1')"/>
628 </xsl:call-template>
629 <xsl:value-of select="$gateway"/>
630 <xsl:call-template name="outputnet">
631 <xsl:with-param name="netstring"
632 select="substring-after($netstring,'192.168.1.1')"/>
633 </xsl:call-template>
634 </xsl:when>
635 <!-- must test this before the following, because 192.168.1.255 contains
636 192.168.1.2! -->
637 <xsl:when test="contains($netstring,'192.168.1.255')">
638 <xsl:call-template name="outputnet">
639 <xsl:with-param name="netstring"
640 select="substring-before($netstring,'192.168.1.255')"/>
641 </xsl:call-template>
642 <xsl:value-of select="$broadcast"/>
643 <xsl:call-template name="outputnet">
644 <xsl:with-param name="netstring"
645 select="substring-after($netstring,'192.168.1.255')"/>
646 </xsl:call-template>
647 </xsl:when>
648 <xsl:when test="contains($netstring,'192.168.1.2')">
649 <xsl:call-template name="outputnet">
650 <xsl:with-param name="netstring"
651 select="substring-before($netstring,'192.168.1.2')"/>
652 </xsl:call-template>
653 <xsl:value-of select="$ip"/>
654 <xsl:call-template name="outputnet">
655 <xsl:with-param name="netstring"
656 select="substring-after($netstring,'192.168.1.2')"/>
657 </xsl:call-template>
658 </xsl:when>
659 <xsl:when test="contains($netstring,'24')">
660 <xsl:call-template name="outputnet">
661 <xsl:with-param name="netstring"
662 select="substring-before($netstring,'24')"/>
663 </xsl:call-template>
664 <xsl:value-of select="$prefix"/>
665 <xsl:call-template name="outputnet">
666 <xsl:with-param name="netstring"
667 select="substring-after($netstring,'24')"/>
668 </xsl:call-template>
669 </xsl:when>
670 <xsl:otherwise>
671 <xsl:value-of select="$netstring"/>
672 </xsl:otherwise>
673 </xsl:choose>
674 </xsl:template>
675
676 <xsl:template name="outputsysdnet">
677 <xsl:param name="netstring" select="''"/>
678 <!-- We suppose that book example has the following values:
679 - interface: eth0
680 - ip: 192.168.0.2
681 - gateway: 192.168.0.1
682 - prefix: 24
683 - DNS: 192.168.0.1
684 - Domain: <Your Domain Name>
685 and gateway comes before DNS. Change below if book changes -->
686 <xsl:choose>
687 <xsl:when test="contains($netstring,'eth0')">
688 <xsl:call-template name="outputsysdnet">
689 <xsl:with-param name="netstring"
690 select="substring-before($netstring,'eth0')"/>
691 </xsl:call-template>
692 <xsl:value-of select="$interface"/>
693 <xsl:call-template name="outputsysdnet">
694 <xsl:with-param name="netstring"
695 select="substring-after($netstring,'eth0')"/>
696 </xsl:call-template>
697 </xsl:when>
698 <xsl:when test="contains($netstring,'192.168.0.1') and
699 contains($netstring,'Gateway')">
700 <xsl:call-template name="outputsysdnet">
701 <xsl:with-param name="netstring"
702 select="substring-before($netstring,'192.168.0.1')"/>
703 </xsl:call-template>
704 <xsl:value-of select="$gateway"/>
705 <xsl:call-template name="outputsysdnet">
706 <xsl:with-param name="netstring"
707 select="substring-after($netstring,'192.168.0.1')"/>
708 </xsl:call-template>
709 </xsl:when>
710 <xsl:when test="contains($netstring,'192.168.0.1') and
711 not(contains($netstring,'Gateway'))">
712 <xsl:call-template name="outputsysdnet">
713 <xsl:with-param name="netstring"
714 select="substring-before($netstring,'192.168.0.1')"/>
715 </xsl:call-template>
716 <xsl:value-of select="$nameserver1"/>
717 <xsl:text>
718DNS=</xsl:text>
719 <xsl:value-of select="$nameserver2"/>
720 <xsl:call-template name="outputsysdnet">
721 <xsl:with-param name="netstring"
722 select="substring-after($netstring,'192.168.0.1')"/>
723 </xsl:call-template>
724 </xsl:when>
725 <xsl:when test="contains($netstring,'192.168.0.2')">
726 <xsl:call-template name="outputsysdnet">
727 <xsl:with-param name="netstring"
728 select="substring-before($netstring,'192.168.0.2')"/>
729 </xsl:call-template>
730 <xsl:value-of select="$ip"/>
731 <xsl:call-template name="outputsysdnet">
732 <xsl:with-param name="netstring"
733 select="substring-after($netstring,'192.168.0.2')"/>
734 </xsl:call-template>
735 </xsl:when>
736 <xsl:when test="contains($netstring,'24')">
737 <xsl:call-template name="outputsysdnet">
738 <xsl:with-param name="netstring"
739 select="substring-before($netstring,'24')"/>
740 </xsl:call-template>
741 <xsl:value-of select="$prefix"/>
742 <xsl:call-template name="outputsysdnet">
743 <xsl:with-param name="netstring"
744 select="substring-after($netstring,'24')"/>
745 </xsl:call-template>
746 </xsl:when>
747 <xsl:when test="contains($netstring,'&lt;Your Domain Name&gt;')">
748 <xsl:call-template name="outputsysdnet">
749 <xsl:with-param name="netstring"
750 select="substring-before($netstring,'&lt;Your Domain Name&gt;')"/>
751 </xsl:call-template>
752 <xsl:value-of select="$domain"/>
753 <xsl:call-template name="outputsysdnet">
754 <xsl:with-param name="netstring"
755 select="substring-after($netstring,'&lt;Your Domain Name&gt;')"/>
756 </xsl:call-template>
757 </xsl:when>
758 <xsl:otherwise>
759 <xsl:value-of select="$netstring"/>
760 </xsl:otherwise>
761 </xsl:choose>
762 </xsl:template>
763
764 <xsl:template name="outputpkgdest">
765 <xsl:param name="outputstring" select="foo"/>
766 <xsl:choose>
767 <xsl:when test="contains($outputstring,'make ')">
768 <xsl:choose>
769 <xsl:when test="not(starts-with($outputstring,'make'))">
770 <xsl:call-template name="outputpkgdest">
771 <xsl:with-param name="outputstring"
772 select="substring-before($outputstring,'make')"/>
773 </xsl:call-template>
774 <xsl:call-template name="outputpkgdest">
775 <xsl:with-param
776 name="outputstring"
777 select="substring-after($outputstring,
778 substring-before($outputstring,'make'))"/>
779 </xsl:call-template>
780 </xsl:when>
781 <xsl:otherwise>
782 <xsl:choose>
783<!-- special cases (no DESTDIR) here -->
784 <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
785 <xsl:text>make install_root=$PKG_DEST -j1</xsl:text>
786 <xsl:value-of
787 select="substring-before(substring-after(string(),'make'),
788 'install')"/>
789 <xsl:text>install&#xA;</xsl:text>
790 </xsl:when>
791 <xsl:when test="ancestor::sect1[@id='ch-system-bzip2']">
792 <xsl:text>make PREFIX=$PKG_DEST/usr install&#xA;</xsl:text>
793 </xsl:when>
794 <xsl:when test="ancestor::sect1[@id='ch-system-sysklogd']">
795 <xsl:text>make BINDIR=$PKG_DEST/sbin prefix=$PKG_DEST install&#xA;</xsl:text>
796 </xsl:when>
797 <xsl:when test="ancestor::sect1[@id='ch-system-iproute2']">
798 <xsl:text>make DESTDIR=$PKG_DEST DOCDIR=</xsl:text>
799 <xsl:value-of
800 select="substring-before(substring-after(string(),'DOCDIR='),
801 'install')"/>
802 <xsl:text>install&#xA;</xsl:text>
803 </xsl:when>
804 <xsl:when test="ancestor::sect1[@id='ch-system-sysvinit']">
805 <xsl:text>make ROOT=$PKG_DEST</xsl:text>
806 <xsl:value-of
807 select="substring-before(substring-after(string(),'make'),
808 'install')"/>
809 <xsl:text>install&#xA;</xsl:text>
810 </xsl:when>
811 <xsl:when test="ancestor::sect1[@id='ch-bootable-kernel']">
812 <xsl:text>make INSTALL_MOD_PATH=$PKG_DEST</xsl:text>
813 <xsl:value-of
814 select="substring-before(substring-after(string(),'make'),
815 'install')"/>
816 <xsl:text>install&#xA;</xsl:text>
817 </xsl:when>
818 <xsl:when test="ancestor::sect1[@id='ch-system-attr']">
819 <xsl:text>DIST_ROOT=$PKG_DEST make</xsl:text>
820 <xsl:call-template name="outputpkgdest">
821 <xsl:with-param name="outputstring"
822 select="substring-after($outputstring,'make')"/>
823 </xsl:call-template>
824 </xsl:when>
825 <xsl:otherwise>
826 <xsl:text>make DESTDIR=$PKG_DEST</xsl:text>
827 <xsl:call-template name="outputpkgdest">
828 <xsl:with-param
829 name="outputstring"
830 select="substring-after($outputstring,'make')"/>
831 </xsl:call-template>
832 </xsl:otherwise>
833 </xsl:choose>
834 </xsl:otherwise>
835 </xsl:choose>
836 </xsl:when>
837 <xsl:otherwise> <!-- no make in this string -->
838 <xsl:choose>
839 <xsl:when test="contains($outputstring,'&gt;/') and
840 not(contains(substring-before($outputstring,'&gt;/'),' /'))">
841 <xsl:value-of select="substring-before($outputstring,'&gt;/')"/>
842 <xsl:text>&gt;$PKG_DEST/</xsl:text>
843 <xsl:call-template name="outputpkgdest">
844 <xsl:with-param name="outputstring" select="substring-after($outputstring,'&gt;/')"/>
845 </xsl:call-template>
846 </xsl:when>
847 <xsl:when test="contains($outputstring,' /')">
848 <xsl:value-of select="substring-before($outputstring,' /')"/>
849 <xsl:text> $PKG_DEST/</xsl:text>
850 <xsl:call-template name="outputpkgdest">
851 <xsl:with-param name="outputstring" select="substring-after($outputstring,' /')"/>
852 </xsl:call-template>
853 </xsl:when>
854 <xsl:otherwise>
855 <xsl:value-of select="$outputstring"/>
856 <xsl:text>&#xA;</xsl:text>
857 </xsl:otherwise>
858 </xsl:choose>
859 </xsl:otherwise>
860 </xsl:choose>
861 </xsl:template>
862
863 <xsl:variable name="APOS">'</xsl:variable>
864 <xsl:template name="output-wrap">
865 <xsl:param name="commands" select="''"/>
866 <xsl:choose>
867 <xsl:when test="contains($commands,string($APOS))">
868 <xsl:call-template name="output-wrap">
869 <xsl:with-param name="commands"
870 select="substring-before($commands,string($APOS))"/>
871 </xsl:call-template>
872 <xsl:text>'\''</xsl:text>
873 <xsl:call-template name="output-wrap">
874 <xsl:with-param name="commands"
875 select="substring-after($commands,string($APOS))"/>
876 </xsl:call-template>
877 </xsl:when>
878 <xsl:otherwise>
879 <xsl:value-of select="$commands"/>
880 </xsl:otherwise>
881 </xsl:choose>
882 </xsl:template>
883
884 <xsl:template name="comment-test">
885 <xsl:param name="instructions" select="''"/>
886 <xsl:choose>
887 <xsl:when test="contains($instructions,'&#xA;')">
888 <xsl:call-template name="comment-test">
889 <xsl:with-param name="instructions"
890 select="substring-before($instructions,'&#xA;')"/>
891 </xsl:call-template>
892 <xsl:call-template name="comment-test">
893 <xsl:with-param name="instructions"
894 select="substring-after($instructions,'&#xA;')"/>
895 </xsl:call-template>
896 </xsl:when>
897 <xsl:otherwise>
898 <xsl:if test="$testsuite = '0' or
899 $testsuite = '1' and
900 not(ancestor::sect1[@id='ch-system-gcc']) and
901 not(ancestor::sect1[@id='ch-system-glibc']) and
902 not(ancestor::sect1[@id='ch-system-gmp']) and
903 not(ancestor::sect1[@id='ch-system-mpfr']) and
904 not(ancestor::sect1[@id='ch-system-binutils']) or
905 $testsuite = '2' and
906 ancestor::chapter[@id='chapter-temporary-tools']">
907 <xsl:text># </xsl:text>
908 </xsl:if>
909 <xsl:choose>
910 <xsl:when test="$bomb-testsuite = 'n'">
911 <xsl:choose>
912 <xsl:when test="contains(string(), 'make -k')">
913 <xsl:value-of select="$instructions"/>
914 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
915 </xsl:when>
916 <xsl:when test="contains($instructions, 'make')">
917 <xsl:value-of select="substring-before($instructions, 'make')"/>
918 <xsl:text>make -k</xsl:text>
919 <xsl:value-of select="substring-after($instructions, 'make')"/>
920 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
921 </xsl:when>
922 <xsl:otherwise>
923 <xsl:value-of select="$instructions"/>
924 <xsl:if test="not(contains($instructions, '&gt;&gt;'))">
925 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
926 </xsl:if>
927 <xsl:text>&#xA;</xsl:text>
928 </xsl:otherwise>
929 </xsl:choose>
930 </xsl:when>
931 <xsl:otherwise>
932 <!-- bomb-testsuite != 'n'-->
933 <xsl:choose>
934 <xsl:when test="contains($instructions, 'make -k')">
935 <xsl:value-of select="$instructions"/>
936 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
937 </xsl:when>
938 <xsl:otherwise>
939 <xsl:value-of select="$instructions"/>
940 <xsl:if test="not(contains($instructions, '&gt;&gt;'))">
941 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
942 </xsl:if>
943 <xsl:text>&#xA;</xsl:text>
944 </xsl:otherwise>
945 </xsl:choose>
946 </xsl:otherwise> <!-- end not bomb-test=n -->
947 </xsl:choose>
948 </xsl:otherwise>
949 </xsl:choose>
950 </xsl:template>
951
952</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.