source: BLFS/xsl/scripts.xsl@ b3825c3

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

Typo

  • 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<!-- $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 cases for llvm -->
423 <xsl:when test="contains(string(),'Recommended Download')">
424 <xsl:apply-templates select="following-sibling::itemizedlist[1]"
425 mode="additional"/>
426 </xsl:when>
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="@role='nodump'"/>
523 <xsl:when test="ancestor::sect1[@id='postlfs-config-vimrc']">
524 <xsl:text>
525cat > ~/.vimrc &lt;&lt;EOF
526</xsl:text>
527 <xsl:apply-templates/>
528 <xsl:text>
529EOF
530</xsl:text>
531 </xsl:when>
532 <xsl:otherwise>
533 <xsl:apply-templates select="." mode="config"/>
534 </xsl:otherwise>
535 </xsl:choose>
536 </xsl:template>
537<!--======================== Commands code ==========================-->
538<!-- Code for installation instructions is in gen-install.xsl -->
539
540 <xsl:template match="screen">
541 <xsl:choose>
542<!-- instructions run as root (configuration mainly) -->
543 <xsl:when test="@role = 'root'">
544<!-- templates begin/end-root are in gen-install.xsl -->
545 <xsl:if test="not(preceding-sibling::screen[1][@role='root'])">
546 <xsl:call-template name="begin-root"/>
547 </xsl:if>
548 <xsl:apply-templates mode="root"/>
549 <xsl:if test="not(following-sibling::screen[1][@role='root'])">
550 <xsl:call-template name="end-root"/>
551 </xsl:if>
552 </xsl:when>
553<!-- then all the instructions run as user -->
554 <xsl:otherwise>
555 <xsl:apply-templates select="userinput"/>
556 </xsl:otherwise>
557 </xsl:choose>
558 </xsl:template>
559
560<!-- Templates for bootscripts/units installation -->
561 <xsl:template name="set-bootpkg-dir">
562 <xsl:param name="bootpkg" select="'bootscripts'"/>
563 <xsl:param name="url" select="''"/>
564 <xsl:text>
565BOOTPKG_DIR=blfs-</xsl:text>
566 <xsl:copy-of select="$bootpkg"/>
567 <xsl:text>
568
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</xsl:text>
600 </xsl:template>
601
602 <xsl:template match="screen" mode="config">
603 <xsl:if test="preceding-sibling::para[1]/xref[@linkend='bootscripts']">
604<!-- if the preceding "screen" tag is role="root", and we are role="root"
605 the end-root has not been called. So do it -->
606 <xsl:if
607 test="preceding-sibling::screen[1][@role='root'] and @role='root'">
608 <xsl:call-template name="end-root"/>
609 </xsl:if>
610 <xsl:call-template name="set-bootpkg-dir">
611 <xsl:with-param name="bootpkg" select="'bootscripts'"/>
612 <xsl:with-param name="url"
613 select="id('bootscripts')//itemizedlist//ulink/@url"/>
614 </xsl:call-template>
615<!-- if the preceding "screen" tag is role="root", and we are role="root"
616 the begin-root will not be called. So do it -->
617 <xsl:if
618 test="preceding-sibling::screen[1][@role='root'] and @role='root'">
619 <xsl:call-template name="begin-root"/>
620 </xsl:if>
621 </xsl:if>
622 <xsl:if test="preceding-sibling::para[1]/xref[@linkend='systemd-units']">
623<!-- if the preceding "screen" tag is role="root", and we are role="root"
624 the end-root has not been called. So do it -->
625 <xsl:if
626 test="preceding-sibling::screen[1][@role='root'] and @role='root'">
627 <xsl:call-template name="end-root"/>
628 </xsl:if>
629 <xsl:call-template name="set-bootpkg-dir">
630 <xsl:with-param name="bootpkg" select="'systemd-units'"/>
631 <xsl:with-param name="url"
632 select="id('systemd-units')//itemizedlist//ulink/@url"/>
633 </xsl:call-template>
634<!-- if the preceding "screen" tag is role="root", and we are role="root"
635 the begin-root will not be called. So do it -->
636 <xsl:if
637 test="preceding-sibling::screen[1][@role='root'] and @role='root'">
638 <xsl:call-template name="begin-root"/>
639 </xsl:if>
640 </xsl:if>
641 <xsl:apply-templates select='.'/>
642 <xsl:if test="preceding-sibling::para[1]/xref[@linkend='bootscripts' or
643 @linkend='systemd-units']">
644<!-- if the next "screen" tag is role="root", and we are role="root"
645 the end-root has not been called. So do it -->
646 <xsl:if
647 test="following-sibling::screen[1][@role='root'] and @role='root'">
648 <xsl:call-template name="end-root"/>
649 </xsl:if>
650 <xsl:text>
651popd</xsl:text>
652<!-- if the next "screen" tag is role="root", and we are role="root"
653 the begin-root will not be called. So do it -->
654 <xsl:if
655 test="following-sibling::screen[1][@role='root'] and @role='root'">
656 <xsl:call-template name="begin-root"/>
657 </xsl:if>
658 </xsl:if>
659 </xsl:template>
660
661 <xsl:template match="command" mode="installation">
662 <xsl:param name="want-stats" select="false"/>
663 <xsl:variable name="ns" select="normalize-space(string())"/>
664 <xsl:variable name="first"
665 select="not(
666 boolean(
667 preceding-sibling::command[contains(text(),'check') or
668 contains(text(),'test')]))"/>
669 <xsl:variable name="last"
670 select="not(
671 boolean(
672 following-sibling::command[contains(text(),'check') or
673 contains(text(),'test')]))"/>
674 <xsl:choose>
675 <xsl:when test="$want-stats">
676 <xsl:if test="$first">
677 <xsl:text>
678
679echo Time after make: ${SECONDS} >> $INFOLOG
680echo Size after make: $(sudo du -skx --exclude home /) >> $INFOLOG
681echo Time before test: ${SECONDS} >> $INFOLOG
682
683</xsl:text>
684 </xsl:if>
685 </xsl:when>
686 <xsl:otherwise>
687 <xsl:text>
688#</xsl:text>
689 </xsl:otherwise>
690 </xsl:choose>
691 <xsl:choose>
692 <xsl:when test="contains($ns,'make')">
693 <xsl:value-of select="substring-before($ns,'make ')"/>
694 <xsl:text>make </xsl:text>
695 <xsl:if test="not(contains($ns,'-k'))">
696 <xsl:text>-k </xsl:text>
697 </xsl:if>
698 <xsl:value-of select="substring-after($ns,'make ')"/>
699 </xsl:when>
700 <xsl:otherwise>
701 <xsl:copy-of select="$ns"/>
702 </xsl:otherwise>
703 </xsl:choose>
704 <xsl:if test="$want-stats">
705 <xsl:text> &gt;&gt; $TESTLOG 2&gt;&amp;1</xsl:text>
706 </xsl:if>
707 <xsl:text> || true</xsl:text>
708 <xsl:if test="$want-stats">
709 <xsl:text>
710
711echo Time after test: ${SECONDS} >> $INFOLOG
712echo Size after test: $(sudo du -skx --exclude home /) >> $INFOLOG
713echo Time before install: ${SECONDS} >> $INFOLOG
714</xsl:text>
715 </xsl:if>
716 </xsl:template>
717
718 <xsl:template match="userinput|command">
719 <xsl:text>
720</xsl:text>
721 <xsl:apply-templates/>
722 </xsl:template>
723
724 <xsl:template match="userinput" mode="root">
725 <xsl:text>
726</xsl:text>
727 <xsl:apply-templates mode="root"/>
728 </xsl:template>
729
730 <xsl:template match="text()">
731 <xsl:call-template name="remove-ampersand">
732 <xsl:with-param name="out-string" select="string()"/>
733 </xsl:call-template>
734 </xsl:template>
735
736 <xsl:template match="text()" mode="root">
737 <xsl:call-template name="output-root">
738 <xsl:with-param name="out-string" select="string()"/>
739 </xsl:call-template>
740 </xsl:template>
741
742 <xsl:template name="output-root">
743 <xsl:param name="out-string" select="''"/>
744 <xsl:choose>
745 <xsl:when test="contains($out-string,'$') and $sudo = 'y'">
746 <xsl:call-template name="output-root">
747 <xsl:with-param name="out-string"
748 select="substring-before($out-string,'$')"/>
749 </xsl:call-template>
750 <xsl:text>\$</xsl:text>
751 <xsl:call-template name="output-root">
752 <xsl:with-param name="out-string"
753 select="substring-after($out-string,'$')"/>
754 </xsl:call-template>
755 </xsl:when>
756 <xsl:when test="contains($out-string,'`') and $sudo = 'y'">
757 <xsl:call-template name="output-root">
758 <xsl:with-param name="out-string"
759 select="substring-before($out-string,'`')"/>
760 </xsl:call-template>
761 <xsl:text>\`</xsl:text>
762 <xsl:call-template name="output-root">
763 <xsl:with-param name="out-string"
764 select="substring-after($out-string,'`')"/>
765 </xsl:call-template>
766 </xsl:when>
767 <xsl:when test="contains($out-string,'\') and $sudo = 'y'">
768 <xsl:call-template name="output-root">
769 <xsl:with-param name="out-string"
770 select="substring-before($out-string,'\')"/>
771 </xsl:call-template>
772 <xsl:text>\\</xsl:text>
773 <xsl:call-template name="output-root">
774 <xsl:with-param name="out-string"
775 select="substring-after($out-string,'\')"/>
776 </xsl:call-template>
777 </xsl:when>
778 <xsl:otherwise>
779 <xsl:call-template name="remove-ampersand">
780 <xsl:with-param name="out-string" select="$out-string"/>
781 </xsl:call-template>
782<!-- <xsl:value-of select="$out-string"/> -->
783 </xsl:otherwise>
784 </xsl:choose>
785 </xsl:template>
786
787 <xsl:template name="output-destdir">
788 <xsl:apply-templates
789 select="userinput|following-sibling::screen[@role='root']/userinput"
790 mode="destdir"/>
791 <xsl:text>
792
793echo Time after install: ${SECONDS} >> $INFOLOG
794echo Size after install: $(sudo du -skx --exclude home /) >> $INFOLOG
795</xsl:text>
796 </xsl:template>
797
798 <xsl:template match="userinput" mode="destdir">
799 <xsl:text>
800</xsl:text>
801 <xsl:choose>
802 <xsl:when test="./literal">
803 <xsl:call-template name="outputpkgdest">
804 <xsl:with-param name="outputstring" select="text()[1]"/>
805 </xsl:call-template>
806 <xsl:apply-templates select="literal"/>
807 <xsl:call-template name="outputpkgdest">
808 <xsl:with-param name="outputstring" select="text()[2]"/>
809 </xsl:call-template>
810 </xsl:when>
811 <xsl:otherwise>
812 <xsl:call-template name="outputpkgdest">
813 <xsl:with-param name="outputstring" select="string()"/>
814 </xsl:call-template>
815 </xsl:otherwise>
816 </xsl:choose>
817 </xsl:template>
818
819 <xsl:template name="outputpkgdest">
820 <xsl:param name="outputstring" select="'foo'"/>
821 <xsl:choose>
822 <xsl:when test="contains($outputstring,'make ')">
823 <xsl:choose>
824 <xsl:when test="not(starts-with($outputstring,'make'))">
825 <xsl:call-template name="outputpkgdest">
826 <xsl:with-param name="outputstring"
827 select="substring-before($outputstring,'make')"/>
828 </xsl:call-template>
829 <xsl:call-template name="outputpkgdest">
830 <xsl:with-param
831 name="outputstring"
832 select="substring-after($outputstring,
833 substring-before($outputstring,'make'))"/>
834 </xsl:call-template>
835 </xsl:when>
836 <xsl:otherwise>
837 <xsl:text>
838make DESTDIR=$PKG_DEST</xsl:text>
839 <xsl:call-template name="outputpkgdest">
840 <xsl:with-param
841 name="outputstring"
842 select="substring-after($outputstring,'make')"/>
843 </xsl:call-template>
844 </xsl:otherwise>
845 </xsl:choose>
846 </xsl:when>
847 <xsl:when test="contains($outputstring,'ninja install')">
848 <xsl:choose>
849 <xsl:when test="not(starts-with($outputstring,'ninja install'))">
850 <xsl:call-template name="outputpkgdest">
851 <xsl:with-param name="outputstring"
852 select="substring-before($outputstring,'ninja install')"/>
853 </xsl:call-template>
854 <xsl:call-template name="outputpkgdest">
855 <xsl:with-param
856 name="outputstring"
857 select="substring-after($outputstring,
858 substring-before($outputstring,'ninja install'))"/>
859 </xsl:call-template>
860 </xsl:when>
861 <xsl:otherwise>
862 <xsl:text>
863DESTDIR=$PKG_DEST ninja</xsl:text>
864 <xsl:call-template name="outputpkgdest">
865 <xsl:with-param
866 name="outputstring"
867 select="substring-after($outputstring,'ninja')"/>
868 </xsl:call-template>
869 </xsl:otherwise>
870 </xsl:choose>
871 </xsl:when>
872 <xsl:otherwise> <!-- no make nor ninja in this string -->
873 <xsl:choose>
874 <xsl:when test="contains($outputstring,'&gt;/') and
875 not(contains(substring-before($outputstring,'&gt;/'),' /'))">
876 <xsl:call-template name="remove-ampersand">
877 <xsl:with-param name="out-string"
878 select="substring-before($outputstring,'&gt;/')"/>
879 </xsl:call-template>
880<!-- <xsl:value-of select="substring-before($outputstring,'&gt;/')"/>-->
881 <xsl:text>&gt;$PKG_DEST/</xsl:text>
882 <xsl:call-template name="outputpkgdest">
883 <xsl:with-param name="outputstring" select="substring-after($outputstring,'&gt;/')"/>
884 </xsl:call-template>
885 </xsl:when>
886 <xsl:when test="contains($outputstring,' /')">
887 <xsl:call-template name="remove-ampersand">
888 <xsl:with-param name="out-string"
889 select="substring-before($outputstring,' /')"/>
890 </xsl:call-template>
891<!-- <xsl:value-of select="substring-before($outputstring,' /')"/>-->
892 <xsl:text> $PKG_DEST/</xsl:text>
893 <xsl:call-template name="outputpkgdest">
894 <xsl:with-param name="outputstring" select="substring-after($outputstring,' /')"/>
895 </xsl:call-template>
896 </xsl:when>
897 <xsl:otherwise>
898 <xsl:call-template name="remove-ampersand">
899 <xsl:with-param name="out-string" select="$outputstring"/>
900 </xsl:call-template>
901<!-- <xsl:value-of select="$outputstring"/>-->
902 </xsl:otherwise>
903 </xsl:choose>
904 </xsl:otherwise>
905 </xsl:choose>
906 </xsl:template>
907
908 <xsl:template name="remove-ampersand">
909 <xsl:param name="out-string" select="''"/>
910 <xsl:choose>
911 <xsl:when test="contains($out-string,'&amp;&amp;&#xA;')">
912 <xsl:variable name="instruction-before">
913 <xsl:call-template name="last-line">
914 <xsl:with-param
915 name="instructions"
916 select="substring-before($out-string,'&amp;&amp;&#xA;')"/>
917 </xsl:call-template>
918 </xsl:variable>
919 <xsl:call-template name="remove-end-space">
920 <xsl:with-param
921 name="instructions"
922 select="substring-before($out-string,'&amp;&amp;&#xA;')"/>
923 </xsl:call-template>
924 <xsl:if test="contains($instruction-before,' ]') or
925 contains($instruction-before,'test ') or
926 contains($instruction-before,'pgrep -l')">
927 <xsl:text> &amp;&amp;</xsl:text>
928 </xsl:if>
929 <xsl:text>
930</xsl:text>
931 <xsl:call-template name="remove-ampersand">
932 <xsl:with-param name="out-string"
933 select="substring-after($out-string,
934 '&amp;&amp;&#xA;')"/>
935 </xsl:call-template>
936 </xsl:when>
937 <xsl:otherwise>
938 <xsl:copy-of select="$out-string"/>
939 </xsl:otherwise>
940 </xsl:choose>
941 </xsl:template>
942
943 <xsl:template name="last-line">
944 <xsl:param name="instructions" select="''"/>
945 <xsl:choose>
946 <xsl:when test="contains($instructions,'&#xA;')">
947 <xsl:call-template name="last-line">
948 <xsl:with-param
949 name="instructions"
950 select="substring-after($instructions,'&#xA;')"/>
951 </xsl:call-template>
952 </xsl:when>
953 <xsl:otherwise>
954 <xsl:copy-of select="normalize-space($instructions)"/>
955 </xsl:otherwise>
956 </xsl:choose>
957 </xsl:template>
958
959 <xsl:template name="remove-end-space">
960 <xsl:param name="instructions" select="''"/>
961 <xsl:choose>
962 <xsl:when
963 test="substring($instructions,string-length($instructions))=' '">
964 <xsl:call-template name="remove-end-space">
965 <xsl:with-param
966 name="instructions"
967 select="substring($instructions,
968 1,
969 string-length($instructions)-1)"/>
970 </xsl:call-template>
971 </xsl:when>
972 <xsl:otherwise>
973 <xsl:copy-of select="$instructions"/>
974 </xsl:otherwise>
975 </xsl:choose>
976 </xsl:template>
977
978</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.