source: BLFS/xsl/gen_pkg_list.xsl@ e6a1ec3

ablfs-more trunk
Last change on this file since e6a1ec3 was 0cd09c6, checked in by Pierre Labastie <pierre.labastie@…>, 14 months ago

Add automation for kf5 and plasma5

  • Property mode set to 100644
File size: 19.8 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-') or
363 @linkend='kf5-frameworks' or
364 @linkend='plasma5-build'">
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>
372 <xsl:with-param name="build">
373 <xsl:choose>
374 <xsl:when test="@role='runtime'">after</xsl:when>
375 <xsl:when test="@role='first'">first</xsl:when>
376 <xsl:otherwise>before</xsl:otherwise>
377 </xsl:choose>
378 </xsl:with-param>
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>
388 <xsl:attribute name="build">
389 <xsl:choose>
390 <xsl:when test="@role='runtime'">after</xsl:when>
391 <xsl:when test="@role='first'">first</xsl:when>
392 <xsl:otherwise>before</xsl:otherwise>
393 </xsl:choose>
394 </xsl:attribute>
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>
403<!-- then external dependencies -->
404 <xsl:for-each select=".//ulink">
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>
410 </xsl:text>
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>
418 <xsl:when test="@role='first'">first</xsl:when>
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>
429 </xsl:for-each>
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>
440 <xsl:attribute name="build">before</xsl:attribute>
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>
452 <xsl:when test="para/xref[not(@role) or @role != 'nodep']|para[@id]/ulink">
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>
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>
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.