source: LFS/lfs.xsl@ 6f74ca1

ablfs-more legacy trunk
Last change on this file since 6f74ca1 was 88a8275, checked in by Pierre Labastie <pierre@…>, 4 years ago

lfs.xsl: mode=pkgmngt: use $pos and not position() when calling

start-script

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