source: BLFS/xsl/gen_pkg_list.xsl@ 83cfe91

trunk
Last change on this file since 83cfe91 was 83cfe91, checked in by Pierre Labastie <pierre.labastie@…>, 3 days ago

fix building xcb-utilities
Fixes ticket #1741

  • Property mode set to 100644
File size: 19.9 KB
RevLine 
[e576789]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') -->
[506120ee]7<!-- Extract also a list of LFS packages from stringparam lfs-full -->
[e576789]8
9<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
10 version="1.0">
11
[506120ee]12 <xsl:param name="lfs-full" select="'./lfs-xml/lfs-full.xml'"/>
[e576789]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>
[506120ee]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>
[cce9c16]33 <xsl:attribute name="id">lfs-system</xsl:attribute>
[506120ee]34 <xsl:text>&#xA; </xsl:text>
[cce9c16]35 <name>LFS Final System</name>
[506120ee]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>
[654f592]42 <sublist>
[cce9c16]43 <xsl:attribute name="id">lfs-conf</xsl:attribute>
[654f592]44 <xsl:text>&#xA; </xsl:text>
[cce9c16]45 <name>LFS Configuration files</name>
[654f592]46 <xsl:apply-templates
47 select='document($lfs-full)//
[cce9c16]48 chapter[@id="chapter-config"]/
[654f592]49 sect1/sect1info[./productname="bootscripts"]'/>
50 <xsl:text>&#xA; </xsl:text>
51 </sublist>
[506120ee]52 <sublist>
[cce9c16]53 <xsl:attribute name="id">lfs-boot</xsl:attribute>
[506120ee]54 <xsl:text>&#xA; </xsl:text>
[cce9c16]55 <name>LFS Making Bootable</name>
[619b313]56 <xsl:apply-templates select='document($lfs-full)//chapter[@id="chapter-bootable"]/sect1/sect1info[./productname="kernel"]'/>
[506120ee]57 <xsl:text>&#xA; </xsl:text>
58 </sublist>
59 <sublist>
[cce9c16]60 <xsl:attribute name="id">lfs-theend</xsl:attribute>
[506120ee]61 <xsl:text>&#xA; </xsl:text>
[cce9c16]62 <name>LFS The end</name>
[506120ee]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>
[e576789]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
[506120ee]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 -->
[619b313]98 <xsl:when test="./productname='linux-headers'"/>
[506120ee]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'"/>
[d0d4181]103<!-- Vim version is taken from BLFS -->
104 <xsl:when test="./productname='vim'"/>
[506120ee]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'"/>
[619b313]109<!-- Same for python3 -->
[8740529]110 <xsl:when test="./productname='Python'"/>
[506120ee]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
[e576789]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">
[ebb631a]147 <xsl:value-of select="normalize-space(title)"/>
[e576789]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')
[0336215]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 -->
[e576789]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">
[ebb631a]170 <xsl:value-of select="normalize-space(title)"/>
[e576789]171 </xsl:element>
172 <xsl:text>&#xA;</xsl:text>
[82bd7a6]173 <xsl:apply-templates select=".//sect1">
[e576789]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">
[ebb631a]198 <xsl:value-of select="normalize-space(title)"/>
[51dba86]199 </xsl:element>
[e576789]200 <xsl:text>&#xA;</xsl:text>
[1646303]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">
[e576789]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 -->
[7735c7a]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)-->
[bd07ef5]306 <xsl:if test="ancestor::chapter[@id='kde4-core'
307 or @id='xfce-core'
[6f48f76]308 or @id='lxqt-desktop'
[bd07ef5]309 or @id='lxde-desktop']
310 and preceding-sibling::sect1[1]">
[e576789]311 <xsl:text>
312 </xsl:text>
[7735c7a]313 <xsl:element name="dependency">
314 <xsl:attribute name="status">required</xsl:attribute>
[7a0c3d2]315 <xsl:attribute name="build">before</xsl:attribute>
[7735c7a]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>
[e576789]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"/>
[12fc178]354<!-- First internal dependencies -->
[9575278]355 <xsl:for-each select=".//xref">
[e576789]356 <xsl:choose>
[2ae5bbe]357<!-- Avoid depending of myself -->
358 <xsl:when test="ancestor::*[@id=current()/@linkend]"/>
[7a0c3d2]359<!-- do not depend on something which is not a dependency -->
360 <xsl:when test="@role='nodep'"/>
[faa6594]361<!-- Call list expansion when we have a compound package -->
[0cd09c6]362 <xsl:when test="contains(@linkend,'xorg7-') or
363 @linkend='kf5-frameworks' or
[83cfe91]364 @linkend='plasma5-build' or
365 @linkend='xcb-utilities'">
[e576789]366 <xsl:call-template name="expand-deps">
367 <xsl:with-param name="section">
368 <xsl:value-of select="@linkend"/>
369 </xsl:with-param>
370 <xsl:with-param name="status">
371 <xsl:value-of select="$status"/>
372 </xsl:with-param>
[7a0c3d2]373 <xsl:with-param name="build">
374 <xsl:choose>
375 <xsl:when test="@role='runtime'">after</xsl:when>
[2140f22]376 <xsl:when test="@role='first'">first</xsl:when>
[7a0c3d2]377 <xsl:otherwise>before</xsl:otherwise>
378 </xsl:choose>
379 </xsl:with-param>
[e576789]380 </xsl:call-template>
381 </xsl:when>
382 <xsl:otherwise>
383 <xsl:text>
384 </xsl:text>
385 <xsl:element name="dependency">
386 <xsl:attribute name="status">
387 <xsl:value-of select="$status"/>
388 </xsl:attribute>
[7a0c3d2]389 <xsl:attribute name="build">
390 <xsl:choose>
391 <xsl:when test="@role='runtime'">after</xsl:when>
[2140f22]392 <xsl:when test="@role='first'">first</xsl:when>
[7a0c3d2]393 <xsl:otherwise>before</xsl:otherwise>
394 </xsl:choose>
395 </xsl:attribute>
[e576789]396 <xsl:attribute name="name">
397 <xsl:value-of select="@linkend"/>
398 </xsl:attribute>
399 <xsl:attribute name="type">ref</xsl:attribute>
400 </xsl:element>
401 </xsl:otherwise>
402 </xsl:choose>
403 </xsl:for-each>
[12fc178]404<!-- then external dependencies -->
[9575278]405 <xsl:for-each select=".//ulink">
[7a0c3d2]406 <xsl:choose>
407<!-- do not depend on something which is not a dependency -->
408 <xsl:when test="@role='nodep'"/>
409 <xsl:otherwise>
410 <xsl:text>
[12fc178]411 </xsl:text>
[7a0c3d2]412 <xsl:element name="dependency">
413 <xsl:attribute name="status">
414 <xsl:value-of select="$status"/>
415 </xsl:attribute>
416 <xsl:attribute name="build">
417 <xsl:choose>
418 <xsl:when test="@role='runtime'">after</xsl:when>
[2140f22]419 <xsl:when test="@role='first'">first</xsl:when>
[7a0c3d2]420 <xsl:otherwise>before</xsl:otherwise>
421 </xsl:choose>
422 </xsl:attribute>
423 <xsl:attribute name="name">
424 <xsl:value-of select="translate(normalize-space(text()),' /,()','-----')"/>
425 </xsl:attribute>
426 <xsl:attribute name="type">link</xsl:attribute>
427 </xsl:element>
428 </xsl:otherwise>
429 </xsl:choose>
[12fc178]430 </xsl:for-each>
[e576789]431 </xsl:template>
432
433 <xsl:template match="listitem" mode="prec-dep">
434 <xsl:if test="preceding-sibling::listitem">
435 <xsl:text>
436 </xsl:text>
437 <xsl:element name="dependency">
438<!-- the dep on the preceding package used to be required for python.
439 It seems optional now -->
440 <xsl:attribute name="status">optional</xsl:attribute>
[7a0c3d2]441 <xsl:attribute name="build">before</xsl:attribute>
[e576789]442 <xsl:attribute name="name">
443 <xsl:value-of select="preceding-sibling::listitem[1]//@linkend"/>
444 </xsl:attribute>
445 <xsl:attribute name="type">ref</xsl:attribute>
446 </xsl:element>
447 </xsl:if>
448 </xsl:template>
449
450 <xsl:template match="listitem" mode="perlmod-dep">
451 <xsl:param name="glue" select="'&#xA; '"/>
452 <xsl:choose>
[7a0c3d2]453 <xsl:when test="para/xref[not(@role) or @role != 'nodep']|para[@id]/ulink">
[e576789]454 <xsl:value-of select="$glue"/>
455 <xsl:element name="dependency">
456 <xsl:attribute name="status">
457 <xsl:choose>
458 <xsl:when
459 test="count(./para/text()[contains(string(),
460 'ptional')
461 ]
462 )&gt;0">optional</xsl:when>
463 <xsl:otherwise>required</xsl:otherwise>
464 </xsl:choose>
465 </xsl:attribute>
[7a0c3d2]466 <xsl:attribute name="build">
467 <xsl:choose>
468 <xsl:when test="para/xref/@role='runtime'">after</xsl:when>
469 <xsl:when test="para/ulink/@role='runtime'">after</xsl:when>
470 <xsl:otherwise>before</xsl:otherwise>
471 </xsl:choose>
472 </xsl:attribute>
[e576789]473 <xsl:attribute name="name">
474 <xsl:if test="para/xref">
475 <xsl:value-of select="para/xref/@linkend"/>
476 </xsl:if>
477 <xsl:if test="para/ulink">
478 <xsl:value-of select="para/@id"/>
479 </xsl:if>
480 </xsl:attribute>
481 <xsl:attribute name="type">
482 <xsl:if test="para/xref">ref</xsl:if>
483 <xsl:if test="para/ulink">link</xsl:if>
484 </xsl:attribute>
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="concat($glue,' ')"/>
491 </xsl:apply-templates>
492 </xsl:element>
493 </xsl:when>
494 <xsl:otherwise>
495 <xsl:apply-templates select="itemizedlist/listitem"
496 mode="perlmod-dep">
497 <xsl:sort select="position()"
498 data-type="number"
499 order="descending"/>
500 <xsl:with-param name="glue" select="$glue"/>
501 </xsl:apply-templates>
502 </xsl:otherwise>
503 </xsl:choose>
504 </xsl:template>
505
506</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.