source: LFS/lfs.xsl@ d505128

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

Allow DESTDIR to work for libelf, now that it is in LFS

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