source: BLFS/xsl/gen_pkg_list.xsl@ b0965fa

ablfs-more legacy trunk
Last change on this file since b0965fa was fd4a798, checked in by Pierre Labastie <pierre.labastie@…>, 3 years ago

Remove $Id$ comments, they are useless with git

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