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 | <xsl:param name="pack-install" select="'$HOME/blfs_root/packInstall.sh'"/>
|
---|
27 |
|
---|
28 | <!-- list of packages needing stats -->
|
---|
29 | <xsl:param name="list-stat" select="''"/>
|
---|
30 |
|
---|
31 | <!-- Remove libtool .la files -->
|
---|
32 | <xsl:param name="del-la-files" select="'y'"/>
|
---|
33 |
|
---|
34 | <!-- Build as user (y) or as root (n)? -->
|
---|
35 | <xsl:param name="sudo" select="'y'"/>
|
---|
36 |
|
---|
37 | <!-- Root of sources directory -->
|
---|
38 | <xsl:param name="src-archive" select="'/sources'"/>
|
---|
39 |
|
---|
40 | <!-- Download and archive tarballs to subdirs. Can be 'y' or '',
|
---|
41 | not 'n' -->
|
---|
42 | <xsl:param name="src-subdirs" select="''"/>
|
---|
43 |
|
---|
44 | <!-- Root of build directory -->
|
---|
45 | <xsl:param name="build-root" select="'/sources'"/>
|
---|
46 |
|
---|
47 | <!-- extract sources and build into subdirs. Can be 'y' or '',
|
---|
48 | not 'n' -->
|
---|
49 | <xsl:param name="build-subdirs" select="''"/>
|
---|
50 |
|
---|
51 | <!-- Keep files in the build directory after building. Can be 'y' or '',
|
---|
52 | not 'n' -->
|
---|
53 | <xsl:param name="keep-files" select="''"/>
|
---|
54 |
|
---|
55 | <!-- Number of parallel jobs; type integer, not string -->
|
---|
56 | <xsl:param name="jobs" select="0"/>
|
---|
57 | <!-- simple instructions for removing .la files. -->
|
---|
58 | <!-- We'll use the rule that any text output begins with a linefeed if needed
|
---|
59 | so that we do not need to output one at the end-->
|
---|
60 | <xsl:variable name="la-files-instr">
|
---|
61 |
|
---|
62 | for libdir in /lib /usr/lib $(find /opt -name lib); do
|
---|
63 | find $libdir -name \*.la \
|
---|
64 | ! -path \*ImageMagick\* \
|
---|
65 | -delete
|
---|
66 | done</xsl:variable>
|
---|
67 |
|
---|
68 | <xsl:variable name="list-stat-norm"
|
---|
69 | select="concat(' ', normalize-space($list-stat),' ')"/>
|
---|
70 |
|
---|
71 | <!-- To be able to use the single quote in tests -->
|
---|
72 | <xsl:variable name="APOS">'</xsl:variable>
|
---|
73 |
|
---|
74 | <!-- end parameters and global variables -->
|
---|
75 |
|
---|
76 | <!-- include the template for processing screen children of
|
---|
77 | role="install" sect2 -->
|
---|
78 | <xsl:include href="process-install.xsl"/>
|
---|
79 |
|
---|
80 | <!-- include the template for replaceable tags -->
|
---|
81 | <xsl:include href="process-replaceable.xsl"/>
|
---|
82 |
|
---|
83 | <!--=================== Begin processing ========================-->
|
---|
84 |
|
---|
85 | <xsl:template match="/">
|
---|
86 | <xsl:apply-templates select="//sect1[@id != 'bootscripts' and
|
---|
87 | @id != 'systemd-units']"/>
|
---|
88 | </xsl:template>
|
---|
89 |
|
---|
90 | <!--=================== Master chunks code ======================-->
|
---|
91 |
|
---|
92 | <xsl:template match="sect1">
|
---|
93 |
|
---|
94 | <!-- Are stat requested for this page? -->
|
---|
95 | <xsl:variable name="want-stats"
|
---|
96 | select="contains($list-stat-norm,
|
---|
97 | concat(' ',@id,' '))"/>
|
---|
98 |
|
---|
99 | <!-- The file names -->
|
---|
100 | <xsl:variable name="filename" select="@id"/>
|
---|
101 |
|
---|
102 | <!-- The build order -->
|
---|
103 | <xsl:variable name="position" select="position()"/>
|
---|
104 | <xsl:variable name="order">
|
---|
105 | <xsl:choose>
|
---|
106 | <xsl:when test="string-length($position) = 1">
|
---|
107 | <xsl:text>00</xsl:text>
|
---|
108 | <xsl:value-of select="$position"/>
|
---|
109 | </xsl:when>
|
---|
110 | <xsl:when test="string-length($position) = 2">
|
---|
111 | <xsl:text>0</xsl:text>
|
---|
112 | <xsl:value-of select="$position"/>
|
---|
113 | </xsl:when>
|
---|
114 | <xsl:otherwise>
|
---|
115 | <xsl:value-of select="$position"/>
|
---|
116 | </xsl:otherwise>
|
---|
117 | </xsl:choose>
|
---|
118 | </xsl:variable>
|
---|
119 |
|
---|
120 | <!-- Depuration code -->
|
---|
121 | <xsl:message>
|
---|
122 | <xsl:text>SCRIPT is </xsl:text>
|
---|
123 | <xsl:value-of select="concat($order,'-z-',$filename)"/>
|
---|
124 | <xsl:text>
 FTPDIR is </xsl:text>
|
---|
125 | <xsl:value-of select="$filename"/>
|
---|
126 | <xsl:text>

</xsl:text>
|
---|
127 | </xsl:message>
|
---|
128 |
|
---|
129 | <!-- Creating the scripts -->
|
---|
130 | <exsl:document href="{$order}-z-{$filename}" method="text">
|
---|
131 | <xsl:text>#!/bin/bash
|
---|
132 | set -e
|
---|
133 | # Variables coming from configuration
|
---|
134 | export JH_PACK_INSTALL="</xsl:text>
|
---|
135 | <xsl:copy-of select="$pack-install"/>
|
---|
136 | <xsl:text>"
|
---|
137 | export JH_SRC_ARCHIVE="</xsl:text>
|
---|
138 | <xsl:copy-of select="$src-archive"/>
|
---|
139 | <xsl:text>"
|
---|
140 | export JH_SRC_SUBDIRS="</xsl:text>
|
---|
141 | <xsl:copy-of select="$src-subdirs"/>
|
---|
142 | <xsl:text>"
|
---|
143 | export JH_BUILD_ROOT="</xsl:text>
|
---|
144 | <xsl:copy-of select="$build-root"/>
|
---|
145 | <xsl:text>"
|
---|
146 | export JH_BUILD_SUBDIRS="</xsl:text>
|
---|
147 | <xsl:copy-of select="$build-subdirs"/>
|
---|
148 | <xsl:text>"
|
---|
149 | export JH_KEEP_FILES="</xsl:text>
|
---|
150 | <xsl:copy-of select="$keep-files"/>
|
---|
151 | <xsl:text>"
|
---|
152 | </xsl:text>
|
---|
153 | <xsl:choose>
|
---|
154 | <xsl:when test="$cfg-cflags = 'EMPTY'">
|
---|
155 | <xsl:text>unset CFLAGS
|
---|
156 | </xsl:text>
|
---|
157 | </xsl:when>
|
---|
158 | <xsl:otherwise>
|
---|
159 | <xsl:text>export CFLAGS="</xsl:text>
|
---|
160 | <xsl:copy-of select="$cfg-cflags"/>
|
---|
161 | <xsl:text>"
|
---|
162 | </xsl:text>
|
---|
163 | </xsl:otherwise>
|
---|
164 | </xsl:choose>
|
---|
165 | <xsl:choose>
|
---|
166 | <xsl:when test="$cfg-cxxflags = 'EMPTY'">
|
---|
167 | <xsl:text>unset CXXFLAGS
|
---|
168 | </xsl:text>
|
---|
169 | </xsl:when>
|
---|
170 | <xsl:otherwise>
|
---|
171 | <xsl:text>export CXXFLAGS="</xsl:text>
|
---|
172 | <xsl:copy-of select="$cfg-cxxflags"/>
|
---|
173 | <xsl:text>"
|
---|
174 | </xsl:text>
|
---|
175 | </xsl:otherwise>
|
---|
176 | </xsl:choose>
|
---|
177 | <xsl:choose>
|
---|
178 | <xsl:when test="$cfg-ldflags = 'EMPTY'">
|
---|
179 | <xsl:text>unset LDFLAGS
|
---|
180 | </xsl:text>
|
---|
181 | </xsl:when>
|
---|
182 | <xsl:otherwise>
|
---|
183 | <xsl:text>export LDFLAGS="</xsl:text>
|
---|
184 | <xsl:copy-of select="$cfg-ldflags"/>
|
---|
185 | <xsl:text>"
|
---|
186 | </xsl:text>
|
---|
187 | </xsl:otherwise>
|
---|
188 | </xsl:choose>
|
---|
189 | <!-- We use MAKEFLAGS and NINJAJOBS for setting the number of
|
---|
190 | parallel jobs. This supposes that ninja has been build with
|
---|
191 | support for NINJAJOBS in lfs. We'll have to change that code
|
---|
192 | if lfs changes its policy for ninja. -->
|
---|
193 | <xsl:text>export MAKEFLAGS="-j</xsl:text>
|
---|
194 | <xsl:choose>
|
---|
195 | <xsl:when test="$jobs = 0">
|
---|
196 | <xsl:text>$(nproc)"
|
---|
197 | </xsl:text>
|
---|
198 | </xsl:when>
|
---|
199 | <xsl:otherwise>
|
---|
200 | <xsl:value-of select="$jobs"/>
|
---|
201 | <xsl:text>"
|
---|
202 | </xsl:text>
|
---|
203 | </xsl:otherwise>
|
---|
204 | </xsl:choose>
|
---|
205 | <xsl:choose>
|
---|
206 | <xsl:when test="$jobs = 0">
|
---|
207 | <xsl:text>unset NINJAJOBS
|
---|
208 | </xsl:text>
|
---|
209 | </xsl:when>
|
---|
210 | <xsl:otherwise>
|
---|
211 | <xsl:text>export NINJAJOBS="</xsl:text>
|
---|
212 | <xsl:value-of select="$jobs"/>
|
---|
213 | <xsl:text>"
|
---|
214 | </xsl:text>
|
---|
215 | </xsl:otherwise>
|
---|
216 | </xsl:choose>
|
---|
217 | <!-- Unsetting MAKELEVEL is needed for some packages which assume that
|
---|
218 | their top level Makefile is at level zero.
|
---|
219 | Some packages (cmake) use MAKE_TERMOUT and MAKE_TERMERR to determine
|
---|
220 | whether they are talking to a terminal.
|
---|
221 | In our case, stdout/stderr are always redirected, so unset them.-->
|
---|
222 | <xsl:text>unset MAKELEVEL
|
---|
223 | unset MAKE_TERMOUT
|
---|
224 | unset MAKE_TERMERR
|
---|
225 | <!-- When installing several packages, and profile or profile.d
|
---|
226 | has been modified by a previous package, we need to ensure that
|
---|
227 | the updated profile is used.
|
---|
228 | -->if [ -r /etc/profile ]; then source /etc/profile; fi
|
---|
229 | # End of environment</xsl:text>
|
---|
230 |
|
---|
231 | <xsl:choose>
|
---|
232 | <!-- Package page -->
|
---|
233 | <xsl:when test="sect2[@role='package']">
|
---|
234 | <!-- We build in a subdirectory, whose name may be needed
|
---|
235 | if using package management, so
|
---|
236 | "export" it -->
|
---|
237 | <xsl:text>
|
---|
238 | export JH_PKG_DIR=</xsl:text>
|
---|
239 | <xsl:value-of select="$filename"/>
|
---|
240 | <xsl:text>
|
---|
241 | SRC_DIR=${JH_SRC_ARCHIVE}${JH_SRC_SUBDIRS:+/${JH_PKG_DIR}}
|
---|
242 | BUILD_DIR=${JH_BUILD_ROOT}${JH_BUILD_SUBDIRS:+/${JH_PKG_DIR}}
|
---|
243 | mkdir -p $SRC_DIR
|
---|
244 | mkdir -p $BUILD_DIR
|
---|
245 | </xsl:text>
|
---|
246 |
|
---|
247 | <!-- If stats are requested, include some definitions and initializations -->
|
---|
248 | <xsl:if test="$want-stats">
|
---|
249 | <xsl:text>
|
---|
250 | INFOLOG=$(pwd)/info-${JH_PKG_DIR}
|
---|
251 | TESTLOG=$(pwd)/test-${JH_PKG_DIR}
|
---|
252 | echo MAKEFLAGS: $MAKEFLAGS > $INFOLOG
|
---|
253 | echo NINJAJOBS: $NINJAJOBS >> $INFOLOG
|
---|
254 | : > $TESTLOG
|
---|
255 | PKG_DEST=${BUILD_DIR}/dest
|
---|
256 | </xsl:text>
|
---|
257 | <!-- in some cases, DESTDIR may have been populated by root -->
|
---|
258 | <xsl:if test="$sudo = 'y'">
|
---|
259 | <xsl:text>sudo </xsl:text>
|
---|
260 | </xsl:if>
|
---|
261 | <xsl:text>rm -rf $PKG_DEST
|
---|
262 | </xsl:text>
|
---|
263 | </xsl:if><!-- want-stats -->
|
---|
264 | <!-- Download code and build commands -->
|
---|
265 | <xsl:apply-templates select="sect2">
|
---|
266 | <xsl:with-param name="want-stats" select="$want-stats"/>
|
---|
267 | </xsl:apply-templates>
|
---|
268 | <!-- Clean-up -->
|
---|
269 | <xsl:text>
|
---|
270 |
|
---|
271 | cd $BUILD_DIR
|
---|
272 | [[ -n "$JH_KEEP_FILES" ]] || </xsl:text>
|
---|
273 | <!-- In some case, some files in the build tree are owned
|
---|
274 | by root -->
|
---|
275 | <xsl:if test="$sudo='y'">
|
---|
276 | <xsl:text>sudo </xsl:text>
|
---|
277 | </xsl:if>
|
---|
278 | <xsl:text>rm -rf $JH_UNPACKDIR unpacked
|
---|
279 | </xsl:text>
|
---|
280 | </xsl:when>
|
---|
281 | <!-- Non-package page -->
|
---|
282 | <xsl:otherwise>
|
---|
283 | <xsl:apply-templates select=".//screen" mode="not-pack"/>
|
---|
284 | </xsl:otherwise>
|
---|
285 | </xsl:choose>
|
---|
286 | <xsl:text>
|
---|
287 | exit
|
---|
288 | </xsl:text><!-- include a \n at the end of document-->
|
---|
289 | </exsl:document>
|
---|
290 | </xsl:template>
|
---|
291 |
|
---|
292 | <!--======================= Sub-sections code =======================-->
|
---|
293 |
|
---|
294 | <xsl:template match="sect2">
|
---|
295 | <xsl:param name="want-stats" select="false"/>
|
---|
296 | <xsl:choose>
|
---|
297 |
|
---|
298 | <xsl:when test="@role = 'package'">
|
---|
299 | <xsl:text>
|
---|
300 | cd $SRC_DIR</xsl:text>
|
---|
301 | <!-- Download information is in bridgehead tags -->
|
---|
302 | <xsl:apply-templates select="bridgehead[@renderas='sect3']"/>
|
---|
303 | </xsl:when><!-- @role="package" -->
|
---|
304 |
|
---|
305 | <xsl:when test="@role = 'qt4-prefix' or @role = 'qt5-prefix'">
|
---|
306 | <xsl:apply-templates select=".//screen[./userinput]"/>
|
---|
307 | </xsl:when>
|
---|
308 |
|
---|
309 | <xsl:when test="@role = 'installation' and
|
---|
310 | not(preceding-sibling::sect2[@role = 'installation'])">
|
---|
311 | <xsl:text>
|
---|
312 | cd $BUILD_DIR
|
---|
313 | find . -maxdepth 1 -mindepth 1 -type d | xargs </xsl:text>
|
---|
314 | <xsl:if test="$sudo='y'">
|
---|
315 | <xsl:text>sudo </xsl:text>
|
---|
316 | </xsl:if>
|
---|
317 | <xsl:text>rm -rf
|
---|
318 | </xsl:text>
|
---|
319 | <!-- If stats are requested, insert the start size -->
|
---|
320 | <xsl:if test="$want-stats">
|
---|
321 | <xsl:text>
|
---|
322 | echo Start Size: $(sudo du -skx --exclude home $BUILD_DIR) >> $INFOLOG
|
---|
323 | </xsl:text>
|
---|
324 | </xsl:if>
|
---|
325 |
|
---|
326 | <xsl:text>
|
---|
327 | case $PACKAGE in
|
---|
328 | *.tar.gz|*.tar.bz2|*.tar.xz|*.tgz|*.tar.lzma)
|
---|
329 | tar -xvf $SRC_DIR/$PACKAGE > unpacked
|
---|
330 | JH_UNPACKDIR=`grep '[^./]\+' unpacked | head -n1 | sed 's@^\./@@;s@/.*@@'`
|
---|
331 | ;;
|
---|
332 | *.tar.lz)
|
---|
333 | bsdtar -xvf $SRC_DIR/$PACKAGE 2> unpacked
|
---|
334 | JH_UNPACKDIR=`head -n1 unpacked | cut -d" " -f2 | sed 's@^\./@@;s@/.*@@'`
|
---|
335 | ;;
|
---|
336 | *.zip)
|
---|
337 | zipinfo -1 $SRC_DIR/$PACKAGE > unpacked
|
---|
338 | JH_UNPACKDIR="$(sed 's@/.*@@' unpacked | uniq )"
|
---|
339 | if test $(wc -w <<< $JH_UNPACKDIR) -eq 1; then
|
---|
340 | unzip $SRC_DIR/$PACKAGE
|
---|
341 | else
|
---|
342 | JH_UNPACKDIR=${PACKAGE%.zip}
|
---|
343 | unzip -d $JH_UNPACKDIR $SRC_DIR/$PACKAGE
|
---|
344 | fi
|
---|
345 | ;;
|
---|
346 | *)
|
---|
347 | JH_UNPACKDIR=$JH_PKG_DIR-build
|
---|
348 | mkdir $JH_UNPACKDIR
|
---|
349 | cp $SRC_DIR/$PACKAGE $JH_UNPACKDIR
|
---|
350 | ADDITIONAL="$(find . -mindepth 1 -maxdepth 1 -type l)"
|
---|
351 | if [ -n "$ADDITIONAL" ]; then
|
---|
352 | cp $ADDITIONAL $JH_UNPACKDIR
|
---|
353 | fi
|
---|
354 | ;;
|
---|
355 | esac
|
---|
356 | export JH_UNPACKDIR
|
---|
357 | cd $JH_UNPACKDIR
|
---|
358 | </xsl:text>
|
---|
359 | <!-- If stats are requested, insert the start time -->
|
---|
360 | <xsl:if test="$want-stats">
|
---|
361 | <xsl:text>
|
---|
362 | echo Start Time: ${SECONDS} >> $INFOLOG
|
---|
363 | </xsl:text>
|
---|
364 | </xsl:if>
|
---|
365 |
|
---|
366 | <xsl:call-template name="process-install">
|
---|
367 | <xsl:with-param
|
---|
368 | name="instruction-tree"
|
---|
369 | select=".//screen[not(@role = 'nodump') and ./userinput] |
|
---|
370 | .//para/command[contains(text(),'check') or
|
---|
371 | contains(text(),'test')]"/>
|
---|
372 | <xsl:with-param name="want-stats" select="$want-stats"/>
|
---|
373 | <xsl:with-param name="root-seen" select="boolean(0)"/>
|
---|
374 | <xsl:with-param name="install-seen" select="boolean(0)"/>
|
---|
375 | <xsl:with-param name="test-seen" select="boolean(0)"/>
|
---|
376 | <xsl:with-param name="doc-seen" select="boolean(0)"/>
|
---|
377 | </xsl:call-template>
|
---|
378 | <xsl:text>
|
---|
379 | </xsl:text>
|
---|
380 | <xsl:if test="$sudo = 'y'">
|
---|
381 | <xsl:text>sudo /sbin/</xsl:text>
|
---|
382 | </xsl:if>
|
---|
383 | <xsl:text>ldconfig</xsl:text>
|
---|
384 | </xsl:when><!-- @role="installation" -->
|
---|
385 |
|
---|
386 | <xsl:when test="@role = 'configuration'">
|
---|
387 | <xsl:text>
</xsl:text>
|
---|
388 | <xsl:apply-templates mode="config"
|
---|
389 | select=".//screen[not(@role = 'nodump') and ./userinput]"/>
|
---|
390 | </xsl:when><!-- @role="configuration" -->
|
---|
391 |
|
---|
392 | </xsl:choose>
|
---|
393 | </xsl:template>
|
---|
394 |
|
---|
395 | <!--==================== Download code =======================-->
|
---|
396 |
|
---|
397 | <!-- template for extracting the filename from an url in the form:
|
---|
398 | proto://internet.name/dir1/.../dirn/filename?condition.
|
---|
399 | Needed, because substring-after(...,'/') returns only the
|
---|
400 | substring after the first '/'. -->
|
---|
401 | <xsl:template name="package_name">
|
---|
402 | <xsl:param name="url" select="foo"/>
|
---|
403 | <xsl:param name="sub-url" select="substring-after($url,'/')"/>
|
---|
404 | <xsl:choose>
|
---|
405 | <xsl:when test="contains($sub-url,'/')">
|
---|
406 | <xsl:call-template name="package_name">
|
---|
407 | <xsl:with-param name="url" select="$sub-url"/>
|
---|
408 | </xsl:call-template>
|
---|
409 | </xsl:when>
|
---|
410 | <xsl:otherwise>
|
---|
411 | <xsl:choose>
|
---|
412 | <xsl:when test="contains($sub-url,'?')">
|
---|
413 | <xsl:value-of select="substring-before($sub-url,'?')"/>
|
---|
414 | </xsl:when>
|
---|
415 | <xsl:otherwise>
|
---|
416 | <xsl:value-of select="$sub-url"/>
|
---|
417 | </xsl:otherwise>
|
---|
418 | </xsl:choose>
|
---|
419 | </xsl:otherwise>
|
---|
420 | </xsl:choose>
|
---|
421 | </xsl:template>
|
---|
422 |
|
---|
423 | <!-- Generates the code to download a package, an additional package or
|
---|
424 | a patch. -->
|
---|
425 | <xsl:template name="download-file">
|
---|
426 | <xsl:param name="httpurl" select="''"/>
|
---|
427 | <xsl:param name="ftpurl" select="''"/>
|
---|
428 | <xsl:param name="md5" select="''"/>
|
---|
429 | <xsl:param name="varname" select="''"/>
|
---|
430 | <xsl:variable name="package">
|
---|
431 | <xsl:call-template name="package_name">
|
---|
432 | <xsl:with-param name="url">
|
---|
433 | <xsl:choose>
|
---|
434 | <xsl:when test="string-length($httpurl) > 10">
|
---|
435 | <xsl:value-of select="$httpurl"/>
|
---|
436 | </xsl:when>
|
---|
437 | <xsl:otherwise>
|
---|
438 | <xsl:value-of select="$ftpurl"/>
|
---|
439 | </xsl:otherwise>
|
---|
440 | </xsl:choose>
|
---|
441 | </xsl:with-param>
|
---|
442 | </xsl:call-template>
|
---|
443 | </xsl:variable>
|
---|
444 | <xsl:variable name="first_letter"
|
---|
445 | select="translate(substring($package,1,1),
|
---|
446 | 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
---|
447 | 'abcdefghijklmnopqrstuvwxyz')"/>
|
---|
448 | <xsl:text>
</xsl:text>
|
---|
449 | <xsl:value-of select="$varname"/>
|
---|
450 | <xsl:text>=</xsl:text>
|
---|
451 | <xsl:value-of select="$package"/>
|
---|
452 | <xsl:text>
if [[ ! -f $</xsl:text>
|
---|
453 | <xsl:value-of select="$varname"/>
|
---|
454 | <xsl:text> ]] ; then
|
---|
455 | if [ -f "$JH_SRC_ARCHIVE/$</xsl:text>
|
---|
456 | <xsl:value-of select="$varname"/>
|
---|
457 | <xsl:text>" ] ; then
</xsl:text>
|
---|
458 | <xsl:text> cp "$JH_SRC_ARCHIVE/$</xsl:text>
|
---|
459 | <xsl:value-of select="$varname"/>
|
---|
460 | <xsl:text>" "$</xsl:text>
|
---|
461 | <xsl:value-of select="$varname"/>
|
---|
462 | <xsl:text>"
|
---|
463 | else
</xsl:text>
|
---|
464 | <!-- Download from upstream http -->
|
---|
465 | <xsl:if test="string-length($httpurl) > 10">
|
---|
466 | <xsl:text> wget -T 30 -t 5 "</xsl:text>
|
---|
467 | <xsl:value-of select="$httpurl"/>
|
---|
468 | <xsl:text>" ||
</xsl:text>
|
---|
469 | </xsl:if>
|
---|
470 | <!-- Download from upstream ftp -->
|
---|
471 | <xsl:if test="string-length($ftpurl) > 10">
|
---|
472 | <xsl:text> wget -T 30 -t 5 "</xsl:text>
|
---|
473 | <xsl:value-of select="$ftpurl"/>
|
---|
474 | <xsl:text>" ||
</xsl:text>
|
---|
475 | </xsl:if>
|
---|
476 | <!-- The FTP_SERVER mirror as a last resort -->
|
---|
477 | <xsl:text> wget -T 30 -t 5 "${JH_FTP_SERVER}svn/</xsl:text>
|
---|
478 | <xsl:value-of select="$first_letter"/>
|
---|
479 | <xsl:text>/$</xsl:text>
|
---|
480 | <xsl:value-of select="$varname"/>
|
---|
481 | <xsl:text>"
|
---|
482 | fi
|
---|
483 | fi</xsl:text>
|
---|
484 | <xsl:if test="string-length($md5) > 10">
|
---|
485 | <xsl:text>
|
---|
486 | echo "</xsl:text>
|
---|
487 | <xsl:value-of select="$md5"/>
|
---|
488 | <xsl:text>  $</xsl:text>
|
---|
489 | <xsl:value-of select="$varname"/>
|
---|
490 | <xsl:text>" | md5sum -c -</xsl:text>
|
---|
491 | </xsl:if>
|
---|
492 | <!-- link additional packages into $BUILD_DIR, because they are supposed to
|
---|
493 | be there-->
|
---|
494 | <xsl:if test="string($varname) != 'PACKAGE'">
|
---|
495 | <xsl:text>
|
---|
496 | [ "$SRC_DIR" != "$BUILD_DIR" ] && ln -sf "$SRC_DIR/$</xsl:text>
|
---|
497 | <xsl:value-of select="$varname"/>
|
---|
498 | <xsl:text>" "$BUILD_DIR"</xsl:text>
|
---|
499 | </xsl:if>
|
---|
500 | <xsl:text>
</xsl:text>
|
---|
501 | </xsl:template>
|
---|
502 |
|
---|
503 | <!-- Extract the MD5 sum information -->
|
---|
504 | <xsl:template match="para" mode="md5">
|
---|
505 | <xsl:choose>
|
---|
506 | <xsl:when test="contains(substring-after(string(),'sum: '),'
')">
|
---|
507 | <xsl:value-of select="substring-before(substring-after(string(),'sum: '),'
')"/>
|
---|
508 | </xsl:when>
|
---|
509 | <xsl:otherwise>
|
---|
510 | <xsl:value-of select="substring-after(string(),'sum: ')"/>
|
---|
511 | </xsl:otherwise>
|
---|
512 | </xsl:choose>
|
---|
513 | </xsl:template>
|
---|
514 |
|
---|
515 | <!-- We have several templates itemizedlist, depending on whether we
|
---|
516 | expect the package information, or additional package(s) or patch(es)
|
---|
517 | information. Select the appropriate mode here. -->
|
---|
518 | <xsl:template match="bridgehead">
|
---|
519 | <xsl:choose>
|
---|
520 | <!-- Special case for Openjdk -->
|
---|
521 | <xsl:when test="contains(string(),'Source Package Information')">
|
---|
522 | <xsl:apply-templates
|
---|
523 | select="following-sibling::itemizedlist[1]//simplelist">
|
---|
524 | <xsl:with-param name="varname" select="'PACKAGE'"/>
|
---|
525 | </xsl:apply-templates>
|
---|
526 | <xsl:apply-templates select="following-sibling::itemizedlist
|
---|
527 | [preceding-sibling::bridgehead[1]=current()
|
---|
528 | and position() >1]//simplelist">
|
---|
529 | <xsl:with-param name="varname" select="'PACKAGE1'"/>
|
---|
530 | </xsl:apply-templates>
|
---|
531 | </xsl:when>
|
---|
532 | <!-- Package information -->
|
---|
533 | <xsl:when test="contains(string(),'Package Information')">
|
---|
534 | <xsl:apply-templates select="following-sibling::itemizedlist
|
---|
535 | [preceding-sibling::bridgehead[1]=current()]"
|
---|
536 | mode="package"/>
|
---|
537 | </xsl:when>
|
---|
538 | <!-- Additional package information -->
|
---|
539 | <!-- special cases for llvm -->
|
---|
540 | <xsl:when test="contains(string(),'Recommended Download')">
|
---|
541 | <xsl:apply-templates select="following-sibling::itemizedlist
|
---|
542 | [preceding-sibling::bridgehead[1]=current()]"
|
---|
543 | mode="additional"/>
|
---|
544 | </xsl:when>
|
---|
545 | <xsl:when test="contains(string(),'Optional Download')">
|
---|
546 | <xsl:apply-templates select="following-sibling::itemizedlist
|
---|
547 | [preceding-sibling::bridgehead[1]=current()]"
|
---|
548 | mode="additional"/>
|
---|
549 | </xsl:when>
|
---|
550 | <!-- All other additional packages have "Additional" -->
|
---|
551 | <xsl:when test="contains(string(),'Additional')">
|
---|
552 | <xsl:apply-templates select="following-sibling::itemizedlist
|
---|
553 | [preceding-sibling::bridgehead[1]=current()]"
|
---|
554 | mode="additional"/>
|
---|
555 | </xsl:when>
|
---|
556 | <!-- Do not do anything if the dev has created another type of
|
---|
557 | bridgehead. -->
|
---|
558 | <xsl:otherwise/>
|
---|
559 | </xsl:choose>
|
---|
560 | </xsl:template>
|
---|
561 |
|
---|
562 | <!-- Call the download code template with appropriate parameters -->
|
---|
563 | <xsl:template match="itemizedlist" mode="package">
|
---|
564 | <xsl:call-template name="download-file">
|
---|
565 | <xsl:with-param name="httpurl">
|
---|
566 | <xsl:value-of select="./listitem[1]/para/ulink/@url"/>
|
---|
567 | </xsl:with-param>
|
---|
568 | <xsl:with-param name="ftpurl">
|
---|
569 | <xsl:value-of select="./listitem/para[contains(string(),'FTP')]/ulink/@url"/>
|
---|
570 | </xsl:with-param>
|
---|
571 | <xsl:with-param name="md5">
|
---|
572 | <xsl:apply-templates select="./listitem/para[contains(string(),'MD5')]"
|
---|
573 | mode="md5"/>
|
---|
574 | </xsl:with-param>
|
---|
575 | <xsl:with-param name="varname" select="'PACKAGE'"/>
|
---|
576 | </xsl:call-template>
|
---|
577 | </xsl:template>
|
---|
578 |
|
---|
579 | <xsl:template match="itemizedlist" mode="additional">
|
---|
580 | <!-- The normal layout is "one listitem"<->"one url", but some devs
|
---|
581 | find amusing to have FTP and/or MD5sum listitems, or to
|
---|
582 | enclose the download information inside a simplelist tag... -->
|
---|
583 | <xsl:for-each select="listitem[.//ulink]">
|
---|
584 | <xsl:choose>
|
---|
585 | <!-- hopefully, there was a HTTP line before -->
|
---|
586 | <xsl:when test="contains(string(./para),'FTP')"/>
|
---|
587 | <xsl:when test=".//simplelist">
|
---|
588 | <xsl:apply-templates select=".//simplelist">
|
---|
589 | <xsl:with-param name="varname" select="'PACKAGE1'"/>
|
---|
590 | </xsl:apply-templates>
|
---|
591 | </xsl:when>
|
---|
592 | <xsl:otherwise>
|
---|
593 | <xsl:call-template name="download-file">
|
---|
594 | <xsl:with-param name="httpurl">
|
---|
595 | <xsl:value-of select="./para/ulink/@url"/>
|
---|
596 | </xsl:with-param>
|
---|
597 | <xsl:with-param name="ftpurl">
|
---|
598 | <xsl:value-of
|
---|
599 | select="following-sibling::listitem[1]/
|
---|
600 | para[contains(string(),'FTP')]/ulink/@url"/>
|
---|
601 | </xsl:with-param>
|
---|
602 | <xsl:with-param name="md5">
|
---|
603 | <xsl:apply-templates
|
---|
604 | select="following-sibling::listitem[position()<3]/
|
---|
605 | para[contains(string(),'MD5')]"
|
---|
606 | mode="md5"/>
|
---|
607 | </xsl:with-param>
|
---|
608 | <xsl:with-param name="varname">
|
---|
609 | <xsl:choose>
|
---|
610 | <xsl:when test="contains(./para/ulink/@url,'.patch')">
|
---|
611 | <xsl:text>PATCH</xsl:text>
|
---|
612 | </xsl:when>
|
---|
613 | <xsl:otherwise>
|
---|
614 | <xsl:text>PACKAGE1</xsl:text>
|
---|
615 | </xsl:otherwise>
|
---|
616 | </xsl:choose>
|
---|
617 | </xsl:with-param>
|
---|
618 | </xsl:call-template>
|
---|
619 | </xsl:otherwise>
|
---|
620 | </xsl:choose>
|
---|
621 | </xsl:for-each>
|
---|
622 | </xsl:template>
|
---|
623 |
|
---|
624 | <!-- the simplelist case. Hopefully, the layout is one member for
|
---|
625 | url, one for md5 and others for various information, that we do not
|
---|
626 | use -->
|
---|
627 | <xsl:template match="simplelist">
|
---|
628 | <xsl:param name="varname" select="'PACKAGE1'"/>
|
---|
629 | <xsl:call-template name="download-file">
|
---|
630 | <xsl:with-param name="httpurl" select=".//ulink/@url"/>
|
---|
631 | <xsl:with-param name="md5">
|
---|
632 | <xsl:value-of select="substring-after(member[contains(string(),'MD5')],'sum: ')"/>
|
---|
633 | </xsl:with-param>
|
---|
634 | <xsl:with-param name="varname" select="$varname"/>
|
---|
635 | </xsl:call-template>
|
---|
636 | </xsl:template>
|
---|
637 |
|
---|
638 | <!--====================== Non package code =========================-->
|
---|
639 |
|
---|
640 | <xsl:template match="screen" mode="not-pack">
|
---|
641 | <xsl:choose>
|
---|
642 | <xsl:when test="@role='nodump'"/>
|
---|
643 | <xsl:when test="ancestor::sect1[@id='postlfs-config-vimrc']">
|
---|
644 | <xsl:text>
|
---|
645 | cat > ~/.vimrc <<EOF
|
---|
646 | </xsl:text>
|
---|
647 | <xsl:apply-templates/>
|
---|
648 | <xsl:text>
|
---|
649 | EOF
|
---|
650 | </xsl:text>
|
---|
651 | </xsl:when>
|
---|
652 | <xsl:otherwise>
|
---|
653 | <xsl:apply-templates select="." mode="config"/>
|
---|
654 | </xsl:otherwise>
|
---|
655 | </xsl:choose>
|
---|
656 | </xsl:template>
|
---|
657 | <!--======================== Commands code ==========================-->
|
---|
658 | <!-- Code for installation instructions is in gen-install.xsl -->
|
---|
659 |
|
---|
660 | <xsl:template match="screen">
|
---|
661 | <xsl:choose>
|
---|
662 | <!-- instructions run as root (configuration mainly) -->
|
---|
663 | <xsl:when test="@role = 'root'">
|
---|
664 | <!-- templates begin/end-root are in gen-install.xsl -->
|
---|
665 | <xsl:if test="not(preceding-sibling::screen[1][@role='root'])">
|
---|
666 | <xsl:call-template name="begin-root"/>
|
---|
667 | </xsl:if>
|
---|
668 | <xsl:apply-templates mode="root"/>
|
---|
669 | <xsl:if test="not(following-sibling::screen[1][@role='root'])">
|
---|
670 | <xsl:call-template name="end-root"/>
|
---|
671 | </xsl:if>
|
---|
672 | </xsl:when>
|
---|
673 | <!-- then all the instructions run as user -->
|
---|
674 | <xsl:otherwise>
|
---|
675 | <xsl:apply-templates select="userinput"/>
|
---|
676 | </xsl:otherwise>
|
---|
677 | </xsl:choose>
|
---|
678 | </xsl:template>
|
---|
679 |
|
---|
680 | <!-- Templates for bootscripts/units installation -->
|
---|
681 | <xsl:template name="set-bootpkg-dir">
|
---|
682 | <xsl:param name="bootpkg" select="'bootscripts'"/>
|
---|
683 | <xsl:param name="url" select="''"/>
|
---|
684 | <xsl:text>
|
---|
685 | BOOTPKG_DIR=blfs-</xsl:text>
|
---|
686 | <xsl:copy-of select="$bootpkg"/>
|
---|
687 | <xsl:text>
|
---|
688 |
|
---|
689 | BOOTSRC_DIR=${JH_SRC_ARCHIVE}${JH_SRC_SUBDIRS:+/${BOOTPKG_DIR}}
|
---|
690 | BOOTBUILD_DIR=${JH_BUILD_ROOT}${JH_BUILD_SUBDIRS:+/${BOOTPKG_DIR}}
|
---|
691 | mkdir -p $BOOTSRC_DIR
|
---|
692 | mkdir -p $BOOTBUILD_DIR
|
---|
693 |
|
---|
694 | pushd $BOOTSRC_DIR
|
---|
695 | URL=</xsl:text>
|
---|
696 | <xsl:value-of select="$url"/>
|
---|
697 | <xsl:text>
|
---|
698 | BOOTPACKG=$(basename $URL)
|
---|
699 | if [[ ! -f $BOOTPACKG ]] ; then
|
---|
700 | if [[ -f $JH_SRC_ARCHIVE/$BOOTPACKG ]] ; then
|
---|
701 | cp $JH_SRC_ARCHIVE/$BOOTPACKG $BOOTPACKG
|
---|
702 | else
|
---|
703 | wget -T 30 -t 5 $URL
|
---|
704 | fi
|
---|
705 | rm -f $BOOTBUILD_DIR/unpacked
|
---|
706 | fi
|
---|
707 |
|
---|
708 | cd $BOOTBUILD_DIR
|
---|
709 | if [[ -e unpacked ]] ; then
|
---|
710 | BOOTUNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
|
---|
711 | if ! [[ -d $BOOTUNPACKDIR ]]; then
|
---|
712 | tar -xvf $BOOTSRC_DIR/$BOOTPACKG > unpacked
|
---|
713 | BOOTUNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
|
---|
714 | fi
|
---|
715 | else
|
---|
716 | tar -xvf $BOOTSRC_DIR/$BOOTPACKG > unpacked
|
---|
717 | BOOTUNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
|
---|
718 | fi
|
---|
719 | cd $BOOTUNPACKDIR</xsl:text>
|
---|
720 | </xsl:template>
|
---|
721 |
|
---|
722 | <xsl:template match="screen" mode="config">
|
---|
723 | <xsl:if test="preceding-sibling::para[1]/xref[@linkend='bootscripts']">
|
---|
724 | <!-- if the preceding "screen" tag is role="root", and we are role="root"
|
---|
725 | the end-root has not been called, except if the preceding "screen"
|
---|
726 | tag is itself preceded by a <para> containing and <xref> to
|
---|
727 | bootscripts. So close it only if needed -->
|
---|
728 | <xsl:if
|
---|
729 | test="preceding-sibling::screen[1][@role='root'] and
|
---|
730 | @role='root' and
|
---|
731 | not(preceding-sibling::screen[1]/preceding-sibling::para[1]/xref[@linkend='bootscripts'])">
|
---|
732 | <xsl:call-template name="end-root"/>
|
---|
733 | </xsl:if>
|
---|
734 | <xsl:call-template name="set-bootpkg-dir">
|
---|
735 | <xsl:with-param name="bootpkg" select="'bootscripts'"/>
|
---|
736 | <xsl:with-param name="url"
|
---|
737 | select="id('bootscripts')//itemizedlist//ulink/@url"/>
|
---|
738 | </xsl:call-template>
|
---|
739 | <!-- if the preceding "screen" tag is role="root", and we are role="root"
|
---|
740 | the begin-root will not be called. So do it.-->
|
---|
741 | <xsl:if
|
---|
742 | test="preceding-sibling::screen[1][@role='root'] and
|
---|
743 | @role='root'">
|
---|
744 | <xsl:call-template name="begin-root"/>
|
---|
745 | </xsl:if>
|
---|
746 | </xsl:if>
|
---|
747 | <xsl:if test="preceding-sibling::para[1]/xref[@linkend='systemd-units']">
|
---|
748 | <!-- if the preceding "screen" tag is role="root", and we are role="root"
|
---|
749 | the end-root has not been called. So do it, except if it was already a
|
---|
750 | unit install -->
|
---|
751 | <xsl:if
|
---|
752 | test="preceding-sibling::screen[1][@role='root'] and
|
---|
753 | @role='root' and
|
---|
754 | not(preceding-sibling::screen[1]/preceding-sibling::para[1]/xref[@linkend='systemd-units'])">
|
---|
755 | <xsl:call-template name="end-root"/>
|
---|
756 | </xsl:if>
|
---|
757 | <xsl:call-template name="set-bootpkg-dir">
|
---|
758 | <xsl:with-param name="bootpkg" select="'systemd-units'"/>
|
---|
759 | <xsl:with-param name="url"
|
---|
760 | select="id('systemd-units')//itemizedlist//ulink/@url"/>
|
---|
761 | </xsl:call-template>
|
---|
762 | <!-- if the preceding "screen" tag is role="root", and we are role="root"
|
---|
763 | the begin-root will not be called. So do it. -->
|
---|
764 | <xsl:if
|
---|
765 | test="preceding-sibling::screen[1][@role='root'] and
|
---|
766 | @role='root'">
|
---|
767 | <xsl:call-template name="begin-root"/>
|
---|
768 | </xsl:if>
|
---|
769 | </xsl:if>
|
---|
770 | <xsl:apply-templates select='.'/>
|
---|
771 | <xsl:if test="preceding-sibling::para[1]/xref[@linkend='bootscripts' or
|
---|
772 | @linkend='systemd-units']">
|
---|
773 | <!-- if the next "screen" tag is role="root", and we are role="root"
|
---|
774 | the end-root has not been called. -->
|
---|
775 | <xsl:if
|
---|
776 | test="following-sibling::screen[1][@role='root'] and @role='root'">
|
---|
777 | <xsl:call-template name="end-root"/>
|
---|
778 | </xsl:if>
|
---|
779 | <xsl:text>
|
---|
780 | popd</xsl:text>
|
---|
781 | <!-- if the next "screen" tag is role="root", and we are role="root"
|
---|
782 | the begin-root will not be called. So do it, except if the next
|
---|
783 | <screen> is itself a unit or bootscript install -->
|
---|
784 | <xsl:if
|
---|
785 | test="following-sibling::screen[1][@role='root'] and
|
---|
786 | @role='root' and
|
---|
787 | not(following-sibling::screen[1]/preceding-sibling::para[1]/xref[@linkend='bootscripts' or @linkend='systemd-units'])">
|
---|
788 | <xsl:call-template name="begin-root"/>
|
---|
789 | </xsl:if>
|
---|
790 | </xsl:if>
|
---|
791 | </xsl:template>
|
---|
792 |
|
---|
793 | <xsl:template match="command" mode="installation">
|
---|
794 | <xsl:param name="want-stats" select="false"/>
|
---|
795 | <xsl:variable name="ns" select="normalize-space(string())"/>
|
---|
796 | <xsl:variable name="first"
|
---|
797 | select="not(
|
---|
798 | boolean(
|
---|
799 | preceding-sibling::command[contains(text(),'check') or
|
---|
800 | contains(text(),'test')]))"/>
|
---|
801 | <xsl:variable name="last"
|
---|
802 | select="not(
|
---|
803 | boolean(
|
---|
804 | following-sibling::command[contains(text(),'check') or
|
---|
805 | contains(text(),'test')]))"/>
|
---|
806 | <xsl:choose>
|
---|
807 | <xsl:when test="$want-stats">
|
---|
808 | <xsl:if test="$first">
|
---|
809 | <xsl:text>
|
---|
810 |
|
---|
811 | echo Time after make: ${SECONDS} >> $INFOLOG
|
---|
812 | echo Size after make: $(sudo du -skx --exclude home $BUILD_DIR) >> $INFOLOG
|
---|
813 | echo Time before test: ${SECONDS} >> $INFOLOG
|
---|
814 |
|
---|
815 | </xsl:text>
|
---|
816 | </xsl:if>
|
---|
817 | </xsl:when>
|
---|
818 | <xsl:otherwise>
|
---|
819 | <xsl:text>
|
---|
820 | #</xsl:text>
|
---|
821 | </xsl:otherwise>
|
---|
822 | </xsl:choose>
|
---|
823 | <xsl:choose>
|
---|
824 | <xsl:when test="contains($ns,'make')">
|
---|
825 | <xsl:value-of select="substring-before($ns,'make ')"/>
|
---|
826 | <xsl:text>make </xsl:text>
|
---|
827 | <xsl:if test="not(contains($ns,'-k'))">
|
---|
828 | <xsl:text>-k </xsl:text>
|
---|
829 | </xsl:if>
|
---|
830 | <xsl:value-of select="substring-after($ns,'make ')"/>
|
---|
831 | </xsl:when>
|
---|
832 | <xsl:otherwise>
|
---|
833 | <xsl:copy-of select="$ns"/>
|
---|
834 | </xsl:otherwise>
|
---|
835 | </xsl:choose>
|
---|
836 | <xsl:if test="$want-stats">
|
---|
837 | <xsl:text> >> $TESTLOG 2>&1</xsl:text>
|
---|
838 | </xsl:if>
|
---|
839 | <xsl:text> || true</xsl:text>
|
---|
840 | <xsl:if test="$want-stats">
|
---|
841 | <xsl:text>
|
---|
842 |
|
---|
843 | echo Time after test: ${SECONDS} >> $INFOLOG
|
---|
844 | echo Size after test: $(sudo du -skx --exclude home $BUILD_DIR) >> $INFOLOG
|
---|
845 | echo Time before install: ${SECONDS} >> $INFOLOG
|
---|
846 | </xsl:text>
|
---|
847 | </xsl:if>
|
---|
848 | </xsl:template>
|
---|
849 |
|
---|
850 | <xsl:template match="userinput|command">
|
---|
851 | <xsl:text>
|
---|
852 | </xsl:text>
|
---|
853 | <xsl:apply-templates/>
|
---|
854 | </xsl:template>
|
---|
855 |
|
---|
856 | <xsl:template match="userinput" mode="root">
|
---|
857 | <xsl:text>
|
---|
858 | </xsl:text>
|
---|
859 | <xsl:apply-templates mode="root"/>
|
---|
860 | </xsl:template>
|
---|
861 |
|
---|
862 | <xsl:template match="text()">
|
---|
863 | <xsl:call-template name="remove-ampersand">
|
---|
864 | <xsl:with-param name="out-string" select="string()"/>
|
---|
865 | </xsl:call-template>
|
---|
866 | </xsl:template>
|
---|
867 |
|
---|
868 | <xsl:template match="text()" mode="root">
|
---|
869 | <xsl:call-template name="output-root">
|
---|
870 | <xsl:with-param name="out-string" select="string()"/>
|
---|
871 | </xsl:call-template>
|
---|
872 | </xsl:template>
|
---|
873 |
|
---|
874 | <xsl:template name="output-root">
|
---|
875 | <xsl:param name="out-string" select="''"/>
|
---|
876 | <xsl:choose>
|
---|
877 | <xsl:when test="contains($out-string,'$') and $sudo = 'y'">
|
---|
878 | <xsl:call-template name="output-root">
|
---|
879 | <xsl:with-param name="out-string"
|
---|
880 | select="substring-before($out-string,'$')"/>
|
---|
881 | </xsl:call-template>
|
---|
882 | <xsl:text>\$</xsl:text>
|
---|
883 | <xsl:call-template name="output-root">
|
---|
884 | <xsl:with-param name="out-string"
|
---|
885 | select="substring-after($out-string,'$')"/>
|
---|
886 | </xsl:call-template>
|
---|
887 | </xsl:when>
|
---|
888 | <xsl:when test="contains($out-string,'`') and $sudo = 'y'">
|
---|
889 | <xsl:call-template name="output-root">
|
---|
890 | <xsl:with-param name="out-string"
|
---|
891 | select="substring-before($out-string,'`')"/>
|
---|
892 | </xsl:call-template>
|
---|
893 | <xsl:text>\`</xsl:text>
|
---|
894 | <xsl:call-template name="output-root">
|
---|
895 | <xsl:with-param name="out-string"
|
---|
896 | select="substring-after($out-string,'`')"/>
|
---|
897 | </xsl:call-template>
|
---|
898 | </xsl:when>
|
---|
899 | <xsl:when test="contains($out-string,'\') and $sudo = 'y'">
|
---|
900 | <xsl:call-template name="output-root">
|
---|
901 | <xsl:with-param name="out-string"
|
---|
902 | select="substring-before($out-string,'\')"/>
|
---|
903 | </xsl:call-template>
|
---|
904 | <xsl:text>\\</xsl:text>
|
---|
905 | <xsl:call-template name="output-root">
|
---|
906 | <xsl:with-param name="out-string"
|
---|
907 | select="substring-after($out-string,'\')"/>
|
---|
908 | </xsl:call-template>
|
---|
909 | </xsl:when>
|
---|
910 | <xsl:otherwise>
|
---|
911 | <xsl:call-template name="remove-ampersand">
|
---|
912 | <xsl:with-param name="out-string" select="$out-string"/>
|
---|
913 | </xsl:call-template>
|
---|
914 | <!-- <xsl:value-of select="$out-string"/> -->
|
---|
915 | </xsl:otherwise>
|
---|
916 | </xsl:choose>
|
---|
917 | </xsl:template>
|
---|
918 |
|
---|
919 | <xsl:template name="output-destdir">
|
---|
920 | <xsl:apply-templates
|
---|
921 | select="userinput|following-sibling::screen[@role='root']/userinput"
|
---|
922 | mode="destdir"/>
|
---|
923 | <xsl:text>
|
---|
924 |
|
---|
925 | echo Time after install: ${SECONDS} >> $INFOLOG
|
---|
926 | echo Size after install: $(sudo du -skx --exclude home $BUILD_DIR) >> $INFOLOG
|
---|
927 | </xsl:text>
|
---|
928 | </xsl:template>
|
---|
929 |
|
---|
930 | <xsl:template match="userinput" mode="destdir">
|
---|
931 | <xsl:text>
|
---|
932 | </xsl:text>
|
---|
933 | <xsl:for-each select="./literal">
|
---|
934 | <xsl:call-template name="outputpkgdest">
|
---|
935 | <xsl:with-param name="outputstring" select="preceding-sibling::text()[1]"/>
|
---|
936 | </xsl:call-template>
|
---|
937 | <xsl:apply-templates select="."/>
|
---|
938 | </xsl:for-each>
|
---|
939 | <xsl:call-template name="outputpkgdest">
|
---|
940 | <xsl:with-param name="outputstring" select="text()[last()]"/>
|
---|
941 | </xsl:call-template>
|
---|
942 | </xsl:template>
|
---|
943 |
|
---|
944 | <xsl:template name="outputpkgdest">
|
---|
945 | <xsl:param name="outputstring" select="'foo'"/>
|
---|
946 | <xsl:choose>
|
---|
947 | <xsl:when test="contains($outputstring,'make ')">
|
---|
948 | <xsl:choose>
|
---|
949 | <xsl:when test="not(starts-with($outputstring,'make'))">
|
---|
950 | <xsl:call-template name="outputpkgdest">
|
---|
951 | <xsl:with-param name="outputstring"
|
---|
952 | select="substring-before($outputstring,'make')"/>
|
---|
953 | </xsl:call-template>
|
---|
954 | <xsl:call-template name="outputpkgdest">
|
---|
955 | <xsl:with-param
|
---|
956 | name="outputstring"
|
---|
957 | select="substring-after($outputstring,
|
---|
958 | substring-before($outputstring,'make'))"/>
|
---|
959 | </xsl:call-template>
|
---|
960 | </xsl:when>
|
---|
961 | <xsl:otherwise>
|
---|
962 | <xsl:text>
|
---|
963 | make DESTDIR=$PKG_DEST</xsl:text>
|
---|
964 | <xsl:call-template name="outputpkgdest">
|
---|
965 | <xsl:with-param
|
---|
966 | name="outputstring"
|
---|
967 | select="substring-after($outputstring,'make')"/>
|
---|
968 | </xsl:call-template>
|
---|
969 | </xsl:otherwise>
|
---|
970 | </xsl:choose>
|
---|
971 | </xsl:when>
|
---|
972 | <xsl:when test="contains($outputstring,'ninja install')">
|
---|
973 | <xsl:choose>
|
---|
974 | <xsl:when test="not(starts-with($outputstring,'ninja install'))">
|
---|
975 | <xsl:call-template name="outputpkgdest">
|
---|
976 | <xsl:with-param name="outputstring"
|
---|
977 | select="substring-before($outputstring,'ninja install')"/>
|
---|
978 | </xsl:call-template>
|
---|
979 | <xsl:call-template name="outputpkgdest">
|
---|
980 | <xsl:with-param
|
---|
981 | name="outputstring"
|
---|
982 | select="substring-after($outputstring,
|
---|
983 | substring-before($outputstring,'ninja install'))"/>
|
---|
984 | </xsl:call-template>
|
---|
985 | </xsl:when>
|
---|
986 | <xsl:otherwise>
|
---|
987 | <xsl:text>
|
---|
988 | DESTDIR=$PKG_DEST ninja</xsl:text>
|
---|
989 | <xsl:call-template name="outputpkgdest">
|
---|
990 | <xsl:with-param
|
---|
991 | name="outputstring"
|
---|
992 | select="substring-after($outputstring,'ninja')"/>
|
---|
993 | </xsl:call-template>
|
---|
994 | </xsl:otherwise>
|
---|
995 | </xsl:choose>
|
---|
996 | </xsl:when>
|
---|
997 | <xsl:otherwise> <!-- no make nor ninja in this string -->
|
---|
998 | <xsl:choose>
|
---|
999 | <xsl:when test="contains($outputstring,'>/') and
|
---|
1000 | not(contains(substring-before($outputstring,'>/'),' /'))">
|
---|
1001 | <xsl:call-template name="remove-ampersand">
|
---|
1002 | <xsl:with-param name="out-string"
|
---|
1003 | select="substring-before($outputstring,'>/')"/>
|
---|
1004 | </xsl:call-template>
|
---|
1005 | <!-- <xsl:value-of select="substring-before($outputstring,'>/')"/>-->
|
---|
1006 | <xsl:text>>$PKG_DEST/</xsl:text>
|
---|
1007 | <xsl:call-template name="outputpkgdest">
|
---|
1008 | <xsl:with-param name="outputstring" select="substring-after($outputstring,'>/')"/>
|
---|
1009 | </xsl:call-template>
|
---|
1010 | </xsl:when>
|
---|
1011 | <xsl:when test="contains($outputstring,' /')">
|
---|
1012 | <xsl:call-template name="remove-ampersand">
|
---|
1013 | <xsl:with-param name="out-string"
|
---|
1014 | select="substring-before($outputstring,' /')"/>
|
---|
1015 | </xsl:call-template>
|
---|
1016 | <!-- <xsl:value-of select="substring-before($outputstring,' /')"/>-->
|
---|
1017 | <xsl:text> $PKG_DEST/</xsl:text>
|
---|
1018 | <xsl:call-template name="outputpkgdest">
|
---|
1019 | <xsl:with-param name="outputstring" select="substring-after($outputstring,' /')"/>
|
---|
1020 | </xsl:call-template>
|
---|
1021 | </xsl:when>
|
---|
1022 | <xsl:otherwise>
|
---|
1023 | <xsl:call-template name="remove-ampersand">
|
---|
1024 | <xsl:with-param name="out-string" select="$outputstring"/>
|
---|
1025 | </xsl:call-template>
|
---|
1026 | <!-- <xsl:value-of select="$outputstring"/>-->
|
---|
1027 | </xsl:otherwise>
|
---|
1028 | </xsl:choose>
|
---|
1029 | </xsl:otherwise>
|
---|
1030 | </xsl:choose>
|
---|
1031 | </xsl:template>
|
---|
1032 |
|
---|
1033 | <xsl:template name="remove-ampersand">
|
---|
1034 | <xsl:param name="out-string" select="''"/>
|
---|
1035 | <xsl:choose>
|
---|
1036 | <xsl:when test="contains($out-string,'&&
')">
|
---|
1037 | <xsl:variable name="instruction-before">
|
---|
1038 | <xsl:call-template name="last-line">
|
---|
1039 | <xsl:with-param
|
---|
1040 | name="instructions"
|
---|
1041 | select="substring-before($out-string,'&&
')"/>
|
---|
1042 | </xsl:call-template>
|
---|
1043 | </xsl:variable>
|
---|
1044 | <xsl:call-template name="remove-end-space">
|
---|
1045 | <xsl:with-param
|
---|
1046 | name="instructions"
|
---|
1047 | select="substring-before($out-string,'&&
')"/>
|
---|
1048 | </xsl:call-template>
|
---|
1049 | <xsl:if test="contains($instruction-before,' ]') or
|
---|
1050 | contains($instruction-before,'test ') or
|
---|
1051 | contains($instruction-before,'pgrep -l')">
|
---|
1052 | <xsl:text> &&</xsl:text>
|
---|
1053 | </xsl:if>
|
---|
1054 | <xsl:text>
|
---|
1055 | </xsl:text>
|
---|
1056 | <xsl:call-template name="remove-ampersand">
|
---|
1057 | <xsl:with-param name="out-string"
|
---|
1058 | select="substring-after($out-string,
|
---|
1059 | '&&
')"/>
|
---|
1060 | </xsl:call-template>
|
---|
1061 | </xsl:when>
|
---|
1062 | <xsl:otherwise>
|
---|
1063 | <xsl:copy-of select="$out-string"/>
|
---|
1064 | </xsl:otherwise>
|
---|
1065 | </xsl:choose>
|
---|
1066 | </xsl:template>
|
---|
1067 |
|
---|
1068 | <xsl:template name="last-line">
|
---|
1069 | <xsl:param name="instructions" select="''"/>
|
---|
1070 | <xsl:choose>
|
---|
1071 | <xsl:when test="contains($instructions,'
')">
|
---|
1072 | <xsl:call-template name="last-line">
|
---|
1073 | <xsl:with-param
|
---|
1074 | name="instructions"
|
---|
1075 | select="substring-after($instructions,'
')"/>
|
---|
1076 | </xsl:call-template>
|
---|
1077 | </xsl:when>
|
---|
1078 | <xsl:otherwise>
|
---|
1079 | <xsl:copy-of select="normalize-space($instructions)"/>
|
---|
1080 | </xsl:otherwise>
|
---|
1081 | </xsl:choose>
|
---|
1082 | </xsl:template>
|
---|
1083 |
|
---|
1084 | <xsl:template name="remove-end-space">
|
---|
1085 | <xsl:param name="instructions" select="''"/>
|
---|
1086 | <xsl:choose>
|
---|
1087 | <xsl:when
|
---|
1088 | test="substring($instructions,string-length($instructions))=' '">
|
---|
1089 | <xsl:call-template name="remove-end-space">
|
---|
1090 | <xsl:with-param
|
---|
1091 | name="instructions"
|
---|
1092 | select="substring($instructions,
|
---|
1093 | 1,
|
---|
1094 | string-length($instructions)-1)"/>
|
---|
1095 | </xsl:call-template>
|
---|
1096 | </xsl:when>
|
---|
1097 | <xsl:otherwise>
|
---|
1098 | <xsl:copy-of select="$instructions"/>
|
---|
1099 | </xsl:otherwise>
|
---|
1100 | </xsl:choose>
|
---|
1101 | </xsl:template>
|
---|
1102 |
|
---|
1103 | </xsl:stylesheet>
|
---|