source: LFS/lfs.xsl@ 4b80795

trunk
Last change on this file since 4b80795 was 4b80795, checked in by Xi Ruoyao <xry111@…>, 3 months ago

Fix --from lfs removal when there's only one occurence of it

This code path has been incorrect but the vanilla book does not invoke
it. But fix it anyway for customized LFS branches.

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