source: BLFS/xsl/make_book.xsl@ fbdd1a8

2.4 ablfs-more legacy trunk
Last change on this file since fbdd1a8 was 342c862, checked in by Pierre Labastie <pierre@…>, 8 years ago

Merge new_feature branch r3884 to3886:

  • Adapt BLFS/envars.conf to modern BLFS books
  • Fix try order for downloading BLFS packages
  • Fixes to use the XORG Legacy page in BLFS
  • Property mode set to 100644
File size: 18.9 KB
RevLine 
[e576789]1<?xml version="1.0" encoding="ISO-8859-1"?>
2
3<!-- $Id: make_book.xsl 31 2012-02-19 08:25:04Z labastie $ -->
4
5<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
6 version="1.0">
7
8 <xsl:param name="list" select="''"/>
9 <xsl:param name="MTA" select="'sendmail'"/>
10
11 <xsl:output
12 method="xml"
13 encoding="ISO-8859-1"
14 doctype-system="http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"/>
15
16 <xsl:template match="/">
17 <book>
18 <xsl:copy-of select="/book/bookinfo"/>
19 <preface>
20 <?dbhtml filename="preface.html"?>
21 <title>Preface</title>
22 <xsl:copy-of select="id('bootscripts')"/>
23 </preface>
24 <chapter>
25 <?dbhtml filename="chapter.html"?>
26 <title>Installing packages in dependency build order</title>
27 <xsl:call-template name="apply-list">
28 <xsl:with-param name="list" select="normalize-space($list)"/>
29 </xsl:call-template>
30 </chapter>
31 <xsl:copy-of select="id('CC')"/>
32 <xsl:copy-of select="id('MIT')"/>
33 <index/>
34 </book>
35 </xsl:template>
36
37<!-- apply-templates for each item in the list.
38 Normally, those items are id of nodes.
39 Those nodes can be sect1 (normal case),
40 sect2 (python modules or DBus bindings)
41 bridgehead (perl modules)
42 para (dependency of perl modules).
43 The templates after this one treat each of those cases.
44 However, some items are xorg package names, and not id.
45 We need special instructions in that case.
46 The difficulty is that some of those names *are* id's,
47 because they are referenced in the index.
48 Hopefully, none of those id's are sect{1,2}, bridgehead or para...-->
49 <xsl:template name="apply-list">
50 <xsl:param name="list" select="''"/>
51 <xsl:if test="string-length($list) &gt; 0">
52 <xsl:choose>
53 <xsl:when test="contains($list,' ')">
54 <xsl:call-template name="apply-list">
55 <xsl:with-param name="list"
56 select="substring-before($list,' ')"/>
57 </xsl:call-template>
58 <xsl:call-template name="apply-list">
59 <xsl:with-param name="list"
60 select="substring-after($list,' ')"/>
61 </xsl:call-template>
62 </xsl:when>
63 <xsl:otherwise>
64 <xsl:choose>
65 <xsl:when test="not(id($list)[self::sect1 or self::sect2 or self::para or self::bridgehead])">
66 <xsl:apply-templates
67 select="//sect1[contains(@id,'xorg7')
68 and contains(string(.//userinput),
69 concat($list,'-'))]"
70 mode="xorg">
71 <xsl:with-param name="package" select="$list"/>
72 </xsl:apply-templates>
73 </xsl:when>
74 <xsl:otherwise>
75 <xsl:apply-templates select="id($list)"/>
76 </xsl:otherwise>
77 </xsl:choose>
78 </xsl:otherwise>
79 </xsl:choose>
80 </xsl:if>
81 </xsl:template>
82
83<!-- The normal case : just copy to the book. Exceptions are if there
84 is a xref, so use a special "mode" template -->
85 <xsl:template match="sect1">
86 <xsl:apply-templates select="." mode="sect1"/>
87 </xsl:template>
88
89 <xsl:template match="processing-instruction()" mode="sect1">
90 <xsl:copy-of select="."/>
91 </xsl:template>
92
93<!-- Any node which has no xref descendant is copied verbatim. If there
94 is an xref descendant, output the node and recurse. -->
95 <xsl:template match="*" mode="sect1">
96 <xsl:choose>
97 <xsl:when test="self::xref">
98 <xsl:choose>
99 <xsl:when test="contains(concat(' ',normalize-space($list),' '),
100 concat(' ',@linkend,' '))">
101 <xsl:choose>
102 <xsl:when test="@linkend='x-window-system' or @linkend='xorg7'">
103 <xref linkend="xorg7-server"/>
104 </xsl:when>
105 <xsl:when test="@linkend='server-mail'">
106 <xref linkend="{$MTA}"/>
107 </xsl:when>
108 <xsl:otherwise>
109 <xsl:copy-of select="."/>
110 </xsl:otherwise>
111 </xsl:choose>
112 </xsl:when>
113 <xsl:otherwise>
114 <xsl:choose>
115 <xsl:when test="@linkend='bootscripts'">
116 <xsl:copy-of select="."/>
117 </xsl:when>
118 <xsl:otherwise>
119 <xsl:value-of select="@linkend"/> (in full book)
120 </xsl:otherwise>
121 </xsl:choose>
122 </xsl:otherwise>
123 </xsl:choose>
124 </xsl:when>
125 <xsl:when test=".//xref">
126 <xsl:element name="{name()}">
127 <xsl:for-each select="attribute::*">
128 <xsl:attribute name="{name()}">
129 <xsl:value-of select="."/>
130 </xsl:attribute>
131 </xsl:for-each>
132 <xsl:apply-templates mode="sect1"/>
133 </xsl:element>
134 </xsl:when>
135 <xsl:otherwise>
136 <xsl:copy-of select="."/>
137 </xsl:otherwise>
138 </xsl:choose>
139 </xsl:template>
140
141<!-- Python modules and DBus bindings -->
142 <xsl:template match="sect2">
143 <xsl:apply-templates select='.' mode="sect2"/>
144 </xsl:template>
145
146 <xsl:template match="*" mode="sect2">
147 <xsl:choose>
148 <xsl:when test="self::sect2">
149 <xsl:element name="sect1">
150 <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
151 <xsl:attribute name="xreflabel"><xsl:value-of select="@xreflabel"/></xsl:attribute>
152 <xsl:processing-instruction name="dbhtml">filename="<xsl:value-of
153 select="@id"/>.html"</xsl:processing-instruction>
154 <xsl:apply-templates mode="sect2"/>
155 </xsl:element>
156 </xsl:when>
157 <xsl:when test="self::sect3">
158 <xsl:element name="sect2">
159 <xsl:attribute name="role">
160 <xsl:value-of select="@role"/>
161 </xsl:attribute>
162 <xsl:apply-templates mode="sect2"/>
163 </xsl:element>
164 </xsl:when>
165 <xsl:when test="self::bridgehead">
166 <xsl:element name="bridgehead">
167 <xsl:attribute name="renderas">
168 <xsl:if test="@renderas='sect4'">sect3</xsl:if>
169 <xsl:if test="@renderas='sect5'">sect4</xsl:if>
170 </xsl:attribute>
171 <xsl:value-of select='.'/>
172 </xsl:element>
173 </xsl:when>
174 <xsl:when test="self::xref">
175 <xsl:choose>
176 <xsl:when test="contains(concat(' ',normalize-space($list),' '),
177 concat(' ',@linkend,' '))">
178 <xsl:choose>
179 <xsl:when test="@linkend='x-window-system' or @linkend='xorg7'">
180 <xref linkend="xorg7-server"/>
181 </xsl:when>
182 <xsl:when test="@linkend='server-mail'">
183 <xref linkend="{$MTA}"/>
184 </xsl:when>
185 <xsl:otherwise>
186 <xsl:copy-of select="."/>
187 </xsl:otherwise>
188 </xsl:choose>
189 </xsl:when>
190 <xsl:otherwise>
191 <xsl:value-of select="@linkend"/> (in full book)
192 </xsl:otherwise>
193 </xsl:choose>
194 </xsl:when>
195 <xsl:when test=".//xref">
196 <xsl:element name="{name()}">
197 <xsl:for-each select="attribute::*">
198 <xsl:attribute name="{name()}">
199 <xsl:value-of select="."/>
200 </xsl:attribute>
201 </xsl:for-each>
202 <xsl:apply-templates mode="sect2"/>
203 </xsl:element>
204 </xsl:when>
205 <xsl:otherwise>
206 <xsl:copy-of select="."/>
207 </xsl:otherwise>
208 </xsl:choose>
209 </xsl:template>
210
211<!-- Perl modules : transform them to minimal sect1. Use a template
212 for installation instructions -->
213 <xsl:template match="bridgehead">
214 <xsl:element name="sect1">
215 <xsl:attribute name="id"><xsl:value-of select="./@id"/></xsl:attribute>
216 <xsl:attribute name="xreflabel"><xsl:value-of select="./@xreflabel"/></xsl:attribute>
217 <xsl:processing-instruction name="dbhtml">
218 filename="<xsl:value-of select="@id"/>.html"</xsl:processing-instruction>
219 <title><xsl:value-of select="./@xreflabel"/></title>
220 <sect2 role="package">
221 <title>Introduction to <xsl:value-of select="@id"/></title>
222 <bridgehead renderas="sect3">Package Information</bridgehead>
223 <itemizedlist spacing="compact">
224 <listitem>
225 <para>Download (HTTP): <xsl:copy-of select="./following-sibling::itemizedlist[1]/listitem/para/ulink"/></para>
226 </listitem>
227 <listitem>
228 <para>Download (FTP): <ulink url=" "/></para>
229 </listitem>
230 </itemizedlist>
231 </sect2>
232 <xsl:choose>
233 <xsl:when test="following-sibling::itemizedlist[1]//xref[@linkend='perl-standard-install'] | following-sibling::itemizedlist[1]/preceding-sibling::para//xref[@linkend='perl-standard-install']">
234 <xsl:apply-templates mode="perl-install" select="id('perl-standard-install')"/>
235 </xsl:when>
236 <xsl:otherwise>
237 <sect2 role="installation">
238 <title>Installation of <xsl:value-of select="@xreflabel"/></title>
239 <para>Run the following commands:</para>
240 <for-each select="following-sibling::bridgehead/preceding-sibling::screen[not(@role)]">
241 <xsl:copy-of select="."/>
242 </for-each>
243 <para>Now, as the <systemitem class="username">root</systemitem> user:</para>
244 <for-each select="following-sibling::bridgehead/preceding-sibling::screen[@role='root']">
245 <xsl:copy-of select="."/>
246 </for-each>
247 </sect2>
248 </xsl:otherwise>
249 </xsl:choose>
250 </xsl:element>
251 </xsl:template>
252
253<!-- The case of depdendencies of perl modules. Same treatment
254 as for perl modules. Just easier because always perl standard -->
255 <xsl:template match="para">
256 <xsl:element name="sect1">
257 <xsl:attribute name="id"><xsl:value-of select="./@id"/></xsl:attribute>
258 <xsl:attribute name="xreflabel"><xsl:value-of select="./@xreflabel"/></xsl:attribute>
259 <xsl:processing-instruction name="dbhtml">filename="<xsl:value-of
260 select="@id"/>.html"</xsl:processing-instruction>
261 <title><xsl:value-of select="./@xreflabel"/></title>
262 <sect2 role="package">
263 <title>Introduction to <xsl:value-of select="@id"/></title>
264 <bridgehead renderas="sect3">Package Information</bridgehead>
265 <itemizedlist spacing="compact">
266 <listitem>
267 <para>Download (HTTP): <xsl:copy-of select="./ulink"/></para>
268 </listitem>
269 <listitem>
270 <para>Download (FTP): <ulink url=" "/></para>
271 </listitem>
272 </itemizedlist>
273 </sect2>
274 <xsl:apply-templates mode="perl-install" select="id('perl-standard-install')"/>
275 </xsl:element>
276 </xsl:template>
277
278<!-- copy of the perl standard installation instructions:
279 suppress id (otherwise not unique) and note (which we
280 do not want to apply -->
281 <xsl:template match="sect2" mode="perl-install">
282 <sect2 role="installation">
283 <xsl:for-each select="./*">
284 <xsl:if test="not(self::note)">
285 <xsl:copy-of select="."/>
286 </xsl:if>
287 </xsl:for-each>
288 </sect2>
289 </xsl:template>
290
291<!-- we have got an xorg package. We are at the installation page
292 but now we need to make an autonomous page from the global
293 one -->
294 <xsl:template match="sect1" mode="xorg">
295 <xsl:param name="package"/>
296 <xsl:variable name="tarball">
297 <xsl:call-template name="tarball">
298 <xsl:with-param name="package" select="concat(' ',$package,'-')"/>
299 <xsl:with-param name="cat-md5"
300 select="string(.//userinput[starts-with(string(),'cat ')])"/>
301 </xsl:call-template>
302 </xsl:variable>
303 <xsl:variable name="md5sum">
304 <xsl:call-template name="md5sum">
305 <xsl:with-param name="package" select="concat(' ',$package,'-')"/>
306 <xsl:with-param name="cat-md5"
307 select=".//userinput[starts-with(string(),'cat ')]"/>
308 </xsl:call-template>
309 </xsl:variable>
[342c862]310 <xsl:variable name="download-dir">
311 <xsl:call-template name="download-dir">
312 <xsl:with-param name="package" select="concat(' ',$package,'-')"/>
313 <xsl:with-param name="cat-md5"
314 select=".//userinput[starts-with(string(),'cat ')]"/>
315 </xsl:call-template>
316 </xsl:variable>
[e576789]317 <xsl:variable name="install-instructions">
318 <xsl:call-template name="inst-instr">
319 <xsl:with-param name="inst-instr"
320 select=".//userinput[starts-with(string(),'for ')]"/>
321 </xsl:call-template>
322 </xsl:variable>
323 <xsl:element name="sect1">
324 <xsl:attribute name="id"><xsl:value-of select="$package"/></xsl:attribute>
325 <xsl:processing-instruction name="dbhtml">
326 filename="<xsl:value-of select='$package'/>.html"
327 </xsl:processing-instruction>
328 <title><xsl:value-of select="$package"/></title>
329 <sect2 role="package">
330 <title>Introduction to <xsl:value-of select="$package"/></title>
331 <bridgehead renderas="sect3">Package Information</bridgehead>
332 <itemizedlist spacing="compact">
333 <listitem>
334 <para>Download (HTTP): <xsl:element name="ulink">
335 <xsl:attribute name="url">
336 <xsl:value-of
337 select=".//para[contains(string(),'(HTTP)')]/ulink/@url"/>
[342c862]338 <xsl:value-of select="$download-dir"/>
[e576789]339 <xsl:value-of select="$tarball"/>
340 </xsl:attribute>
341 </xsl:element>
342 </para>
343 </listitem>
344 <listitem>
345 <para>Download (FTP): <xsl:element name="ulink">
346 <xsl:attribute name="url">
347 <xsl:value-of
348 select=".//para[contains(string(),'(FTP)')]/ulink/@url"/>
[342c862]349 <xsl:value-of select="$download-dir"/>
[e576789]350 <xsl:value-of select="$tarball"/>
351 </xsl:attribute>
352 </xsl:element>
353 </para>
354 </listitem>
355 <listitem>
356 <para>
357 Download MD5 sum: <xsl:value-of select="$md5sum"/>
358 </para>
359 </listitem>
360 </itemizedlist>
[642722f]361 <!-- If there is an additional download, we need to output that -->
362 <xsl:if test=".//bridgehead[contains(string(),'Additional')]">
363 <xsl:copy-of
364 select=".//bridgehead[contains(string(),'Additional')]"/>
365 <xsl:copy-of
366 select=".//bridgehead[contains(string(),'Additional')]
367 /following-sibling::itemizedlist[1]"/>
368 </xsl:if>
[e576789]369 </sect2>
370 <sect2 role="installation">
371 <title>Installation of <xsl:value-of select="$package"/></title>
372
373 <para>
374 Install <application><xsl:value-of select="$package"/></application>
375 by running the following commands:
376 </para>
377
378 <screen><userinput>packagedir=<xsl:value-of
379 select="substring-before($tarball,'.tar.bz2')"/>
380 <xsl:text>&#xA;</xsl:text>
381 <xsl:value-of select="substring-before($install-instructions,
382 'as_root')"/>
383 </userinput></screen>
384
385 <para>
386 Now as the <systemitem class="username">root</systemitem> user:
387 </para>
388 <screen role='root'>
389 <userinput><xsl:value-of select="substring-after(
390 $install-instructions,
391 'as_root')"/>
392 </userinput>
393 </screen>
394 </sect2>
395 </xsl:element><!-- sect1 -->
396
397 </xsl:template>
398
399<!-- get the tarball name from the text that comes from the .md5 file -->
400 <xsl:template name="tarball">
401 <xsl:param name="package"/>
402 <xsl:param name="cat-md5"/>
403<!-- DEBUG
404<xsl:message><xsl:text>Entering "tarball" template:
405 package is: </xsl:text>
406<xsl:value-of select="$package"/><xsl:text>
407 cat-md5 is: </xsl:text>
408<xsl:value-of select="$cat-md5"/>
409</xsl:message>
410END DEBUG -->
411 <xsl:choose>
412 <xsl:when test="contains(substring-before($cat-md5,$package),'&#xA;')">
413 <xsl:call-template name="tarball">
414 <xsl:with-param name="package" select="$package"/>
415 <xsl:with-param name="cat-md5"
416 select="substring-after($cat-md5,'&#xA;')"/>
417 </xsl:call-template>
418 </xsl:when>
[342c862]419 <xsl:when test="contains(substring-before($cat-md5,$package),' ')">
420 <xsl:call-template name="tarball">
421 <xsl:with-param name="package" select="$package"/>
422 <xsl:with-param name="cat-md5"
423 select="substring-after($cat-md5,' ')"/>
424 </xsl:call-template>
425 </xsl:when>
[e576789]426 <xsl:otherwise>
427 <xsl:copy-of select="substring-after(
[342c862]428 substring-before($cat-md5,'&#xA;'),' ')"/>
429 </xsl:otherwise>
430 </xsl:choose>
431 </xsl:template>
432<!-- get the download dirname from the text that comes from the .md5 file -->
433 <xsl:template name="download-dir">
434 <xsl:param name="package"/>
435 <xsl:param name="cat-md5"/>
436 <xsl:choose>
437 <xsl:when test="not(@id='xorg7-legacy')">
438 <xsl:copy-of select="''"/>
439 </xsl:when>
440 <xsl:when test="contains(substring-before($cat-md5,$package),'&#xA;')">
441 <xsl:call-template name="download-dir">
442 <xsl:with-param name="package" select="$package"/>
443 <xsl:with-param name="cat-md5"
444 select="substring-after($cat-md5,'&#xA;')"/>
445 </xsl:call-template>
446 </xsl:when>
447 <xsl:when test="contains(substring-before($cat-md5,$package),' ')">
448 <xsl:call-template name="download-dir">
449 <xsl:with-param name="package" select="$package"/>
450 <xsl:with-param name="cat-md5"
451 select="substring-after($cat-md5,' ')"/>
452 </xsl:call-template>
453 </xsl:when>
454 <xsl:otherwise>
455 <xsl:copy-of select="substring-before($cat-md5,' ')"/>
[e576789]456 </xsl:otherwise>
457 </xsl:choose>
458 </xsl:template>
459<!-- same for md5sum -->
460 <xsl:template name="md5sum">
461 <xsl:param name="package"/>
462 <xsl:param name="cat-md5"/>
463 <xsl:choose>
464 <xsl:when test="contains(substring-before($cat-md5,$package),'&#xA;')">
465 <xsl:call-template name="md5sum">
466 <xsl:with-param name="package" select="$package"/>
467 <xsl:with-param name="cat-md5"
468 select="substring-after($cat-md5,'&#xA;')"/>
469 </xsl:call-template>
470 </xsl:when>
471 <xsl:otherwise>
472 <xsl:copy-of select="substring-before($cat-md5,' ')"/>
473 </xsl:otherwise>
474 </xsl:choose>
475 </xsl:template>
476
477 <xsl:template name="inst-instr">
478 <xsl:param name="inst-instr"/>
479 <xsl:choose>
480 <xsl:when test="contains($inst-instr,'pushd')">
481 <xsl:call-template name="inst-instr">
482 <xsl:with-param name="inst-instr"
483 select="substring-after(
484 substring-after($inst-instr,'pushd'),
485 '&#xA;')"/>
486 </xsl:call-template>
487 </xsl:when>
488 <xsl:otherwise>
489 <xsl:copy-of select="substring-before($inst-instr,'popd')"/>
490 </xsl:otherwise>
491 </xsl:choose>
492 </xsl:template>
493</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.