source: LFS/lfs.xsl@ ad747ed

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

Move the linefeed. Sometimes, several attempts are needed to make things
rignt, sorry

  • Property mode set to 100644
File size: 41.1 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:text>&#xA;</xsl:text>
493 </xsl:otherwise>
494 </xsl:choose>
495 </xsl:when> <!-- @remap='install' -->
496 <!-- if package management, we should make an independant package for
497 tzdata. -->
498 <xsl:when test="contains(string(),'tzdata') and $pkgmngt='y'">
499 <xsl:text>
500OLD_PKG_DEST="$PKG_DEST"
501OLD_PKGDIR=$PKGDIR
502PKG_DEST=$(dirname $OLD_PKG_DEST)/001-tzdata
503PKGDIR=$(dirname $PKGDIR)/tzdata-</xsl:text>
504 <xsl:copy-of select="substring-before(
505 substring-after(string(),'tzdata'),
506 '.tar')"/>
507 <xsl:text>
508</xsl:text>
509 <xsl:choose>
510 <xsl:when test="$wrap-install='n'">
511 <xsl:copy-of select="substring-before(string(),'ZONEINFO=')"/>
512 <xsl:text>ZONEINFO=$PKG_DEST</xsl:text>
513 <xsl:copy-of select="substring-after(string(),'ZONEINFO=')"/>
514 <xsl:text>
515PREV_SEC=${SECONDS}
516packInstall
517SECONDS=${PREV_SEC}
518rm -rf $PKG_DEST
519</xsl:text>
520 </xsl:when>
521 <xsl:otherwise><!-- wrap-install='y' -->
522 <xsl:copy-of select="substring-before(string(),'ZONEINFO=')"/>
523 <xsl:text>
524wrapInstall '
525ZONEINFO=</xsl:text>
526 <xsl:copy-of select="substring-after(string(),'ZONEINFO=')"/>
527 <xsl:text>'
528PREV_SEC=${SECONDS}
529packInstall
530SECONDS=${PREV_SEC}
531</xsl:text>
532 </xsl:otherwise>
533 </xsl:choose>
534 <xsl:text>
535PKG_DEST=$OLD_PKG_DEST
536unset OLD_PKG_DEST
537PKGDIR=$OLD_PKGDIR
538unset OLD_PKGDIR
539</xsl:text>
540 </xsl:when><!-- addition for tzdata + package management -->
541 <!-- End addition for package management -->
542 <!-- The rest of commands -->
543 <xsl:otherwise>
544 <xsl:apply-templates/>
545 <xsl:text>&#xA;</xsl:text>
546 </xsl:otherwise>
547 </xsl:choose>
548 </xsl:template>
549
550 <xsl:template match="replaceable">
551 <xsl:choose>
552 <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
553 <xsl:value-of select="$timezone"/>
554 </xsl:when>
555 <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
556 <xsl:value-of select="$page"/>
557 </xsl:when>
558 <xsl:when test="contains(string(.),'&lt;ll&gt;_&lt;CC&gt;')">
559 <xsl:value-of select="$lang"/>
560 </xsl:when>
561 <xsl:when test="contains(string(.),'Domain')">
562 <xsl:value-of select="$domain"/>
563 </xsl:when>
564 <xsl:when test="contains(string(.),'primary')">
565 <xsl:value-of select="$nameserver1"/>
566 </xsl:when>
567 <xsl:when test="contains(string(.),'secondary')">
568 <xsl:value-of select="$nameserver2"/>
569 </xsl:when>
570 <xsl:when test="contains(string(.),'192.168.1.1')">
571 <xsl:value-of select="$ip"/>
572 </xsl:when>
573 <xsl:when test="contains(string(.),'192.168.0.2')">
574 <xsl:value-of select="$ip"/>
575 </xsl:when>
576<!-- Only adapted to LFS-20170310 and later -->
577 <xsl:when test="contains(string(.),'HOSTNAME')">
578 <xsl:value-of select="$hostname"/>
579 </xsl:when>
580 <xsl:when test="contains(string(.),'FQDN')">
581 <xsl:value-of select="$hostname"/>
582 <xsl:text>.</xsl:text>
583 <xsl:value-of select="$domain"/>
584 </xsl:when>
585 <xsl:when test="contains(string(.),'alias')"/>
586 <xsl:when test="contains(string(.),'&lt;lfs&gt;')">
587 <xsl:value-of select="$hostname"/>
588 </xsl:when>
589 <xsl:otherwise>
590 <xsl:text>**EDITME</xsl:text>
591 <xsl:apply-templates/>
592 <xsl:text>EDITME**</xsl:text>
593 </xsl:otherwise>
594 </xsl:choose>
595 </xsl:template>
596
597 <xsl:template match="literal">
598 <xsl:choose>
599 <xsl:when test="contains(string(),'ONBOOT')">
600 <xsl:call-template name="outputnet">
601 <xsl:with-param name="netstring" select="string()"/>
602 </xsl:call-template>
603 </xsl:when>
604 <xsl:when test="contains(string(),'[Match]')">
605 <xsl:call-template name="outputsysdnet">
606 <xsl:with-param name="netstring" select="string()"/>
607 </xsl:call-template>
608 </xsl:when>
609 <xsl:otherwise>
610 <xsl:apply-templates/>
611 </xsl:otherwise>
612 </xsl:choose>
613 </xsl:template>
614
615 <xsl:template name="outputnet">
616 <xsl:param name="netstring" select="''"/>
617 <!-- We suppose that book example has the following values:
618 - interface: eth0
619 - ip: 192.168.1.2
620 - gateway: 192.168.1.1
621 - prefix: 24
622 - broadcast: 192.168.1.255
623 Change below if book changes -->
624 <xsl:choose>
625 <xsl:when test="contains($netstring,'eth0')">
626 <xsl:call-template name="outputnet">
627 <xsl:with-param name="netstring"
628 select="substring-before($netstring,'eth0')"/>
629 </xsl:call-template>
630 <xsl:value-of select="$interface"/>
631 <xsl:call-template name="outputnet">
632 <xsl:with-param name="netstring"
633 select="substring-after($netstring,'eth0')"/>
634 </xsl:call-template>
635 </xsl:when>
636 <xsl:when test="contains($netstring,'192.168.1.1')">
637 <xsl:call-template name="outputnet">
638 <xsl:with-param name="netstring"
639 select="substring-before($netstring,'192.168.1.1')"/>
640 </xsl:call-template>
641 <xsl:value-of select="$gateway"/>
642 <xsl:call-template name="outputnet">
643 <xsl:with-param name="netstring"
644 select="substring-after($netstring,'192.168.1.1')"/>
645 </xsl:call-template>
646 </xsl:when>
647 <!-- must test this before the following, because 192.168.1.255 contains
648 192.168.1.2! -->
649 <xsl:when test="contains($netstring,'192.168.1.255')">
650 <xsl:call-template name="outputnet">
651 <xsl:with-param name="netstring"
652 select="substring-before($netstring,'192.168.1.255')"/>
653 </xsl:call-template>
654 <xsl:value-of select="$broadcast"/>
655 <xsl:call-template name="outputnet">
656 <xsl:with-param name="netstring"
657 select="substring-after($netstring,'192.168.1.255')"/>
658 </xsl:call-template>
659 </xsl:when>
660 <xsl:when test="contains($netstring,'192.168.1.2')">
661 <xsl:call-template name="outputnet">
662 <xsl:with-param name="netstring"
663 select="substring-before($netstring,'192.168.1.2')"/>
664 </xsl:call-template>
665 <xsl:value-of select="$ip"/>
666 <xsl:call-template name="outputnet">
667 <xsl:with-param name="netstring"
668 select="substring-after($netstring,'192.168.1.2')"/>
669 </xsl:call-template>
670 </xsl:when>
671 <xsl:when test="contains($netstring,'24')">
672 <xsl:call-template name="outputnet">
673 <xsl:with-param name="netstring"
674 select="substring-before($netstring,'24')"/>
675 </xsl:call-template>
676 <xsl:value-of select="$prefix"/>
677 <xsl:call-template name="outputnet">
678 <xsl:with-param name="netstring"
679 select="substring-after($netstring,'24')"/>
680 </xsl:call-template>
681 </xsl:when>
682 <xsl:otherwise>
683 <xsl:value-of select="$netstring"/>
684 </xsl:otherwise>
685 </xsl:choose>
686 </xsl:template>
687
688 <xsl:template name="outputsysdnet">
689 <xsl:param name="netstring" select="''"/>
690 <!-- We suppose that book example has the following values:
691 - interface: eth0
692 - ip: 192.168.0.2
693 - gateway: 192.168.0.1
694 - prefix: 24
695 - DNS: 192.168.0.1
696 - Domain: <Your Domain Name>
697 and gateway comes before DNS. Change below if book changes -->
698 <xsl:choose>
699 <xsl:when test="contains($netstring,'eth0')">
700 <xsl:call-template name="outputsysdnet">
701 <xsl:with-param name="netstring"
702 select="substring-before($netstring,'eth0')"/>
703 </xsl:call-template>
704 <xsl:value-of select="$interface"/>
705 <xsl:call-template name="outputsysdnet">
706 <xsl:with-param name="netstring"
707 select="substring-after($netstring,'eth0')"/>
708 </xsl:call-template>
709 </xsl:when>
710 <xsl:when test="contains($netstring,'192.168.0.1') and
711 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="$gateway"/>
717 <xsl:call-template name="outputsysdnet">
718 <xsl:with-param name="netstring"
719 select="substring-after($netstring,'192.168.0.1')"/>
720 </xsl:call-template>
721 </xsl:when>
722 <xsl:when test="contains($netstring,'192.168.0.1') and
723 not(contains($netstring,'Gateway'))">
724 <xsl:call-template name="outputsysdnet">
725 <xsl:with-param name="netstring"
726 select="substring-before($netstring,'192.168.0.1')"/>
727 </xsl:call-template>
728 <xsl:value-of select="$nameserver1"/>
729 <xsl:text>
730DNS=</xsl:text>
731 <xsl:value-of select="$nameserver2"/>
732 <xsl:call-template name="outputsysdnet">
733 <xsl:with-param name="netstring"
734 select="substring-after($netstring,'192.168.0.1')"/>
735 </xsl:call-template>
736 </xsl:when>
737 <xsl:when test="contains($netstring,'192.168.0.2')">
738 <xsl:call-template name="outputsysdnet">
739 <xsl:with-param name="netstring"
740 select="substring-before($netstring,'192.168.0.2')"/>
741 </xsl:call-template>
742 <xsl:value-of select="$ip"/>
743 <xsl:call-template name="outputsysdnet">
744 <xsl:with-param name="netstring"
745 select="substring-after($netstring,'192.168.0.2')"/>
746 </xsl:call-template>
747 </xsl:when>
748 <xsl:when test="contains($netstring,'24')">
749 <xsl:call-template name="outputsysdnet">
750 <xsl:with-param name="netstring"
751 select="substring-before($netstring,'24')"/>
752 </xsl:call-template>
753 <xsl:value-of select="$prefix"/>
754 <xsl:call-template name="outputsysdnet">
755 <xsl:with-param name="netstring"
756 select="substring-after($netstring,'24')"/>
757 </xsl:call-template>
758 </xsl:when>
759 <xsl:when test="contains($netstring,'&lt;Your Domain Name&gt;')">
760 <xsl:call-template name="outputsysdnet">
761 <xsl:with-param name="netstring"
762 select="substring-before($netstring,'&lt;Your Domain Name&gt;')"/>
763 </xsl:call-template>
764 <xsl:value-of select="$domain"/>
765 <xsl:call-template name="outputsysdnet">
766 <xsl:with-param name="netstring"
767 select="substring-after($netstring,'&lt;Your Domain Name&gt;')"/>
768 </xsl:call-template>
769 </xsl:when>
770 <xsl:otherwise>
771 <xsl:value-of select="$netstring"/>
772 </xsl:otherwise>
773 </xsl:choose>
774 </xsl:template>
775
776 <xsl:template name="outputpkgdest">
777 <xsl:param name="outputstring" select="foo"/>
778 <xsl:choose>
779 <xsl:when test="contains($outputstring,'make ')">
780 <xsl:choose>
781 <xsl:when test="not(starts-with($outputstring,'make'))">
782 <xsl:call-template name="outputpkgdest">
783 <xsl:with-param name="outputstring"
784 select="substring-before($outputstring,'make')"/>
785 </xsl:call-template>
786 <xsl:call-template name="outputpkgdest">
787 <xsl:with-param
788 name="outputstring"
789 select="substring-after($outputstring,
790 substring-before($outputstring,'make'))"/>
791 </xsl:call-template>
792 </xsl:when>
793 <xsl:otherwise>
794 <xsl:choose>
795<!-- special cases (no DESTDIR) here -->
796 <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
797 <xsl:text>make install_root=$PKG_DEST -j1</xsl:text>
798 <xsl:value-of
799 select="substring-before(substring-after(string(),'make'),
800 'install')"/>
801 <xsl:text>install&#xA;</xsl:text>
802 </xsl:when>
803 <xsl:when test="ancestor::sect1[@id='ch-system-bzip2']">
804 <xsl:text>make PREFIX=$PKG_DEST/usr install&#xA;</xsl:text>
805 </xsl:when>
806 <xsl:when test="ancestor::sect1[@id='ch-system-sysklogd']">
807 <xsl:text>make BINDIR=$PKG_DEST/sbin prefix=$PKG_DEST install&#xA;</xsl:text>
808 </xsl:when>
809 <xsl:when test="ancestor::sect1[@id='ch-system-iproute2']">
810 <xsl:text>make DESTDIR=$PKG_DEST DOCDIR=</xsl:text>
811 <xsl:value-of
812 select="substring-before(substring-after(string(),'DOCDIR='),
813 'install')"/>
814 <xsl:text>install&#xA;</xsl:text>
815 </xsl:when>
816 <xsl:when test="ancestor::sect1[@id='ch-system-sysvinit']">
817 <xsl:text>make ROOT=$PKG_DEST</xsl:text>
818 <xsl:value-of
819 select="substring-before(substring-after(string(),'make'),
820 'install')"/>
821 <xsl:text>install&#xA;</xsl:text>
822 </xsl:when>
823 <xsl:when test="ancestor::sect1[@id='ch-bootable-kernel']">
824 <xsl:text>make INSTALL_MOD_PATH=$PKG_DEST</xsl:text>
825 <xsl:value-of
826 select="substring-before(substring-after(string(),'make'),
827 'install')"/>
828 <xsl:text>install&#xA;</xsl:text>
829 </xsl:when>
830 <xsl:when test="ancestor::sect1[@id='ch-system-attr']">
831 <xsl:text>DIST_ROOT=$PKG_DEST make</xsl:text>
832 <xsl:call-template name="outputpkgdest">
833 <xsl:with-param name="outputstring"
834 select="substring-after($outputstring,'make')"/>
835 </xsl:call-template>
836 </xsl:when>
837 <xsl:otherwise>
838 <xsl:text>make DESTDIR=$PKG_DEST</xsl:text>
839 <xsl:call-template name="outputpkgdest">
840 <xsl:with-param
841 name="outputstring"
842 select="substring-after($outputstring,'make')"/>
843 </xsl:call-template>
844 </xsl:otherwise>
845 </xsl:choose>
846 </xsl:otherwise>
847 </xsl:choose>
848 </xsl:when>
849 <xsl:when test="contains($outputstring,'ninja install')">
850 <xsl:choose>
851 <xsl:when test="not(starts-with($outputstring,'ninja install'))">
852 <xsl:call-template name="outputpkgdest">
853 <xsl:with-param name="outputstring"
854 select="substring-before($outputstring,'ninja install')"/>
855 </xsl:call-template>
856 <xsl:call-template name="outputpkgdest">
857 <xsl:with-param
858 name="outputstring"
859 select="substring-after($outputstring,
860 substring-before($outputstring,'ninja install'))"/>
861 </xsl:call-template>
862 </xsl:when>
863 <xsl:otherwise> <!-- "ninja" is the first word and is followed by
864 "install"-->
865 <xsl:text>DESTDIR=$PKG_DEST ninja</xsl:text>
866 <xsl:call-template name="outputpkgdest">
867 <xsl:with-param
868 name="outputstring"
869 select="substring-after($outputstring,'ninja')"/>
870 </xsl:call-template>
871 </xsl:otherwise>
872 </xsl:choose>
873 </xsl:when>
874 <xsl:otherwise> <!-- no make nor ninja in this string -->
875 <xsl:choose>
876 <xsl:when test="contains($outputstring,'&gt;/') and
877 not(contains(substring-before($outputstring,'&gt;/'),' /'))">
878 <xsl:value-of select="substring-before($outputstring,'&gt;/')"/>
879 <xsl:text>&gt;$PKG_DEST/</xsl:text>
880 <xsl:call-template name="outputpkgdest">
881 <xsl:with-param name="outputstring" select="substring-after($outputstring,'&gt;/')"/>
882 </xsl:call-template>
883 </xsl:when>
884 <xsl:when test="contains($outputstring,' /')">
885 <xsl:value-of select="substring-before($outputstring,' /')"/>
886 <xsl:text> $PKG_DEST/</xsl:text>
887 <xsl:call-template name="outputpkgdest">
888 <xsl:with-param name="outputstring" select="substring-after($outputstring,' /')"/>
889 </xsl:call-template>
890 </xsl:when>
891 <xsl:otherwise>
892 <xsl:value-of select="$outputstring"/>
893 </xsl:otherwise>
894 </xsl:choose>
895 </xsl:otherwise>
896 </xsl:choose>
897 </xsl:template>
898
899 <xsl:variable name="APOS">'</xsl:variable>
900 <xsl:template name="output-wrap">
901 <xsl:param name="commands" select="''"/>
902 <xsl:choose>
903 <xsl:when test="contains($commands,string($APOS))">
904 <xsl:call-template name="output-wrap">
905 <xsl:with-param name="commands"
906 select="substring-before($commands,string($APOS))"/>
907 </xsl:call-template>
908 <xsl:text>'\''</xsl:text>
909 <xsl:call-template name="output-wrap">
910 <xsl:with-param name="commands"
911 select="substring-after($commands,string($APOS))"/>
912 </xsl:call-template>
913 </xsl:when>
914 <xsl:otherwise>
915 <xsl:value-of select="$commands"/>
916 </xsl:otherwise>
917 </xsl:choose>
918 </xsl:template>
919
920 <xsl:template name="comment-strip">
921 <xsl:param name="instructions" select="''"/>
922 <xsl:choose>
923 <xsl:when test="contains($instructions,'&#xA;')">
924 <xsl:call-template name="comment-strip">
925 <xsl:with-param name="instructions"
926 select="substring-before($instructions,'&#xA;')"/>
927 </xsl:call-template>
928 <xsl:call-template name="comment-strip">
929 <xsl:with-param name="instructions"
930 select="substring-after($instructions,'&#xA;')"/>
931 </xsl:call-template>
932 </xsl:when>
933 <xsl:when test="contains($instructions,'\*.la')">
934 <xsl:if test="$del-la-files='n'">
935 <xsl:text># </xsl:text>
936 </xsl:if>
937 <xsl:value-of select="$instructions"/>
938 <xsl:text>&#xA;</xsl:text>
939 </xsl:when>
940 <xsl:when test="contains($instructions,'strip ')">
941 <xsl:if test="$strip='n'">
942 <xsl:text># </xsl:text>
943 </xsl:if>
944 <xsl:value-of select="$instructions"/>
945 <xsl:text> || true&#xA;</xsl:text>
946 </xsl:when>
947 <xsl:otherwise>
948 <xsl:value-of select="$instructions"/>
949 <xsl:text>&#xA;</xsl:text>
950 </xsl:otherwise>
951 </xsl:choose>
952 </xsl:template>
953
954 <xsl:template name="comment-test">
955 <xsl:param name="instructions" select="''"/>
956 <xsl:choose>
957 <xsl:when test="contains($instructions,'&#xA;')">
958 <xsl:call-template name="comment-test">
959 <xsl:with-param name="instructions"
960 select="substring-before($instructions,'&#xA;')"/>
961 </xsl:call-template>
962 <xsl:call-template name="comment-test">
963 <xsl:with-param name="instructions"
964 select="substring-after($instructions,'&#xA;')"/>
965 </xsl:call-template>
966 </xsl:when>
967 <xsl:otherwise>
968 <xsl:if test="$testsuite = '0' or
969 $testsuite = '1' and
970 not(ancestor::sect1[@id='ch-system-gcc']) and
971 not(ancestor::sect1[@id='ch-system-glibc']) and
972 not(ancestor::sect1[@id='ch-system-gmp']) and
973 not(ancestor::sect1[@id='ch-system-mpfr']) and
974 not(ancestor::sect1[@id='ch-system-binutils']) or
975 $testsuite = '2' and
976 ancestor::chapter[@id='chapter-temporary-tools']">
977 <xsl:text># </xsl:text>
978 </xsl:if>
979 <xsl:choose>
980 <xsl:when test="$bomb-testsuite = 'n'">
981 <xsl:choose>
982 <xsl:when test="contains(string(), '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:when test="contains($instructions, 'make')">
987 <xsl:value-of select="substring-before($instructions, 'make')"/>
988 <xsl:text>make -k</xsl:text>
989 <xsl:value-of select="substring-after($instructions, 'make')"/>
990 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
991 </xsl:when>
992 <xsl:otherwise>
993 <xsl:value-of select="$instructions"/>
994 <xsl:if
995 test="not(contains($instructions, '&gt;&gt;')) and
996 substring($instructions,
997 string-length($instructions)) != '\'">
998 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
999 </xsl:if>
1000 <xsl:text>&#xA;</xsl:text>
1001 </xsl:otherwise>
1002 </xsl:choose>
1003 </xsl:when>
1004 <xsl:otherwise>
1005 <!-- bomb-testsuite != 'n'-->
1006 <xsl:choose>
1007 <xsl:when test="contains($instructions, 'make -k')">
1008 <xsl:value-of select="$instructions"/>
1009 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
1010 </xsl:when>
1011 <xsl:otherwise>
1012 <xsl:value-of select="$instructions"/>
1013 <xsl:if test="not(contains($instructions, '&gt;&gt;')) and
1014 substring($instructions,
1015 string-length($instructions)) != '\'">
1016 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
1017 </xsl:if>
1018 <xsl:text>&#xA;</xsl:text>
1019 </xsl:otherwise>
1020 </xsl:choose>
1021 </xsl:otherwise> <!-- end not bomb-test=n -->
1022 </xsl:choose>
1023 </xsl:otherwise>
1024 </xsl:choose>
1025 </xsl:template>
1026
1027</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.