source: LFS/lfs.xsl@ 1b02a9a

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