source: BLFS/xsl/gen_pkg_list.xsl@ df1f318

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

New management of dependencies:

  • Even if only required or recommended deps only are requested and built, account for optional deps to build the pacakge order
  • build "runtime" deps after the pacakge dependening on them, but before any other package
  • using the "first" role in the book, implement pass1 pacakges when there are circular dependencies
  • Documentation has still to be written
  • There must be bugs, thank you for testing...
  • Property mode set to 100644
File size: 19.4 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-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>
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
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'"/>
95<!-- Vim version is taken from BLFS -->
96 <xsl:when test="./productname='vim'"/>
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<!-- Same for python and ninja -->
102 <xsl:when test="./productname='ninja'"/>
103 <xsl:when test="./productname='Python'"/>
104 <xsl:otherwise>
105 <package><xsl:text>&#xA; </xsl:text>
106 <xsl:element name="name">
107 <xsl:value-of select="./productname"/>
108 </xsl:element>
109 <xsl:text>&#xA; </xsl:text>
110 <xsl:element name="version">
111 <xsl:value-of select="./productnumber"/>
112 </xsl:element>
113 <xsl:if
114 test="document($installed-packages)//package[name=current()/productname]">
115 <xsl:text>&#xA; </xsl:text>
116 <xsl:element name="inst-version">
117 <xsl:value-of
118 select="document(
119 $installed-packages
120 )//package[name=current()/productname]/version"/>
121 </xsl:element>
122 </xsl:if>
123 </package>
124 </xsl:otherwise>
125 </xsl:choose>
126<!-- No deps for now: a former version is always installed -->
127 </xsl:template>
128
129 <xsl:template match="part">
130 <xsl:if test="count(.//*[contains(translate(@xreflabel,
131 '123456789',
132 '000000000'),
133 '-0')
134 ]) &gt; 0">
135 <xsl:text> </xsl:text>
136 <list>
137 <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
138 <xsl:text>&#xA; </xsl:text>
139 <xsl:element name="name">
140 <xsl:value-of select="normalize-space(title)"/>
141 </xsl:element>
142 <xsl:text>&#xA;&#xA;</xsl:text>
143 <xsl:apply-templates select="chapter"/>
144 <xsl:text> </xsl:text>
145 </list>
146 <xsl:text>&#xA;&#xA;</xsl:text>
147 </xsl:if>
148 </xsl:template>
149
150 <xsl:template match="chapter">
151 <xsl:if test="count(.//*[contains(translate(@xreflabel,
152 '123456789',
153 '000000000'),
154 '-0')
155 ]) &gt; 0">
156 <xsl:text> </xsl:text>
157 <sublist>
158 <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
159 <xsl:text>&#xA; </xsl:text>
160 <xsl:element name="name">
161 <xsl:value-of select="normalize-space(title)"/>
162 </xsl:element>
163 <xsl:text>&#xA;</xsl:text>
164 <xsl:apply-templates select=".//sect1">
165 <xsl:sort select="@id"/>
166 </xsl:apply-templates>
167 <xsl:text> </xsl:text>
168 </sublist><xsl:text>&#xA;&#xA;</xsl:text>
169 </xsl:if>
170 </xsl:template>
171
172 <xsl:template match="sect1">
173 <xsl:choose>
174<!-- This test is to find sections containing modules (PERL, Python
175 DBus,...) -->
176 <xsl:when
177 test="not(contains(translate(@xreflabel,
178 '123456789',
179 '000000000'),
180 '-0')) and
181 count(descendant::node()[contains(translate(@xreflabel,
182 '123456789',
183 '000000000'),
184 '-0')
185 ]) &gt; 0">
186 <xsl:text> </xsl:text>
187 <package><xsl:text>&#xA; </xsl:text>
188 <xsl:element name="name">
189 <xsl:value-of select="normalize-space(title)"/>
190 </xsl:element>
191 <xsl:text>&#xA;</xsl:text>
192<!-- Do not use .//*, which would include self. -->
193 <xsl:apply-templates
194 select="descendant::node()[contains(translate(@xreflabel,
195 '123456789',
196 '000000000'),
197 '-0')
198 ]"
199 mode="normal">
200 <xsl:sort select="@id"/>
201 </xsl:apply-templates>
202 <xsl:text> </xsl:text>
203 </package><xsl:text>&#xA;&#xA;</xsl:text>
204 </xsl:when>
205 <xsl:otherwise>
206<!-- Calls the template of specialCases.xsl,
207 which calls the "normal" template when the
208 case is normal. -->
209 <xsl:apply-templates select='.' mode="special">
210 <xsl:sort select="@id"/>
211 </xsl:apply-templates>
212 </xsl:otherwise>
213 </xsl:choose>
214 </xsl:template>
215
216 <xsl:template match="*" mode="normal">
217 <xsl:variable name="version">
218 <xsl:call-template name="version">
219 <xsl:with-param name="label" select="./@xreflabel"/>
220 </xsl:call-template>
221 </xsl:variable>
222 <xsl:choose>
223<!-- If there is a "sect1" ancestor, this means that
224 we have a module -->
225 <xsl:when test="ancestor::sect1">
226 <xsl:text> </xsl:text>
227 <module><xsl:text>&#xA; </xsl:text>
228 <xsl:element name="name">
229 <xsl:value-of select="./@id"/>
230 </xsl:element>
231 <xsl:text>&#xA; </xsl:text>
232 <xsl:element name="version">
233 <xsl:value-of select="$version"/>
234 </xsl:element>
235 <xsl:if
236 test="document($installed-packages)//package[name=current()/@id]">
237 <xsl:text>&#xA; </xsl:text>
238 <xsl:element name="inst-version">
239 <xsl:value-of
240 select="document(
241 $installed-packages
242 )//package[name=current()/@id]/version"/>
243 </xsl:element>
244 </xsl:if>
245<!-- Dependencies -->
246<!-- First the case of python modules or d-bus bindings -->
247 <xsl:if test="self::sect2">
248<!-- dependencies -->
249 <xsl:apply-templates select=".//para[@role='required' or
250 @role='recommended' or
251 @role='optional']"
252 mode="dependency"/>
253 </xsl:if>
254<!-- For python modules, the preceding module is an optional dep -->
255 <xsl:if test="ancestor::sect1[@id='python-modules']">
256 <xsl:apply-templates
257 select="preceding-sibling::sect2[@role='package']
258 //listitem[para/xref/@linkend=current()/@id]"
259 mode="prec-dep"/>
260 </xsl:if>
261<!-- Now the case of perl modules: let us test our XSLT abilities.
262 Well, "use the sibling, Luke" -->
263 <xsl:if test="self::bridgehead">
264 <xsl:apply-templates select="following-sibling::itemizedlist[1]
265 /listitem/itemizedlist/listitem"
266 mode="perlmod-dep">
267 <xsl:sort select="position()"
268 data-type="number"
269 order="descending"/>
270 </xsl:apply-templates>
271 </xsl:if>
272<!-- End dependencies -->
273 <xsl:text>&#xA; </xsl:text>
274 </module><xsl:text>&#xA;</xsl:text>
275 </xsl:when>
276 <xsl:otherwise>
277 <xsl:text> </xsl:text>
278 <package><xsl:text>&#xA; </xsl:text>
279 <xsl:element name="name">
280 <xsl:value-of select="./@id"/>
281 </xsl:element>
282 <xsl:text>&#xA; </xsl:text>
283 <xsl:element name="version">
284 <xsl:value-of select="$version"/>
285 </xsl:element>
286 <xsl:if
287 test="document($installed-packages)//package[name=current()/@id]">
288 <xsl:text>&#xA; </xsl:text>
289 <xsl:element name="inst-version">
290 <xsl:value-of
291 select="document(
292 $installed-packages
293 )//package[name=current()/@id]/version"/>
294 </xsl:element>
295 </xsl:if>
296<!-- Dependencies -->
297<!-- If in Xorg (not anymore) or KDE chapter, consider that the preceding
298 package is the first dependency (not always noted in the book)-->
299 <xsl:if test="ancestor::chapter[@id='kde4-core'
300 or @id='xfce-core'
301 or @id='lxqt-desktop'
302 or @id='lxde-desktop']
303 and preceding-sibling::sect1[1]">
304 <xsl:text>
305 </xsl:text>
306 <xsl:element name="dependency">
307 <xsl:attribute name="status">required</xsl:attribute>
308 <xsl:attribute name="build">before</xsl:attribute>
309 <xsl:attribute name="name">
310 <xsl:value-of select="preceding-sibling::sect1[1]/@id"/>
311 </xsl:attribute>
312 <xsl:attribute name="type">ref</xsl:attribute>
313 </xsl:element>
314 </xsl:if>
315 <xsl:apply-templates select=".//para[@role='required' or
316 @role='recommended' or
317 @role='optional']"
318 mode="dependency"/>
319<!-- End dependencies -->
320 <xsl:text>&#xA; </xsl:text>
321 </package><xsl:text>&#xA;</xsl:text>
322 </xsl:otherwise>
323 </xsl:choose>
324 </xsl:template>
325
326 <xsl:template name="version">
327 <xsl:param name="label" select="abc-2"/>
328 <xsl:variable name="start" select="string-length(substring-before(translate($label,'123456789','000000000'),'-0'))+2"/>
329 <xsl:variable name="prelim-ver" select="substring($label,$start)"/>
330 <xsl:choose>
331 <xsl:when test="contains($prelim-ver,'onfiguration')"/>
332 <xsl:when test="contains($prelim-ver,'escription')"/>
333 <xsl:when test="contains($prelim-ver,'EggDBus')">
334 <xsl:value-of select="substring-before($prelim-ver,' (EggDBus)')"/>
335 </xsl:when>
336 <xsl:when test="contains($label,'JDK')">
337 <xsl:value-of select="translate($prelim-ver,' ','_')"/>
338 </xsl:when>
339 <xsl:otherwise>
340 <xsl:value-of select="$prelim-ver"/>
341 </xsl:otherwise>
342 </xsl:choose>
343 </xsl:template>
344
345 <xsl:template match="para" mode="dependency">
346 <xsl:variable name="status" select="./@role"/>
347<!-- First internal dependencies -->
348 <xsl:for-each select=".//xref">
349 <xsl:choose>
350<!-- Avoid depending of myself -->
351 <xsl:when test="ancestor::*[@id=current()/@linkend]"/>
352<!-- do not depend on something which is not a dependency -->
353 <xsl:when test="@role='nodep'"/>
354<!-- Call list expansion when we have an xorg7 series of packages -->
355 <xsl:when test="contains(@linkend,'xorg7-')">
356 <xsl:call-template name="expand-deps">
357 <xsl:with-param name="section">
358 <xsl:value-of select="@linkend"/>
359 </xsl:with-param>
360 <xsl:with-param name="status">
361 <xsl:value-of select="$status"/>
362 </xsl:with-param>
363 <xsl:with-param name="build">
364 <xsl:choose>
365 <xsl:when test="@role='runtime'">after</xsl:when>
366 <xsl:when test="@role='first'">first</xsl:when>
367 <xsl:otherwise>before</xsl:otherwise>
368 </xsl:choose>
369 </xsl:with-param>
370 </xsl:call-template>
371 </xsl:when>
372 <xsl:otherwise>
373 <xsl:text>
374 </xsl:text>
375 <xsl:element name="dependency">
376 <xsl:attribute name="status">
377 <xsl:value-of select="$status"/>
378 </xsl:attribute>
379 <xsl:attribute name="build">
380 <xsl:choose>
381 <xsl:when test="@role='runtime'">after</xsl:when>
382 <xsl:when test="@role='first'">first</xsl:when>
383 <xsl:otherwise>before</xsl:otherwise>
384 </xsl:choose>
385 </xsl:attribute>
386 <xsl:attribute name="name">
387 <xsl:value-of select="@linkend"/>
388 </xsl:attribute>
389 <xsl:attribute name="type">ref</xsl:attribute>
390 </xsl:element>
391 </xsl:otherwise>
392 </xsl:choose>
393 </xsl:for-each>
394<!-- then external dependencies -->
395 <xsl:for-each select=".//ulink">
396 <xsl:choose>
397<!-- do not depend on something which is not a dependency -->
398 <xsl:when test="@role='nodep'"/>
399 <xsl:otherwise>
400 <xsl:text>
401 </xsl:text>
402 <xsl:element name="dependency">
403 <xsl:attribute name="status">
404 <xsl:value-of select="$status"/>
405 </xsl:attribute>
406 <xsl:attribute name="build">
407 <xsl:choose>
408 <xsl:when test="@role='runtime'">after</xsl:when>
409 <xsl:when test="@role='first'">first</xsl:when>
410 <xsl:otherwise>before</xsl:otherwise>
411 </xsl:choose>
412 </xsl:attribute>
413 <xsl:attribute name="name">
414 <xsl:value-of select="translate(normalize-space(text()),' /,()','-----')"/>
415 </xsl:attribute>
416 <xsl:attribute name="type">link</xsl:attribute>
417 </xsl:element>
418 </xsl:otherwise>
419 </xsl:choose>
420 </xsl:for-each>
421 </xsl:template>
422
423 <xsl:template match="listitem" mode="prec-dep">
424 <xsl:if test="preceding-sibling::listitem">
425 <xsl:text>
426 </xsl:text>
427 <xsl:element name="dependency">
428<!-- the dep on the preceding package used to be required for python.
429 It seems optional now -->
430 <xsl:attribute name="status">optional</xsl:attribute>
431 <xsl:attribute name="build">before</xsl:attribute>
432 <xsl:attribute name="name">
433 <xsl:value-of select="preceding-sibling::listitem[1]//@linkend"/>
434 </xsl:attribute>
435 <xsl:attribute name="type">ref</xsl:attribute>
436 </xsl:element>
437 </xsl:if>
438 </xsl:template>
439
440 <xsl:template match="listitem" mode="perlmod-dep">
441 <xsl:param name="glue" select="'&#xA; '"/>
442 <xsl:choose>
443 <xsl:when test="para/xref[not(@role) or @role != 'nodep']|para[@id]/ulink">
444 <xsl:value-of select="$glue"/>
445 <xsl:element name="dependency">
446 <xsl:attribute name="status">
447 <xsl:choose>
448 <xsl:when
449 test="count(./para/text()[contains(string(),
450 'ptional')
451 ]
452 )&gt;0">optional</xsl:when>
453 <xsl:otherwise>required</xsl:otherwise>
454 </xsl:choose>
455 </xsl:attribute>
456 <xsl:attribute name="build">
457 <xsl:choose>
458 <xsl:when test="para/xref/@role='runtime'">after</xsl:when>
459 <xsl:when test="para/ulink/@role='runtime'">after</xsl:when>
460 <xsl:otherwise>before</xsl:otherwise>
461 </xsl:choose>
462 </xsl:attribute>
463 <xsl:attribute name="name">
464 <xsl:if test="para/xref">
465 <xsl:value-of select="para/xref/@linkend"/>
466 </xsl:if>
467 <xsl:if test="para/ulink">
468 <xsl:value-of select="para/@id"/>
469 </xsl:if>
470 </xsl:attribute>
471 <xsl:attribute name="type">
472 <xsl:if test="para/xref">ref</xsl:if>
473 <xsl:if test="para/ulink">link</xsl:if>
474 </xsl:attribute>
475 <xsl:apply-templates select="itemizedlist/listitem"
476 mode="perlmod-dep">
477 <xsl:sort select="position()"
478 data-type="number"
479 order="descending"/>
480 <xsl:with-param name="glue" select="concat($glue,' ')"/>
481 </xsl:apply-templates>
482 </xsl:element>
483 </xsl:when>
484 <xsl:otherwise>
485 <xsl:apply-templates select="itemizedlist/listitem"
486 mode="perlmod-dep">
487 <xsl:sort select="position()"
488 data-type="number"
489 order="descending"/>
490 <xsl:with-param name="glue" select="$glue"/>
491 </xsl:apply-templates>
492 </xsl:otherwise>
493 </xsl:choose>
494 </xsl:template>
495
496</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.