source: BLFS/xsl/make_book.xsl@ 1d5f3e3

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

Avoid parsing a bridgehead which is not a perl-module

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