source: LFS/lfs.xsl@ c7b535b

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

Do not add >> $TESTLOG to lines ending with "\"

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