source: LFS/lfs.xsl@ 7072e1f

2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since 7072e1f was 7072e1f, checked in by Thomas Pegg <thomasp@…>, 13 years ago

Commit Pierre Labastie's patch for including package management support in jhalfs. NOTE: Package management is by default disabled.

  • Property mode set to 100644
File size: 20.1 KB
RevLine 
[7072e1f]1<?xml version="1.0" encoding="ISO-8859-1"?>
[db181c47]2
[877cc6a]3<!-- $Id$ -->
4
[7072e1f]5<xsl:stylesheet
6 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
7 xmlns:exsl="http://exslt.org/common"
8 extension-element-prefixes="exsl"
9 version="1.0">
[557fe91]10
[7072e1f]11 <!-- use package management ?
12 n = no, original behavior
13 y = yes, add PKG_DEST to scripts in install commands of chapter06-08
14 -->
15 <xsl:param name="pkgmngt" select="n"/>
16
[31d6944]17 <!-- Run test suites?
18 0 = none
19 1 = only chapter06 Glibc, GCC and Binutils testsuites
20 2 = all chapter06 testsuites
[28f4756]21 3 = all chapter05 and chapter06 testsuites
22 -->
[31d6944]23 <xsl:param name="testsuite" select="1"/>
[01e51a1]24
[28f4756]25 <!-- Bomb on test suites failures?
[401f81e]26 n = no, I want to build the full system and review the logs
27 y = yes, bomb at the first test suite failure to can review the build dir
[28f4756]28 -->
[401f81e]29 <xsl:param name="bomb-testsuite" select="n"/>
[28f4756]30
[7072e1f]31 <!-- Install vim-lang package? OBSOLETE should always be 'n'-->
32 <xsl:param name="vim-lang" select="n"/>
33
[877cc6a]34 <!-- Time zone -->
[a229600]35 <xsl:param name="timezone" select="GMT"/>
[7072e1f]36
[877cc6a]37 <!-- Page size -->
38 <xsl:param name="page" select="letter"/>
[7072e1f]39
[877cc6a]40 <!-- Locale settings -->
[a229600]41 <xsl:param name="lang" select="C"/>
[7072e1f]42
[557fe91]43 <xsl:template match="/">
44 <xsl:apply-templates select="//sect1"/>
45 </xsl:template>
[7072e1f]46
[557fe91]47 <xsl:template match="sect1">
[7072e1f]48 <xsl:if test="(../@id='chapter-temporary-tools' or
[14eaa9f]49 ../@id='chapter-building-system' or
50 ../@id='chapter-bootscripts' or
51 ../@id='chapter-bootable') and
52 count(descendant::screen/userinput) &gt; 0 and
53 count(descendant::screen/userinput) &gt;
[7072e1f]54 count(descendant::screen[@role='nodump'])">
[c4cf6de]55 <!-- The dirs names -->
56 <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
57 <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
58 <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
59 <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
[7072e1f]60 <!-- The file names -->
61 <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
62 <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
63 <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
64 <!-- The build order -->
65 <xsl:variable name="position" select="position()"/>
66 <xsl:variable name="order">
67 <xsl:choose>
68 <xsl:when test="string-length($position) = 1">
69 <xsl:text>00</xsl:text>
70 <xsl:value-of select="$position"/>
71 </xsl:when>
72 <xsl:when test="string-length($position) = 2">
73 <xsl:text>0</xsl:text>
74 <xsl:value-of select="$position"/>
75 </xsl:when>
76 <xsl:otherwise>
77 <xsl:value-of select="$position"/>
78 </xsl:otherwise>
79 </xsl:choose>
80 </xsl:variable>
81 <!-- Inclusion of package manager scriptlets -->
82 <xsl:if test="@id='ch-tools-stripping' and $pkgmngt='y'">
83 <xsl:apply-templates
84 select="document('packageManager.xml')//sect1[@id='ch-tools-pkgmngt']"
85 mode="pkgmngt">
86 <xsl:with-param name="order" select="concat($order,'-1')"/>
87 <xsl:with-param name="dirname" select="$dirname"/>
88 </xsl:apply-templates>
89 </xsl:if>
90 <xsl:if test="@id='ch-system-strippingagain' and $pkgmngt='y'">
91 <xsl:apply-templates
92 select="document('packageManager.xml')//sect1[@id='ch-system-pkgmngt']"
93 mode="pkgmngt">
94 <xsl:with-param name="order" select="concat($order,'-1')"/>
95 <xsl:with-param name="dirname" select="$dirname"/>
96 </xsl:apply-templates>
97 </xsl:if>
98 <!-- Creating dirs and files -->
99 <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
100 <xsl:choose>
101 <xsl:when test="@id='ch-system-creatingdirs' or
102 @id='ch-system-createfiles' or
103 @id='ch-system-strippingagain'">
104 <xsl:text>#!/tools/bin/bash&#xA;set +h&#xA;</xsl:text>
105 </xsl:when>
106 <xsl:otherwise>
107 <xsl:text>#!/bin/bash&#xA;set +h&#xA;</xsl:text>
108 </xsl:otherwise>
109 </xsl:choose>
110 <xsl:if test="not(@id='ch-tools-stripping') and
111 not(@id='ch-system-strippingagain')">
112 <xsl:text>set -e&#xA;</xsl:text>
113 </xsl:if>
114 <xsl:text>&#xA;</xsl:text>
115 <xsl:if test="sect2[@role='installation']">
116 <xsl:text>cd $PKGDIR&#xA;</xsl:text>
117 </xsl:if>
118 <xsl:apply-templates
119 select=".//screen[not(@role) or
120 @role != 'nodump']/userinput[
121 @remap = 'pre' or
122 @remap = 'configure' or
123 @remap = 'make' or
124 @remap = 'test' and
125 not(current()/@id='ch-tools-dejagnu')]"/>
126 <xsl:if
127 test="ancestor::chapter[@id != 'chapter-temporary-tools'] and
128 $pkgmngt = 'y' and
129 descendant::screen[not(@role) or
130 @role != 'nodump']/userinput[
131 @remap='install']">
132 <xsl:text>mkdir -pv $PKG_DEST/{boot,etc,lib,bin,sbin}
133mkdir -pv $PKG_DEST/usr/{lib,bin,sbin,include}
134mkdir -pv $PKG_DEST/usr/share/{doc,info,man}
135mkdir -pv $PKG_DEST/usr/share/man/man{1..8}
136ln -sv share/{man,doc,info} $PKG_DEST/usr
137case $(uname -m) in
138 x86_64) ln -sv lib $PKG_DEST/lib64 &amp;&amp; ln -sv lib $PKG_DEST/usr/lib64 ;;
139esac
140</xsl:text>
141 </xsl:if>
142 <xsl:if test="@id = 'ch-system-glibc' and
143 $pkgmngt = 'y'">
144 <xsl:text>mkdir -pv $PKG_DEST/usr/include/{rpc,rpcsvc}
145</xsl:text>
146 </xsl:if>
147 <xsl:apply-templates
148 select=".//screen[not(@role) or
149 @role != 'nodump']/userinput[@remap = 'install']"/>
150 <xsl:if test="ancestor::chapter[@id != 'chapter-temporary-tools'] and
151 $pkgmngt = 'y' and
152 descendant::screen[not(@role) or
153 @role != 'nodump']/userinput[
154 @remap='install']">
155 <xsl:if test="@id = 'ch-system-man-pages'">
156<!-- those files are provided by the shadow package -->
157 <xsl:text>rm -fv $PKG_DEST/usr/share/man/{man3/getspnam.3,man5/passwd.5}
158</xsl:text>
[5f4982d]159 </xsl:if>
[7072e1f]160 <xsl:text>rm -fv $PKG_DEST/{,usr/}lib64
161rm -fv $PKG_DEST/usr/{man,doc,info}
162for dir in $PKG_DEST/usr/share/man/man{1..8}; do
163 [[ -z $(ls $dir) ]] &amp;&amp; rmdir -v $dir
164done
165for dir in $PKG_DEST/usr/share/{doc,info,man}; do
166 [[ -z $(ls $dir) ]] &amp;&amp; rmdir -v $dir
167done
168for dir in $PKG_DEST/usr/{lib,bin,sbin,include}; do
169 [[ -z $(ls $dir) ]] &amp;&amp; rmdir -v $dir
170done
171for dir in $PKG_DEST/{boot,etc,lib,bin,sbin}; do
172 [[ -z $(ls $dir) ]] &amp;&amp; rmdir -v $dir
173done
174packInstall
175rm -rf $PKG_DEST
176</xsl:text>
177 </xsl:if>
178 <xsl:if test="$testsuite='3' and @id='ch-tools-glibc' or @id='ch-system-glibc'">
179 <xsl:copy-of select="//userinput[@remap='locale-test']"/>
[5f4982d]180 <xsl:text>&#xA;</xsl:text>
[7072e1f]181 </xsl:if>
182 <xsl:apply-templates
183 select=".//screen[
184 not(@role) or
185 @role != 'nodump'
186 ]/userinput[
187 not(@remap) or
188 @remap='adjust' or
189 @remap='test' and current()/@id='ch-tools-dejagnu'
190 ]"/>
191 <xsl:if test="@id='ch-system-creatingdirs'">
192 <xsl:apply-templates
193 select="document('packageManager.xml')//sect1[
194 @id='ch-system-pkgmngt-creatingdirs'
195 ]//userinput"/>
196 </xsl:if>
197 <xsl:if test="@id='ch-system-createfiles'">
198 <xsl:apply-templates
199 select="document('packageManager.xml')//sect1[
200 @id='ch-system-pkgmngt-createfiles'
201 ]//userinput"/>
202 </xsl:if>
203 <xsl:if test="not(@id='ch-system-chroot') and
204 not(@id='ch-system-revisedchroot')">
205 <xsl:text>echo -e "\n\nTotalseconds: $SECONDS\n"&#xA;</xsl:text>
206 </xsl:if>
207 <xsl:text>exit&#xA;</xsl:text>
208 </exsl:document>
[c4cf6de]209 </xsl:if>
[557fe91]210 </xsl:template>
211
[7072e1f]212<xsl:template match="sect1" mode="pkgmngt">
213 <xsl:param name="dirname" select="chapter05"/>
214 <!-- The build order -->
215 <xsl:param name="order" select="062-1"/>
216<!-- The file names -->
217 <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
218 <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
219 <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
220 <!-- Creating dirs and files -->
221 <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
222 <xsl:text>#!/bin/bash
223set +h
224set -e
225
226cd $PKGDIR
227</xsl:text>
228 <xsl:apply-templates
229 select=".//screen[not(@role) or @role != 'nodump']/userinput[@remap != 'adjust']"
230 mode="pkgmngt"/>
231 <xsl:if test="@id = 'ch-system-pkgmngt'">
232 <xsl:text>packInstall
233rm -rf $PKG_DEST
234</xsl:text>
235 </xsl:if>
236 <xsl:apply-templates
237 select=".//screen[
238 not(@role) or
239 @role != 'nodump'
240 ]/userinput[
241 not(@remap) or
242 @remap='adjust'
243 ]"
244 mode="pkgmngt"/>
245 <xsl:text>
246echo -e "\n\nTotalseconds: $SECONDS\n"
247exit
248</xsl:text>
249 </exsl:document>
[557fe91]250 </xsl:template>
251
[7072e1f]252 <xsl:template match="userinput" mode="pkgmngt">
253 <xsl:apply-templates/>
254 <xsl:text>&#xA;</xsl:text>
255 </xsl:template>
256
257 <xsl:template match="userinput">
[3eb60fa]258 <xsl:choose>
[fd691b4]259 <!-- Copying the kernel config file -->
260 <xsl:when test="string() = 'make mrproper'">
261 <xsl:text>make mrproper&#xA;</xsl:text>
[7072e1f]262 <xsl:if test="ancestor::sect1[@id='ch-bootable-kernel']">
[bcfb3bf]263 <xsl:text>cp -v ../kernel-config .config&#xA;</xsl:text>
264 </xsl:if>
[92568bf]265 </xsl:when>
[7072e1f]266<!-- test instructions -->
267 <xsl:when test="@remap = 'test'">
[4afcedb]268 <xsl:choose>
269 <xsl:when test="$testsuite = '0'"/>
270 <xsl:when test="$testsuite = '1' and
271 not(ancestor::sect1[@id='ch-system-gcc']) and
272 not(ancestor::sect1[@id='ch-system-glibc']) and
[7072e1f]273 not(ancestor::sect1[@id='ch-system-gmp']) and
274 not(ancestor::sect1[@id='ch-system-mpfr']) and
[4afcedb]275 not(ancestor::sect1[@id='ch-system-binutils'])"/>
276 <xsl:when test="$testsuite = '2' and
277 ancestor::chapter[@id='chapter-temporary-tools']"/>
278 <xsl:otherwise>
279 <xsl:choose>
280 <xsl:when test="$bomb-testsuite = 'n'">
[7072e1f]281 <xsl:choose>
282 <!-- special case for glibc -->
283 <xsl:when test="contains(string(), 'glibc-check-log')">
284 <xsl:value-of
285 select="substring-before(string(),'2&gt;&amp;1')"/>
286 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
287 </xsl:when>
288 <xsl:when test="contains(string(), 'make -k')">
289 <xsl:apply-templates/>
290 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
291 </xsl:when>
292 <xsl:when test="contains(string(), 'make')">
293 <xsl:value-of select="substring-before(string(),'make')"/>
294 <xsl:text>make -k</xsl:text>
295 <xsl:value-of select="substring-after(string(),'make')"/>
296 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
297 </xsl:when>
298 <xsl:otherwise>
299 <xsl:apply-templates/>
300 <xsl:if test="not(contains(string(), '&gt;&gt;'))">
301 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
302 </xsl:if>
303 <xsl:text>&#xA;</xsl:text>
304 </xsl:otherwise>
305 </xsl:choose>
[4afcedb]306 </xsl:when>
307 <xsl:otherwise>
[7072e1f]308 <!-- bomb-testsuite != 'n'-->
309 <xsl:choose>
310 <!-- special case for glibc -->
311 <xsl:when test="contains(string(), 'glibc-check-log')">
312 <xsl:value-of
313 select="substring-before(string(),'2&gt;&amp;1')"/>
314 <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 &#xA;</xsl:text>
315 </xsl:when>
316 <xsl:otherwise>
317 <xsl:apply-templates/>
318 <xsl:if test="not(contains(string(), '&gt;&gt;'))">
319 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
320 </xsl:if>
321 <xsl:text>&#xA;</xsl:text>
322 </xsl:otherwise>
323 </xsl:choose>
[4afcedb]324 </xsl:otherwise>
325 </xsl:choose>
326 </xsl:otherwise>
327 </xsl:choose>
328 </xsl:when>
[7072e1f]329<!-- End of test instructions -->
[fd691b4]330 <!-- Don't stop on strip run -->
331 <xsl:when test="contains(string(),'strip ')">
[3eb60fa]332 <xsl:apply-templates/>
[fd691b4]333 <xsl:text> || true&#xA;</xsl:text>
[1f025ca]334 </xsl:when>
[7072e1f]335<!-- Package management -->
336<!-- Add $PKG_DEST to installation commands -->
337 <xsl:when test="@remap='install' and
338 not(ancestor::chapter[
339 @id='chapter-temporary-tools'
340 ])">
341 <xsl:choose>
342 <xsl:when test="$pkgmngt='n'">
343 <xsl:choose>
344 <xsl:when test="contains(string(),'firmware,udev')">
345 <xsl:text>if [[ ! -d /lib/udev/devices ]] ; then&#xA;</xsl:text>
346 <xsl:apply-templates/>
347 <xsl:text>&#xA;fi&#xA;</xsl:text>
348 </xsl:when>
349 <xsl:otherwise>
350 <xsl:apply-templates/>
351 <xsl:text>&#xA;</xsl:text>
352 </xsl:otherwise>
353 </xsl:choose>
354 </xsl:when>
355 <xsl:otherwise><!--pkgmngt = 'y'-->
356 <xsl:choose>
357 <xsl:when test="./literal">
358 <xsl:call-template name="outputpkgdest">
359 <xsl:with-param name="outputstring"
360 select="text()[1]"/>
361 </xsl:call-template>
362 <xsl:apply-templates select="literal"/>
363 <xsl:call-template name="outputpkgdest">
364 <xsl:with-param name="outputstring"
365 select="text()[2]"/>
366 </xsl:call-template>
367 </xsl:when>
368 <xsl:otherwise>
369 <xsl:call-template name="outputpkgdest">
370 <xsl:with-param name="outputstring" select="string()"/>
371 </xsl:call-template>
372 </xsl:otherwise>
373 </xsl:choose>
374 </xsl:otherwise>
375 </xsl:choose>
376 </xsl:when>
377 <!-- End addition for package management -->
[fd691b4]378 <!-- The rest of commands -->
[1f025ca]379 <xsl:otherwise>
380 <xsl:apply-templates/>
[fd691b4]381 <xsl:text>&#xA;</xsl:text>
[1f025ca]382 </xsl:otherwise>
383 </xsl:choose>
384 </xsl:template>
[7072e1f]385
[557fe91]386 <xsl:template match="replaceable">
[a41ce58]387 <xsl:choose>
[2a54650]388 <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
[877cc6a]389 <xsl:value-of select="$timezone"/>
[2a54650]390 </xsl:when>
[a41ce58]391 <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
[877cc6a]392 <xsl:value-of select="$page"/>
[a41ce58]393 </xsl:when>
[81a7fb8]394 <xsl:when test="contains(string(.),'&lt;ll&gt;_&lt;CC&gt;')">
395 <xsl:value-of select="$lang"/>
396 </xsl:when>
[a41ce58]397 <xsl:otherwise>
398 <xsl:text>**EDITME</xsl:text>
399 <xsl:apply-templates/>
400 <xsl:text>EDITME**</xsl:text>
401 </xsl:otherwise>
402 </xsl:choose>
[557fe91]403 </xsl:template>
[7072e1f]404
405 <xsl:template name="outputpkgdest">
406 <xsl:param name="outputstring" select="foo"/>
407 <xsl:choose>
408 <xsl:when test="contains($outputstring,'make ')">
409 <xsl:choose>
410 <xsl:when test="not(starts-with($outputstring,'make'))">
411 <xsl:call-template name="outputpkgdest">
412 <xsl:with-param name="outputstring"
413 select="substring-before($outputstring,'make')"/>
414 </xsl:call-template>
415 <xsl:call-template name="outputpkgdest">
416 <xsl:with-param
417 name="outputstring"
418 select="substring-after($outputstring,
419 substring-before($outputstring,'make'))"/>
420 </xsl:call-template>
421 </xsl:when>
422 <xsl:otherwise>
423 <xsl:choose>
424<!-- special cases (no DESTDIR) here -->
425 <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
426 <xsl:text>make install_root=$PKG_DEST -j1</xsl:text>
427 <xsl:value-of
428 select="substring-before(substring-after(string(),'make'),
429 'install')"/>
430 <xsl:text>install&#xA;</xsl:text>
431 </xsl:when>
432 <xsl:when test="ancestor::sect1[@id='ch-system-bzip2']">
433 <xsl:text>make PREFIX=$PKG_DEST/usr install&#xA;</xsl:text>
434 </xsl:when>
435 <xsl:when test="ancestor::sect1[@id='ch-system-sysklogd']">
436 <xsl:text>make BINDIR=$PKG_DEST/sbin prefix=$PKG_DEST install&#xA;</xsl:text>
437 </xsl:when>
438 <xsl:when test="ancestor::sect1[@id='ch-system-iproute2']">
439 <xsl:text>make DESTDIR=$PKG_DEST</xsl:text>
440 <xsl:value-of
441 select="substring-before(substring-after(string(),'DESTDIR='),
442 'install')"/>
443 <xsl:text>install&#xA;</xsl:text>
444 </xsl:when>
445 <xsl:when test="ancestor::sect1[@id='ch-system-sysvinit']">
446 <xsl:text>make ROOT=$PKG_DEST</xsl:text>
447 <xsl:value-of
448 select="substring-before(substring-after(string(),'make'),
449 'install')"/>
450 <xsl:text>install&#xA;</xsl:text>
451 </xsl:when>
452 <xsl:when test="ancestor::sect1[@id='ch-bootable-kernel']">
453 <xsl:text>make INSTALL_MOD_PATH=$PKG_DEST</xsl:text>
454 <xsl:value-of
455 select="substring-before(substring-after(string(),'make'),
456 'install')"/>
457 <xsl:text>install&#xA;</xsl:text>
458 </xsl:when>
459 <xsl:otherwise>
460 <xsl:text>make DESTDIR=$PKG_DEST</xsl:text>
461 <xsl:call-template name="outputpkgdest">
462 <xsl:with-param
463 name="outputstring"
464 select="substring-after($outputstring,'make')"/>
465 </xsl:call-template>
466 </xsl:otherwise>
467 </xsl:choose>
468 </xsl:otherwise>
469 </xsl:choose>
470 </xsl:when>
471 <xsl:otherwise> <!-- no make in this string -->
472 <xsl:choose>
473 <xsl:when test="contains($outputstring,'&gt;/') and
474 not(contains(substring-before($outputstring,'&gt;/'),' /'))">
475 <xsl:value-of select="substring-before($outputstring,'&gt;/')"/>
476 <xsl:text>&gt;$PKG_DEST/</xsl:text>
477 <xsl:call-template name="outputpkgdest">
478 <xsl:with-param name="outputstring" select="substring-after($outputstring,'&gt;/')"/>
479 </xsl:call-template>
480 </xsl:when>
481 <xsl:when test="contains($outputstring,' /')">
482 <xsl:value-of select="substring-before($outputstring,' /')"/>
483 <xsl:text> $PKG_DEST/</xsl:text>
484 <xsl:call-template name="outputpkgdest">
485 <xsl:with-param name="outputstring" select="substring-after($outputstring,' /')"/>
486 </xsl:call-template>
487 </xsl:when>
488 <xsl:otherwise>
489 <xsl:value-of select="$outputstring"/>
490 <xsl:text>&#xA;</xsl:text>
491 </xsl:otherwise>
492 </xsl:choose>
493 </xsl:otherwise>
494 </xsl:choose>
495 </xsl:template>
[557fe91]496</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.