source: BLFS/xsl/gen_pkg_list.xsl@ e3ccc27

ablfs-more legacy trunk
Last change on this file since e3ccc27 was cce9c16, checked in by Pierre Labastie <pierre@…>, 4 years ago

Change names for lfs chapters in blfs tools:

  • change "6" to "final system"
  • change "7" to "configuration"
  • change "8" to "Bootable"
  • change "9" to "The End"
  • also fix a id that has changed in January in the lfs book
  • Property mode set to 100644
File size: 19.7 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2
3<!-- $Id$ -->
4<!-- Takes the blfs-full.xml file and extract a list
5 of packages obeying packdesc.dtd + looks for already
6 installed packages in the tracking file (stringparam
7 'installed-packages') -->
8<!-- Extract also a list of LFS packages from stringparam lfs-full -->
9
10<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
11 version="1.0">
12
13 <xsl:param name="lfs-full" select="'./lfs-xml/lfs-full.xml'"/>
14 <xsl:param name="installed-packages" select="'../lib/instpkg.xml'"/>
15
16 <xsl:output method="xml"
17 encoding='ISO-8859-1'
18 doctype-system="./packdesc.dtd"/>
19
20<!-- specialCases.xsl is generated by a shell script:
21 allows for cases where version begins with a letter
22 and when there is no version (such as xorg7 packages) -->
23 <xsl:include href="./specialCases.xsl"/>
24
25 <xsl:template match="/">
26 <princList>
27 <xsl:text>&#xA;&#xA; </xsl:text>
28 <list>
29 <xsl:attribute name="id">lfs</xsl:attribute>
30 <xsl:text>&#xA; </xsl:text>
31 <name>LFS Packages</name>
32 <xsl:text>&#xA; </xsl:text>
33 <sublist>
34 <xsl:attribute name="id">lfs-system</xsl:attribute>
35 <xsl:text>&#xA; </xsl:text>
36 <name>LFS Final System</name>
37 <xsl:apply-templates
38 select='document($lfs-full)//
39 chapter[@id="chapter-building-system"]/
40 sect1/sect1info'/>
41 <xsl:text>&#xA; </xsl:text>
42 </sublist>
43 <sublist>
44 <xsl:attribute name="id">lfs-conf</xsl:attribute>
45 <xsl:text>&#xA; </xsl:text>
46 <name>LFS Configuration files</name>
47 <xsl:apply-templates
48 select='document($lfs-full)//
49 chapter[@id="chapter-config"]/
50 sect1/sect1info[./productname="bootscripts"]'/>
51 <xsl:text>&#xA; </xsl:text>
52 </sublist>
53 <sublist>
54 <xsl:attribute name="id">lfs-boot</xsl:attribute>
55 <xsl:text>&#xA; </xsl:text>
56 <name>LFS Making Bootable</name>
57 <xsl:apply-templates select='document($lfs-full)//chapter[@id="chapter-bootable"]/sect1/sect1info[./productname="kernel"]'/>
58 <xsl:text>&#xA; </xsl:text>
59 </sublist>
60 <sublist>
61 <xsl:attribute name="id">lfs-theend</xsl:attribute>
62 <xsl:text>&#xA; </xsl:text>
63 <name>LFS The end</name>
64 <xsl:apply-templates select='document($lfs-full)//sect1[@id="ch-finish-theend"]//userinput[starts-with(string(),"echo")]'/>
65 <xsl:text>&#xA; </xsl:text>
66 </sublist>
67 <xsl:text>&#xA;&#xA; </xsl:text>
68 </list>
69<!-- How to have blfs-bootscripts versionned? Do not know, so
70 avoid it (TODO ?) -->
71 <xsl:apply-templates select="//part[not(@id='introduction')]"/>
72 </princList>
73 </xsl:template>
74
75 <xsl:template match="userinput">
76<!-- Only used in lFS chapter 9, to retrieve book version -->
77 <package>
78 <name>LFS-Release</name>
79 <xsl:element name="version">
80 <xsl:copy-of select="substring-after(substring-before(string(),' &gt;'),'echo ')"/>
81 </xsl:element>
82 <xsl:if
83 test="document($installed-packages)//package[name='LFS-Release']">
84 <xsl:text>&#xA; </xsl:text>
85 <xsl:element name="inst-version">
86 <xsl:value-of
87 select="document(
88 $installed-packages
89 )//package[name='LFS-Release']/version"/>
90 </xsl:element>
91 </xsl:if>
92 </package>
93 </xsl:template>
94
95 <xsl:template match="sect1info">
96 <xsl:text> </xsl:text>
97 <xsl:choose>
98<!-- Never update linux headers -->
99 <xsl:when test="./productname='linux-headers'"/>
100<!-- Gcc version is taken from BLFS -->
101 <xsl:when test="./productname='gcc'"/>
102<!-- Shadow version is taken from BLFS -->
103 <xsl:when test="./productname='shadow'"/>
104<!-- Vim version is taken from BLFS -->
105 <xsl:when test="./productname='vim'"/>
106<!-- Dbus version is taken from BLFS -->
107 <xsl:when test="./productname='dbus'"/>
108<!-- Systemd version is taken from BLFS -->
109 <xsl:when test="./productname='systemd'"/>
110<!-- Same for python3 -->
111 <xsl:when test="./productname='Python'"/>
112 <xsl:otherwise>
113 <package><xsl:text>&#xA; </xsl:text>
114 <xsl:element name="name">
115 <xsl:value-of select="./productname"/>
116 </xsl:element>
117 <xsl:text>&#xA; </xsl:text>
118 <xsl:element name="version">
119 <xsl:value-of select="./productnumber"/>
120 </xsl:element>
121 <xsl:if
122 test="document($installed-packages)//package[name=current()/productname]">
123 <xsl:text>&#xA; </xsl:text>
124 <xsl:element name="inst-version">
125 <xsl:value-of
126 select="document(
127 $installed-packages
128 )//package[name=current()/productname]/version"/>
129 </xsl:element>
130 </xsl:if>
131 </package>
132 </xsl:otherwise>
133 </xsl:choose>
134<!-- No deps for now: a former version is always installed -->
135 </xsl:template>
136
137 <xsl:template match="part">
138 <xsl:if test="count(.//*[contains(translate(@xreflabel,
139 '123456789',
140 '000000000'),
141 '-0')
142 ]) &gt; 0">
143 <xsl:text> </xsl:text>
144 <list>
145 <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
146 <xsl:text>&#xA; </xsl:text>
147 <xsl:element name="name">
148 <xsl:value-of select="normalize-space(title)"/>
149 </xsl:element>
150 <xsl:text>&#xA;&#xA;</xsl:text>
151 <xsl:apply-templates select="chapter"/>
152 <xsl:text> </xsl:text>
153 </list>
154 <xsl:text>&#xA;&#xA;</xsl:text>
155 </xsl:if>
156 </xsl:template>
157
158 <xsl:template match="chapter">
159 <xsl:if test="count(.//*[contains(translate(@xreflabel,
160 '123456789',
161 '000000000'),
162 '-0')
163 ]) &gt; 0 or @id='postlfs-config'">
164<!-- With the removal of lsb-release, there are no more versioned package
165 in the After LFS configuration issue chapter, so test explicitly -->
166 <xsl:text> </xsl:text>
167 <sublist>
168 <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
169 <xsl:text>&#xA; </xsl:text>
170 <xsl:element name="name">
171 <xsl:value-of select="normalize-space(title)"/>
172 </xsl:element>
173 <xsl:text>&#xA;</xsl:text>
174 <xsl:apply-templates select=".//sect1">
175 <xsl:sort select="@id"/>
176 </xsl:apply-templates>
177 <xsl:text> </xsl:text>
178 </sublist><xsl:text>&#xA;&#xA;</xsl:text>
179 </xsl:if>
180 </xsl:template>
181
182 <xsl:template match="sect1">
183 <xsl:choose>
184<!-- This test is to find sections containing modules (PERL, Python
185 DBus,...) -->
186 <xsl:when
187 test="not(contains(translate(@xreflabel,
188 '123456789',
189 '000000000'),
190 '-0')) and
191 count(descendant::node()[contains(translate(@xreflabel,
192 '123456789',
193 '000000000'),
194 '-0')
195 ]) &gt; 0">
196 <xsl:text> </xsl:text>
197 <package><xsl:text>&#xA; </xsl:text>
198 <xsl:element name="name">
199 <xsl:value-of select="normalize-space(title)"/>
200 </xsl:element>
201 <xsl:text>&#xA;</xsl:text>
202<!-- Do not use .//*, which would include self.
203 Even a module can be a special case, so
204 call the template of specialCases.xsl,
205 which calls the "normal" template when the
206 case is normal. -->
207 <xsl:apply-templates select="descendant::*" mode="special">
208 <xsl:sort select="@id"/>
209 </xsl:apply-templates>
210 <xsl:text> </xsl:text>
211 </package><xsl:text>&#xA;&#xA;</xsl:text>
212 </xsl:when>
213 <xsl:otherwise>
214<!-- Calls the template of specialCases.xsl,
215 which calls the "normal" template when the
216 case is normal. -->
217 <xsl:apply-templates select='.' mode="special">
218 <xsl:sort select="@id"/>
219 </xsl:apply-templates>
220 </xsl:otherwise>
221 </xsl:choose>
222 </xsl:template>
223
224 <xsl:template match="*" mode="normal">
225 <xsl:variable name="version">
226 <xsl:call-template name="version">
227 <xsl:with-param name="label" select="./@xreflabel"/>
228 </xsl:call-template>
229 </xsl:variable>
230 <xsl:choose>
231<!-- If there is a "sect1" ancestor, this means that
232 we have a module -->
233 <xsl:when test="ancestor::sect1">
234 <xsl:text> </xsl:text>
235 <module><xsl:text>&#xA; </xsl:text>
236 <xsl:element name="name">
237 <xsl:value-of select="./@id"/>
238 </xsl:element>
239 <xsl:text>&#xA; </xsl:text>
240 <xsl:element name="version">
241 <xsl:value-of select="$version"/>
242 </xsl:element>
243 <xsl:if
244 test="document($installed-packages)//package[name=current()/@id]">
245 <xsl:text>&#xA; </xsl:text>
246 <xsl:element name="inst-version">
247 <xsl:value-of
248 select="document(
249 $installed-packages
250 )//package[name=current()/@id]/version"/>
251 </xsl:element>
252 </xsl:if>
253<!-- Dependencies -->
254<!-- First the case of python modules or d-bus bindings -->
255 <xsl:if test="self::sect2">
256<!-- dependencies -->
257 <xsl:apply-templates select=".//para[@role='required' or
258 @role='recommended' or
259 @role='optional']"
260 mode="dependency"/>
261 </xsl:if>
262<!-- For python modules, the preceding module is an optional dep -->
263 <xsl:if test="ancestor::sect1[@id='python-modules']">
264 <xsl:apply-templates
265 select="preceding-sibling::sect2[@role='package']
266 //listitem[para/xref/@linkend=current()/@id]"
267 mode="prec-dep"/>
268 </xsl:if>
269<!-- Now the case of perl modules: let us test our XSLT abilities.
270 Well, "use the sibling, Luke" -->
271 <xsl:if test="self::bridgehead">
272 <xsl:apply-templates select="following-sibling::itemizedlist[1]
273 /listitem/itemizedlist/listitem"
274 mode="perlmod-dep">
275 <xsl:sort select="position()"
276 data-type="number"
277 order="descending"/>
278 </xsl:apply-templates>
279 </xsl:if>
280<!-- End dependencies -->
281 <xsl:text>&#xA; </xsl:text>
282 </module><xsl:text>&#xA;</xsl:text>
283 </xsl:when>
284 <xsl:otherwise>
285 <xsl:text> </xsl:text>
286 <package><xsl:text>&#xA; </xsl:text>
287 <xsl:element name="name">
288 <xsl:value-of select="./@id"/>
289 </xsl:element>
290 <xsl:text>&#xA; </xsl:text>
291 <xsl:element name="version">
292 <xsl:value-of select="$version"/>
293 </xsl:element>
294 <xsl:if
295 test="document($installed-packages)//package[name=current()/@id]">
296 <xsl:text>&#xA; </xsl:text>
297 <xsl:element name="inst-version">
298 <xsl:value-of
299 select="document(
300 $installed-packages
301 )//package[name=current()/@id]/version"/>
302 </xsl:element>
303 </xsl:if>
304<!-- Dependencies -->
305<!-- If in Xorg (not anymore) or KDE chapter, consider that the preceding
306 package is the first dependency (not always noted in the book)-->
307 <xsl:if test="ancestor::chapter[@id='kde4-core'
308 or @id='xfce-core'
309 or @id='lxqt-desktop'
310 or @id='lxde-desktop']
311 and preceding-sibling::sect1[1]">
312 <xsl:text>
313 </xsl:text>
314 <xsl:element name="dependency">
315 <xsl:attribute name="status">required</xsl:attribute>
316 <xsl:attribute name="build">before</xsl:attribute>
317 <xsl:attribute name="name">
318 <xsl:value-of select="preceding-sibling::sect1[1]/@id"/>
319 </xsl:attribute>
320 <xsl:attribute name="type">ref</xsl:attribute>
321 </xsl:element>
322 </xsl:if>
323 <xsl:apply-templates select=".//para[@role='required' or
324 @role='recommended' or
325 @role='optional']"
326 mode="dependency"/>
327<!-- End dependencies -->
328 <xsl:text>&#xA; </xsl:text>
329 </package><xsl:text>&#xA;</xsl:text>
330 </xsl:otherwise>
331 </xsl:choose>
332 </xsl:template>
333
334 <xsl:template name="version">
335 <xsl:param name="label" select="abc-2"/>
336 <xsl:variable name="start" select="string-length(substring-before(translate($label,'123456789','000000000'),'-0'))+2"/>
337 <xsl:variable name="prelim-ver" select="substring($label,$start)"/>
338 <xsl:choose>
339 <xsl:when test="contains($prelim-ver,'onfiguration')"/>
340 <xsl:when test="contains($prelim-ver,'escription')"/>
341 <xsl:when test="contains($prelim-ver,'EggDBus')">
342 <xsl:value-of select="substring-before($prelim-ver,' (EggDBus)')"/>
343 </xsl:when>
344 <xsl:when test="contains($label,'JDK')">
345 <xsl:value-of select="translate($prelim-ver,' ','_')"/>
346 </xsl:when>
347 <xsl:otherwise>
348 <xsl:value-of select="$prelim-ver"/>
349 </xsl:otherwise>
350 </xsl:choose>
351 </xsl:template>
352
353 <xsl:template match="para" mode="dependency">
354 <xsl:variable name="status" select="./@role"/>
355<!-- First internal dependencies -->
356 <xsl:for-each select=".//xref">
357 <xsl:choose>
358<!-- Avoid depending of myself -->
359 <xsl:when test="ancestor::*[@id=current()/@linkend]"/>
360<!-- do not depend on something which is not a dependency -->
361 <xsl:when test="@role='nodep'"/>
362<!-- Call list expansion when we have an xorg7 series of packages -->
363 <xsl:when test="contains(@linkend,'xorg7-')">
364 <xsl:call-template name="expand-deps">
365 <xsl:with-param name="section">
366 <xsl:value-of select="@linkend"/>
367 </xsl:with-param>
368 <xsl:with-param name="status">
369 <xsl:value-of select="$status"/>
370 </xsl:with-param>
371 <xsl:with-param name="build">
372 <xsl:choose>
373 <xsl:when test="@role='runtime'">after</xsl:when>
374 <xsl:when test="@role='first'">first</xsl:when>
375 <xsl:otherwise>before</xsl:otherwise>
376 </xsl:choose>
377 </xsl:with-param>
378 </xsl:call-template>
379 </xsl:when>
380 <xsl:otherwise>
381 <xsl:text>
382 </xsl:text>
383 <xsl:element name="dependency">
384 <xsl:attribute name="status">
385 <xsl:value-of select="$status"/>
386 </xsl:attribute>
387 <xsl:attribute name="build">
388 <xsl:choose>
389 <xsl:when test="@role='runtime'">after</xsl:when>
390 <xsl:when test="@role='first'">first</xsl:when>
391 <xsl:otherwise>before</xsl:otherwise>
392 </xsl:choose>
393 </xsl:attribute>
394 <xsl:attribute name="name">
395 <xsl:value-of select="@linkend"/>
396 </xsl:attribute>
397 <xsl:attribute name="type">ref</xsl:attribute>
398 </xsl:element>
399 </xsl:otherwise>
400 </xsl:choose>
401 </xsl:for-each>
402<!-- then external dependencies -->
403 <xsl:for-each select=".//ulink">
404 <xsl:choose>
405<!-- do not depend on something which is not a dependency -->
406 <xsl:when test="@role='nodep'"/>
407 <xsl:otherwise>
408 <xsl:text>
409 </xsl:text>
410 <xsl:element name="dependency">
411 <xsl:attribute name="status">
412 <xsl:value-of select="$status"/>
413 </xsl:attribute>
414 <xsl:attribute name="build">
415 <xsl:choose>
416 <xsl:when test="@role='runtime'">after</xsl:when>
417 <xsl:when test="@role='first'">first</xsl:when>
418 <xsl:otherwise>before</xsl:otherwise>
419 </xsl:choose>
420 </xsl:attribute>
421 <xsl:attribute name="name">
422 <xsl:value-of select="translate(normalize-space(text()),' /,()','-----')"/>
423 </xsl:attribute>
424 <xsl:attribute name="type">link</xsl:attribute>
425 </xsl:element>
426 </xsl:otherwise>
427 </xsl:choose>
428 </xsl:for-each>
429 </xsl:template>
430
431 <xsl:template match="listitem" mode="prec-dep">
432 <xsl:if test="preceding-sibling::listitem">
433 <xsl:text>
434 </xsl:text>
435 <xsl:element name="dependency">
436<!-- the dep on the preceding package used to be required for python.
437 It seems optional now -->
438 <xsl:attribute name="status">optional</xsl:attribute>
439 <xsl:attribute name="build">before</xsl:attribute>
440 <xsl:attribute name="name">
441 <xsl:value-of select="preceding-sibling::listitem[1]//@linkend"/>
442 </xsl:attribute>
443 <xsl:attribute name="type">ref</xsl:attribute>
444 </xsl:element>
445 </xsl:if>
446 </xsl:template>
447
448 <xsl:template match="listitem" mode="perlmod-dep">
449 <xsl:param name="glue" select="'&#xA; '"/>
450 <xsl:choose>
451 <xsl:when test="para/xref[not(@role) or @role != 'nodep']|para[@id]/ulink">
452 <xsl:value-of select="$glue"/>
453 <xsl:element name="dependency">
454 <xsl:attribute name="status">
455 <xsl:choose>
456 <xsl:when
457 test="count(./para/text()[contains(string(),
458 'ptional')
459 ]
460 )&gt;0">optional</xsl:when>
461 <xsl:otherwise>required</xsl:otherwise>
462 </xsl:choose>
463 </xsl:attribute>
464 <xsl:attribute name="build">
465 <xsl:choose>
466 <xsl:when test="para/xref/@role='runtime'">after</xsl:when>
467 <xsl:when test="para/ulink/@role='runtime'">after</xsl:when>
468 <xsl:otherwise>before</xsl:otherwise>
469 </xsl:choose>
470 </xsl:attribute>
471 <xsl:attribute name="name">
472 <xsl:if test="para/xref">
473 <xsl:value-of select="para/xref/@linkend"/>
474 </xsl:if>
475 <xsl:if test="para/ulink">
476 <xsl:value-of select="para/@id"/>
477 </xsl:if>
478 </xsl:attribute>
479 <xsl:attribute name="type">
480 <xsl:if test="para/xref">ref</xsl:if>
481 <xsl:if test="para/ulink">link</xsl:if>
482 </xsl:attribute>
483 <xsl:apply-templates select="itemizedlist/listitem"
484 mode="perlmod-dep">
485 <xsl:sort select="position()"
486 data-type="number"
487 order="descending"/>
488 <xsl:with-param name="glue" select="concat($glue,' ')"/>
489 </xsl:apply-templates>
490 </xsl:element>
491 </xsl:when>
492 <xsl:otherwise>
493 <xsl:apply-templates select="itemizedlist/listitem"
494 mode="perlmod-dep">
495 <xsl:sort select="position()"
496 data-type="number"
497 order="descending"/>
498 <xsl:with-param name="glue" select="$glue"/>
499 </xsl:apply-templates>
500 </xsl:otherwise>
501 </xsl:choose>
502 </xsl:template>
503
504</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.