source: BLFS/xsl/scripts.xsl@ dfc023a

ablfs-more legacy trunk
Last change on this file since dfc023a was c048987, checked in by Pierre Labastie <pierre@…>, 5 years ago

BLFS: fix generation of install and test instructions (ticket #1721):

  • add a gen-install.xsl stylesheet for grouping all cases
  • add a mode="installation" attribute for templates
  • rewrite sect2 template so that the right templates are applied
  • adapt other templates so that they are compatible
  • rewording of some comments (no direct relation with the ticket)
  • Property mode set to 100644
File size: 32.8 KB
Line 
1<?xml version="1.0"?>
2
3<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:exsl="http://exslt.org/common"
5 extension-element-prefixes="exsl"
6 version="1.0">
7
8<!-- $Id$ -->
9
10<!-- XSLT stylesheet to create shell scripts from "linear build" BLFS books. -->
11
12<!-- parameters and global variables -->
13 <!-- Check whether the book is sysv or systemd -->
14 <xsl:variable name="rev">
15 <xsl:choose>
16 <xsl:when test="//bookinfo/title/phrase[@revision='systemd']">
17 systemd
18 </xsl:when>
19 <xsl:otherwise>
20 sysv
21 </xsl:otherwise>
22 </xsl:choose>
23 </xsl:variable>
24
25 <!-- Wrap "root" commands inside a wrapper function, allowing
26 "porg style" package management -->
27 <xsl:param name="wrap-install" select="'n'"/>
28
29 <!-- list of packages needing stats -->
30 <xsl:param name="list-stat" select="''"/>
31
32 <!-- Remove libtool .la files -->
33 <xsl:param name="del-la-files" select="'y'"/>
34
35 <!-- Build as user (y) or as root (n)? -->
36 <xsl:param name="sudo" select="'y'"/>
37
38 <!-- Localization in the form ll_CC.charmap@modifier (to be used in
39 bash shell startup scripts). ll, CC, and charmap must be present:
40 no way to use "C" or "POSIX". -->
41 <xsl:param name="language" select="'en_US.UTF-8'"/>
42
43 <!-- Break it in pieces -->
44 <xsl:variable name="lang-ll">
45 <xsl:copy-of select="substring-before($language,'_')"/>
46 </xsl:variable>
47 <xsl:variable name="lang-CC">
48 <xsl:copy-of
49 select="substring-before(substring-after($language,'_'),'.')"/>
50 </xsl:variable>
51 <xsl:variable name="lang-charmap">
52 <xsl:choose>
53 <xsl:when test="contains($language,'@')">
54 <xsl:copy-of
55 select="substring-before(substring-after($language,'.'),'@')"/>
56 </xsl:when>
57 <xsl:otherwise>
58 <xsl:copy-of select="substring-after($language,'.')"/>
59 </xsl:otherwise>
60 </xsl:choose>
61 </xsl:variable>
62 <xsl:variable name="lang-modifier">
63 <xsl:choose>
64 <xsl:when test="contains($language,'@')">
65 <xsl:copy-of select="concat('@',substring-after($language,'@'))"/>
66 </xsl:when>
67 <xsl:otherwise>
68 <xsl:copy-of select="''"/>
69 </xsl:otherwise>
70 </xsl:choose>
71 </xsl:variable>
72
73<!-- simple instructions for removing .la files. -->
74 <xsl:variable name="la-files-instr">
75
76for libdir in /lib /usr/lib $(find /opt -name lib); do
77 find $libdir -name \*.la \
78 ! -path \*ImageMagick\* \
79 -delete
80done
81
82</xsl:variable>
83
84 <xsl:variable name="list-stat-norm"
85 select="concat(' ', normalize-space($list-stat),' ')"/>
86
87<!-- To be able to use the single quote in tests -->
88 <xsl:variable name="APOS">'</xsl:variable>
89
90<!-- end parameters and global variables -->
91
92<!-- include the templates for the screen children of role="install" sect2 -->
93 <xsl:include href="gen-install.xsl"/>
94
95<!--=================== Begin processing ========================-->
96
97 <xsl:template match="/">
98 <xsl:apply-templates select="//sect1[@id != 'bootscripts' and
99 @id != 'systemd-units']"/>
100 </xsl:template>
101
102<!--=================== Master chunks code ======================-->
103
104 <xsl:template match="sect1">
105
106 <!-- The file names -->
107 <xsl:variable name="filename" select="@id"/>
108
109 <!-- The build order -->
110 <xsl:variable name="position" select="position()"/>
111 <xsl:variable name="order">
112 <xsl:choose>
113 <xsl:when test="string-length($position) = 1">
114 <xsl:text>00</xsl:text>
115 <xsl:value-of select="$position"/>
116 </xsl:when>
117 <xsl:when test="string-length($position) = 2">
118 <xsl:text>0</xsl:text>
119 <xsl:value-of select="$position"/>
120 </xsl:when>
121 <xsl:otherwise>
122 <xsl:value-of select="$position"/>
123 </xsl:otherwise>
124 </xsl:choose>
125 </xsl:variable>
126
127 <!-- Depuration code -->
128 <xsl:message>
129 <xsl:text>SCRIPT is </xsl:text>
130 <xsl:value-of select="concat($order,'-z-',$filename)"/>
131 <xsl:text>&#xA; FTPDIR is </xsl:text>
132 <xsl:value-of select="$filename"/>
133 <xsl:text>&#xA;&#xA;</xsl:text>
134 </xsl:message>
135
136 <!-- Creating the scripts -->
137 <exsl:document href="{$order}-z-{$filename}" method="text">
138 <xsl:text>#!/bin/bash
139set -e
140unset MAKELEVEL
141<!-- the above is needed for some packages -->
142</xsl:text>
143 <xsl:choose>
144 <!-- Package page -->
145 <xsl:when test="sect2[@role='package']">
146 <!-- We build in a subdirectory, whose name may be needed
147 if using package management (see envars.conf), so
148 "export" it -->
149 <xsl:text>export JH_PKG_DIR=</xsl:text>
150 <xsl:value-of select="$filename"/>
151 <xsl:text>
152SRC_DIR=${JH_SRC_ARCHIVE}${JH_SRC_SUBDIRS:+/${JH_PKG_DIR}}
153BUILD_DIR=${JH_BUILD_ROOT}${JH_BUILD_SUBDIRS:+/${JH_PKG_DIR}}
154mkdir -p $SRC_DIR
155mkdir -p $BUILD_DIR
156
157</xsl:text>
158
159<!-- If stats are requested, include some definitions and intitializations -->
160 <xsl:if test="contains($list-stat-norm,concat(' ',@id,' '))">
161 <xsl:text>INFOLOG=$(pwd)/info-${JH_PKG_DIR}
162TESTLOG=$(pwd)/test-${JH_PKG_DIR}
163unset MAKEFLAGS
164#MAKEFLAGS=-j4
165echo MAKEFLAGS: $MAKEFLAGS > $INFOLOG
166: > $TESTLOG
167PKG_DEST=${BUILD_DIR}/dest
168rm -rf $PKG_DEST
169
170</xsl:text>
171 </xsl:if>
172 <!-- Download code and build commands -->
173 <xsl:apply-templates select="sect2"/>
174 <!-- Clean-up -->
175 <xsl:text>cd $BUILD_DIR
176[[ -n "$JH_KEEP_FILES" ]] || </xsl:text>
177 <!-- In some case, some files in the build tree are owned
178 by root -->
179 <xsl:if test="$sudo='y'">
180 <xsl:text>sudo </xsl:text>
181 </xsl:if>
182 <xsl:text>rm -rf $JH_UNPACKDIR unpacked&#xA;&#xA;</xsl:text>
183 </xsl:when>
184 <!-- Non-package page -->
185 <xsl:otherwise>
186 <xsl:apply-templates select=".//screen" mode="not-pack"/>
187 </xsl:otherwise>
188 </xsl:choose>
189 <xsl:text>exit</xsl:text>
190 </exsl:document>
191 </xsl:template>
192
193<!--======================= Sub-sections code =======================-->
194
195 <xsl:template match="sect2">
196 <xsl:choose>
197
198 <xsl:when test="@role = 'package'">
199 <xsl:text>cd $SRC_DIR
200</xsl:text>
201 <!-- Download information is in bridgehead tags -->
202 <xsl:apply-templates select="bridgehead[@renderas='sect3']"/>
203 <xsl:text>&#xA;</xsl:text>
204 </xsl:when><!-- @role="package" -->
205
206 <xsl:when test="@role = 'qt4-prefix' or @role = 'qt5-prefix'">
207 <xsl:apply-templates select=".//screen[./userinput]"/>
208 </xsl:when>
209
210 <xsl:when test="@role = 'installation'">
211 <xsl:text>
212cd $BUILD_DIR
213find . -maxdepth 1 -mindepth 1 -type d | xargs </xsl:text>
214 <xsl:if test="$sudo='y'">
215 <xsl:text>sudo </xsl:text>
216 </xsl:if>
217 <xsl:text>rm -rf
218
219</xsl:text>
220<!-- If stats are requested, insert the start size -->
221 <xsl:if test="contains($list-stat-norm,concat(' ',../@id,' '))">
222 <xsl:text>echo Start Size: $(sudo du -skx --exclude home /) >> $INFOLOG
223
224</xsl:text>
225 </xsl:if>
226
227 <xsl:text>case $PACKAGE in
228 *.tar.gz|*.tar.bz2|*.tar.xz|*.tgz|*.tar.lzma)
229 tar -xvf $SRC_DIR/$PACKAGE &gt; unpacked
230 JH_UNPACKDIR=`grep '[^./]\+' unpacked | head -n1 | sed 's@^\./@@;s@/.*@@'`
231 ;;
232 *.tar.lz)
233 bsdtar -xvf $SRC_DIR/$PACKAGE 2&gt; unpacked
234 JH_UNPACKDIR=`head -n1 unpacked | cut -d" " -f2 | sed 's@^\./@@;s@/.*@@'`
235 ;;
236 *.zip)
237 zipinfo -1 $SRC_DIR/$PACKAGE &gt; unpacked
238 JH_UNPACKDIR="$(sed 's@/.*@@' unpacked | uniq )"
239 if test $(wc -w &lt;&lt;&lt; $JH_UNPACKDIR) -eq 1; then
240 unzip $SRC_DIR/$PACKAGE
241 else
242 JH_UNPACKDIR=${PACKAGE%.zip}
243 unzip -d $JH_UNPACKDIR $SRC_DIR/$PACKAGE
244 fi
245 ;;
246 *)
247 JH_UNPACKDIR=$JH_PKG_DIR-build
248 mkdir $JH_UNPACKDIR
249 cp $SRC_DIR/$PACKAGE $JH_UNPACKDIR
250 cp $(find . -mindepth 1 -maxdepth 1 -type l) $JH_UNPACKDIR
251 ;;
252esac
253export JH_UNPACKDIR
254cd $JH_UNPACKDIR&#xA;
255</xsl:text>
256<!-- If stats are requested, insert the start time -->
257 <xsl:if test="contains($list-stat-norm,concat(' ',../@id,' '))">
258 <xsl:text>echo Start Time: ${SECONDS} >> $INFOLOG
259
260</xsl:text>
261 </xsl:if>
262
263 <xsl:apply-templates
264 mode="installation"
265 select=".//screen[not(@role = 'nodump') and ./userinput] |
266 .//para/command[contains(text(),'check') or
267 contains(text(),'test')]"/>
268 <xsl:if test="$sudo = 'y'">
269 <xsl:text>sudo /sbin/</xsl:text>
270 </xsl:if>
271 <xsl:text>ldconfig&#xA;&#xA;</xsl:text>
272 </xsl:when><!-- @role="installation" -->
273
274 <xsl:when test="@role = 'configuration'">
275 <xsl:apply-templates mode="config"
276 select=".//screen[not(@role = 'nodump') and ./userinput]"/>
277 </xsl:when><!-- @role="configuration" -->
278
279 </xsl:choose>
280 </xsl:template>
281
282<!--==================== Download code =======================-->
283
284 <!-- template for extracting the filename from an url in the form:
285 proto://internet.name/dir1/.../dirn/filename?condition.
286 Needed, because substring-after(...,'/') returns only the
287 substring after the first '/'. -->
288 <xsl:template name="package_name">
289 <xsl:param name="url" select="foo"/>
290 <xsl:param name="sub-url" select="substring-after($url,'/')"/>
291 <xsl:choose>
292 <xsl:when test="contains($sub-url,'/')">
293 <xsl:call-template name="package_name">
294 <xsl:with-param name="url" select="$sub-url"/>
295 </xsl:call-template>
296 </xsl:when>
297 <xsl:otherwise>
298 <xsl:choose>
299 <xsl:when test="contains($sub-url,'?')">
300 <xsl:value-of select="substring-before($sub-url,'?')"/>
301 </xsl:when>
302 <xsl:otherwise>
303 <xsl:value-of select="$sub-url"/>
304 </xsl:otherwise>
305 </xsl:choose>
306 </xsl:otherwise>
307 </xsl:choose>
308 </xsl:template>
309
310 <!-- Generates the code to download a package, an additional package or
311 a patch. -->
312 <xsl:template name="download-file">
313 <xsl:param name="httpurl" select="''"/>
314 <xsl:param name="ftpurl" select="''"/>
315 <xsl:param name="md5" select="''"/>
316 <xsl:param name="varname" select="''"/>
317 <xsl:variable name="package">
318 <xsl:call-template name="package_name">
319 <xsl:with-param name="url">
320 <xsl:choose>
321 <xsl:when test="string-length($httpurl) &gt; 10">
322 <xsl:value-of select="$httpurl"/>
323 </xsl:when>
324 <xsl:otherwise>
325 <xsl:value-of select="$ftpurl"/>
326 </xsl:otherwise>
327 </xsl:choose>
328 </xsl:with-param>
329 </xsl:call-template>
330 </xsl:variable>
331 <xsl:variable name="first_letter"
332 select="translate(substring($package,1,1),
333 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
334 'abcdefghijklmnopqrstuvwxyz')"/>
335 <xsl:text>&#xA;</xsl:text>
336 <xsl:value-of select="$varname"/>
337 <xsl:text>=</xsl:text>
338 <xsl:value-of select="$package"/>
339 <xsl:text>&#xA;if [[ ! -f $</xsl:text>
340 <xsl:value-of select="$varname"/>
341 <xsl:text> ]] ; then
342 if [[ -f $JH_SRC_ARCHIVE/$</xsl:text>
343 <xsl:value-of select="$varname"/>
344 <xsl:text> ]] ; then&#xA;</xsl:text>
345 <xsl:text> cp $JH_SRC_ARCHIVE/$</xsl:text>
346 <xsl:value-of select="$varname"/>
347 <xsl:text> $</xsl:text>
348 <xsl:value-of select="$varname"/>
349 <xsl:text>
350 else&#xA;</xsl:text>
351 <!-- Download from upstream http -->
352 <xsl:if test="string-length($httpurl) &gt; 10">
353 <xsl:text> wget -T 30 -t 5 </xsl:text>
354 <xsl:value-of select="$httpurl"/>
355 <xsl:text> ||&#xA;</xsl:text>
356 </xsl:if>
357 <!-- Download from upstream ftp -->
358 <xsl:if test="string-length($ftpurl) &gt; 10">
359 <xsl:text> wget -T 30 -t 5 </xsl:text>
360 <xsl:value-of select="$ftpurl"/>
361 <xsl:text> ||&#xA;</xsl:text>
362 </xsl:if>
363 <!-- The FTP_SERVER mirror as a last resort -->
364 <xsl:text> wget -T 30 -t 5 ${JH_FTP_SERVER}svn/</xsl:text>
365 <xsl:value-of select="$first_letter"/>
366 <xsl:text>/$</xsl:text>
367 <xsl:value-of select="$varname"/>
368 <xsl:text>
369 fi
370fi
371</xsl:text>
372 <xsl:if test="string-length($md5) &gt; 10">
373 <xsl:text>echo "</xsl:text>
374 <xsl:value-of select="$md5"/>
375 <xsl:text>&#x20;&#x20;$</xsl:text>
376 <xsl:value-of select="$varname"/>
377 <xsl:text>" | md5sum -c -
378</xsl:text>
379 </xsl:if>
380<!-- link additional packages into $BUILD_DIR, because they are supposed to
381 be there-->
382 <xsl:if test="string($varname) != 'PACKAGE'">
383 <xsl:text>[[ "$SRC_DIR" != "$BUILD_DIR" ]] &amp;&amp; ln -sf $SRC_DIR/$</xsl:text>
384 <xsl:value-of select="$varname"/>
385 <xsl:text> $BUILD_DIR
386</xsl:text>
387 </xsl:if>
388 </xsl:template>
389
390 <!-- Extract the MD5 sum information -->
391 <xsl:template match="para" mode="md5">
392 <xsl:choose>
393 <xsl:when test="contains(substring-after(string(),'sum: '),'&#xA;')">
394 <xsl:value-of select="substring-before(substring-after(string(),'sum: '),'&#xA;')"/>
395 </xsl:when>
396 <xsl:otherwise>
397 <xsl:value-of select="substring-after(string(),'sum: ')"/>
398 </xsl:otherwise>
399 </xsl:choose>
400 </xsl:template>
401
402 <!-- We have several templates itemizedlist, depending on whether we
403 expect the package information, or additional package(s) or patch(es)
404 information. Select the appropriate mode here. -->
405 <xsl:template match="bridgehead">
406 <xsl:choose>
407 <!-- Special case for Openjdk -->
408 <xsl:when test="contains(string(),'Source Package Information')">
409 <xsl:apply-templates
410 select="following-sibling::itemizedlist[1]//simplelist">
411 <xsl:with-param name="varname" select="'PACKAGE'"/>
412 </xsl:apply-templates>
413 <xsl:apply-templates select="following-sibling::itemizedlist
414 [preceding-sibling::bridgehead[1]=current()
415 and position() &gt;1]//simplelist">
416 <xsl:with-param name="varname" select="'PACKAGE1'"/>
417 </xsl:apply-templates>
418 </xsl:when>
419 <!-- Package information -->
420 <xsl:when test="contains(string(),'Package Information')">
421 <xsl:apply-templates select="following-sibling::itemizedlist
422 [preceding-sibling::bridgehead[1]=current()]"
423 mode="package"/>
424 </xsl:when>
425 <!-- Additional package information -->
426 <!-- special case for llvm -->
427 <xsl:when test="contains(string(),'Optional Download')">
428 <xsl:apply-templates select="following-sibling::itemizedlist"
429 mode="additional"/>
430 </xsl:when>
431 <!-- All other additional packages have "Additional" -->
432 <xsl:when test="contains(string(),'Additional')">
433 <xsl:apply-templates select="following-sibling::itemizedlist"
434 mode="additional"/>
435 </xsl:when>
436 <!-- Do not do anything if the dev has created another type of
437 bridgehead. -->
438 <xsl:otherwise/>
439 </xsl:choose>
440 </xsl:template>
441
442 <!-- Call the download code template with appropriate parameters -->
443 <xsl:template match="itemizedlist" mode="package">
444 <xsl:call-template name="download-file">
445 <xsl:with-param name="httpurl">
446 <xsl:value-of select="./listitem[1]/para/ulink/@url"/>
447 </xsl:with-param>
448 <xsl:with-param name="ftpurl">
449 <xsl:value-of select="./listitem/para[contains(string(),'FTP')]/ulink/@url"/>
450 </xsl:with-param>
451 <xsl:with-param name="md5">
452 <xsl:apply-templates select="./listitem/para[contains(string(),'MD5')]"
453 mode="md5"/>
454 </xsl:with-param>
455 <xsl:with-param name="varname" select="'PACKAGE'"/>
456 </xsl:call-template>
457 </xsl:template>
458
459 <xsl:template match="itemizedlist" mode="additional">
460 <!-- The normal layout is "one listitem"<->"one url", but some devs
461 find amusing to have FTP and/or MD5sum listitems, or to
462 enclose the download information inside a simplelist tag... -->
463 <xsl:for-each select="listitem[.//ulink]">
464 <xsl:choose>
465 <!-- hopefully, there was a HTTP line before -->
466 <xsl:when test="contains(string(./para),'FTP')"/>
467 <xsl:when test=".//simplelist">
468 <xsl:apply-templates select=".//simplelist">
469 <xsl:with-param name="varname" select="'PACKAGE1'"/>
470 </xsl:apply-templates>
471 </xsl:when>
472 <xsl:otherwise>
473 <xsl:call-template name="download-file">
474 <xsl:with-param name="httpurl">
475 <xsl:value-of select="./para/ulink/@url"/>
476 </xsl:with-param>
477 <xsl:with-param name="ftpurl">
478 <xsl:value-of
479 select="following-sibling::listitem[1]/
480 para[contains(string(),'FTP')]/ulink/@url"/>
481 </xsl:with-param>
482 <xsl:with-param name="md5">
483 <xsl:apply-templates
484 select="following-sibling::listitem[position()&lt;3]/
485 para[contains(string(),'MD5')]"
486 mode="md5"/>
487 </xsl:with-param>
488 <xsl:with-param name="varname">
489 <xsl:choose>
490 <xsl:when test="contains(./para/ulink/@url,'.patch')">
491 <xsl:text>PATCH</xsl:text>
492 </xsl:when>
493 <xsl:otherwise>
494 <xsl:text>PACKAGE1</xsl:text>
495 </xsl:otherwise>
496 </xsl:choose>
497 </xsl:with-param>
498 </xsl:call-template>
499 </xsl:otherwise>
500 </xsl:choose>
501 </xsl:for-each>
502 </xsl:template>
503
504 <!-- the simplelist case. Hopefully, the layout is one member for
505 url, one for md5 and others for various information, that we do not
506 use -->
507 <xsl:template match="simplelist">
508 <xsl:param name="varname" select="'PACKAGE1'"/>
509 <xsl:call-template name="download-file">
510 <xsl:with-param name="httpurl" select=".//ulink/@url"/>
511 <xsl:with-param name="md5">
512 <xsl:value-of select="substring-after(member[contains(string(),'MD5')],'sum: ')"/>
513 </xsl:with-param>
514 <xsl:with-param name="varname" select="$varname"/>
515 </xsl:call-template>
516 </xsl:template>
517
518<!--====================== Non package code =========================-->
519
520 <xsl:template match="screen" mode="not-pack">
521 <xsl:choose>
522 <xsl:when test="ancestor::sect1[@id='postlfs-config-vimrc']">
523 <xsl:text>
524cat > ~/.vimrc &lt;&lt;EOF
525</xsl:text>
526 <xsl:apply-templates/>
527 <xsl:text>
528EOF
529</xsl:text>
530 </xsl:when>
531 <xsl:otherwise>
532 <xsl:apply-templates select="." mode="config"/>
533 </xsl:otherwise>
534 </xsl:choose>
535 </xsl:template>
536<!--======================== Commands code ==========================-->
537<!-- Code for installation instructions is in gen-install.xsl -->
538
539 <xsl:template match="screen">
540 <xsl:choose>
541<!-- instructions run as root (configuration mainly) -->
542 <xsl:when test="@role = 'root'">
543 <xsl:if test="not(preceding-sibling::screen[1][@role='root'])">
544 <xsl:if test="$sudo = 'y'">
545 <xsl:text>sudo -E sh &lt;&lt; ROOT_EOF&#xA;</xsl:text>
546 </xsl:if>
547 </xsl:if>
548 <xsl:apply-templates mode="root"/>
549 <xsl:if test="not(following-sibling::screen[1][@role='root'])">
550 <xsl:if test="$sudo = 'y'">
551 <xsl:text>&#xA;ROOT_EOF</xsl:text>
552 </xsl:if>
553 </xsl:if>
554 </xsl:when>
555<!-- then all the instructions run as user -->
556 <xsl:otherwise>
557 <xsl:apply-templates select="userinput"/>
558 </xsl:otherwise>
559 </xsl:choose>
560 <xsl:text>&#xA;</xsl:text>
561 </xsl:template>
562
563 <xsl:template name="set-bootpkg-dir">
564 <xsl:param name="bootpkg" select="'bootscripts'"/>
565 <xsl:param name="url" select="''"/>
566 <xsl:text>BOOTPKG_DIR=blfs-</xsl:text>
567 <xsl:copy-of select="$bootpkg"/>
568 <xsl:text>
569BOOTSRC_DIR=${JH_SRC_ARCHIVE}${JH_SRC_SUBDIRS:+/${BOOTPKG_DIR}}
570BOOTBUILD_DIR=${JH_BUILD_ROOT}${JH_BUILD_SUBDIRS:+/${BOOTPKG_DIR}}
571mkdir -p $BOOTSRC_DIR
572mkdir -p $BOOTBUILD_DIR
573
574pushd $BOOTSRC_DIR
575URL=</xsl:text>
576 <xsl:value-of select="$url"/>
577 <xsl:text>
578BOOTPACKG=$(basename $URL)
579if [[ ! -f $BOOTPACKG ]] ; then
580 if [[ -f $JH_SRC_ARCHIVE/$BOOTPACKG ]] ; then
581 cp $JH_SRC_ARCHIVE/$BOOTPACKG $BOOTPACKG
582 else
583 wget -T 30 -t 5 $URL
584 fi
585 rm -f $BOOTBUILD_DIR/unpacked
586fi
587
588cd $BOOTBUILD_DIR
589if [[ -e unpacked ]] ; then
590 BOOTUNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
591 if ! [[ -d $BOOTUNPACKDIR ]]; then
592 tar -xvf $BOOTSRC_DIR/$BOOTPACKG > unpacked
593 BOOTUNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
594 fi
595else
596 tar -xvf $BOOTSRC_DIR/$BOOTPACKG > unpacked
597 BOOTUNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
598fi
599cd $BOOTUNPACKDIR
600</xsl:text>
601 </xsl:template>
602
603 <xsl:template match="screen" mode="config">
604 <xsl:if test="preceding-sibling::para[1]/xref[@linkend='bootscripts']">
605 <xsl:call-template name="set-bootpkg-dir">
606 <xsl:with-param name="bootpkg" select="'bootscripts'"/>
607 <xsl:with-param name="url"
608 select="id('bootscripts')//itemizedlist//ulink/@url"/>
609 </xsl:call-template>
610 </xsl:if>
611 <xsl:if test="preceding-sibling::para[1]/xref[@linkend='systemd-units']">
612 <xsl:call-template name="set-bootpkg-dir">
613 <xsl:with-param name="bootpkg" select="'systemd-units'"/>
614 <xsl:with-param name="url"
615 select="id('systemd-units')//itemizedlist//ulink/@url"/>
616 </xsl:call-template>
617 </xsl:if>
618 <xsl:apply-templates select='.'/>
619 <xsl:if test="preceding-sibling::para[1]/xref[@linkend='bootscripts' or
620 @linkend='systemd-units']">
621 <xsl:text>
622popd</xsl:text>
623 </xsl:if>
624 <xsl:text>&#xA;</xsl:text>
625 </xsl:template>
626
627 <xsl:template match="command" mode="installation">
628 <xsl:variable name="ns" select="normalize-space(string())"/>
629 <xsl:variable name="first"
630 select="not(
631 boolean(
632 preceding-sibling::command[contains(text(),'check') or
633 contains(text(),'test')]))"/>
634 <xsl:variable name="last"
635 select="not(
636 boolean(
637 following-sibling::command[contains(text(),'check') or
638 contains(text(),'test')]))"/>
639 <xsl:choose>
640 <xsl:when test="contains($list-stat-norm,
641 concat(' ',ancestor::sect1/@id,' '))">
642 <xsl:if test="$first">
643 <xsl:text>
644echo Time after make: ${SECONDS} >> $INFOLOG
645echo Size after make: $(sudo du -skx --exclude home /) >> $INFOLOG
646echo Time before test: ${SECONDS} >> $INFOLOG
647
648</xsl:text>
649 </xsl:if>
650 </xsl:when>
651 <xsl:otherwise>
652 <xsl:text>#</xsl:text>
653 </xsl:otherwise>
654 </xsl:choose>
655 <xsl:choose>
656 <xsl:when test="contains($ns,'make')">
657 <xsl:value-of select="substring-before($ns,'make ')"/>
658 <xsl:text>make </xsl:text>
659 <xsl:if test="not(contains($ns,'-k'))">
660 <xsl:text>-k </xsl:text>
661 </xsl:if>
662 <xsl:value-of select="substring-after($ns,'make ')"/>
663 </xsl:when>
664 <xsl:otherwise>
665 <xsl:copy-of select="$ns"/>
666 </xsl:otherwise>
667 </xsl:choose>
668 <xsl:if test="contains($list-stat-norm,
669 concat(' ',ancestor::sect1/@id,' '))">
670 <xsl:text> &gt;&gt; $TESTLOG 2&gt;&amp;1</xsl:text>
671 </xsl:if>
672 <xsl:text> || true&#xA;</xsl:text>
673 <xsl:if test="contains($list-stat-norm,
674 concat(' ',ancestor::sect1/@id,' ')) and $last">
675 <xsl:text>
676echo Time after test: ${SECONDS} >> $INFOLOG
677echo Size after test: $(sudo du -skx --exclude home /) >> $INFOLOG
678echo Time before install: ${SECONDS} >> $INFOLOG
679
680</xsl:text>
681 </xsl:if>
682 </xsl:template>
683
684 <xsl:template match="userinput">
685 <xsl:apply-templates/>
686 </xsl:template>
687
688 <xsl:template match="text()" mode="root">
689 <xsl:call-template name="output-root">
690 <xsl:with-param name="out-string" select="string()"/>
691 </xsl:call-template>
692 </xsl:template>
693
694 <xsl:template name="output-root">
695 <xsl:param name="out-string" select="''"/>
696 <xsl:choose>
697 <xsl:when test="contains($out-string,'make ')">
698 <xsl:call-template name="output-root">
699 <xsl:with-param name="out-string"
700 select="substring-before($out-string,'make ')"/>
701 </xsl:call-template>
702 <xsl:text>make -j1 </xsl:text>
703 <xsl:call-template name="output-root">
704 <xsl:with-param name="out-string"
705 select="substring-after($out-string,'make ')"/>
706 </xsl:call-template>
707 </xsl:when>
708 <xsl:when test="contains($out-string,'$') and $sudo = 'y'">
709 <xsl:call-template name="output-root">
710 <xsl:with-param name="out-string"
711 select="substring-before($out-string,'$')"/>
712 </xsl:call-template>
713 <xsl:text>\$</xsl:text>
714 <xsl:call-template name="output-root">
715 <xsl:with-param name="out-string"
716 select="substring-after($out-string,'$')"/>
717 </xsl:call-template>
718 </xsl:when>
719 <xsl:when test="contains($out-string,'`') and $sudo = 'y'">
720 <xsl:call-template name="output-root">
721 <xsl:with-param name="out-string"
722 select="substring-before($out-string,'`')"/>
723 </xsl:call-template>
724 <xsl:text>\`</xsl:text>
725 <xsl:call-template name="output-root">
726 <xsl:with-param name="out-string"
727 select="substring-after($out-string,'`')"/>
728 </xsl:call-template>
729 </xsl:when>
730 <xsl:when test="contains($out-string,'\') and $sudo = 'y'">
731 <xsl:call-template name="output-root">
732 <xsl:with-param name="out-string"
733 select="substring-before($out-string,'\')"/>
734 </xsl:call-template>
735 <xsl:text>\\</xsl:text>
736 <xsl:call-template name="output-root">
737 <xsl:with-param name="out-string"
738 select="substring-after($out-string,'\')"/>
739 </xsl:call-template>
740 </xsl:when>
741 <xsl:otherwise>
742 <xsl:value-of select="$out-string"/>
743 </xsl:otherwise>
744 </xsl:choose>
745 </xsl:template>
746
747 <xsl:template match="replaceable">
748 <xsl:choose>
749<!-- When adding a user to a group, the book uses "username" in a replaceable
750 tag. Replace by the user name only if not running as root -->
751 <xsl:when test="contains(string(),'username') and $sudo='y'">
752 <xsl:text>$USER</xsl:text>
753 </xsl:when>
754<!-- The next three entries are for gpm. I guess those settings are OK
755 for a laptop or desktop. -->
756 <xsl:when test="contains(string(),'yourprotocol')">
757 <xsl:text>imps2</xsl:text>
758 </xsl:when>
759 <xsl:when test="contains(string(),'yourdevice')">
760 <xsl:text>/dev/input/mice</xsl:text>
761 </xsl:when>
762 <xsl:when test="contains(string(),'additional options')"/>
763<!-- the book has four fields for language. The language param is
764 broken into four pieces above. We use the results here. -->
765 <xsl:when test="contains(string(),'&lt;ll&gt;')">
766 <xsl:copy-of select="$lang-ll"/>
767 </xsl:when>
768 <xsl:when test="contains(string(),'&lt;CC&gt;')">
769 <xsl:copy-of select="$lang-CC"/>
770 </xsl:when>
771 <xsl:when test="contains(string(),'&lt;charmap&gt;')">
772 <xsl:copy-of select="$lang-charmap"/>
773 </xsl:when>
774 <xsl:when test="contains(string(),'@modifier')">
775 <xsl:copy-of select="$lang-modifier"/>
776 </xsl:when>
777<!-- At several places, the number of jobs is given as "N" in a replaceable
778 tag. We either detect "N" alone or &lt;N&gt; Replace N with 4. -->
779 <xsl:when test="contains(string(),'&lt;N&gt;') or string()='N'">
780 <xsl:text>4</xsl:text>
781 </xsl:when>
782<!-- Mercurial config file uses user_name. Replace only if non root.
783 Add a bogus mail field. That works for the proposed tests anyway. -->
784 <xsl:when test="contains(string(),'user_name') and $sudo='y'">
785 <xsl:text>$USER ${USER}@mail.bogus</xsl:text>
786 </xsl:when>
787<!-- Use the config for Gtk+3 as is -->
788 <xsl:when test="ancestor::sect1[@id='gtk3']">
789 <xsl:copy-of select="string()"/>
790 </xsl:when>
791<!-- Give 1Gb to fop. Hopefully, nobody has less RAM nowadays. -->
792 <xsl:when test="contains(string(),'RAM_Installed')">
793 <xsl:text>1024</xsl:text>
794 </xsl:when>
795 <xsl:otherwise>
796 <xsl:text>**EDITME</xsl:text>
797 <xsl:apply-templates/>
798 <xsl:text>EDITME**</xsl:text>
799 </xsl:otherwise>
800 </xsl:choose>
801 </xsl:template>
802
803 <xsl:template match="replaceable" mode="root">
804 <xsl:apply-templates select="."/>
805 </xsl:template>
806
807 <xsl:template name="output-destdir">
808 <xsl:apply-templates
809 select="userinput|following-sibling::screen[@role='root']/userinput"
810 mode="destdir"/>
811 <xsl:text>
812echo Time after install: ${SECONDS} >> $INFOLOG
813echo Size after install: $(sudo du -skx --exclude home /) >> $INFOLOG
814</xsl:text>
815 </xsl:template>
816
817 <xsl:template match="userinput" mode="destdir">
818 <xsl:choose>
819 <xsl:when test="./literal">
820 <xsl:call-template name="outputpkgdest">
821 <xsl:with-param name="outputstring" select="text()[1]"/>
822 </xsl:call-template>
823 <xsl:apply-templates select="literal"/>
824 <xsl:call-template name="outputpkgdest">
825 <xsl:with-param name="outputstring" select="text()[2]"/>
826 </xsl:call-template>
827 </xsl:when>
828 <xsl:otherwise>
829 <xsl:call-template name="outputpkgdest">
830 <xsl:with-param name="outputstring" select="string()"/>
831 </xsl:call-template>
832 </xsl:otherwise>
833 </xsl:choose>
834 <xsl:text>&#xA;</xsl:text>
835 </xsl:template>
836
837 <xsl:template name="outputpkgdest">
838 <xsl:param name="outputstring" select="'foo'"/>
839 <xsl:choose>
840 <xsl:when test="contains($outputstring,'make ')">
841 <xsl:choose>
842 <xsl:when test="not(starts-with($outputstring,'make'))">
843 <xsl:call-template name="outputpkgdest">
844 <xsl:with-param name="outputstring"
845 select="substring-before($outputstring,'make')"/>
846 </xsl:call-template>
847 <xsl:call-template name="outputpkgdest">
848 <xsl:with-param
849 name="outputstring"
850 select="substring-after($outputstring,
851 substring-before($outputstring,'make'))"/>
852 </xsl:call-template>
853 </xsl:when>
854 <xsl:otherwise>
855 <xsl:text>make DESTDIR=$PKG_DEST</xsl:text>
856 <xsl:call-template name="outputpkgdest">
857 <xsl:with-param
858 name="outputstring"
859 select="substring-after($outputstring,'make')"/>
860 </xsl:call-template>
861 </xsl:otherwise>
862 </xsl:choose>
863 </xsl:when>
864 <xsl:when test="contains($outputstring,'ninja install')">
865 <xsl:choose>
866 <xsl:when test="not(starts-with($outputstring,'ninja install'))">
867 <xsl:call-template name="outputpkgdest">
868 <xsl:with-param name="outputstring"
869 select="substring-before($outputstring,'ninja install')"/>
870 </xsl:call-template>
871 <xsl:call-template name="outputpkgdest">
872 <xsl:with-param
873 name="outputstring"
874 select="substring-after($outputstring,
875 substring-before($outputstring,'ninja install'))"/>
876 </xsl:call-template>
877 </xsl:when>
878 <xsl:otherwise>
879 <xsl:text>DESTDIR=$PKG_DEST ninja</xsl:text>
880 <xsl:call-template name="outputpkgdest">
881 <xsl:with-param
882 name="outputstring"
883 select="substring-after($outputstring,'ninja')"/>
884 </xsl:call-template>
885 </xsl:otherwise>
886 </xsl:choose>
887 </xsl:when>
888 <xsl:otherwise> <!-- no make nor ninja in this string -->
889 <xsl:choose>
890 <xsl:when test="contains($outputstring,'&gt;/') and
891 not(contains(substring-before($outputstring,'&gt;/'),' /'))">
892 <xsl:value-of select="substring-before($outputstring,'&gt;/')"/>
893 <xsl:text>&gt;$PKG_DEST/</xsl:text>
894 <xsl:call-template name="outputpkgdest">
895 <xsl:with-param name="outputstring" select="substring-after($outputstring,'&gt;/')"/>
896 </xsl:call-template>
897 </xsl:when>
898 <xsl:when test="contains($outputstring,' /')">
899 <xsl:value-of select="substring-before($outputstring,' /')"/>
900 <xsl:text> $PKG_DEST/</xsl:text>
901 <xsl:call-template name="outputpkgdest">
902 <xsl:with-param name="outputstring" select="substring-after($outputstring,' /')"/>
903 </xsl:call-template>
904 </xsl:when>
905 <xsl:otherwise>
906 <xsl:value-of select="$outputstring"/>
907 </xsl:otherwise>
908 </xsl:choose>
909 </xsl:otherwise>
910 </xsl:choose>
911 </xsl:template>
912
913</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.