source: BLFS/xsl/gen_pkg_list.xsl@ d0d4181

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

Vim is in BLFS and should not be in LFS package list

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