source: BLFS/libs/scripts.xsl@ 4a33ef0

2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since 4a33ef0 was 0efb837, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

BLFS: Changes to handle the new Xorg7 installation commands structure.

  • Property mode set to 100644
File size: 16.1 KB
RevLine 
[3c10176]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
[c0bc66d]12 <!-- Build as user (y) or as root (n)? -->
13 <xsl:param name="sudo" select="y"/>
14
[3c10176]15 <xsl:template match="/">
16 <xsl:apply-templates select="//sect1"/>
17 </xsl:template>
18
19<!--=================== Master chunks code ======================-->
20
21 <xsl:template match="sect1">
[b45f723]22 <xsl:if test="(count(descendant::screen/userinput) &gt; 0 and
[3c10176]23 count(descendant::screen/userinput) &gt;
[b45f723]24 count(descendant::screen[@role='nodump'])) and
25 @id != 'locale-issues' and @id != 'xorg7' and
26 @id != 'x-setup'">
[3c10176]27
28 <!-- The file names -->
[f4ed135]29 <xsl:variable name="filename" select="@id"/>
[3c10176]30
31 <!-- Package name (use "Download FTP" by default. If empty, use "Download HTTP" -->
[55bc23b]32 <xsl:variable name="package">
[3c10176]33 <xsl:choose>
34 <xsl:when
35 test="string-length(sect2[@role='package']/itemizedlist/listitem[2]/para/ulink/@url)
36 &gt; '10'">
37 <xsl:call-template name="package_name">
38 <xsl:with-param name="url"
39 select="sect2[@role='package']/itemizedlist/listitem[2]/para/ulink/@url"/>
40 </xsl:call-template>
41 </xsl:when>
42 <xsl:otherwise>
43 <xsl:call-template name="package_name">
44 <xsl:with-param name="url"
45 select="sect2[@role='package']/itemizedlist/listitem[1]/para/ulink/@url"/>
46 </xsl:call-template>
47 </xsl:otherwise>
48 </xsl:choose>
[55bc23b]49 </xsl:variable>
[3c10176]50
51 <!-- FTP dir name -->
[55bc23b]52 <xsl:variable name="ftpdir">
[3c10176]53 <xsl:call-template name="ftp_dir">
54 <xsl:with-param name="package" select="$package"/>
55 </xsl:call-template>
[55bc23b]56 </xsl:variable>
[3c10176]57
58 <!-- The build order -->
59 <xsl:variable name="position" select="position()"/>
60 <xsl:variable name="order">
61 <xsl:choose>
62 <xsl:when test="string-length($position) = 1">
63 <xsl:text>00</xsl:text>
64 <xsl:value-of select="$position"/>
65 </xsl:when>
66 <xsl:when test="string-length($position) = 2">
67 <xsl:text>0</xsl:text>
68 <xsl:value-of select="$position"/>
69 </xsl:when>
70 <xsl:otherwise>
71 <xsl:value-of select="$position"/>
72 </xsl:otherwise>
73 </xsl:choose>
74 </xsl:variable>
75
76 <!-- Depuration code -->
77 <xsl:message>
78 <xsl:text>SCRIPT is </xsl:text>
79 <xsl:value-of select="concat($order,'-',$filename)"/>
80 <xsl:text>&#xA; PACKAGE is </xsl:text>
81 <xsl:value-of select="$package"/>
82 <xsl:text>&#xA; FTPDIR is </xsl:text>
83 <xsl:value-of select="$ftpdir"/>
84 <xsl:text>&#xA;&#xA;</xsl:text>
85 </xsl:message>
86
87 <!-- Creating the scripts -->
[73c3c1c]88 <exsl:document href="{$order}-z-{$filename}" method="text">
[91ff6a9]89 <xsl:text>#!/bin/bash&#xA;set -e&#xA;&#xA;</xsl:text>
[3c10176]90 <xsl:choose>
91 <!-- Package page -->
[b45f723]92 <xsl:when test="sect2[@role='package'] and not(@id = 'xorg7-app' or
93 @id = 'xorg7-data' or @id = 'xorg7-driver' or
94 @id = 'xorg7-font' or @id = 'xorg7-lib' or
95 @id = 'xorg7-proto' or @id = 'xorg7-util')">
[3c10176]96 <!-- Variables -->
97 <xsl:text>SRC_ARCHIVE=$SRC_ARCHIVE&#xA;</xsl:text>
98 <xsl:text>FTP_SERVER=$FTP_SERVER&#xA;&#xA;PACKAGE=</xsl:text>
99 <xsl:value-of select="$package"/>
100 <xsl:text>&#xA;PKG_DIR=</xsl:text>
101 <xsl:value-of select="$ftpdir"/>
[8b57785]102 <xsl:text>&#xA;SRC_DIR=$SRC_DIR&#xA;&#xA;</xsl:text>
[3c10176]103 <!-- Download code and build commands -->
104 <xsl:apply-templates select="sect2">
105 <xsl:with-param name="package" select="$package"/>
106 <xsl:with-param name="ftpdir" select="$ftpdir"/>
107 </xsl:apply-templates>
108 <!-- Clean-up -->
[f65d3cb]109 <xsl:text>cd $SRC_DIR/$PKG_DIR&#xA;</xsl:text>
[859d863]110 <xsl:text>rm -rf $UNPACKDIR unpacked&#xA;&#xA;</xsl:text>
[3c10176]111 </xsl:when>
[b45f723]112 <!-- Xorg7 pseudo-packages -->
113 <xsl:when test="contains(@id,'xorg7') and not(@id = 'xorg7-server')">
114 <xsl:text>SRC_DIR=$SRC_DIR
115
116cd $SRC_DIR
117mkdir -p xc
118cd xc&#xA;</xsl:text>
119 <xsl:apply-templates select="sect2" mode="xorg7"/>
120 </xsl:when>
[3c10176]121 <!-- Non-package page -->
122 <xsl:otherwise>
123 <xsl:apply-templates select=".//screen"/>
124 </xsl:otherwise>
125 </xsl:choose>
126 <xsl:text>exit</xsl:text>
127 </exsl:document>
128
129 </xsl:if>
130 </xsl:template>
131
132<!--======================= Sub-sections code =======================-->
133
134 <xsl:template match="sect2">
135 <xsl:param name="package" select="foo"/>
136 <xsl:param name="ftpdir" select="foo"/>
137 <xsl:choose>
138 <xsl:when test="@role = 'package'">
[f65d3cb]139 <xsl:text>mkdir -p $SRC_DIR/$PKG_DIR&#xA;</xsl:text>
140 <xsl:text>cd $SRC_DIR/$PKG_DIR&#xA;</xsl:text>
[3c10176]141 <xsl:apply-templates select="itemizedlist/listitem/para">
142 <xsl:with-param name="package" select="$package"/>
143 <xsl:with-param name="ftpdir" select="$ftpdir"/>
144 </xsl:apply-templates>
145 <xsl:text>&#xA;</xsl:text>
146 </xsl:when>
147 <xsl:when test="@role = 'installation'">
[859d863]148 <xsl:text>
149if [[ -e unpacked ]] ; then
150 UNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
151 rm -rf $UNPACKDIR
152fi
153tar -xvf $PACKAGE > unpacked
154UNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
[6ff1be4]155cd $UNPACKDIR&#xA;</xsl:text>
[3c10176]156 <xsl:apply-templates select=".//screen | .//para/command"/>
[a1d0d5c]157 <xsl:if test="$sudo = 'y'">
[52b0d10]158 <xsl:text>sudo /sbin/</xsl:text>
[a1d0d5c]159 </xsl:if>
160 <xsl:text>ldconfig&#xA;&#xA;</xsl:text>
[3c10176]161 </xsl:when>
162 <xsl:when test="@role = 'configuration'">
163 <xsl:apply-templates select=".//screen"/>
164 <xsl:text>&#xA;</xsl:text>
165 </xsl:when>
166 </xsl:choose>
167 </xsl:template>
168
[b45f723]169 <xsl:template match="sect2" mode="xorg7">
170 <xsl:choose>
[0efb837]171 <xsl:when test="@role = 'package'">
172 <xsl:apply-templates select="itemizedlist/listitem/para" mode="xorg7"/>
173 </xsl:when>
[b45f723]174 <xsl:when test="not(@role)">
175 <xsl:apply-templates select=".//screen"/>
[0efb837]176 <xsl:apply-templates select="../sect2[@role='package']/itemizedlist/listitem/para" mode="xorg7-patch"/>
177 <xsl:apply-templates select=".//screen" mode="sect-ver"/>
[b45f723]178 </xsl:when>
179 <xsl:when test="@role = 'installation'">
[0efb837]180 <xsl:text>for package in $(grep -v '^#' ../${sect-ver}.wget) ; do
[b45f723]181 packagedir=$(echo $package | sed 's/.tar.bz2//')
182 tar -xf $package
183 cd $packagedir&#xA;</xsl:text>
184 <xsl:apply-templates select=".//screen | .//para/command"/>
[5be3651]185 <xsl:text> cd ..
[b45f723]186 rm -rf $packagedir
187done&#xA;</xsl:text>
188 <xsl:if test="$sudo = 'y'">
[52b0d10]189 <xsl:text>sudo /sbin/</xsl:text>
[b45f723]190 </xsl:if>
191 <xsl:text>ldconfig&#xA;&#xA;</xsl:text>
192 </xsl:when>
[0efb837]193 <xsl:when test="@role = 'configuration'">
194 <xsl:apply-templates select=".//screen"/>
195 <xsl:text>&#xA;</xsl:text>
196 </xsl:when>
[b45f723]197 </xsl:choose>
198 </xsl:template>
199
[3c10176]200<!--==================== Download code =======================-->
201
202 <xsl:template name="package_name">
203 <xsl:param name="url" select="foo"/>
204 <xsl:param name="sub-url" select="substring-after($url,'/')"/>
205 <xsl:choose>
206 <xsl:when test="contains($sub-url,'/')">
207 <xsl:call-template name="package_name">
208 <xsl:with-param name="url" select="$sub-url"/>
209 </xsl:call-template>
210 </xsl:when>
211 <xsl:otherwise>
212 <xsl:choose>
213 <xsl:when test="contains($sub-url,'?')">
214 <xsl:value-of select="substring-before($sub-url,'?')"/>
215 </xsl:when>
216 <xsl:when test="contains($sub-url,'.patch')"/>
217 <xsl:otherwise>
218 <xsl:value-of select="$sub-url"/>
219 </xsl:otherwise>
220 </xsl:choose>
221 </xsl:otherwise>
222 </xsl:choose>
223 </xsl:template>
224
225 <xsl:template name="ftp_dir">
226 <xsl:param name="package" select="foo"/>
227 <!-- A lot of hardcoded dir names. Not full revised yet. -->
228 <xsl:choose>
229 <!-- cdparanoia -->
230 <xsl:when test="contains($package, '-III')">
231 <xsl:text>cdparanoia</xsl:text>
232 </xsl:when>
233 <!-- DobBook 3.1 -->
234 <xsl:when test="contains($package, 'docbk31')">
235 <xsl:text>docbk</xsl:text>
236 </xsl:when>
237 <!-- gc -->
238 <xsl:when test="contains($package, 'gc6')">
239 <xsl:text>gc</xsl:text>
240 </xsl:when>
241 <!-- ISO-codes -->
242 <xsl:when test="contains($package, 'iso-codes')">
243 <xsl:text>iso-codes</xsl:text>
244 </xsl:when>
245 <!-- JPEG -->
246 <xsl:when test="contains($package, 'jpegsrc')">
247 <xsl:text>jpeg</xsl:text>
248 </xsl:when>
249 <!-- lynx -->
250 <xsl:when test="contains($package, 'lynx')">
251 <xsl:text>lynx</xsl:text>
252 </xsl:when>
253 <!-- ntp -->
254 <xsl:when test="contains($package, 'ntp')">
255 <xsl:text>ntp</xsl:text>
256 </xsl:when>
257 <!-- OpenLDAP -->
258 <xsl:when test="contains($package, 'openldap')">
259 <xsl:text>openldap</xsl:text>
260 </xsl:when>
261 <!-- Open Office -->
262 <xsl:when test="contains($package, 'OOo')">
263 <xsl:text>OOo</xsl:text>
264 </xsl:when>
265 <!-- pine -->
266 <xsl:when test="contains($package, 'pine')">
267 <xsl:text>pine</xsl:text>
268 </xsl:when>
269 <!-- portmap -->
270 <xsl:when test="contains($package, 'portmap')">
271 <xsl:text>portmap</xsl:text>
272 </xsl:when>
273 <!-- psutils -->
274 <xsl:when test="contains($package, 'psutils')">
275 <xsl:text>psutils</xsl:text>
276 </xsl:when>
277 <!-- qpopper -->
278 <xsl:when test="contains($package, 'qpopper')">
279 <xsl:text>qpopper</xsl:text>
280 </xsl:when>
281 <!-- QT -->
282 <xsl:when test="contains($package, 'qt-x')">
283 <xsl:text>qt-x11-free</xsl:text>
284 </xsl:when>
285 <!-- sendmail -->
286 <xsl:when test="contains($package, 'sendmail')">
287 <xsl:text>sendmail</xsl:text>
288 </xsl:when>
289 <!-- Slib -->
290 <xsl:when test="contains($package, 'slib')">
291 <xsl:text>slib</xsl:text>
292 </xsl:when>
293 <!-- TCL -->
294 <xsl:when test="contains($package, 'tcl')">
295 <xsl:text>tcl</xsl:text>
296 </xsl:when>
297 <!-- tcpwrappers -->
298 <xsl:when test="contains($package, 'tcp_wrappers')">
299 <xsl:text>tcp_wrappers</xsl:text>
300 </xsl:when>
301 <!-- TeTeX -->
302 <xsl:when test="contains($package, 'tetex')">
303 <xsl:text>tetex</xsl:text>
304 </xsl:when>
305 <!-- Tidy -->
306 <xsl:when test="contains($package, 'tidy')">
307 <xsl:text>tidy</xsl:text>
308 </xsl:when>
309 <!-- Tk -->
310 <xsl:when test="contains($package, 'tk8')">
311 <xsl:text>tk</xsl:text>
312 </xsl:when>
313 <!-- unzip -->
314 <xsl:when test="contains($package, 'unzip')">
315 <xsl:text>unzip</xsl:text>
316 </xsl:when>
317 <!-- wireless_tools -->
318 <xsl:when test="contains($package, 'wireless_tools')">
319 <xsl:text>wireless_tools</xsl:text>
320 </xsl:when>
321 <!-- whois -->
322 <xsl:when test="contains($package, 'whois')">
323 <xsl:text>whois</xsl:text>
324 </xsl:when>
325 <!-- XOrg -->
326 <xsl:when test="contains($package, 'X11R6')">
327 <xsl:text>Xorg</xsl:text>
328 </xsl:when>
329 <!-- zip -->
330 <xsl:when test="contains($package, 'zip2')">
331 <xsl:text>zip</xsl:text>
332 </xsl:when>
333 <!-- General rule -->
334 <xsl:otherwise>
335 <xsl:variable name="cut"
336 select="translate(substring-after($package, '-'), '0123456789', '0000000000')"/>
337 <xsl:variable name="package2">
338 <xsl:value-of select="substring-before($package, '-')"/>
339 <xsl:text>-</xsl:text>
340 <xsl:value-of select="$cut"/>
341 </xsl:variable>
342 <xsl:value-of select="substring-before($package2, '-0')"/>
343 </xsl:otherwise>
344 </xsl:choose>
345 </xsl:template>
346
347 <xsl:template match="itemizedlist/listitem/para">
348 <xsl:param name="package" select="foo"/>
349 <xsl:param name="ftpdir" select="foo"/>
350 <xsl:choose>
351 <!-- This depend on all package pages having both "Download HTTP" and "Download FTP" lines -->
352 <xsl:when test="contains(string(),'HTTP')">
353 <xsl:text>if [[ ! -f $PACKAGE ]] ; then&#xA;</xsl:text>
354 <!-- SRC_ARCHIVE may have subdirectories or not -->
355 <xsl:text> if [[ -f $SRC_ARCHIVE/$PKG_DIR/$PACKAGE ]] ; then&#xA;</xsl:text>
356 <xsl:text> cp $SRC_ARCHIVE/$PKG_DIR/$PACKAGE $PACKAGE&#xA;</xsl:text>
357 <xsl:text> elif [[ -f $SRC_ARCHIVE/$PACKAGE ]] ; then&#xA;</xsl:text>
358 <xsl:text> cp $SRC_ARCHIVE/$PACKAGE $PACKAGE&#xA; else&#xA;</xsl:text>
359 <!-- The FTP_SERVER mirror -->
[6d0dbc3]360 <xsl:text> wget ${FTP_SERVER}conglomeration/$PKG_DIR/$PACKAGE</xsl:text>
[3c10176]361 <!-- Upstream HTTP URL -->
[f221c2c]362 <xsl:if test="string-length(ulink/@url) &gt; '10'">
[3c10176]363 <xsl:text> || \&#xA; wget </xsl:text>
[f221c2c]364 <xsl:choose>
365 <xsl:when test="contains(ulink/@url,'?')">
366 <xsl:value-of select="substring-before(ulink/@url,'?')"/>
367 </xsl:when>
368 <xsl:otherwise>
369 <xsl:value-of select="ulink/@url"/>
370 </xsl:otherwise>
371 </xsl:choose>
[3c10176]372 </xsl:if>
373 </xsl:when>
374 <xsl:when test="contains(string(),'FTP')">
375 <!-- Upstream FTP URL -->
376 <xsl:if test="string-length(ulink/@url) &gt; '10'">
377 <xsl:text> || \&#xA; wget </xsl:text>
378 <xsl:value-of select="ulink/@url"/>
379 </xsl:if>
380 <xsl:text>&#xA; fi&#xA;fi&#xA;</xsl:text>
381 </xsl:when>
382 <xsl:when test="contains(string(),'MD5')">
383 <xsl:text>echo "</xsl:text>
384 <xsl:value-of select="substring-after(string(),'sum: ')"/>
385 <xsl:text>&#x20;&#x20;$PACKAGE" | md5sum -c -&#xA;</xsl:text>
386 </xsl:when>
387 <!-- Patches -->
388 <xsl:when test="contains(string(ulink/@url),'.patch')">
389 <xsl:text>wget </xsl:text>
390 <xsl:value-of select="ulink/@url"/>
391 <xsl:text>&#xA;</xsl:text>
392 </xsl:when>
393 </xsl:choose>
394 </xsl:template>
395
[5be3651]396 <xsl:template match="itemizedlist/listitem/para" mode="xorg7">
[0efb837]397 <xsl:if test="contains(string(ulink/@url),'.md5') or
398 contains(string(ulink/@url),'.wget')">
399 <xsl:text>wget </xsl:text>
400 <xsl:value-of select="ulink/@url"/>
401 <xsl:text>&#xA;</xsl:text>
402 </xsl:if>
403 </xsl:template>
404
405 <xsl:template match="itemizedlist/listitem/para" mode="xorg7-patch">
[5be3651]406 <xsl:if test="contains(string(ulink/@url),'.patch')">
407 <xsl:text>wget </xsl:text>
408 <xsl:value-of select="ulink/@url"/>
409 <xsl:text>&#xA;</xsl:text>
410 </xsl:if>
411 </xsl:template>
412
[3c10176]413<!--======================== Commands code ==========================-->
414
415 <xsl:template match="screen">
416 <xsl:if test="child::* = userinput and not(@role = 'nodump')">
[c0bc66d]417 <xsl:if test="@role = 'root' and $sudo = 'y'">
[3c10176]418 <xsl:text>sudo sh -c "</xsl:text>
419 </xsl:if>
420 <xsl:apply-templates select="userinput"/>
[c0bc66d]421 <xsl:if test="@role = 'root' and $sudo = 'y'">
[3c10176]422 <xsl:text>"</xsl:text>
423 </xsl:if>
424 <xsl:text>&#xA;</xsl:text>
425 </xsl:if>
426 </xsl:template>
427
[0efb837]428 <xsl:template match="screen" mode="sect-ver">
429 <xsl:text>sect-ver=</xsl:text>
430 <xsl:value-of select="substring-before(substring-after(string(),'-c ../'),'.md5')"/>
431 <xsl:text>&#xA;</xsl:text>
[b45f723]432 </xsl:template>
433
[3c10176]434 <xsl:template match="para/command">
435 <xsl:if test="(contains(string(),'test') or
436 contains(string(),'check'))">
437 <xsl:text>#</xsl:text>
438 <xsl:value-of select="substring-before(string(),'make')"/>
439 <xsl:text>make -k</xsl:text>
440 <xsl:value-of select="substring-after(string(),'make')"/>
441 <xsl:text> || true&#xA;</xsl:text>
442 </xsl:if>
443 </xsl:template>
444
445 <xsl:template match="userinput">
446 <xsl:apply-templates/>
447 </xsl:template>
448
449 <xsl:template match="replaceable">
450 <xsl:text>**EDITME</xsl:text>
451 <xsl:apply-templates/>
452 <xsl:text>EDITME**</xsl:text>
453 </xsl:template>
454
455</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.