source: LFS/lfs.xsl@ cff36a7

ablfs-more trunk
Last change on this file since cff36a7 was 3c43655, checked in by Pierre Labastie <pierre.labastie@…>, 8 months ago

Only replace $(nproc) in scriptlets

There is no more $(nproc
echo 1). Note that we may replace

it with $(nproc) if using all cores, so don't replace it in
the comment-test template (otherwise we have infinite recursion).

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