source: BLFS/xsl/make_book.xsl@ 6d1d77c

ablfs-more legacy trunk
Last change on this file since 6d1d77c was 91b7b5f, checked in by Pierre Labastie <pierre@…>, 7 years ago

Output a linear book for LFS, with BLFS format

  • Property mode set to 100644
File size: 20.3 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2
3<!-- $Id$ -->
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 <xsl:param name="lfsbook" select="'lfs-full.xml'"/>
11
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
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
29 <xsl:include href="lfs_make_book.xsl"/>
30
31 <xsl:template match="/">
32 <book>
33 <xsl:copy-of select="/book/bookinfo"/>
34 <preface>
35 <?dbhtml filename="preface.html"?>
36 <title>Preface</title>
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>
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>
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>
92 <xsl:choose>
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>
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>
153 <xsl:when test="@linkend='bootscripts' or
154 @linkend='systemd-units'">
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">
253 <xsl:element name="sect1">
254 <xsl:attribute name="id"><xsl:value-of select="./@id"/></xsl:attribute>
255 <xsl:attribute name="xreflabel"><xsl:value-of select="./@xreflabel"/></xsl:attribute>
256 <xsl:processing-instruction name="dbhtml">
257 filename="<xsl:value-of select="@id"/>.html"</xsl:processing-instruction>
258 <title><xsl:value-of select="./@xreflabel"/></title>
259 <sect2 role="package">
260 <title>Introduction to <xsl:value-of select="@id"/></title>
261 <bridgehead renderas="sect3">Package Information</bridgehead>
262 <itemizedlist spacing="compact">
263 <listitem>
264 <para>Download (HTTP): <xsl:copy-of select="./following-sibling::itemizedlist[1]/listitem/para/ulink"/></para>
265 </listitem>
266 <listitem>
267 <para>Download (FTP): <ulink url=" "/></para>
268 </listitem>
269 </itemizedlist>
270 </sect2>
271 <xsl:choose>
272 <xsl:when test="following-sibling::itemizedlist[1]//xref[@linkend='perl-standard-install'] | following-sibling::itemizedlist[1]/preceding-sibling::para//xref[@linkend='perl-standard-install']">
273 <xsl:apply-templates mode="perl-install" select="id('perl-standard-install')"/>
274 </xsl:when>
275 <xsl:otherwise>
276 <sect2 role="installation">
277 <title>Installation of <xsl:value-of select="@xreflabel"/></title>
278 <para>Run the following commands:</para>
279 <for-each select="following-sibling::bridgehead/preceding-sibling::screen[not(@role)]">
280 <xsl:copy-of select="."/>
281 </for-each>
282 <para>Now, as the <systemitem class="username">root</systemitem> user:</para>
283 <for-each select="following-sibling::bridgehead/preceding-sibling::screen[@role='root']">
284 <xsl:copy-of select="."/>
285 </for-each>
286 </sect2>
287 </xsl:otherwise>
288 </xsl:choose>
289 </xsl:element>
290 </xsl:template>
291
292<!-- The case of depdendencies of perl modules. Same treatment
293 as for perl modules. Just easier because always perl standard -->
294 <xsl:template match="para">
295 <xsl:element name="sect1">
296 <xsl:attribute name="id"><xsl:value-of select="./@id"/></xsl:attribute>
297 <xsl:attribute name="xreflabel"><xsl:value-of select="./@xreflabel"/></xsl:attribute>
298 <xsl:processing-instruction name="dbhtml">filename="<xsl:value-of
299 select="@id"/>.html"</xsl:processing-instruction>
300 <title><xsl:value-of select="./@xreflabel"/></title>
301 <sect2 role="package">
302 <title>Introduction to <xsl:value-of select="@id"/></title>
303 <bridgehead renderas="sect3">Package Information</bridgehead>
304 <itemizedlist spacing="compact">
305 <listitem>
306 <para>Download (HTTP): <xsl:copy-of select="./ulink"/></para>
307 </listitem>
308 <listitem>
309 <para>Download (FTP): <ulink url=" "/></para>
310 </listitem>
311 </itemizedlist>
312 </sect2>
313 <xsl:apply-templates mode="perl-install" select="id('perl-standard-install')"/>
314 </xsl:element>
315 </xsl:template>
316
317<!-- copy of the perl standard installation instructions:
318 suppress id (otherwise not unique) and note (which we
319 do not want to apply -->
320 <xsl:template match="sect2" mode="perl-install">
321 <sect2 role="installation">
322 <xsl:for-each select="./*">
323 <xsl:if test="not(self::note)">
324 <xsl:copy-of select="."/>
325 </xsl:if>
326 </xsl:for-each>
327 </sect2>
328 </xsl:template>
329
330<!-- we have got an xorg package. We are at the installation page
331 but now we need to make an autonomous page from the global
332 one -->
333 <xsl:template match="sect1" mode="xorg">
334 <xsl:param name="package"/>
335 <xsl:variable name="tarball">
336 <xsl:call-template name="tarball">
337 <xsl:with-param name="package" select="concat(' ',$package,'-')"/>
338 <xsl:with-param name="cat-md5"
339 select="string(.//userinput[starts-with(string(),'cat ')])"/>
340 </xsl:call-template>
341 </xsl:variable>
342 <xsl:variable name="md5sum">
343 <xsl:call-template name="md5sum">
344 <xsl:with-param name="package" select="concat(' ',$package,'-')"/>
345 <xsl:with-param name="cat-md5"
346 select=".//userinput[starts-with(string(),'cat ')]"/>
347 </xsl:call-template>
348 </xsl:variable>
349 <xsl:variable name="download-dir">
350 <xsl:call-template name="download-dir">
351 <xsl:with-param name="package" select="concat(' ',$package,'-')"/>
352 <xsl:with-param name="cat-md5"
353 select=".//userinput[starts-with(string(),'cat ')]"/>
354 </xsl:call-template>
355 </xsl:variable>
356 <xsl:variable name="install-instructions">
357 <xsl:call-template name="inst-instr">
358 <xsl:with-param name="inst-instr"
359 select=".//userinput[starts-with(string(),'for ')]"/>
360 </xsl:call-template>
361 </xsl:variable>
362 <xsl:element name="sect1">
363 <xsl:attribute name="id"><xsl:value-of select="$package"/></xsl:attribute>
364 <xsl:processing-instruction name="dbhtml">
365 filename="<xsl:value-of select='$package'/>.html"
366 </xsl:processing-instruction>
367 <title><xsl:value-of select="$package"/></title>
368 <sect2 role="package">
369 <title>Introduction to <xsl:value-of select="$package"/></title>
370 <bridgehead renderas="sect3">Package Information</bridgehead>
371 <itemizedlist spacing="compact">
372 <listitem>
373 <para>Download (HTTP): <xsl:element name="ulink">
374 <xsl:attribute name="url">
375 <xsl:value-of
376 select=".//para[contains(string(),'(HTTP)')]/ulink/@url"/>
377 <xsl:value-of select="$download-dir"/>
378 <xsl:value-of select="$tarball"/>
379 </xsl:attribute>
380 </xsl:element>
381 </para>
382 </listitem>
383 <listitem>
384 <para>Download (FTP): <xsl:element name="ulink">
385 <xsl:attribute name="url">
386 <xsl:value-of
387 select=".//para[contains(string(),'(FTP)')]/ulink/@url"/>
388 <xsl:value-of select="$download-dir"/>
389 <xsl:value-of select="$tarball"/>
390 </xsl:attribute>
391 </xsl:element>
392 </para>
393 </listitem>
394 <listitem>
395 <para>
396 Download MD5 sum: <xsl:value-of select="$md5sum"/>
397 </para>
398 </listitem>
399 </itemizedlist>
400 <!-- If there is an additional download, we need to output that -->
401 <xsl:if test=".//bridgehead[contains(string(),'Additional')]">
402 <xsl:copy-of
403 select=".//bridgehead[contains(string(),'Additional')]"/>
404 <xsl:copy-of
405 select=".//bridgehead[contains(string(),'Additional')]
406 /following-sibling::itemizedlist[1]"/>
407 </xsl:if>
408 </sect2>
409 <sect2 role="installation">
410 <title>Installation of <xsl:value-of select="$package"/></title>
411
412 <para>
413 Install <application><xsl:value-of select="$package"/></application>
414 by running the following commands:
415 </para>
416
417 <screen><userinput>packagedir=<xsl:value-of
418 select="substring-before($tarball,'.tar.bz2')"/>
419 <xsl:text>&#xA;</xsl:text>
420 <xsl:value-of select="substring-before($install-instructions,
421 'as_root')"/>
422 </userinput></screen>
423
424 <para>
425 Now as the <systemitem class="username">root</systemitem> user:
426 </para>
427 <screen role='root'>
428 <userinput><xsl:value-of select="substring-after(
429 $install-instructions,
430 'as_root')"/>
431 </userinput>
432 </screen>
433 </sect2>
434 </xsl:element><!-- sect1 -->
435
436 </xsl:template>
437
438<!-- get the tarball name from the text that comes from the .md5 file -->
439 <xsl:template name="tarball">
440 <xsl:param name="package"/>
441 <xsl:param name="cat-md5"/>
442<!-- DEBUG
443<xsl:message><xsl:text>Entering "tarball" template:
444 package is: </xsl:text>
445<xsl:value-of select="$package"/><xsl:text>
446 cat-md5 is: </xsl:text>
447<xsl:value-of select="$cat-md5"/>
448</xsl:message>
449END DEBUG -->
450 <xsl:choose>
451 <xsl:when test="contains(substring-before($cat-md5,$package),'&#xA;')">
452 <xsl:call-template name="tarball">
453 <xsl:with-param name="package" select="$package"/>
454 <xsl:with-param name="cat-md5"
455 select="substring-after($cat-md5,'&#xA;')"/>
456 </xsl:call-template>
457 </xsl:when>
458 <xsl:when test="contains(substring-before($cat-md5,$package),' ')">
459 <xsl:call-template name="tarball">
460 <xsl:with-param name="package" select="$package"/>
461 <xsl:with-param name="cat-md5"
462 select="substring-after($cat-md5,' ')"/>
463 </xsl:call-template>
464 </xsl:when>
465 <xsl:otherwise>
466 <xsl:copy-of select="substring-after(
467 substring-before($cat-md5,'&#xA;'),' ')"/>
468 </xsl:otherwise>
469 </xsl:choose>
470 </xsl:template>
471<!-- get the download dirname from the text that comes from the .md5 file -->
472 <xsl:template name="download-dir">
473 <xsl:param name="package"/>
474 <xsl:param name="cat-md5"/>
475 <xsl:choose>
476 <xsl:when test="not(@id='xorg7-legacy')">
477 <xsl:copy-of select="''"/>
478 </xsl:when>
479 <xsl:when test="contains(substring-before($cat-md5,$package),'&#xA;')">
480 <xsl:call-template name="download-dir">
481 <xsl:with-param name="package" select="$package"/>
482 <xsl:with-param name="cat-md5"
483 select="substring-after($cat-md5,'&#xA;')"/>
484 </xsl:call-template>
485 </xsl:when>
486 <xsl:when test="contains(substring-before($cat-md5,$package),' ')">
487 <xsl:call-template name="download-dir">
488 <xsl:with-param name="package" select="$package"/>
489 <xsl:with-param name="cat-md5"
490 select="substring-after($cat-md5,' ')"/>
491 </xsl:call-template>
492 </xsl:when>
493 <xsl:otherwise>
494 <xsl:copy-of select="substring-before($cat-md5,' ')"/>
495 </xsl:otherwise>
496 </xsl:choose>
497 </xsl:template>
498<!-- same for md5sum -->
499 <xsl:template name="md5sum">
500 <xsl:param name="package"/>
501 <xsl:param name="cat-md5"/>
502 <xsl:choose>
503 <xsl:when test="contains(substring-before($cat-md5,$package),'&#xA;')">
504 <xsl:call-template name="md5sum">
505 <xsl:with-param name="package" select="$package"/>
506 <xsl:with-param name="cat-md5"
507 select="substring-after($cat-md5,'&#xA;')"/>
508 </xsl:call-template>
509 </xsl:when>
510 <xsl:otherwise>
511 <xsl:copy-of select="substring-before($cat-md5,' ')"/>
512 </xsl:otherwise>
513 </xsl:choose>
514 </xsl:template>
515
516 <xsl:template name="inst-instr">
517 <xsl:param name="inst-instr"/>
518 <xsl:choose>
519 <xsl:when test="contains($inst-instr,'pushd')">
520 <xsl:call-template name="inst-instr">
521 <xsl:with-param name="inst-instr"
522 select="substring-after(
523 substring-after($inst-instr,'pushd'),
524 '&#xA;')"/>
525 </xsl:call-template>
526 </xsl:when>
527 <xsl:otherwise>
528 <xsl:copy-of select="substring-before($inst-instr,'popd')"/>
529 </xsl:otherwise>
530 </xsl:choose>
531 </xsl:template>
532</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.