source: BLFS/xsl/gen_pkg_list.xsl@ f1da335

2.4 ablfs-more legacy new_features trunk
Last change on this file since f1da335 was 2982825, checked in by Pierre Labastie <pierre@…>, 11 years ago

Suppress reference to "printproto" in BLFS package list generation

  • Property mode set to 100644
File size: 14.2 KB
RevLine 
[e576789]1<?xml version="1.0" encoding="ISO-8859-1"?>
2
3<!-- $Id: gen_pkg_list.xsl 21 2012-02-16 15:06:19Z labastie $ -->
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">
43 <xsl:value-of select="title"/>
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">
64 <xsl:value-of select="title"/>
65 </xsl:element>
66 <xsl:text>&#xA;</xsl:text>
67 <xsl:apply-templates select=".//sect1[@xreflabel]">
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">
92 <xsl:value-of select="title"/>
93 </xsl:element>
94 <xsl:text>&#xA;</xsl:text>
95<!-- Do not use .//*, which would include self.
96 Calls the template of specialCases.xsl,
97 which calls the "normal" template when the
98 case is normal. -->
99 <xsl:apply-templates
100 select="descendant::node()[contains(translate(@xreflabel,
101 '123456789',
102 '000000000'),
103 '-0')
104 ]"
105 mode="special">
106 <xsl:sort select="@id"/>
107 </xsl:apply-templates>
108 <xsl:text> </xsl:text>
109 </package><xsl:text>&#xA;&#xA;</xsl:text>
110 </xsl:when>
111 <xsl:otherwise>
112<!-- Calls the template of specialCases.xsl,
113 which calls the "normal" template when the
114 case is normal. -->
115 <xsl:apply-templates select='.' mode="special">
116 <xsl:sort select="@id"/>
117 </xsl:apply-templates>
118 </xsl:otherwise>
119 </xsl:choose>
120 </xsl:template>
121
122 <xsl:template match="*" mode="normal">
123 <xsl:variable name="version">
124 <xsl:call-template name="version">
125 <xsl:with-param name="label" select="./@xreflabel"/>
126 </xsl:call-template>
127 </xsl:variable>
128 <xsl:choose>
129<!-- If there is a "sect1" ancestor, this means that
130 we have a module -->
131 <xsl:when test="ancestor::sect1">
132 <xsl:text> </xsl:text>
133 <module><xsl:text>&#xA; </xsl:text>
134 <xsl:element name="name">
135 <xsl:value-of select="./@id"/>
136 </xsl:element>
137 <xsl:text>&#xA; </xsl:text>
138 <xsl:element name="version">
139 <xsl:value-of select="$version"/>
140 </xsl:element>
141 <xsl:if
142 test="document($installed-packages)//package[name=current()/@id]">
143 <xsl:text>&#xA; </xsl:text>
144 <xsl:element name="inst-version">
145 <xsl:value-of
146 select="document(
147 $installed-packages
148 )//package[name=current()/@id]/version"/>
149 </xsl:element>
150 </xsl:if>
151<!-- Dependencies -->
152<!-- First the case of python modules or d-bus bindings -->
153 <xsl:if test="self::sect2">
154<!-- dependencies -->
155 <xsl:apply-templates select=".//para[@role='required' or
156 @role='recommended' or
157 @role='optional']"
158 mode="dependency"/>
159 </xsl:if>
160<!-- For python modules, the preceding module is an optional dep -->
161 <xsl:if test="ancestor::sect1[@id='python-modules']">
162 <xsl:apply-templates
163 select="preceding-sibling::sect2[@role='package']
164 //listitem[para/xref/@linkend=current()/@id]"
165 mode="prec-dep"/>
166 </xsl:if>
167<!-- Now the case of perl modules: let us test our XSLT abilities.
168 Well, "use the sibling, Luke" -->
169 <xsl:if test="self::bridgehead">
170 <xsl:apply-templates select="following-sibling::itemizedlist[1]
171 /listitem/itemizedlist/listitem"
172 mode="perlmod-dep">
173 <xsl:sort select="position()"
174 data-type="number"
175 order="descending"/>
176 </xsl:apply-templates>
177 </xsl:if>
178<!-- End dependencies -->
179 <xsl:text>&#xA; </xsl:text>
180 </module><xsl:text>&#xA;</xsl:text>
181 </xsl:when>
182 <xsl:otherwise>
183 <xsl:text> </xsl:text>
184 <package><xsl:text>&#xA; </xsl:text>
185 <xsl:element name="name">
186 <xsl:value-of select="./@id"/>
187 </xsl:element>
188 <xsl:text>&#xA; </xsl:text>
189 <xsl:element name="version">
190 <xsl:value-of select="$version"/>
191 </xsl:element>
192 <xsl:if
193 test="document($installed-packages)//package[name=current()/@id]">
194 <xsl:text>&#xA; </xsl:text>
195 <xsl:element name="inst-version">
196 <xsl:value-of
197 select="document(
198 $installed-packages
199 )//package[name=current()/@id]/version"/>
200 </xsl:element>
201 </xsl:if>
202<!-- Dependencies -->
203<!-- If in Xorg or KDE chapter, consider that the preceding package is
204 the first dependency (not always noted in the book) -->
205 <xsl:if test="ancestor::chapter[@id='kde4-core'] or
206 (ancestor::chapter[@id='x-window-system'] and
207 preceding-sibling::sect1[@id != 'xorg7'])">
208 <xsl:text>
209 </xsl:text>
210 <xsl:choose>
211 <xsl:when test="contains(preceding-sibling::sect1[1]/@id,
[2982825]212 'xorg7-') and
213 not(contains(preceding-sibling::sect1[1]/@id,
214 'driver'))">
[e576789]215 <xsl:call-template name="expand-deps">
216 <xsl:with-param name="section">
217 <xsl:value-of select="preceding-sibling::sect1[1]/@id"/>
218 </xsl:with-param>
219 <xsl:with-param name="status" select="'required'"/>
220 </xsl:call-template>
221 </xsl:when>
222 <xsl:otherwise>
223 <xsl:element name="dependency">
224 <xsl:attribute name="status">required</xsl:attribute>
225 <xsl:attribute name="name">
226 <xsl:choose>
227 <xsl:when test="@id='printproto'">xorg-server</xsl:when>
228 <xsl:otherwise>
229 <xsl:value-of
230 select="preceding-sibling::sect1[1]/@id"/>
231 </xsl:otherwise>
232 </xsl:choose>
233 </xsl:attribute>
234 <xsl:attribute name="type">ref</xsl:attribute>
235 </xsl:element>
236 </xsl:otherwise>
237 </xsl:choose>
238 </xsl:if>
239 <xsl:apply-templates select=".//para[@role='required' or
240 @role='recommended' or
241 @role='optional']"
242 mode="dependency"/>
243<!-- End dependencies -->
244 <xsl:text>&#xA; </xsl:text>
245 </package><xsl:text>&#xA;</xsl:text>
246 </xsl:otherwise>
247 </xsl:choose>
248 </xsl:template>
249
250 <xsl:template name="version">
251 <xsl:param name="label" select="abc-2"/>
252 <xsl:variable name="start" select="string-length(substring-before(translate($label,'123456789','000000000'),'-0'))+2"/>
253 <xsl:variable name="prelim-ver" select="substring($label,$start)"/>
254 <xsl:choose>
255 <xsl:when test="contains($prelim-ver,'onfiguration')"/>
256 <xsl:when test="contains($prelim-ver,'escription')"/>
257 <xsl:when test="contains($prelim-ver,'EggDBus')">
258 <xsl:value-of select="substring-before($prelim-ver,' (EggDBus)')"/>
259 </xsl:when>
260 <xsl:when test="contains($label,'JDK')">
261 <xsl:value-of select="translate($prelim-ver,' ','_')"/>
262 </xsl:when>
263 <xsl:otherwise>
264 <xsl:value-of select="$prelim-ver"/>
265 </xsl:otherwise>
266 </xsl:choose>
267 </xsl:template>
268
269 <xsl:template match="para" mode="dependency">
270 <xsl:variable name="status" select="./@role"/>
271<!-- No ulink for now (see special case for Perl modules) -->
272 <xsl:for-each select="./xref">
273 <xsl:choose>
274 <xsl:when test="contains(@linkend,'xorg7-')">
275 <xsl:call-template name="expand-deps">
276 <xsl:with-param name="section">
277 <xsl:value-of select="@linkend"/>
278 </xsl:with-param>
279 <xsl:with-param name="status">
280 <xsl:value-of select="$status"/>
281 </xsl:with-param>
282 </xsl:call-template>
283 </xsl:when>
284 <xsl:otherwise>
285 <xsl:text>
286 </xsl:text>
287 <xsl:element name="dependency">
288 <xsl:attribute name="status">
289 <xsl:value-of select="$status"/>
290 </xsl:attribute>
291 <xsl:attribute name="name">
292 <xsl:value-of select="@linkend"/>
293 </xsl:attribute>
294 <xsl:attribute name="type">ref</xsl:attribute>
295 </xsl:element>
296 </xsl:otherwise>
297 </xsl:choose>
298 </xsl:for-each>
299 </xsl:template>
300
301 <xsl:template match="listitem" mode="prec-dep">
302 <xsl:if test="preceding-sibling::listitem">
303 <xsl:text>
304 </xsl:text>
305 <xsl:element name="dependency">
306<!-- the dep on the preceding package used to be required for python.
307 It seems optional now -->
308 <xsl:attribute name="status">optional</xsl:attribute>
309 <xsl:attribute name="name">
310 <xsl:value-of select="preceding-sibling::listitem[1]//@linkend"/>
311 </xsl:attribute>
312 <xsl:attribute name="type">ref</xsl:attribute>
313 </xsl:element>
314 </xsl:if>
315 </xsl:template>
316
317 <xsl:template match="listitem" mode="perlmod-dep">
318 <xsl:param name="glue" select="'&#xA; '"/>
319 <xsl:choose>
320 <xsl:when test="para/xref|para[@id]/ulink">
321 <xsl:value-of select="$glue"/>
322 <xsl:element name="dependency">
323 <xsl:attribute name="status">
324 <xsl:choose>
325 <xsl:when
326 test="count(./para/text()[contains(string(),
327 'ptional')
328 ]
329 )&gt;0">optional</xsl:when>
330 <xsl:otherwise>required</xsl:otherwise>
331 </xsl:choose>
332 </xsl:attribute>
333 <xsl:attribute name="name">
334 <xsl:if test="para/xref">
335 <xsl:value-of select="para/xref/@linkend"/>
336 </xsl:if>
337 <xsl:if test="para/ulink">
338 <xsl:value-of select="para/@id"/>
339 </xsl:if>
340 </xsl:attribute>
341 <xsl:attribute name="type">
342 <xsl:if test="para/xref">ref</xsl:if>
343 <xsl:if test="para/ulink">link</xsl:if>
344 </xsl:attribute>
345 <xsl:apply-templates select="itemizedlist/listitem"
346 mode="perlmod-dep">
347 <xsl:sort select="position()"
348 data-type="number"
349 order="descending"/>
350 <xsl:with-param name="glue" select="concat($glue,' ')"/>
351 </xsl:apply-templates>
352 </xsl:element>
353 </xsl:when>
354 <xsl:otherwise>
355 <xsl:apply-templates select="itemizedlist/listitem"
356 mode="perlmod-dep">
357 <xsl:sort select="position()"
358 data-type="number"
359 order="descending"/>
360 <xsl:with-param name="glue" select="$glue"/>
361 </xsl:apply-templates>
362 </xsl:otherwise>
363 </xsl:choose>
364 </xsl:template>
365
366</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.