source: BLFS/xsl/gen_pkg_list.xsl@ bea551c

trunk
Last change on this file since bea551c was faa6594, checked in by Pierre Labastie <pierre.labastie@…>, 14 months ago

Add comments after adding kf5 and plasma to special

  • Property mode set to 100644
File size: 19.8 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
364 @linkend='plasma5-build'">
[e576789]365 <xsl:call-template name="expand-deps">
366 <xsl:with-param name="section">
367 <xsl:value-of select="@linkend"/>
368 </xsl:with-param>
369 <xsl:with-param name="status">
370 <xsl:value-of select="$status"/>
371 </xsl:with-param>
[7a0c3d2]372 <xsl:with-param name="build">
373 <xsl:choose>
374 <xsl:when test="@role='runtime'">after</xsl:when>
[2140f22]375 <xsl:when test="@role='first'">first</xsl:when>
[7a0c3d2]376 <xsl:otherwise>before</xsl:otherwise>
377 </xsl:choose>
378 </xsl:with-param>
[e576789]379 </xsl:call-template>
380 </xsl:when>
381 <xsl:otherwise>
382 <xsl:text>
383 </xsl:text>
384 <xsl:element name="dependency">
385 <xsl:attribute name="status">
386 <xsl:value-of select="$status"/>
387 </xsl:attribute>
[7a0c3d2]388 <xsl:attribute name="build">
389 <xsl:choose>
390 <xsl:when test="@role='runtime'">after</xsl:when>
[2140f22]391 <xsl:when test="@role='first'">first</xsl:when>
[7a0c3d2]392 <xsl:otherwise>before</xsl:otherwise>
393 </xsl:choose>
394 </xsl:attribute>
[e576789]395 <xsl:attribute name="name">
396 <xsl:value-of select="@linkend"/>
397 </xsl:attribute>
398 <xsl:attribute name="type">ref</xsl:attribute>
399 </xsl:element>
400 </xsl:otherwise>
401 </xsl:choose>
402 </xsl:for-each>
[12fc178]403<!-- then external dependencies -->
[9575278]404 <xsl:for-each select=".//ulink">
[7a0c3d2]405 <xsl:choose>
406<!-- do not depend on something which is not a dependency -->
407 <xsl:when test="@role='nodep'"/>
408 <xsl:otherwise>
409 <xsl:text>
[12fc178]410 </xsl:text>
[7a0c3d2]411 <xsl:element name="dependency">
412 <xsl:attribute name="status">
413 <xsl:value-of select="$status"/>
414 </xsl:attribute>
415 <xsl:attribute name="build">
416 <xsl:choose>
417 <xsl:when test="@role='runtime'">after</xsl:when>
[2140f22]418 <xsl:when test="@role='first'">first</xsl:when>
[7a0c3d2]419 <xsl:otherwise>before</xsl:otherwise>
420 </xsl:choose>
421 </xsl:attribute>
422 <xsl:attribute name="name">
423 <xsl:value-of select="translate(normalize-space(text()),' /,()','-----')"/>
424 </xsl:attribute>
425 <xsl:attribute name="type">link</xsl:attribute>
426 </xsl:element>
427 </xsl:otherwise>
428 </xsl:choose>
[12fc178]429 </xsl:for-each>
[e576789]430 </xsl:template>
431
432 <xsl:template match="listitem" mode="prec-dep">
433 <xsl:if test="preceding-sibling::listitem">
434 <xsl:text>
435 </xsl:text>
436 <xsl:element name="dependency">
437<!-- the dep on the preceding package used to be required for python.
438 It seems optional now -->
439 <xsl:attribute name="status">optional</xsl:attribute>
[7a0c3d2]440 <xsl:attribute name="build">before</xsl:attribute>
[e576789]441 <xsl:attribute name="name">
442 <xsl:value-of select="preceding-sibling::listitem[1]//@linkend"/>
443 </xsl:attribute>
444 <xsl:attribute name="type">ref</xsl:attribute>
445 </xsl:element>
446 </xsl:if>
447 </xsl:template>
448
449 <xsl:template match="listitem" mode="perlmod-dep">
450 <xsl:param name="glue" select="'&#xA; '"/>
451 <xsl:choose>
[7a0c3d2]452 <xsl:when test="para/xref[not(@role) or @role != 'nodep']|para[@id]/ulink">
[e576789]453 <xsl:value-of select="$glue"/>
454 <xsl:element name="dependency">
455 <xsl:attribute name="status">
456 <xsl:choose>
457 <xsl:when
458 test="count(./para/text()[contains(string(),
459 'ptional')
460 ]
461 )&gt;0">optional</xsl:when>
462 <xsl:otherwise>required</xsl:otherwise>
463 </xsl:choose>
464 </xsl:attribute>
[7a0c3d2]465 <xsl:attribute name="build">
466 <xsl:choose>
467 <xsl:when test="para/xref/@role='runtime'">after</xsl:when>
468 <xsl:when test="para/ulink/@role='runtime'">after</xsl:when>
469 <xsl:otherwise>before</xsl:otherwise>
470 </xsl:choose>
471 </xsl:attribute>
[e576789]472 <xsl:attribute name="name">
473 <xsl:if test="para/xref">
474 <xsl:value-of select="para/xref/@linkend"/>
475 </xsl:if>
476 <xsl:if test="para/ulink">
477 <xsl:value-of select="para/@id"/>
478 </xsl:if>
479 </xsl:attribute>
480 <xsl:attribute name="type">
481 <xsl:if test="para/xref">ref</xsl:if>
482 <xsl:if test="para/ulink">link</xsl:if>
483 </xsl:attribute>
484 <xsl:apply-templates select="itemizedlist/listitem"
485 mode="perlmod-dep">
486 <xsl:sort select="position()"
487 data-type="number"
488 order="descending"/>
489 <xsl:with-param name="glue" select="concat($glue,' ')"/>
490 </xsl:apply-templates>
491 </xsl:element>
492 </xsl:when>
493 <xsl:otherwise>
494 <xsl:apply-templates select="itemizedlist/listitem"
495 mode="perlmod-dep">
496 <xsl:sort select="position()"
497 data-type="number"
498 order="descending"/>
499 <xsl:with-param name="glue" select="$glue"/>
500 </xsl:apply-templates>
501 </xsl:otherwise>
502 </xsl:choose>
503 </xsl:template>
504
505</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.