source: BLFS/xsl/gen_pkg_list.xsl@ b9c5dc9

ablfs
Last change on this file since b9c5dc9 was 96a30c7, checked in by Pierre Labastie <pierre@…>, 13 years ago

Adds -j1 to "make install", impose a dependency on preceding package in X*
chapter

  • Property mode set to 100644
File size: 12.7 KB
Line 
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<!-- Python modules have a building order which we have to indicate
155 as dependencies. The preceding module has to be the first
156 dependency. -->
157 <xsl:if test="ancestor::sect1[@id='python-modules']">
158 <xsl:apply-templates
159 select="preceding-sibling::sect2[@role='package']
160 //listitem[para/xref/@linkend=current()/@id]"
161 mode="prec-dep"/>
162 </xsl:if>
163<!-- The other dependencies (for Python modules) or dependencies (for DBus) -->
164 <xsl:apply-templates select=".//para[@role='required' or
165 @role='recommended' or
166 @role='optional']"
167 mode="dependency"/>
168 </xsl:if>
169<!-- Now the case of perl modules: let us test our XSLT abilities.
170 Well, "use the sibling, Luke" -->
171 <xsl:if test="self::bridgehead">
172 <xsl:apply-templates select="following-sibling::itemizedlist[1]
173 /listitem/itemizedlist/listitem"
174 mode="perlmod-dep">
175 <xsl:sort select="position()"
176 data-type="number"
177 order="descending"/>
178 </xsl:apply-templates>
179 </xsl:if>
180<!-- End dependencies -->
181 <xsl:text>&#xA; </xsl:text>
182 </module><xsl:text>&#xA;</xsl:text>
183 </xsl:when>
184 <xsl:otherwise>
185 <xsl:text> </xsl:text>
186 <package><xsl:text>&#xA; </xsl:text>
187 <xsl:element name="name">
188 <xsl:value-of select="./@id"/>
189 </xsl:element>
190 <xsl:text>&#xA; </xsl:text>
191 <xsl:element name="version">
192 <xsl:value-of select="$version"/>
193 </xsl:element>
194 <xsl:if
195 test="document($installed-packages)//package[name=current()/@id]">
196 <xsl:text>&#xA; </xsl:text>
197 <xsl:element name="inst-version">
198 <xsl:value-of
199 select="document(
200 $installed-packages
201 )//package[name=current()/@id]/version"/>
202 </xsl:element>
203 </xsl:if>
204<!-- Dependencies -->
205<!-- If in Xorg chapter, consider that the preceding package is
206 the first dependency (not always noted in the book) -->
207 <xsl:if test="ancestor::chapter[@id='x-window-system'] and
208 preceding-sibling::sect1[@id != 'xorg7']">
209 <xsl:text>
210 </xsl:text>
211 <xsl:element name="dependency">
212 <xsl:attribute name="status">required</xsl:attribute>
213 <xsl:attribute name="name">
214 <xsl:value-of
215 select="preceding-sibling::sect1[1]/@id"/>
216 </xsl:attribute>
217 <xsl:attribute name="type">ref</xsl:attribute>
218 </xsl:element>
219
220 </xsl:if>
221 <xsl:apply-templates select=".//para[@role='required' or
222 @role='recommended' or
223 @role='optional']"
224 mode="dependency"/>
225<!-- End dependencies -->
226 <xsl:text>&#xA; </xsl:text>
227 </package><xsl:text>&#xA;</xsl:text>
228 </xsl:otherwise>
229 </xsl:choose>
230 </xsl:template>
231
232 <xsl:template name="version">
233 <xsl:param name="label" select="abc-2"/>
234 <xsl:variable name="start" select="string-length(substring-before(translate($label,'123456789','000000000'),'-0'))+2"/>
235 <xsl:variable name="prelim-ver" select="substring($label,$start)"/>
236 <xsl:choose>
237 <xsl:when test="contains($prelim-ver,'onfiguration')"/>
238 <xsl:when test="contains($prelim-ver,'escription')"/>
239 <xsl:when test="contains($prelim-ver,'EggDBus')">
240 <xsl:value-of select="substring-before($prelim-ver,' (EggDBus)')"/>
241 </xsl:when>
242 <xsl:when test="contains($label,'JDK')">
243 <xsl:value-of select="translate($prelim-ver,' ','_')"/>
244 </xsl:when>
245 <xsl:otherwise>
246 <xsl:value-of select="$prelim-ver"/>
247 </xsl:otherwise>
248 </xsl:choose>
249 </xsl:template>
250
251 <xsl:template match="para" mode="dependency">
252 <xsl:variable name="status" select="./@role"/>
253<!-- No ulink for now (see special case for Perl modules) -->
254 <xsl:for-each select="./xref">
255 <xsl:text>
256 </xsl:text>
257 <xsl:element name="dependency">
258 <xsl:attribute name="status">
259 <xsl:value-of select="$status"/>
260 </xsl:attribute>
261 <xsl:attribute name="name">
262 <xsl:value-of select="@linkend"/>
263 </xsl:attribute>
264 <xsl:attribute name="type">ref</xsl:attribute>
265 </xsl:element>
266 </xsl:for-each>
267 </xsl:template>
268
269 <xsl:template match="listitem" mode="prec-dep">
270 <xsl:if test="preceding-sibling::listitem">
271 <xsl:text>
272 </xsl:text>
273 <xsl:element name="dependency">
274 <xsl:attribute name="status">required</xsl:attribute>
275 <xsl:attribute name="name">
276 <xsl:value-of select="preceding-sibling::listitem[1]//@linkend"/>
277 </xsl:attribute>
278 <xsl:attribute name="type">ref</xsl:attribute>
279 </xsl:element>
280 </xsl:if>
281 </xsl:template>
282
283 <xsl:template match="listitem" mode="perlmod-dep">
284 <xsl:param name="glue" select="'&#xA; '"/>
285 <xsl:choose>
286 <xsl:when test="para/xref|para[@id]/ulink">
287 <xsl:value-of select="$glue"/>
288 <xsl:element name="dependency">
289 <xsl:attribute name="status">
290 <xsl:choose>
291 <xsl:when
292 test="count(./para/text()[contains(string(),
293 'ptional')
294 ]
295 )&gt;0">optional</xsl:when>
296 <xsl:otherwise>required</xsl:otherwise>
297 </xsl:choose>
298 </xsl:attribute>
299 <xsl:attribute name="name">
300 <xsl:if test="para/xref">
301 <xsl:value-of select="para/xref/@linkend"/>
302 </xsl:if>
303 <xsl:if test="para/ulink">
304 <xsl:value-of select="para/@id"/>
305 </xsl:if>
306 </xsl:attribute>
307 <xsl:attribute name="type">
308 <xsl:if test="para/xref">ref</xsl:if>
309 <xsl:if test="para/ulink">link</xsl:if>
310 </xsl:attribute>
311 <xsl:apply-templates select="itemizedlist/listitem"
312 mode="perlmod-dep">
313 <xsl:sort select="position()"
314 data-type="number"
315 order="descending"/>
316 <xsl:with-param name="glue" select="concat($glue,' ')"/>
317 </xsl:apply-templates>
318 </xsl:element>
319 </xsl:when>
320 <xsl:otherwise>
321 <xsl:apply-templates select="itemizedlist/listitem"
322 mode="perlmod-dep">
323 <xsl:sort select="position()"
324 data-type="number"
325 order="descending"/>
326 <xsl:with-param name="glue" select="$glue"/>
327 </xsl:apply-templates>
328 </xsl:otherwise>
329 </xsl:choose>
330 </xsl:template>
331
332</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.