source: BLFS/xsl/scripts.xsl@ 2b3edd2

ablfs-more legacy trunk
Last change on this file since 2b3edd2 was 59c4761, checked in by Pierre Labastie <pierre.labastie@…>, 3 years ago

Display the size of $BUILD_DIR for stats

Displaying the size of /, but excluding other filesystems is not
good if BUILD_DIR is on another filesystem. Furthermore, when
doing stats, the DESTDIR is inside $BUILD_DIR, so the full size is
recorded. The only thing that is not recorded is if the
build system downloads files to the user's home (cargo, maven, ...).

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