source: BLFS/xsl/scripts.xsl@ dd7e0f67

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

Several things:

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