source: BLFS/xsl/gen_pkg_list.xsl@ 203a64c

ablfs-more legacy trunk
Last change on this file since 203a64c was 56178ba, checked in by Pierre Labastie <pierre@…>, 8 years ago

Add a few forgotten keywords properties

  • Property mode set to 100644
File size: 13.8 KB
RevLine 
[e576789]1<?xml version="1.0" encoding="ISO-8859-1"?>
2
[56178ba]3<!-- $Id$ -->
[e576789]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
9<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
10 version="1.0">
11
12 <xsl:param name="installed-packages" select="'../lib/instpkg.xml'"/>
13
14 <xsl:output method="xml"
15 encoding='ISO-8859-1'
16 doctype-system="./packdesc.dtd"/>
17
18<!-- specialCases.xsl is generated by a shell script:
19 allows for cases where version begins with a letter
20 and when there is no version (such as xorg7 packages) -->
21 <xsl:include href="./specialCases.xsl"/>
22
23 <xsl:template match="/">
24 <princList>
25 <xsl:text>&#xA;&#xA;</xsl:text>
26<!-- How to have blfs-bootscripts versionned? Do not know, so
27 avoid it (TODO ?) -->
28 <xsl:apply-templates select="//part[not(@id='introduction')]"/>
29 </princList>
30 </xsl:template>
31
32 <xsl:template match="part">
33 <xsl:if test="count(.//*[contains(translate(@xreflabel,
34 '123456789',
35 '000000000'),
36 '-0')
37 ]) &gt; 0">
38 <xsl:text> </xsl:text>
39 <list>
40 <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
41 <xsl:text>&#xA; </xsl:text>
42 <xsl:element name="name">
[ebb631a]43 <xsl:value-of select="normalize-space(title)"/>
[e576789]44 </xsl:element>
45 <xsl:text>&#xA;&#xA;</xsl:text>
46 <xsl:apply-templates select="chapter"/>
47 <xsl:text> </xsl:text>
48 </list>
49 <xsl:text>&#xA;&#xA;</xsl:text>
50 </xsl:if>
51 </xsl:template>
52
53 <xsl:template match="chapter">
54 <xsl:if test="count(.//*[contains(translate(@xreflabel,
55 '123456789',
56 '000000000'),
57 '-0')
58 ]) &gt; 0">
59 <xsl:text> </xsl:text>
60 <sublist>
61 <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
62 <xsl:text>&#xA; </xsl:text>
63 <xsl:element name="name">
[ebb631a]64 <xsl:value-of select="normalize-space(title)"/>
[e576789]65 </xsl:element>
66 <xsl:text>&#xA;</xsl:text>
[82bd7a6]67 <xsl:apply-templates select=".//sect1">
[e576789]68 <xsl:sort select="@id"/>
69 </xsl:apply-templates>
70 <xsl:text> </xsl:text>
71 </sublist><xsl:text>&#xA;&#xA;</xsl:text>
72 </xsl:if>
73 </xsl:template>
74
75 <xsl:template match="sect1">
76 <xsl:choose>
77<!-- This test is to find sections containing modules (PERL, Python
78 DBus,...) -->
79 <xsl:when
80 test="not(contains(translate(@xreflabel,
81 '123456789',
82 '000000000'),
83 '-0')) and
84 count(descendant::node()[contains(translate(@xreflabel,
85 '123456789',
86 '000000000'),
87 '-0')
88 ]) &gt; 0">
89 <xsl:text> </xsl:text>
90 <package><xsl:text>&#xA; </xsl:text>
91 <xsl:element name="name">
[ebb631a]92 <xsl:value-of select="normalize-space(title)"/>
[e576789]93 </xsl:element>
94 <xsl:text>&#xA;</xsl:text>
[82bd7a6]95<!-- Do not use .//*, which would include self. -->
[e576789]96 <xsl:apply-templates
97 select="descendant::node()[contains(translate(@xreflabel,
98 '123456789',
99 '000000000'),
100 '-0')
101 ]"
[82bd7a6]102 mode="normal">
[e576789]103 <xsl:sort select="@id"/>
104 </xsl:apply-templates>
105 <xsl:text> </xsl:text>
106 </package><xsl:text>&#xA;&#xA;</xsl:text>
107 </xsl:when>
108 <xsl:otherwise>
109<!-- Calls the template of specialCases.xsl,
110 which calls the "normal" template when the
111 case is normal. -->
112 <xsl:apply-templates select='.' mode="special">
113 <xsl:sort select="@id"/>
114 </xsl:apply-templates>
115 </xsl:otherwise>
116 </xsl:choose>
117 </xsl:template>
118
119 <xsl:template match="*" mode="normal">
120 <xsl:variable name="version">
121 <xsl:call-template name="version">
122 <xsl:with-param name="label" select="./@xreflabel"/>
123 </xsl:call-template>
124 </xsl:variable>
125 <xsl:choose>
126<!-- If there is a "sect1" ancestor, this means that
127 we have a module -->
128 <xsl:when test="ancestor::sect1">
129 <xsl:text> </xsl:text>
130 <module><xsl:text>&#xA; </xsl:text>
131 <xsl:element name="name">
132 <xsl:value-of select="./@id"/>
133 </xsl:element>
134 <xsl:text>&#xA; </xsl:text>
135 <xsl:element name="version">
136 <xsl:value-of select="$version"/>
137 </xsl:element>
138 <xsl:if
139 test="document($installed-packages)//package[name=current()/@id]">
140 <xsl:text>&#xA; </xsl:text>
141 <xsl:element name="inst-version">
142 <xsl:value-of
143 select="document(
144 $installed-packages
145 )//package[name=current()/@id]/version"/>
146 </xsl:element>
147 </xsl:if>
148<!-- Dependencies -->
149<!-- First the case of python modules or d-bus bindings -->
150 <xsl:if test="self::sect2">
151<!-- dependencies -->
152 <xsl:apply-templates select=".//para[@role='required' or
153 @role='recommended' or
154 @role='optional']"
155 mode="dependency"/>
156 </xsl:if>
157<!-- For python modules, the preceding module is an optional dep -->
158 <xsl:if test="ancestor::sect1[@id='python-modules']">
159 <xsl:apply-templates
160 select="preceding-sibling::sect2[@role='package']
161 //listitem[para/xref/@linkend=current()/@id]"
162 mode="prec-dep"/>
163 </xsl:if>
164<!-- Now the case of perl modules: let us test our XSLT abilities.
165 Well, "use the sibling, Luke" -->
166 <xsl:if test="self::bridgehead">
167 <xsl:apply-templates select="following-sibling::itemizedlist[1]
168 /listitem/itemizedlist/listitem"
169 mode="perlmod-dep">
170 <xsl:sort select="position()"
171 data-type="number"
172 order="descending"/>
173 </xsl:apply-templates>
174 </xsl:if>
175<!-- End dependencies -->
176 <xsl:text>&#xA; </xsl:text>
177 </module><xsl:text>&#xA;</xsl:text>
178 </xsl:when>
179 <xsl:otherwise>
180 <xsl:text> </xsl:text>
181 <package><xsl:text>&#xA; </xsl:text>
182 <xsl:element name="name">
183 <xsl:value-of select="./@id"/>
184 </xsl:element>
185 <xsl:text>&#xA; </xsl:text>
186 <xsl:element name="version">
187 <xsl:value-of select="$version"/>
188 </xsl:element>
189 <xsl:if
190 test="document($installed-packages)//package[name=current()/@id]">
191 <xsl:text>&#xA; </xsl:text>
192 <xsl:element name="inst-version">
193 <xsl:value-of
194 select="document(
195 $installed-packages
196 )//package[name=current()/@id]/version"/>
197 </xsl:element>
198 </xsl:if>
199<!-- Dependencies -->
[7735c7a]200<!-- If in Xorg (not anymore) or KDE chapter, consider that the preceding
201 package is the first dependency (not always noted in the book)-->
[bd07ef5]202 <xsl:if test="ancestor::chapter[@id='kde4-core'
203 or @id='xfce-core'
[6f48f76]204 or @id='lxqt-desktop'
[bd07ef5]205 or @id='lxde-desktop']
206 and preceding-sibling::sect1[1]">
[e576789]207 <xsl:text>
208 </xsl:text>
[7735c7a]209 <xsl:element name="dependency">
210 <xsl:attribute name="status">required</xsl:attribute>
211 <xsl:attribute name="name">
212 <xsl:value-of select="preceding-sibling::sect1[1]/@id"/>
213 </xsl:attribute>
214 <xsl:attribute name="type">ref</xsl:attribute>
215 </xsl:element>
[e576789]216 </xsl:if>
217 <xsl:apply-templates select=".//para[@role='required' or
218 @role='recommended' or
219 @role='optional']"
220 mode="dependency"/>
221<!-- End dependencies -->
222 <xsl:text>&#xA; </xsl:text>
223 </package><xsl:text>&#xA;</xsl:text>
224 </xsl:otherwise>
225 </xsl:choose>
226 </xsl:template>
227
228 <xsl:template name="version">
229 <xsl:param name="label" select="abc-2"/>
230 <xsl:variable name="start" select="string-length(substring-before(translate($label,'123456789','000000000'),'-0'))+2"/>
231 <xsl:variable name="prelim-ver" select="substring($label,$start)"/>
232 <xsl:choose>
233 <xsl:when test="contains($prelim-ver,'onfiguration')"/>
234 <xsl:when test="contains($prelim-ver,'escription')"/>
235 <xsl:when test="contains($prelim-ver,'EggDBus')">
236 <xsl:value-of select="substring-before($prelim-ver,' (EggDBus)')"/>
237 </xsl:when>
238 <xsl:when test="contains($label,'JDK')">
239 <xsl:value-of select="translate($prelim-ver,' ','_')"/>
240 </xsl:when>
241 <xsl:otherwise>
242 <xsl:value-of select="$prelim-ver"/>
243 </xsl:otherwise>
244 </xsl:choose>
245 </xsl:template>
246
247 <xsl:template match="para" mode="dependency">
248 <xsl:variable name="status" select="./@role"/>
[12fc178]249<!-- First internal dependencies -->
[9575278]250 <xsl:for-each select=".//xref">
[e576789]251 <xsl:choose>
[2ae5bbe]252<!-- Avoid depending of myself -->
253 <xsl:when test="ancestor::*[@id=current()/@linkend]"/>
254<!-- Call list expansion when we have an xorg7 series of packages -->
[e576789]255 <xsl:when test="contains(@linkend,'xorg7-')">
256 <xsl:call-template name="expand-deps">
257 <xsl:with-param name="section">
258 <xsl:value-of select="@linkend"/>
259 </xsl:with-param>
260 <xsl:with-param name="status">
261 <xsl:value-of select="$status"/>
262 </xsl:with-param>
263 </xsl:call-template>
264 </xsl:when>
265 <xsl:otherwise>
266 <xsl:text>
267 </xsl:text>
268 <xsl:element name="dependency">
269 <xsl:attribute name="status">
270 <xsl:value-of select="$status"/>
271 </xsl:attribute>
272 <xsl:attribute name="name">
273 <xsl:value-of select="@linkend"/>
274 </xsl:attribute>
275 <xsl:attribute name="type">ref</xsl:attribute>
276 </xsl:element>
277 </xsl:otherwise>
278 </xsl:choose>
279 </xsl:for-each>
[12fc178]280<!-- then external dependencies -->
[9575278]281 <xsl:for-each select=".//ulink">
[12fc178]282 <xsl:text>
283 </xsl:text>
284 <xsl:element name="dependency">
285 <xsl:attribute name="status">
286 <xsl:value-of select="$status"/>
287 </xsl:attribute>
288 <xsl:attribute name="name">
[cf8e060]289 <xsl:value-of select="translate(normalize-space(text()),' ','-')"/>
[d020649]290 </xsl:attribute>
[12fc178]291 <xsl:attribute name="type">link</xsl:attribute>
292 </xsl:element>
293 </xsl:for-each>
[e576789]294 </xsl:template>
295
296 <xsl:template match="listitem" mode="prec-dep">
297 <xsl:if test="preceding-sibling::listitem">
298 <xsl:text>
299 </xsl:text>
300 <xsl:element name="dependency">
301<!-- the dep on the preceding package used to be required for python.
302 It seems optional now -->
303 <xsl:attribute name="status">optional</xsl:attribute>
304 <xsl:attribute name="name">
305 <xsl:value-of select="preceding-sibling::listitem[1]//@linkend"/>
306 </xsl:attribute>
307 <xsl:attribute name="type">ref</xsl:attribute>
308 </xsl:element>
309 </xsl:if>
310 </xsl:template>
311
312 <xsl:template match="listitem" mode="perlmod-dep">
313 <xsl:param name="glue" select="'&#xA; '"/>
314 <xsl:choose>
315 <xsl:when test="para/xref|para[@id]/ulink">
316 <xsl:value-of select="$glue"/>
317 <xsl:element name="dependency">
318 <xsl:attribute name="status">
319 <xsl:choose>
320 <xsl:when
321 test="count(./para/text()[contains(string(),
322 'ptional')
323 ]
324 )&gt;0">optional</xsl:when>
325 <xsl:otherwise>required</xsl:otherwise>
326 </xsl:choose>
327 </xsl:attribute>
328 <xsl:attribute name="name">
329 <xsl:if test="para/xref">
330 <xsl:value-of select="para/xref/@linkend"/>
331 </xsl:if>
332 <xsl:if test="para/ulink">
333 <xsl:value-of select="para/@id"/>
334 </xsl:if>
335 </xsl:attribute>
336 <xsl:attribute name="type">
337 <xsl:if test="para/xref">ref</xsl:if>
338 <xsl:if test="para/ulink">link</xsl:if>
339 </xsl:attribute>
340 <xsl:apply-templates select="itemizedlist/listitem"
341 mode="perlmod-dep">
342 <xsl:sort select="position()"
343 data-type="number"
344 order="descending"/>
345 <xsl:with-param name="glue" select="concat($glue,' ')"/>
346 </xsl:apply-templates>
347 </xsl:element>
348 </xsl:when>
349 <xsl:otherwise>
350 <xsl:apply-templates select="itemizedlist/listitem"
351 mode="perlmod-dep">
352 <xsl:sort select="position()"
353 data-type="number"
354 order="descending"/>
355 <xsl:with-param name="glue" select="$glue"/>
356 </xsl:apply-templates>
357 </xsl:otherwise>
358 </xsl:choose>
359 </xsl:template>
360
361</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.