source: LFS/lfs.xsl@ 3d48216

new_features
Last change on this file since 3d48216 was e43d0d0, checked in by Pierre Labastie <pierre@…>, 8 years ago

Test for FQDN in <replaceable> tags, instead of HOSTNAME, for the full
name of the host. Adapted only to LFS-20170310 and up.

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