source: LFS/lfs.xsl@ 2a9b0c3

ablfs-more legacy trunk
Last change on this file since 2a9b0c3 was 94fc75e, checked in by Pierre Labastie <pierre@…>, 4 years ago

Remain compatible with older versions of lfs

  • Property mode set to 100644
File size: 48.1 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2
3<!-- $Id$ -->
4
5<xsl:stylesheet
6 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
7 xmlns:exsl="http://exslt.org/common"
8 extension-element-prefixes="exsl"
9 version="1.0">
10
11<!-- Parameters -->
12
13 <!-- which revision attribute to include: can only be sysv or systemd,
14 but we leave checking to the caller-->
15 <xsl:param name="revision" select="'sysv'"/>
16
17 <!-- use package management ?
18 n = no, original behavior
19 y = yes, add PKG_DEST to scripts in install commands of chapter06-08
20 -->
21 <xsl:param name="pkgmngt" select="'n'"/>
22
23 <!-- Package management with "porg style" ?
24 n = no, same as pkgmngt description above
25 y = yes, wrap install commands of chapter06-08 into a bash function.
26 note that pkgmngt must be 'y' in this case
27 -->
28 <xsl:param name="wrap-install" select='"n"'/>
29
30 <!-- Run test suites?
31 0 = none
32 1 = only chapter06 critical testsuites
33 2 = all chapter06 testsuites
34 3 = all chapter05 and chapter06 testsuites
35 -->
36 <xsl:param name="testsuite" select="1"/>
37
38 <!-- Bomb on test suites failures?
39 n = no, I want to build the full system and review the logs
40 y = yes, bomb at the first test suite failure to can review the build dir
41 -->
42 <xsl:param name="bomb-testsuite" select="'n'"/>
43
44 <!-- Install non wide character ncurses 5? -->
45 <xsl:param name="ncurses5" select="'n'"/>
46
47 <!-- Should we strip excutables and libraries? -->
48 <xsl:param name='strip' select="'n'"/>
49
50 <!-- Should we remove .la files after chapter 5 and chapter 6? -->
51 <xsl:param name='del-la-files' select="'y'"/>
52
53 <!-- Time zone -->
54 <xsl:param name="timezone" select="'GMT'"/>
55
56 <!-- Page size -->
57 <xsl:param name="page" select="'letter'"/>
58
59 <!-- Locale settings -->
60 <xsl:param name="lang" select="'C'"/>
61
62 <!-- Install the whole set of locales -->
63 <xsl:param name='full-locale' select='"n"'/>
64
65 <!-- Hostname -->
66 <xsl:param name='hostname' select='"HOSTNAME"'/>
67
68 <!-- Network parameters: interface, ip, gateway, prefix, broadcast, domain
69 and nameservers -->
70 <xsl:param name='interface' select="'eth0'"/>
71 <xsl:param name='ip' select='"10.0.2.9"'/>
72 <xsl:param name='gateway' select='"10.0.2.2"'/>
73 <xsl:param name='prefix' select='24'/>
74 <xsl:param name='broadcast' select='"10.0.2.255"'/>
75 <xsl:param name='domain' select='"lfs.org"'/>
76 <xsl:param name='nameserver1' select='"10.0.2.3"'/>
77 <xsl:param name='nameserver2' select='"8.8.8.8"'/>
78
79 <!-- Console parameters: font, fontmap, unicode (y/n), keymap, local (y:
80 hardware clock set to local time/n:hardware clock set to UTC)
81 and log-level -->
82 <xsl:param name='font' select="'lat0-16'"/>
83 <xsl:param name='keymap' select="'us'"/>
84 <xsl:param name='local' select="'n'"/>
85 <xsl:param name='log-level' select="'4'"/>
86
87 <!-- The scripts root is needed for printing disk usage -->
88 <xsl:param name='script-root' select="'jhalfs'"/>
89
90<!-- End parameters -->
91
92 <xsl:template match="/">
93 <xsl:apply-templates select="//sect1[not(@revision) or
94 @revision=$revision]"/>
95 </xsl:template>
96
97 <xsl:template match="sect1">
98<!-- Since this xsl:if tag encloses the whole template, it would
99 be much better to transpose this condition to the select part
100 of the "calling" apply-template. But that would change the numbering,
101 so that it would be difficult to compare to previous versions. So for
102 version 2.4, let us keep this -->
103 <xsl:if test="(../@id='chapter-temporary-tools' or
104 ../@id='chapter-building-system' or
105 ../@id='chapter-bootscripts' or
106 ../@id='chapter-config' or
107 ../@id='chapter-bootable') and
108 (sect2[not(@revision) or @revision=$revision]//..|.)/
109 screen[(not(@role) or @role != 'nodump') and
110 (not(@revision) or @revision=$revision)]/
111 userinput[not(starts-with(string(),'chroot'))]">
112<!-- The last condition is a hack to allow previous versions of the
113 book where the chroot commands did not have role="nodump".
114 It only works if the chroot command is the only one on the page -->
115 <!-- The dirs names -->
116 <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
117 <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
118 <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
119 <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
120 <!-- The file names -->
121 <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
122 <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
123 <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
124 <!-- The build order -->
125 <xsl:variable name="position" select="position()"/>
126 <xsl:variable name="order">
127 <xsl:choose>
128 <xsl:when test="string-length($position) = 1">
129 <xsl:text>00</xsl:text>
130 <xsl:value-of select="$position"/>
131 </xsl:when>
132 <xsl:when test="string-length($position) = 2">
133 <xsl:text>0</xsl:text>
134 <xsl:value-of select="$position"/>
135 </xsl:when>
136 <xsl:otherwise>
137 <xsl:value-of select="$position"/>
138 </xsl:otherwise>
139 </xsl:choose>
140 </xsl:variable>
141 <!-- Inclusion of package manager scriptlets -->
142 <xsl:if test="@id='ch-tools-stripping' and $pkgmngt='y'">
143 <xsl:apply-templates
144 select="document('packageManager.xml')//sect1[contains(@id,'ch-tools')]"
145 mode="pkgmngt">
146 <xsl:with-param name="order" select="$order"/>
147 <xsl:with-param name="dirname" select="$dirname"/>
148 </xsl:apply-templates>
149 </xsl:if>
150 <xsl:if test="@id='ch-system-strippingagain' and $pkgmngt='y'">
151 <xsl:apply-templates
152 select="document('packageManager.xml')//sect1[contains(@id,'ch-system')]"
153 mode="pkgmngt">
154 <xsl:with-param name="order" select="$order"/>
155 <xsl:with-param name="dirname" select="$dirname"/>
156 </xsl:apply-templates>
157 </xsl:if>
158 <!-- Creating dirs and files -->
159 <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
160 <xsl:choose>
161 <xsl:when test="@id='ch-system-creatingdirs' or
162 @id='ch-system-createfiles' or
163 @id='ch-system-strippingagain'">
164 <xsl:text>#!/tools/bin/bash&#xA;set +h&#xA;</xsl:text>
165 </xsl:when>
166 <xsl:otherwise>
167 <xsl:text>#!/bin/bash&#xA;set +h&#xA;</xsl:text>
168 </xsl:otherwise>
169 </xsl:choose>
170 <xsl:if test="not(@id='ch-tools-stripping') and
171 not(@id='ch-system-strippingagain')">
172 <xsl:text>set -e&#xA;</xsl:text>
173 </xsl:if>
174 <xsl:text>&#xA;</xsl:text>
175 <xsl:call-template name="start-script">
176 <xsl:with-param name="order" select="$order"/>
177 </xsl:call-template>
178 <xsl:apply-templates select="sect2[not(@revision) or
179 @revision=$revision] |
180 screen[(not(@role) or
181 @role!='nodump') and
182 (not(@revision) or
183 @revision=$revision)]/userinput"/>
184 <xsl:if test="@id='ch-system-creatingdirs' and $pkgmngt='y'">
185 <xsl:apply-templates
186 select="document('packageManager.xml')//sect1[
187 @id='ch-pkgmngt-creatingdirs'
188 ]//userinput"
189 mode="pkgmngt"/>
190 </xsl:if>
191 <xsl:if test="@id='ch-system-createfiles' and $pkgmngt='y'">
192 <xsl:apply-templates
193 select="document('packageManager.xml')//sect1[
194 @id='ch-pkgmngt-createfiles'
195 ]//userinput"
196 mode="pkgmngt"/>
197 </xsl:if>
198 <xsl:text>echo -e "\n\nTotalseconds: $SECONDS\n"&#xA;</xsl:text>
199 <xsl:call-template name="end-script"/>
200 <xsl:text>exit&#xA;</xsl:text>
201 </exsl:document>
202 </xsl:if>
203 </xsl:template>
204
205 <xsl:template match="sect2">
206 <xsl:apply-templates
207 select=".//screen[(not(@role) or
208 @role != 'nodump') and
209 (not(@revision) or
210 @revision=$revision)]/userinput[
211 @remap = 'pre' or
212 @remap = 'configure' or
213 @remap = 'make' or
214 @remap = 'test' and
215 not(current()/../@id='ch-tools-dejagnu') and
216 not(current()/../@id='ch-system-systemd')]"/>
217 <xsl:if
218 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:text>wrapInstall '
226</xsl:text>
227 </xsl:when>
228 <xsl:otherwise>
229<!-- We cannot know which directory(ies) are needed by the package. Create a
230 reasonable bunch of them. Should be close to "Creating Directories".-->
231 <xsl:text>mkdir -pv $PKG_DEST/{bin,boot,etc,lib,sbin}
232mkdir -pv $PKG_DEST/usr/{bin,include,lib/pkgconfig,sbin}
233mkdir -pv $PKG_DEST/usr/share/{doc,info,bash-completion/completions}
234mkdir -pv $PKG_DEST/usr/share/man/man{1..8}
235case $(uname -m) in
236 x86_64) mkdir -v $PKG_DEST/lib64 ;;
237esac
238</xsl:text>
239 </xsl:otherwise>
240 </xsl:choose>
241 </xsl:if>
242 <xsl:apply-templates
243 select=".//screen[(not(@role) or
244 @role != 'nodump') and
245 (not(@revision) or
246 @revision=$revision)]/userinput[@remap = 'install']"/>
247 <xsl:if test="ancestor::chapter[@id != 'chapter-temporary-tools'] and
248 descendant::screen[not(@role) or
249 @role != 'nodump']/userinput[
250 @remap='install']">
251 <xsl:choose>
252 <xsl:when test="$pkgmngt='n'"/>
253 <xsl:when test="$wrap-install='y'">
254 <xsl:if test="../@id = 'ch-system-man-pages'">
255<!-- these files are provided by the shadow package -->
256 <xsl:text>rm -fv /usr/share/man/{man3/getspnam.3,man5/passwd.5}
257</xsl:text>
258 </xsl:if>
259<!-- nologin is installed by util-linux. remove it from shadow -->
260 <xsl:if test="../@id = 'ch-system-shadow'">
261 <xsl:text>rm -fv /usr/share/man/man8/nologin.8
262rm -fv /sbin/nologin
263</xsl:text>
264 </xsl:if>
265 <xsl:text>'
266PREV_SEC=${SECONDS}
267packInstall
268SECONDS=${PREV_SEC}
269</xsl:text>
270 </xsl:when>
271 <xsl:otherwise>
272 <xsl:if test="../@id = 'ch-system-man-pages'">
273<!-- these files are provided by the shadow package -->
274 <xsl:text>rm -fv $PKG_DEST/usr/share/man/{man3/getspnam.3,man5/passwd.5}
275</xsl:text>
276 </xsl:if>
277<!-- nologin is installed by util-linux. remove it from shadow -->
278 <xsl:if test="../@id = 'ch-system-shadow'">
279 <xsl:text>rm -fv $PKG_DEST/usr/share/man/man8/nologin.8
280rm -fv $PKG_DEST/sbin/nologin
281</xsl:text>
282 </xsl:if>
283<!-- remove empty directories -->
284 <xsl:text>for dir in $PKG_DEST/usr/share/man/man{1..8} \
285 $PKG_DEST/usr/share/bash-completion{/completions,} \
286 $PKG_DEST/usr/share/{doc,info,man,} \
287 $PKG_DEST/usr/lib/pkgconfig \
288 $PKG_DEST/usr/{lib,bin,sbin,include} \
289 $PKG_DEST/{boot,etc,lib,bin,sbin}; do
290 [ -d "$dir" ] &amp;&amp; [ -z "$(ls $dir)" ] &amp;&amp; rmdir -v $dir
291done
292[ -d $PKG_DEST/lib64 ] &amp;&amp; [ -z "$(ls $PKG_DEST/lib64)" ] &amp;&amp;
293 rmdir -v $PKG_DEST/lib64
294PREV_SEC=${SECONDS}
295packInstall
296SECONDS=${PREV_SEC}
297rm -rf $PKG_DEST
298</xsl:text>
299 </xsl:otherwise>
300 </xsl:choose>
301 </xsl:if>
302 <xsl:if test="$testsuite='3' and
303 ../@id='ch-tools-glibc' and
304 @role='installation'">
305 <xsl:copy-of select="//userinput[@remap='locale-test']"/>
306 <xsl:text>&#xA;</xsl:text>
307 </xsl:if>
308 <xsl:if test="../@id='ch-system-glibc' and @role='installation'">
309 <xsl:choose>
310 <xsl:when test="$full-locale='y'">
311 <xsl:copy-of select="//userinput[@remap='locale-full']"/>
312 <xsl:text>&#xA;</xsl:text>
313 </xsl:when>
314 <xsl:otherwise>
315 <xsl:copy-of select="//userinput[@remap='locale-test']"/>
316 <xsl:text>&#xA;</xsl:text>
317 <xsl:if test="not(contains(string(//userinput[@remap='locale-test']),$lang)) and $lang!='C' and $lang!='POSIX'">
318 <xsl:text>if LOCALE=`grep "</xsl:text>
319 <xsl:value-of select="$lang"/>
320 <xsl:text>/" $PKGDIR/localedata/SUPPORTED`; then
321 CHARMAP=`echo $LOCALE | sed 's,[^/]*/\([^ ]*\) [\],\1,'`
322 INPUT=`echo $LOCALE | sed 's,[/.].*,,'`
323 LOCALE=`echo $LOCALE | sed 's,/.*,,'`
324 localedef -i $INPUT -f $CHARMAP $LOCALE
325fi
326</xsl:text>
327 </xsl:if>
328 </xsl:otherwise>
329 </xsl:choose>
330 </xsl:if>
331 <xsl:apply-templates
332 select=".//screen[
333 (not(@role) or
334 @role != 'nodump') and
335 (not(@revision) or
336 @revision=$revision)
337 ]/userinput[
338 not(@remap) or
339 @remap='adjust' or
340 @remap='test' and current()/../@id='ch-tools-dejagnu' or
341 @remap='test' and current()/../@id='ch-system-systemd'
342 ]"/>
343 <xsl:if test="../@id='ch-system-ncurses' and $ncurses5='y'">
344 <xsl:apply-templates select=".//screen[@role='nodump']"/>
345 </xsl:if>
346 </xsl:template>
347
348 <xsl:template match="sect1" mode="pkgmngt">
349 <xsl:param name="dirname" select="'chapter05'"/>
350 <!-- The build order -->
351 <xsl:param name="order" select="'062'"/>
352<!-- The file names -->
353 <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
354 <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
355 <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
356 <!-- Creating dirs and files -->
357 <xsl:if test="count(descendant::screen/userinput) &gt; 0 and
358 count(descendant::screen/userinput) &gt;
359 count(descendant::screen[@role='nodump'])">
360 <exsl:document href="{$dirname}/{$order}-{position()}-{$filename}"
361 method="text">
362 <xsl:text>#!/bin/bash
363set +h
364set -e
365</xsl:text>
366 <xsl:call-template name="start-script">
367 <xsl:with-param name="order" select="concat($order,'-',position())"/>
368 </xsl:call-template>
369 <xsl:apply-templates
370 select=".//screen[not(@role) or
371 @role != 'nodump']/userinput[@remap != 'adjust']"
372 mode="pkgmngt"/>
373 <xsl:if test="$dirname = 'chapter06'">
374 <xsl:text>PREV_SEC=${SECONDS}
375packInstall
376SECONDS=${PREV_SEC}
377rm -rf "$PKG_DEST"
378</xsl:text>
379 </xsl:if>
380 <xsl:apply-templates
381 select=".//screen[not(@role) or
382 @role != 'nodump'
383 ]/userinput[not(@remap) or
384 @remap='adjust'
385 ]"
386 mode="pkgmngt"/>
387 <xsl:text>
388echo -e "\n\nTotalseconds: $SECONDS\n"
389</xsl:text>
390 <xsl:call-template name="end-script"/>
391 <xsl:text>exit
392</xsl:text>
393 </exsl:document>
394 </xsl:if>
395 </xsl:template>
396
397 <xsl:template match="userinput" mode="pkgmngt">
398 <xsl:apply-templates/>
399 <xsl:text>&#xA;</xsl:text>
400 </xsl:template>
401
402 <xsl:template match="userinput">
403 <xsl:choose>
404 <!-- Copying the kernel config file -->
405 <xsl:when test="string() = 'make mrproper'">
406 <xsl:text>make mrproper&#xA;</xsl:text>
407 <xsl:if test="ancestor::sect1[@id='ch-bootable-kernel']">
408 <xsl:text>cp -v ../kernel-config .config&#xA;</xsl:text>
409 </xsl:if>
410 </xsl:when>
411<!-- test instructions -->
412 <xsl:when test="@remap = 'test'">
413 <xsl:call-template name="comment-test">
414 <xsl:with-param name="instructions" select="string()"/>
415 </xsl:call-template>
416 </xsl:when>
417<!-- End of test instructions -->
418<!-- If the instructions contain "strip ", it may mean they contain also .la
419 file removal (and possibly other clean up). We therefore call a template
420 to comment them out appropriately and also to not stop if stripping
421 fails. -->
422 <xsl:when test="contains(string(),'strip ') or
423 contains(string(),'\*.la')">
424 <xsl:call-template name="comment-strip">
425 <xsl:with-param name="instructions" select="string()"/>
426 </xsl:call-template>
427 </xsl:when>
428<!-- Package management -->
429<!-- Add $PKG_DEST to installation commands -->
430 <xsl:when test="@remap='install' and
431 not(ancestor::chapter[
432 @id='chapter-temporary-tools'
433 ])">
434 <xsl:choose>
435 <xsl:when test="$pkgmngt='n'">
436 <xsl:choose>
437 <xsl:when test="contains(string(),'firmware,udev')">
438 <xsl:text>if [[ ! -d /lib/udev/devices ]] ; then&#xA;</xsl:text>
439 <xsl:apply-templates/>
440 <xsl:text>&#xA;fi&#xA;</xsl:text>
441 </xsl:when>
442 <xsl:otherwise>
443 <xsl:apply-templates/>
444 <xsl:text>&#xA;</xsl:text>
445 </xsl:otherwise>
446 </xsl:choose>
447 </xsl:when>
448 <xsl:when test="$wrap-install='y'">
449 <xsl:choose>
450 <xsl:when test="./literal">
451 <xsl:call-template name="output-wrap">
452 <xsl:with-param name="commands" select="text()[1]"/>
453 </xsl:call-template>
454 <xsl:apply-templates select="literal"/>
455 <xsl:call-template name="output-wrap">
456 <xsl:with-param name="commands" select="text()[2]"/>
457 </xsl:call-template>
458 </xsl:when>
459 <xsl:otherwise>
460 <xsl:call-template name="output-wrap">
461 <xsl:with-param name="commands" select="string()"/>
462 </xsl:call-template>
463 </xsl:otherwise>
464 </xsl:choose>
465 <xsl:text>&#xA;</xsl:text>
466 </xsl:when>
467 <xsl:otherwise><!--pkgmngt = 'y' and wrap-install='n'-->
468 <xsl:choose>
469 <xsl:when test="./literal">
470 <xsl:call-template name="outputpkgdest">
471 <xsl:with-param name="outputstring" select="text()[1]"/>
472 </xsl:call-template>
473 <xsl:apply-templates select="literal"/>
474 <xsl:call-template name="outputpkgdest">
475 <xsl:with-param name="outputstring" select="text()[2]"/>
476 </xsl:call-template>
477 </xsl:when>
478 <xsl:otherwise>
479 <xsl:call-template name="outputpkgdest">
480 <xsl:with-param name="outputstring" select="string()"/>
481 </xsl:call-template>
482 </xsl:otherwise>
483 </xsl:choose>
484 <xsl:text>&#xA;</xsl:text>
485 </xsl:otherwise>
486 </xsl:choose>
487 </xsl:when> <!-- @remap='install' -->
488 <!-- if package management, we should make an independant package for
489 tzdata. -->
490 <xsl:when test="contains(string(),'tzdata') and $pkgmngt='y'">
491 <xsl:text>
492OLD_PKG_DEST="$PKG_DEST"
493OLD_PKGDIR=$PKGDIR
494PKG_DEST=$(dirname $OLD_PKG_DEST)/001-tzdata
495PKGDIR=$(dirname $PKGDIR)/tzdata-</xsl:text>
496 <xsl:copy-of select="substring-before(
497 substring-after(string(),'tzdata'),
498 '.tar')"/>
499 <xsl:text>
500</xsl:text>
501 <xsl:choose>
502 <xsl:when test="$wrap-install='n'">
503 <xsl:copy-of select="substring-before(string(),'ZONEINFO=')"/>
504 <xsl:text>ZONEINFO=$PKG_DEST</xsl:text>
505 <xsl:copy-of select="substring-after(string(),'ZONEINFO=')"/>
506 <xsl:text>
507PREV_SEC=${SECONDS}
508packInstall
509SECONDS=${PREV_SEC}
510rm -rf $PKG_DEST
511</xsl:text>
512 </xsl:when>
513 <xsl:otherwise><!-- wrap-install='y' -->
514 <xsl:copy-of select="substring-before(string(),'ZONEINFO=')"/>
515 <xsl:text>
516wrapInstall '
517ZONEINFO=</xsl:text>
518 <xsl:copy-of select="substring-after(string(),'ZONEINFO=')"/>
519 <xsl:text>'
520PREV_SEC=${SECONDS}
521packInstall
522SECONDS=${PREV_SEC}
523</xsl:text>
524 </xsl:otherwise>
525 </xsl:choose>
526 <xsl:text>
527PKG_DEST=$OLD_PKG_DEST
528unset OLD_PKG_DEST
529PKGDIR=$OLD_PKGDIR
530unset OLD_PKGDIR
531</xsl:text>
532 </xsl:when><!-- addition for tzdata + package management -->
533 <!-- End addition for package management -->
534 <!-- The rest of commands -->
535 <xsl:otherwise>
536 <xsl:apply-templates/>
537 <xsl:text>&#xA;</xsl:text>
538 </xsl:otherwise>
539 </xsl:choose>
540 </xsl:template>
541
542 <xsl:template match="replaceable">
543 <xsl:choose>
544 <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
545 <xsl:value-of select="$timezone"/>
546 </xsl:when>
547 <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
548 <xsl:value-of select="$page"/>
549 </xsl:when>
550 <xsl:when test="contains(string(.),'&lt;ll&gt;_&lt;CC&gt;')">
551 <xsl:value-of select="$lang"/>
552 </xsl:when>
553 <xsl:when test="contains(string(.),'Domain')">
554 <xsl:value-of select="$domain"/>
555 </xsl:when>
556 <xsl:when test="contains(string(.),'primary')">
557 <xsl:value-of select="$nameserver1"/>
558 </xsl:when>
559 <xsl:when test="contains(string(.),'secondary')">
560 <xsl:value-of select="$nameserver2"/>
561 </xsl:when>
562 <xsl:when test="contains(string(.),'192.168.1.1')">
563 <xsl:value-of select="$ip"/>
564 </xsl:when>
565 <xsl:when test="contains(string(.),'192.168.0.2')">
566 <xsl:value-of select="$ip"/>
567 </xsl:when>
568 <xsl:when test="contains(string(.),'eth0')">
569 <xsl:value-of select="$interface"/>
570 </xsl:when>
571<!-- Only adapted to LFS-20170310 and later -->
572 <xsl:when test="contains(string(.),'HOSTNAME')">
573 <xsl:value-of select="$hostname"/>
574 </xsl:when>
575 <xsl:when test="contains(string(.),'FQDN')">
576 <xsl:value-of select="$hostname"/>
577 <xsl:text>.</xsl:text>
578 <xsl:value-of select="$domain"/>
579 </xsl:when>
580 <xsl:when test="contains(string(.),'alias')"/>
581 <xsl:when test="contains(string(.),'&lt;lfs&gt;')">
582 <xsl:value-of select="$hostname"/>
583 </xsl:when>
584 <xsl:otherwise>
585 <xsl:text>**EDITME</xsl:text>
586 <xsl:apply-templates/>
587 <xsl:text>EDITME**</xsl:text>
588 </xsl:otherwise>
589 </xsl:choose>
590 </xsl:template>
591
592 <xsl:template match="literal">
593 <xsl:choose>
594 <xsl:when test="contains(string(),'ONBOOT')">
595 <xsl:call-template name="outputnet">
596 <xsl:with-param name="netstring" select="string()"/>
597 </xsl:call-template>
598 </xsl:when>
599 <xsl:when test="contains(string(),'[Match]')">
600 <xsl:call-template name="outputsysdnet">
601 <xsl:with-param name="netstring" select="string()"/>
602 </xsl:call-template>
603 </xsl:when>
604 <xsl:when test="contains(string(),'0.0 0 0.0')">
605 <xsl:copy-of select="substring-before(string(),'LOCAL')"/>
606 <xsl:if test="$local='y'"><xsl:text>LOCAL</xsl:text></xsl:if>
607 <xsl:if test="$local='n'"><xsl:text>UTC</xsl:text></xsl:if>
608 </xsl:when>
609 <xsl:when test="contains(string(),'UTC=1')">
610 <xsl:copy-of select="substring-before(string(),'1')"/>
611 <xsl:if test="$local='y'"><xsl:text>0</xsl:text></xsl:if>
612 <xsl:if test="$local='n'"><xsl:text>1</xsl:text></xsl:if>
613 <xsl:copy-of select="substring-after(string(),'1')"/>
614 </xsl:when>
615 <xsl:when test="contains(string(),'bg_bds-')">
616 <xsl:call-template name="outputsysvconsole">
617 <xsl:with-param name="consolestring" select="string()"/>
618 </xsl:call-template>
619 </xsl:when>
620 <xsl:when test="contains(string(),'de-latin1')">
621 <xsl:call-template name="outputsysdconsole">
622 <xsl:with-param name="consolestring" select="string()"/>
623 </xsl:call-template>
624 </xsl:when>
625 <xsl:otherwise>
626 <xsl:apply-templates/>
627 </xsl:otherwise>
628 </xsl:choose>
629 </xsl:template>
630
631 <xsl:template name="outputnet">
632 <xsl:param name="netstring" select="''"/>
633 <!-- We suppose that book example has the following values:
634 - interface: eth0
635 - ip: 192.168.1.2
636 - gateway: 192.168.1.1
637 - prefix: 24
638 - broadcast: 192.168.1.255
639 Change below if book changes -->
640 <xsl:choose>
641 <xsl:when test="contains($netstring,'eth0')">
642 <xsl:call-template name="outputnet">
643 <xsl:with-param name="netstring"
644 select="substring-before($netstring,'eth0')"/>
645 </xsl:call-template>
646 <xsl:value-of select="$interface"/>
647 <xsl:call-template name="outputnet">
648 <xsl:with-param name="netstring"
649 select="substring-after($netstring,'eth0')"/>
650 </xsl:call-template>
651 </xsl:when>
652 <xsl:when test="contains($netstring,'192.168.1.1')">
653 <xsl:call-template name="outputnet">
654 <xsl:with-param name="netstring"
655 select="substring-before($netstring,'192.168.1.1')"/>
656 </xsl:call-template>
657 <xsl:value-of select="$gateway"/>
658 <xsl:call-template name="outputnet">
659 <xsl:with-param name="netstring"
660 select="substring-after($netstring,'192.168.1.1')"/>
661 </xsl:call-template>
662 </xsl:when>
663 <!-- must test this before the following, because 192.168.1.255 contains
664 192.168.1.2! -->
665 <xsl:when test="contains($netstring,'192.168.1.255')">
666 <xsl:call-template name="outputnet">
667 <xsl:with-param name="netstring"
668 select="substring-before($netstring,'192.168.1.255')"/>
669 </xsl:call-template>
670 <xsl:value-of select="$broadcast"/>
671 <xsl:call-template name="outputnet">
672 <xsl:with-param name="netstring"
673 select="substring-after($netstring,'192.168.1.255')"/>
674 </xsl:call-template>
675 </xsl:when>
676 <xsl:when test="contains($netstring,'192.168.1.2')">
677 <xsl:call-template name="outputnet">
678 <xsl:with-param name="netstring"
679 select="substring-before($netstring,'192.168.1.2')"/>
680 </xsl:call-template>
681 <xsl:value-of select="$ip"/>
682 <xsl:call-template name="outputnet">
683 <xsl:with-param name="netstring"
684 select="substring-after($netstring,'192.168.1.2')"/>
685 </xsl:call-template>
686 </xsl:when>
687 <xsl:when test="contains($netstring,'24')">
688 <xsl:call-template name="outputnet">
689 <xsl:with-param name="netstring"
690 select="substring-before($netstring,'24')"/>
691 </xsl:call-template>
692 <xsl:value-of select="$prefix"/>
693 <xsl:call-template name="outputnet">
694 <xsl:with-param name="netstring"
695 select="substring-after($netstring,'24')"/>
696 </xsl:call-template>
697 </xsl:when>
698 <xsl:otherwise>
699 <xsl:value-of select="$netstring"/>
700 </xsl:otherwise>
701 </xsl:choose>
702 </xsl:template>
703
704 <xsl:template name="outputsysdnet">
705 <xsl:param name="netstring" select="''"/>
706 <!-- We suppose that book example has the following values:
707 - interface: <network-device-name>
708 - ip: 192.168.0.2
709 - gateway: 192.168.0.1
710 - prefix: 24
711 - DNS: 192.168.0.1
712 - Domain: <Your Domain Name>
713 and gateway comes before DNS. Change below if book changes -->
714 <xsl:choose>
715 <xsl:when test="contains($netstring,'&lt;network-device-name&gt;')">
716 <xsl:call-template name="outputsysdnet">
717 <xsl:with-param name="netstring"
718 select="substring-before($netstring,'&lt;network-device-name&gt;')"/>
719 </xsl:call-template>
720 <xsl:value-of select="$interface"/>
721 <xsl:call-template name="outputsysdnet">
722 <xsl:with-param name="netstring"
723 select="substring-after($netstring,'&lt;network-device-name&gt;')"/>
724 </xsl:call-template>
725 </xsl:when>
726 <xsl:when test="contains($netstring,'192.168.0.1') and
727 contains($netstring,'Gateway')">
728 <xsl:call-template name="outputsysdnet">
729 <xsl:with-param name="netstring"
730 select="substring-before($netstring,'192.168.0.1')"/>
731 </xsl:call-template>
732 <xsl:value-of select="$gateway"/>
733 <xsl:call-template name="outputsysdnet">
734 <xsl:with-param name="netstring"
735 select="substring-after($netstring,'192.168.0.1')"/>
736 </xsl:call-template>
737 </xsl:when>
738 <xsl:when test="contains($netstring,'192.168.0.1') and
739 not(contains($netstring,'Gateway'))">
740 <xsl:call-template name="outputsysdnet">
741 <xsl:with-param name="netstring"
742 select="substring-before($netstring,'192.168.0.1')"/>
743 </xsl:call-template>
744 <xsl:value-of select="$nameserver1"/>
745 <xsl:text>
746DNS=</xsl:text>
747 <xsl:value-of select="$nameserver2"/>
748 <xsl:call-template name="outputsysdnet">
749 <xsl:with-param name="netstring"
750 select="substring-after($netstring,'192.168.0.1')"/>
751 </xsl:call-template>
752 </xsl:when>
753 <xsl:when test="contains($netstring,'192.168.0.2')">
754 <xsl:call-template name="outputsysdnet">
755 <xsl:with-param name="netstring"
756 select="substring-before($netstring,'192.168.0.2')"/>
757 </xsl:call-template>
758 <xsl:value-of select="$ip"/>
759 <xsl:call-template name="outputsysdnet">
760 <xsl:with-param name="netstring"
761 select="substring-after($netstring,'192.168.0.2')"/>
762 </xsl:call-template>
763 </xsl:when>
764 <xsl:when test="contains($netstring,'24')">
765 <xsl:call-template name="outputsysdnet">
766 <xsl:with-param name="netstring"
767 select="substring-before($netstring,'24')"/>
768 </xsl:call-template>
769 <xsl:value-of select="$prefix"/>
770 <xsl:call-template name="outputsysdnet">
771 <xsl:with-param name="netstring"
772 select="substring-after($netstring,'24')"/>
773 </xsl:call-template>
774 </xsl:when>
775 <xsl:when test="contains($netstring,'&lt;Your Domain Name&gt;')">
776 <xsl:call-template name="outputsysdnet">
777 <xsl:with-param name="netstring"
778 select="substring-before($netstring,'&lt;Your Domain Name&gt;')"/>
779 </xsl:call-template>
780 <xsl:value-of select="$domain"/>
781 <xsl:call-template name="outputsysdnet">
782 <xsl:with-param name="netstring"
783 select="substring-after($netstring,'&lt;Your Domain Name&gt;')"/>
784 </xsl:call-template>
785 </xsl:when>
786 <xsl:otherwise>
787 <xsl:value-of select="$netstring"/>
788 </xsl:otherwise>
789 </xsl:choose>
790 </xsl:template>
791
792 <xsl:template name="outputsysvconsole">
793 <!-- We suppose that book example has the following values:
794 - KEYMAP: bg_bds-utf8
795 - FONT: LatArCyrHeb-16
796 Change below if book changes -->
797 <xsl:param name="consolestring" select="''"/>
798 <xsl:choose>
799 <xsl:when test="contains($consolestring,'bg_bds-utf8')">
800 <xsl:call-template name="outputsysvconsole">
801 <xsl:with-param
802 name="consolestring"
803 select="substring-before($consolestring,'bg_bds-utf8')"/>
804 </xsl:call-template>
805 <xsl:value-of select="$keymap"/>
806 <xsl:call-template name="outputsysvconsole">
807 <xsl:with-param
808 name="consolestring"
809 select="substring-after($consolestring,'bg_bds-utf8')"/>
810 </xsl:call-template>
811 </xsl:when>
812 <xsl:when test="contains($consolestring,'LatArCyrHeb-16')">
813 <xsl:call-template name="outputsysvconsole">
814 <xsl:with-param
815 name="consolestring"
816 select="substring-before($consolestring,'LatArCyrHeb-16')"/>
817 </xsl:call-template>
818 <xsl:value-of select="$font"/>
819 <xsl:text>"
820LOGLEVEL="</xsl:text>
821 <xsl:copy-of select="$log-level"/>
822 <xsl:call-template name="outputsysvconsole">
823 <xsl:with-param
824 name="consolestring"
825 select="substring-after($consolestring,'LatArCyrHeb-16')"/>
826 </xsl:call-template>
827 </xsl:when>
828 <xsl:otherwise>
829 <xsl:copy-of select="$consolestring"/>
830 </xsl:otherwise>
831 </xsl:choose>
832 </xsl:template>
833
834 <xsl:template name="outputsysdconsole">
835 <!-- We suppose that book example has the following values:
836 - KEYMAP: de-latin1
837 - FONT: Lat2-Terminus16
838 Change below if book changes -->
839 <xsl:param name="consolestring" select="''"/>
840 <xsl:choose>
841 <xsl:when test="contains($consolestring,'de-latin1')">
842 <xsl:call-template name="outputsysdconsole">
843 <xsl:with-param
844 name="consolestring"
845 select="substring-before($consolestring,'de-latin1')"/>
846 </xsl:call-template>
847 <xsl:value-of select="$keymap"/>
848 <xsl:call-template name="outputsysdconsole">
849 <xsl:with-param
850 name="consolestring"
851 select="substring-after($consolestring,'de-latin1')"/>
852 </xsl:call-template>
853 </xsl:when>
854 <xsl:when test="contains($consolestring,'Lat2-Terminus16')">
855 <xsl:call-template name="outputsysdconsole">
856 <xsl:with-param
857 name="consolestring"
858 select="substring-before($consolestring,'Lat2-Terminus16')"/>
859 </xsl:call-template>
860 <xsl:value-of select="$font"/>
861 <xsl:call-template name="outputsysdconsole">
862 <xsl:with-param
863 name="consolestring"
864 select="substring-after($consolestring,'Lat2-Terminus16')"/>
865 </xsl:call-template>
866 </xsl:when>
867 <xsl:otherwise>
868 <xsl:copy-of select="$consolestring"/>
869 </xsl:otherwise>
870 </xsl:choose>
871 </xsl:template>
872
873 <xsl:template name="outputpkgdest">
874 <xsl:param name="outputstring" select="foo"/>
875 <xsl:choose>
876 <xsl:when test="contains($outputstring,'make ')">
877 <xsl:choose>
878 <xsl:when test="not(starts-with($outputstring,'make'))">
879 <xsl:call-template name="outputpkgdest">
880 <xsl:with-param name="outputstring"
881 select="substring-before($outputstring,'make')"/>
882 </xsl:call-template>
883 <xsl:call-template name="outputpkgdest">
884 <xsl:with-param
885 name="outputstring"
886 select="substring-after($outputstring,
887 substring-before($outputstring,'make'))"/>
888 </xsl:call-template>
889 </xsl:when>
890 <xsl:otherwise>
891 <xsl:choose>
892<!-- special cases (no DESTDIR) here -->
893 <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
894 <xsl:text>make install_root=$PKG_DEST -j1</xsl:text>
895 <xsl:value-of
896 select="substring-before(substring-after(string(),'make'),
897 'install')"/>
898 <xsl:text>install&#xA;</xsl:text>
899 </xsl:when>
900 <xsl:when test="ancestor::sect1[@id='ch-system-bzip2']">
901 <xsl:text>make PREFIX=$PKG_DEST/usr install&#xA;</xsl:text>
902 </xsl:when>
903 <xsl:when test="ancestor::sect1[@id='ch-system-sysklogd']">
904 <xsl:text>make BINDIR=$PKG_DEST/sbin prefix=$PKG_DEST install&#xA;</xsl:text>
905 </xsl:when>
906 <xsl:when test="ancestor::sect1[@id='ch-system-iproute2']">
907 <xsl:text>make DESTDIR=$PKG_DEST DOCDIR=</xsl:text>
908 <xsl:value-of
909 select="substring-before(substring-after(string(),'DOCDIR='),
910 'install')"/>
911 <xsl:text>install&#xA;</xsl:text>
912 </xsl:when>
913 <xsl:when test="ancestor::sect1[@id='ch-system-sysvinit']">
914 <xsl:text>make ROOT=$PKG_DEST</xsl:text>
915 <xsl:value-of
916 select="substring-before(substring-after(string(),'make'),
917 'install')"/>
918 <xsl:text>install&#xA;</xsl:text>
919 </xsl:when>
920 <xsl:when test="ancestor::sect1[@id='ch-bootable-kernel']">
921 <xsl:text>make INSTALL_MOD_PATH=$PKG_DEST</xsl:text>
922 <xsl:value-of
923 select="substring-before(substring-after(string(),'make'),
924 'install')"/>
925 <xsl:text>install&#xA;</xsl:text>
926 </xsl:when>
927 <xsl:otherwise>
928 <xsl:text>make DESTDIR=$PKG_DEST</xsl:text>
929 <xsl:call-template name="outputpkgdest">
930 <xsl:with-param
931 name="outputstring"
932 select="substring-after($outputstring,'make')"/>
933 </xsl:call-template>
934 </xsl:otherwise>
935 </xsl:choose>
936 </xsl:otherwise>
937 </xsl:choose>
938 </xsl:when>
939 <xsl:when test="contains($outputstring,'ninja install')">
940 <xsl:choose>
941 <xsl:when test="not(starts-with($outputstring,'ninja install'))">
942 <xsl:call-template name="outputpkgdest">
943 <xsl:with-param name="outputstring"
944 select="substring-before($outputstring,'ninja install')"/>
945 </xsl:call-template>
946 <xsl:call-template name="outputpkgdest">
947 <xsl:with-param
948 name="outputstring"
949 select="substring-after($outputstring,
950 substring-before($outputstring,'ninja install'))"/>
951 </xsl:call-template>
952 </xsl:when>
953 <xsl:otherwise> <!-- "ninja" is the first word and is followed by
954 "install"-->
955 <xsl:text>DESTDIR=$PKG_DEST ninja</xsl:text>
956 <xsl:call-template name="outputpkgdest">
957 <xsl:with-param
958 name="outputstring"
959 select="substring-after($outputstring,'ninja')"/>
960 </xsl:call-template>
961 </xsl:otherwise>
962 </xsl:choose>
963 </xsl:when>
964 <xsl:otherwise> <!-- no make nor ninja in this string -->
965 <xsl:choose>
966 <xsl:when test="contains($outputstring,'&gt;/') and
967 not(contains(substring-before($outputstring,'&gt;/'),' /'))">
968 <xsl:value-of select="substring-before($outputstring,'&gt;/')"/>
969 <xsl:text>&gt;$PKG_DEST/</xsl:text>
970 <xsl:call-template name="outputpkgdest">
971 <xsl:with-param name="outputstring" select="substring-after($outputstring,'&gt;/')"/>
972 </xsl:call-template>
973 </xsl:when>
974 <xsl:when test="contains($outputstring,' /')">
975 <xsl:value-of select="substring-before($outputstring,' /')"/>
976 <xsl:text> $PKG_DEST/</xsl:text>
977 <xsl:call-template name="outputpkgdest">
978 <xsl:with-param name="outputstring" select="substring-after($outputstring,' /')"/>
979 </xsl:call-template>
980 </xsl:when>
981 <xsl:otherwise>
982 <xsl:value-of select="$outputstring"/>
983 </xsl:otherwise>
984 </xsl:choose>
985 </xsl:otherwise>
986 </xsl:choose>
987 </xsl:template>
988
989 <xsl:variable name="APOS">'</xsl:variable>
990 <xsl:template name="output-wrap">
991 <xsl:param name="commands" select="''"/>
992 <xsl:choose>
993 <xsl:when test="contains($commands,string($APOS))">
994 <xsl:call-template name="output-wrap">
995 <xsl:with-param name="commands"
996 select="substring-before($commands,string($APOS))"/>
997 </xsl:call-template>
998 <xsl:text>'\''</xsl:text>
999 <xsl:call-template name="output-wrap">
1000 <xsl:with-param name="commands"
1001 select="substring-after($commands,string($APOS))"/>
1002 </xsl:call-template>
1003 </xsl:when>
1004 <xsl:otherwise>
1005 <xsl:value-of select="$commands"/>
1006 </xsl:otherwise>
1007 </xsl:choose>
1008 </xsl:template>
1009
1010 <xsl:template name="comment-strip">
1011 <xsl:param name="instructions" select="''"/>
1012 <xsl:choose>
1013 <xsl:when test="contains($instructions,'&#xA;')">
1014 <xsl:call-template name="comment-strip">
1015 <xsl:with-param name="instructions"
1016 select="substring-before($instructions,'&#xA;')"/>
1017 </xsl:call-template>
1018 <xsl:call-template name="comment-strip">
1019 <xsl:with-param name="instructions"
1020 select="substring-after($instructions,'&#xA;')"/>
1021 </xsl:call-template>
1022 </xsl:when>
1023 <xsl:when test="contains($instructions,'\*.la')">
1024 <xsl:if test="$del-la-files='n'">
1025 <xsl:text># </xsl:text>
1026 </xsl:if>
1027 <xsl:value-of select="$instructions"/>
1028 <xsl:text>&#xA;</xsl:text>
1029 </xsl:when>
1030 <xsl:when test="contains($instructions,'strip ')">
1031 <xsl:if test="$strip='n'">
1032 <xsl:text># </xsl:text>
1033 </xsl:if>
1034 <xsl:value-of select="$instructions"/>
1035 <xsl:text> || true&#xA;</xsl:text>
1036 </xsl:when>
1037 <xsl:otherwise>
1038 <xsl:value-of select="$instructions"/>
1039 <xsl:text>&#xA;</xsl:text>
1040 </xsl:otherwise>
1041 </xsl:choose>
1042 </xsl:template>
1043
1044 <xsl:template name="comment-test">
1045 <xsl:param name="instructions" select="''"/>
1046 <xsl:choose>
1047 <xsl:when test="contains($instructions,'&#xA;')">
1048 <xsl:call-template name="comment-test">
1049 <xsl:with-param name="instructions"
1050 select="substring-before($instructions,'&#xA;')"/>
1051 </xsl:call-template>
1052 <xsl:call-template name="comment-test">
1053 <xsl:with-param name="instructions"
1054 select="substring-after($instructions,'&#xA;')"/>
1055 </xsl:call-template>
1056 </xsl:when>
1057 <xsl:otherwise>
1058 <xsl:if test="$testsuite = '0' or
1059 $testsuite = '1' and
1060 not(ancestor::sect1[@id='ch-system-gcc']) and
1061 not(ancestor::sect1[@id='ch-system-glibc']) and
1062 not(ancestor::sect1[@id='ch-system-gmp']) and
1063 not(ancestor::sect1[@id='ch-system-mpfr']) and
1064 not(ancestor::sect1[@id='ch-system-binutils']) or
1065 $testsuite = '2' and
1066 ancestor::chapter[@id='chapter-temporary-tools']">
1067 <xsl:text># </xsl:text>
1068 </xsl:if>
1069 <xsl:choose>
1070 <xsl:when test="$bomb-testsuite = 'n'">
1071 <xsl:choose>
1072 <xsl:when test="contains(string(), 'make -k')">
1073 <xsl:value-of select="$instructions"/>
1074 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
1075 </xsl:when>
1076 <xsl:when test="contains($instructions, 'make')">
1077 <xsl:value-of select="substring-before($instructions, 'make')"/>
1078 <xsl:text>make -k</xsl:text>
1079 <xsl:value-of select="substring-after($instructions, 'make')"/>
1080 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
1081 </xsl:when>
1082 <xsl:otherwise>
1083 <xsl:value-of select="$instructions"/>
1084 <xsl:if
1085 test="not(contains($instructions, '&gt;&gt;')) and
1086 substring($instructions,
1087 string-length($instructions)) != '\'">
1088 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
1089 </xsl:if>
1090 <xsl:text>&#xA;</xsl:text>
1091 </xsl:otherwise>
1092 </xsl:choose>
1093 </xsl:when>
1094 <xsl:otherwise>
1095 <!-- bomb-testsuite != 'n'-->
1096 <xsl:choose>
1097 <xsl:when test="contains($instructions, 'make -k')">
1098 <xsl:value-of select="$instructions"/>
1099 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
1100 </xsl:when>
1101 <xsl:otherwise>
1102 <xsl:value-of select="$instructions"/>
1103 <xsl:if test="not(contains($instructions, '&gt;&gt;')) and
1104 substring($instructions,
1105 string-length($instructions)) != '\'">
1106 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
1107 </xsl:if>
1108 <xsl:text>&#xA;</xsl:text>
1109 </xsl:otherwise>
1110 </xsl:choose>
1111 </xsl:otherwise> <!-- end not bomb-test=n -->
1112 </xsl:choose>
1113 </xsl:otherwise>
1114 </xsl:choose>
1115 </xsl:template>
1116
1117 <xsl:template name="basename">
1118 <xsl:param name="path" select="''"/>
1119 <xsl:choose>
1120 <xsl:when test="contains($path,'/') and substring-after($path,'/')!=''">
1121 <xsl:call-template name="basename">
1122 <xsl:with-param name="path" select="substring-after($path,'/')"/>
1123 </xsl:call-template>
1124 </xsl:when>
1125 <xsl:when test="contains($path,'/') and substring-after($path,'/')=''">
1126 <xsl:value-of select="substring-before($path,'/')"/>
1127 </xsl:when>
1128 <xsl:otherwise>
1129 <xsl:value-of select="$path"/>
1130 </xsl:otherwise>
1131 </xsl:choose>
1132 </xsl:template>
1133
1134 <xsl:template name="start-script">
1135 <xsl:param name="order" select="'073'"/>
1136 <xsl:text>
1137<!-- save the timer, so that unpacking, and du is not counted -->
1138PREV_SEC=${SECONDS}
1139 <!-- get the location of the system root -->
1140if [ -h /tools ]; then
1141 ROOT=$(dirname $(readlink /tools))/
1142else
1143 ROOT=/
1144fi
1145SCRIPT_ROOT=</xsl:text>
1146 <xsl:copy-of select="$script-root"/>
1147 <xsl:text>
1148</xsl:text>
1149 <xsl:if test="sect2[@role='installation']">
1150 <xsl:text>
1151SRC_DIR=${ROOT}sources
1152<!-- Set variables, for use by the Makefile and package manager -->
1153VERSION=</xsl:text><!-- needed for Makefile, and may be used in PackInstall-->
1154 <xsl:copy-of select=".//sect1info/productnumber/text()"/>
1155 <xsl:text>
1156PKG_DEST=${SRC_DIR}/</xsl:text>
1157 <xsl:copy-of select="$order"/>
1158 <xsl:text>-</xsl:text>
1159 <xsl:copy-of select=".//sect1info/productname/text()"/>
1160 <xsl:text>
1161<!-- Get the tarball name from sect1info -->
1162PACKAGE=</xsl:text>
1163 <xsl:call-template name="basename">
1164 <xsl:with-param name="path" select=".//sect1info/address/text()"/>
1165 </xsl:call-template>
1166 <xsl:if test = "( ../@id != 'chapter-temporary-tools' or
1167 starts-with(@id,'ch-system') ) and $pkgmngt = 'y'">
1168 <xsl:text>
1169source ${ROOT}${SCRIPT_ROOT}/packInstall.sh
1170export -f packInstall</xsl:text>
1171 <xsl:if test="$wrap-install='y'">
1172 <xsl:text>
1173export -f wrapInstall
1174</xsl:text>
1175 </xsl:if>
1176 </xsl:if>
1177<!-- Get the build directory name and clean remnants of previous attempts -->
1178 <xsl:text>
1179cd $SRC_DIR
1180PKGDIR=$(tar -tf $PACKAGE | head -n1 | sed 's@^./@@;s@/.*@@')
1181export PKGDIR VERSION PKG_DEST
1182
1183if [ -d "$PKGDIR" ]; then rm -rf $PKGDIR; fi
1184if [ -d "${PKGDIR%-*}-build" ]; then rm -rf ${PKGDIR%-*}-build; fi
1185</xsl:text>
1186 </xsl:if>
1187 <xsl:text>
1188echo "KB: $(du -skx --exclude=lost+found --exclude=var/lib --exclude=$SCRIPT_ROOT $ROOT)"
1189</xsl:text>
1190 <xsl:if test="sect2[@role='installation']">
1191 <xsl:text>
1192<!-- At last unpack and change directory -->
1193tar -xf $PACKAGE
1194cd $PKGDIR
1195</xsl:text>
1196 </xsl:if>
1197 <xsl:text>SECONDS=${PREV_SEC}
1198
1199# Start of LFS book script
1200</xsl:text>
1201 </xsl:template>
1202
1203 <xsl:template name="end-script">
1204 <xsl:text>
1205# End of LFS book script
1206
1207echo "KB: $(du -skx --exclude=lost+found --exclude=var/lib --exclude=$SCRIPT_ROOT $ROOT)"
1208</xsl:text>
1209 <xsl:if test="sect2[@role='installation']">
1210 <xsl:text>cd $SRC_DIR
1211rm -rf $PKGDIR
1212if [ -d "${PKGDIR%-*}-build" ]; then rm -rf ${PKGDIR%-*}-build; fi
1213</xsl:text>
1214 </xsl:if>
1215 </xsl:template>
1216
1217</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.