source: LFS/lfs.xsl@ d8ddcfb

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

Fix the generation of scripts of
the networkd page (systemd book).

  • Property mode set to 100644
File size: 37.4 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(.),'HOSTNAME')">
613 <xsl:value-of select="$hostname"/>
614 <xsl:text>.</xsl:text>
615 <xsl:value-of select="$domain"/>
616 </xsl:when>
617 <xsl:when test="contains(string(.),'alias')">
618 <xsl:value-of select="$hostname"/>
619 </xsl:when>
620 <xsl:when test="contains(string(.),'&lt;lfs&gt;')">
621 <xsl:value-of select="$hostname"/>
622 </xsl:when>
623 <xsl:otherwise>
624 <xsl:text>**EDITME</xsl:text>
625 <xsl:apply-templates/>
626 <xsl:text>EDITME**</xsl:text>
627 </xsl:otherwise>
628 </xsl:choose>
629 </xsl:template>
630
631 <xsl:template match="literal">
632 <xsl:choose>
633 <xsl:when test="contains(string(),'ONBOOT')">
634 <xsl:call-template name="outputnet">
635 <xsl:with-param name="netstring" select="string()"/>
636 </xsl:call-template>
637 </xsl:when>
638 <xsl:when test="contains(string(),'[Match]')">
639 <xsl:call-template name="outputsysdnet">
640 <xsl:with-param name="netstring" select="string()"/>
641 </xsl:call-template>
642 </xsl:when>
643 <xsl:otherwise>
644 <xsl:apply-templates/>
645 </xsl:otherwise>
646 </xsl:choose>
647 </xsl:template>
648
649 <xsl:template name="outputnet">
650 <xsl:param name="netstring" select="''"/>
651 <!-- We suppose that book example has the following values:
652 - interface: eth0
653 - ip: 192.168.1.2
654 - gateway: 192.168.1.1
655 - prefix: 24
656 - broadcast: 192.168.1.255
657 Change below if book changes -->
658 <xsl:choose>
659 <xsl:when test="contains($netstring,'eth0')">
660 <xsl:call-template name="outputnet">
661 <xsl:with-param name="netstring"
662 select="substring-before($netstring,'eth0')"/>
663 </xsl:call-template>
664 <xsl:value-of select="$interface"/>
665 <xsl:call-template name="outputnet">
666 <xsl:with-param name="netstring"
667 select="substring-after($netstring,'eth0')"/>
668 </xsl:call-template>
669 </xsl:when>
670 <xsl:when test="contains($netstring,'192.168.1.1')">
671 <xsl:call-template name="outputnet">
672 <xsl:with-param name="netstring"
673 select="substring-before($netstring,'192.168.1.1')"/>
674 </xsl:call-template>
675 <xsl:value-of select="$gateway"/>
676 <xsl:call-template name="outputnet">
677 <xsl:with-param name="netstring"
678 select="substring-after($netstring,'192.168.1.1')"/>
679 </xsl:call-template>
680 </xsl:when>
681 <!-- must test this before the following, because 192.168.1.255 contains
682 192.168.1.2! -->
683 <xsl:when test="contains($netstring,'192.168.1.255')">
684 <xsl:call-template name="outputnet">
685 <xsl:with-param name="netstring"
686 select="substring-before($netstring,'192.168.1.255')"/>
687 </xsl:call-template>
688 <xsl:value-of select="$broadcast"/>
689 <xsl:call-template name="outputnet">
690 <xsl:with-param name="netstring"
691 select="substring-after($netstring,'192.168.1.255')"/>
692 </xsl:call-template>
693 </xsl:when>
694 <xsl:when test="contains($netstring,'192.168.1.2')">
695 <xsl:call-template name="outputnet">
696 <xsl:with-param name="netstring"
697 select="substring-before($netstring,'192.168.1.2')"/>
698 </xsl:call-template>
699 <xsl:value-of select="$ip"/>
700 <xsl:call-template name="outputnet">
701 <xsl:with-param name="netstring"
702 select="substring-after($netstring,'192.168.1.2')"/>
703 </xsl:call-template>
704 </xsl:when>
705 <xsl:when test="contains($netstring,'24')">
706 <xsl:call-template name="outputnet">
707 <xsl:with-param name="netstring"
708 select="substring-before($netstring,'24')"/>
709 </xsl:call-template>
710 <xsl:value-of select="$prefix"/>
711 <xsl:call-template name="outputnet">
712 <xsl:with-param name="netstring"
713 select="substring-after($netstring,'24')"/>
714 </xsl:call-template>
715 </xsl:when>
716 <xsl:otherwise>
717 <xsl:value-of select="$netstring"/>
718 </xsl:otherwise>
719 </xsl:choose>
720 </xsl:template>
721
722 <xsl:template name="outputsysdnet">
723 <xsl:param name="netstring" select="''"/>
724 <!-- We suppose that book example has the following values:
725 - interface: eth0
726 - ip: 192.168.0.2
727 - gateway: 192.168.0.1
728 - prefix: 24
729 - DNS: 192.168.0.1
730 - Domain: <Your Domain Name>
731 and gateway comes before DNS. Change below if book changes -->
732 <xsl:choose>
733 <xsl:when test="contains($netstring,'eth0')">
734 <xsl:call-template name="outputsysdnet">
735 <xsl:with-param name="netstring"
736 select="substring-before($netstring,'eth0')"/>
737 </xsl:call-template>
738 <xsl:value-of select="$interface"/>
739 <xsl:call-template name="outputsysdnet">
740 <xsl:with-param name="netstring"
741 select="substring-after($netstring,'eth0')"/>
742 </xsl:call-template>
743 </xsl:when>
744 <xsl:when test="contains($netstring,'192.168.0.1') and
745 contains($netstring,'Gateway')">
746 <xsl:call-template name="outputsysdnet">
747 <xsl:with-param name="netstring"
748 select="substring-before($netstring,'192.168.0.1')"/>
749 </xsl:call-template>
750 <xsl:value-of select="$gateway"/>
751 <xsl:call-template name="outputsysdnet">
752 <xsl:with-param name="netstring"
753 select="substring-after($netstring,'192.168.0.1')"/>
754 </xsl:call-template>
755 </xsl:when>
756 <xsl:when test="contains($netstring,'192.168.0.1') and
757 not(contains($netstring,'Gateway'))">
758 <xsl:call-template name="outputsysdnet">
759 <xsl:with-param name="netstring"
760 select="substring-before($netstring,'192.168.0.1')"/>
761 </xsl:call-template>
762 <xsl:value-of select="$nameserver1"/>
763 <xsl:text>
764DNS=</xsl:text>
765 <xsl:value-of select="$nameserver2"/>
766 <xsl:call-template name="outputsysdnet">
767 <xsl:with-param name="netstring"
768 select="substring-after($netstring,'192.168.0.1')"/>
769 </xsl:call-template>
770 </xsl:when>
771 <xsl:when test="contains($netstring,'192.168.0.2')">
772 <xsl:call-template name="outputsysdnet">
773 <xsl:with-param name="netstring"
774 select="substring-before($netstring,'192.168.0.2')"/>
775 </xsl:call-template>
776 <xsl:value-of select="$ip"/>
777 <xsl:call-template name="outputsysdnet">
778 <xsl:with-param name="netstring"
779 select="substring-after($netstring,'192.168.0.2')"/>
780 </xsl:call-template>
781 </xsl:when>
782 <xsl:when test="contains($netstring,'24')">
783 <xsl:call-template name="outputsysdnet">
784 <xsl:with-param name="netstring"
785 select="substring-before($netstring,'24')"/>
786 </xsl:call-template>
787 <xsl:value-of select="$prefix"/>
788 <xsl:call-template name="outputsysdnet">
789 <xsl:with-param name="netstring"
790 select="substring-after($netstring,'24')"/>
791 </xsl:call-template>
792 </xsl:when>
793 <xsl:when test="contains($netstring,'&lt;Your Domain Name&gt;')">
794 <xsl:call-template name="outputsysdnet">
795 <xsl:with-param name="netstring"
796 select="substring-before($netstring,'&lt;Your Domain Name&gt;')"/>
797 </xsl:call-template>
798 <xsl:value-of select="$domain"/>
799 <xsl:call-template name="outputsysdnet">
800 <xsl:with-param name="netstring"
801 select="substring-after($netstring,'&lt;Your Domain Name&gt;')"/>
802 </xsl:call-template>
803 </xsl:when>
804 <xsl:otherwise>
805 <xsl:value-of select="$netstring"/>
806 </xsl:otherwise>
807 </xsl:choose>
808 </xsl:template>
809
810 <xsl:template name="outputpkgdest">
811 <xsl:param name="outputstring" select="foo"/>
812 <xsl:choose>
813 <xsl:when test="contains($outputstring,'make ')">
814 <xsl:choose>
815 <xsl:when test="not(starts-with($outputstring,'make'))">
816 <xsl:call-template name="outputpkgdest">
817 <xsl:with-param name="outputstring"
818 select="substring-before($outputstring,'make')"/>
819 </xsl:call-template>
820 <xsl:call-template name="outputpkgdest">
821 <xsl:with-param
822 name="outputstring"
823 select="substring-after($outputstring,
824 substring-before($outputstring,'make'))"/>
825 </xsl:call-template>
826 </xsl:when>
827 <xsl:otherwise>
828 <xsl:choose>
829<!-- special cases (no DESTDIR) here -->
830 <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
831 <xsl:text>make install_root=$PKG_DEST -j1</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-bzip2']">
838 <xsl:text>make PREFIX=$PKG_DEST/usr install&#xA;</xsl:text>
839 </xsl:when>
840 <xsl:when test="ancestor::sect1[@id='ch-system-sysklogd']">
841 <xsl:text>make BINDIR=$PKG_DEST/sbin prefix=$PKG_DEST install&#xA;</xsl:text>
842 </xsl:when>
843 <xsl:when test="ancestor::sect1[@id='ch-system-iproute2']">
844 <xsl:text>make DESTDIR=$PKG_DEST DOCDIR=</xsl:text>
845 <xsl:value-of
846 select="substring-before(substring-after(string(),'DOCDIR='),
847 'install')"/>
848 <xsl:text>install&#xA;</xsl:text>
849 </xsl:when>
850 <xsl:when test="ancestor::sect1[@id='ch-system-sysvinit']">
851 <xsl:text>make ROOT=$PKG_DEST</xsl:text>
852 <xsl:value-of
853 select="substring-before(substring-after(string(),'make'),
854 'install')"/>
855 <xsl:text>install&#xA;</xsl:text>
856 </xsl:when>
857 <xsl:when test="ancestor::sect1[@id='ch-bootable-kernel']">
858 <xsl:text>make INSTALL_MOD_PATH=$PKG_DEST</xsl:text>
859 <xsl:value-of
860 select="substring-before(substring-after(string(),'make'),
861 'install')"/>
862 <xsl:text>install&#xA;</xsl:text>
863 </xsl:when>
864 <xsl:when test="ancestor::sect1[@id='ch-system-attr']">
865 <xsl:text>DIST_ROOT=$PKG_DEST make</xsl:text>
866 <xsl:call-template name="outputpkgdest">
867 <xsl:with-param name="outputstring"
868 select="substring-after($outputstring,'make')"/>
869 </xsl:call-template>
870 </xsl:when>
871 <xsl:otherwise>
872 <xsl:text>make DESTDIR=$PKG_DEST</xsl:text>
873 <xsl:call-template name="outputpkgdest">
874 <xsl:with-param
875 name="outputstring"
876 select="substring-after($outputstring,'make')"/>
877 </xsl:call-template>
878 </xsl:otherwise>
879 </xsl:choose>
880 </xsl:otherwise>
881 </xsl:choose>
882 </xsl:when>
883 <xsl:otherwise> <!-- no make in this string -->
884 <xsl:choose>
885 <xsl:when test="contains($outputstring,'&gt;/') and
886 not(contains(substring-before($outputstring,'&gt;/'),' /'))">
887 <xsl:value-of select="substring-before($outputstring,'&gt;/')"/>
888 <xsl:text>&gt;$PKG_DEST/</xsl:text>
889 <xsl:call-template name="outputpkgdest">
890 <xsl:with-param name="outputstring" select="substring-after($outputstring,'&gt;/')"/>
891 </xsl:call-template>
892 </xsl:when>
893 <xsl:when test="contains($outputstring,' /')">
894 <xsl:value-of select="substring-before($outputstring,' /')"/>
895 <xsl:text> $PKG_DEST/</xsl:text>
896 <xsl:call-template name="outputpkgdest">
897 <xsl:with-param name="outputstring" select="substring-after($outputstring,' /')"/>
898 </xsl:call-template>
899 </xsl:when>
900 <xsl:otherwise>
901 <xsl:value-of select="$outputstring"/>
902 <xsl:text>&#xA;</xsl:text>
903 </xsl:otherwise>
904 </xsl:choose>
905 </xsl:otherwise>
906 </xsl:choose>
907 </xsl:template>
908
909 <xsl:variable name="APOS">'</xsl:variable>
910 <xsl:template name="output-wrap">
911 <xsl:param name="commands" select="''"/>
912 <xsl:choose>
913 <xsl:when test="contains($commands,string($APOS))">
914 <xsl:call-template name="output-wrap">
915 <xsl:with-param name="commands"
916 select="substring-before($commands,string($APOS))"/>
917 </xsl:call-template>
918 <xsl:text>'\''</xsl:text>
919 <xsl:call-template name="output-wrap">
920 <xsl:with-param name="commands"
921 select="substring-after($commands,string($APOS))"/>
922 </xsl:call-template>
923 </xsl:when>
924 <xsl:otherwise>
925 <xsl:value-of select="$commands"/>
926 </xsl:otherwise>
927 </xsl:choose>
928 </xsl:template>
929
930</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.