source: BLFS/xsl/gen_pkg_list.xsl@ 30a8961

ablfs-more legacy trunk
Last change on this file since 30a8961 was 619b313, checked in by Pierre Labastie <pierre@…>, 5 years ago

Various fixes and improvements coming from github:

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