source: LFS/lfs.xsl@ eb8667a

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

Porg style package management:

  • Add new variable WRAP_INSTALL in COnfig.in and jhalfs
  • Generates the install commands inside a wrapper function
  • Add files packInstall.sh.porg and packageManager.xml.porg
  • TODO: update README.PACKAGE...
  • TODO: make new templates in pkgmngt and document them
  • Property mode set to 100644
File size: 33.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:otherwise>
639 <xsl:apply-templates/>
640 </xsl:otherwise>
641 </xsl:choose>
642 </xsl:template>
643
644 <xsl:template name="outputnet">
645 <xsl:param name="netstring" select="''"/>
646 <!-- We suppose that book example has the following values:
647 - interface: eth0
648 - ip: 192.168.1.2
649 - gateway: 192.168.1.1
650 - prefix: 24
651 - broadcast: 192.168.1.255
652 Change below if book changes -->
653 <xsl:choose>
654 <xsl:when test="contains($netstring,'eth0')">
655 <xsl:call-template name="outputnet">
656 <xsl:with-param name="netstring"
657 select="substring-before($netstring,'eth0')"/>
658 </xsl:call-template>
659 <xsl:value-of select="$interface"/>
660 <xsl:call-template name="outputnet">
661 <xsl:with-param name="netstring"
662 select="substring-after($netstring,'eth0')"/>
663 </xsl:call-template>
664 </xsl:when>
665 <xsl:when test="contains($netstring,'192.168.1.1')">
666 <xsl:call-template name="outputnet">
667 <xsl:with-param name="netstring"
668 select="substring-before($netstring,'192.168.1.1')"/>
669 </xsl:call-template>
670 <xsl:value-of select="$gateway"/>
671 <xsl:call-template name="outputnet">
672 <xsl:with-param name="netstring"
673 select="substring-after($netstring,'192.168.1.1')"/>
674 </xsl:call-template>
675 </xsl:when>
676 <!-- must test this before the following, because 192.168.1.255 contains
677 192.168.1.2! -->
678 <xsl:when test="contains($netstring,'192.168.1.255')">
679 <xsl:call-template name="outputnet">
680 <xsl:with-param name="netstring"
681 select="substring-before($netstring,'192.168.1.255')"/>
682 </xsl:call-template>
683 <xsl:value-of select="$broadcast"/>
684 <xsl:call-template name="outputnet">
685 <xsl:with-param name="netstring"
686 select="substring-after($netstring,'192.168.1.255')"/>
687 </xsl:call-template>
688 </xsl:when>
689 <xsl:when test="contains($netstring,'192.168.1.2')">
690 <xsl:call-template name="outputnet">
691 <xsl:with-param name="netstring"
692 select="substring-before($netstring,'192.168.1.2')"/>
693 </xsl:call-template>
694 <xsl:value-of select="$ip"/>
695 <xsl:call-template name="outputnet">
696 <xsl:with-param name="netstring"
697 select="substring-after($netstring,'192.168.1.2')"/>
698 </xsl:call-template>
699 </xsl:when>
700 <xsl:when test="contains($netstring,'24')">
701 <xsl:call-template name="outputnet">
702 <xsl:with-param name="netstring"
703 select="substring-before($netstring,'24')"/>
704 </xsl:call-template>
705 <xsl:value-of select="$prefix"/>
706 <xsl:call-template name="outputnet">
707 <xsl:with-param name="netstring"
708 select="substring-after($netstring,'24')"/>
709 </xsl:call-template>
710 </xsl:when>
711 <xsl:otherwise>
712 <xsl:value-of select="$netstring"/>
713 </xsl:otherwise>
714 </xsl:choose>
715 </xsl:template>
716
717 <xsl:template name="outputpkgdest">
718 <xsl:param name="outputstring" select="foo"/>
719 <xsl:choose>
720 <xsl:when test="contains($outputstring,'make ')">
721 <xsl:choose>
722 <xsl:when test="not(starts-with($outputstring,'make'))">
723 <xsl:call-template name="outputpkgdest">
724 <xsl:with-param name="outputstring"
725 select="substring-before($outputstring,'make')"/>
726 </xsl:call-template>
727 <xsl:call-template name="outputpkgdest">
728 <xsl:with-param
729 name="outputstring"
730 select="substring-after($outputstring,
731 substring-before($outputstring,'make'))"/>
732 </xsl:call-template>
733 </xsl:when>
734 <xsl:otherwise>
735 <xsl:choose>
736<!-- special cases (no DESTDIR) here -->
737 <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
738 <xsl:text>make install_root=$PKG_DEST -j1</xsl:text>
739 <xsl:value-of
740 select="substring-before(substring-after(string(),'make'),
741 'install')"/>
742 <xsl:text>install&#xA;</xsl:text>
743 </xsl:when>
744 <xsl:when test="ancestor::sect1[@id='ch-system-bzip2']">
745 <xsl:text>make PREFIX=$PKG_DEST/usr install&#xA;</xsl:text>
746 </xsl:when>
747 <xsl:when test="ancestor::sect1[@id='ch-system-sysklogd']">
748 <xsl:text>make BINDIR=$PKG_DEST/sbin prefix=$PKG_DEST install&#xA;</xsl:text>
749 </xsl:when>
750 <xsl:when test="ancestor::sect1[@id='ch-system-iproute2']">
751 <xsl:text>make DESTDIR=$PKG_DEST DOCDIR=</xsl:text>
752 <xsl:value-of
753 select="substring-before(substring-after(string(),'DOCDIR='),
754 'install')"/>
755 <xsl:text>install&#xA;</xsl:text>
756 </xsl:when>
757 <xsl:when test="ancestor::sect1[@id='ch-system-sysvinit']">
758 <xsl:text>make ROOT=$PKG_DEST</xsl:text>
759 <xsl:value-of
760 select="substring-before(substring-after(string(),'make'),
761 'install')"/>
762 <xsl:text>install&#xA;</xsl:text>
763 </xsl:when>
764 <xsl:when test="ancestor::sect1[@id='ch-bootable-kernel']">
765 <xsl:text>make INSTALL_MOD_PATH=$PKG_DEST</xsl:text>
766 <xsl:value-of
767 select="substring-before(substring-after(string(),'make'),
768 'install')"/>
769 <xsl:text>install&#xA;</xsl:text>
770 </xsl:when>
771 <xsl:when test="ancestor::sect1[@id='ch-system-attr']">
772 <xsl:text>DIST_ROOT=$PKG_DEST make</xsl:text>
773 <xsl:call-template name="outputpkgdest">
774 <xsl:with-param name="outputstring"
775 select="substring-after($outputstring,'make')"/>
776 </xsl:call-template>
777 </xsl:when>
778 <xsl:otherwise>
779 <xsl:text>make DESTDIR=$PKG_DEST</xsl:text>
780 <xsl:call-template name="outputpkgdest">
781 <xsl:with-param
782 name="outputstring"
783 select="substring-after($outputstring,'make')"/>
784 </xsl:call-template>
785 </xsl:otherwise>
786 </xsl:choose>
787 </xsl:otherwise>
788 </xsl:choose>
789 </xsl:when>
790 <xsl:otherwise> <!-- no make in this string -->
791 <xsl:choose>
792 <xsl:when test="contains($outputstring,'&gt;/') and
793 not(contains(substring-before($outputstring,'&gt;/'),' /'))">
794 <xsl:value-of select="substring-before($outputstring,'&gt;/')"/>
795 <xsl:text>&gt;$PKG_DEST/</xsl:text>
796 <xsl:call-template name="outputpkgdest">
797 <xsl:with-param name="outputstring" select="substring-after($outputstring,'&gt;/')"/>
798 </xsl:call-template>
799 </xsl:when>
800 <xsl:when test="contains($outputstring,' /')">
801 <xsl:value-of select="substring-before($outputstring,' /')"/>
802 <xsl:text> $PKG_DEST/</xsl:text>
803 <xsl:call-template name="outputpkgdest">
804 <xsl:with-param name="outputstring" select="substring-after($outputstring,' /')"/>
805 </xsl:call-template>
806 </xsl:when>
807 <xsl:otherwise>
808 <xsl:value-of select="$outputstring"/>
809 <xsl:text>&#xA;</xsl:text>
810 </xsl:otherwise>
811 </xsl:choose>
812 </xsl:otherwise>
813 </xsl:choose>
814 </xsl:template>
815
816 <xsl:variable name="APOS">'</xsl:variable>
817 <xsl:template name="output-wrap">
818 <xsl:param name="commands" select="''"/>
819 <xsl:choose>
820 <xsl:when test="contains($commands,string($APOS))">
821 <xsl:call-template name="output-wrap">
822 <xsl:with-param name="commands"
823 select="substring-before($commands,string($APOS))"/>
824 </xsl:call-template>
825 <xsl:text>'\''</xsl:text>
826 <xsl:call-template name="output-wrap">
827 <xsl:with-param name="commands"
828 select="substring-after($commands,string($APOS))"/>
829 </xsl:call-template>
830 </xsl:when>
831 <xsl:otherwise>
832 <xsl:value-of select="$commands"/>
833 </xsl:otherwise>
834 </xsl:choose>
835 </xsl:template>
836
837</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.