source: BLFS/xsl/scripts.xsl@ 6622409

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

Don't output role="nodump" in "not-pack" mode

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