source: BLFS/xsl/dependencies.xsl@ 875366f

ablfs-more trunk
Last change on this file since 875366f was 5132b93, checked in by Pierre Labastie <pierre.labastie@…>, 3 years ago

[BLFS] Ticket #1730: compute the full dependency chain

Comment out the version comparison in BLFS/xsl/dependencies.xsl. It is
a mess in xslt anyway...

  • Property mode set to 100644
File size: 6.2 KB
Line 
1<?xml version="1.0"?>
2
3<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 version="1.0">
5
6 <xsl:output method="text"/>
7
8 <xsl:param name="MTA" select="'sendmail'"/>
9 <xsl:param name="idofdep" select="'dbus'"/>
10
11 <xsl:key name="depnode"
12 match="package|module"
13 use="name"/>
14
15 <xsl:template match="/">
16 <xsl:apply-templates select="key('depnode',$idofdep)"/>
17 </xsl:template>
18
19 <xsl:template match="package">
20 <xsl:apply-templates select="./dependency"/>
21 </xsl:template>
22
23 <xsl:template match="module">
24 <xsl:apply-templates select="./dependency"/>
25 </xsl:template>
26
27 <xsl:template match="dependency">
28 <xsl:variable name="depname">
29 <xsl:choose>
30 <xsl:when test="@name='x-window-system'">xinit</xsl:when>
31 <xsl:when test="@name='xorg7'">xinit</xsl:when>
32 <xsl:when test="@name='server-mail'">
33 <xsl:value-of select="$MTA"/>
34 </xsl:when>
35 <xsl:otherwise>
36 <xsl:value-of select="@name"/>
37 </xsl:otherwise>
38 </xsl:choose>
39 </xsl:variable>
40<!--
41 <xsl:variable name="install_it">
42 <xsl:choose>
43 <xsl:when test="@type='link'">
44<!- - No way to track versions: install ! - ->
45 1
46 </xsl:when>
47 <xsl:otherwise>
48 <xsl:call-template name="compare-versions">
49 <xsl:with-param name="version" select="key('depnode',$depname)/version"/>
50 <xsl:with-param name="inst-version" select="key('depnode',$depname)/inst-version"/>
51 </xsl:call-template>
52 </xsl:otherwise>
53 </xsl:choose>
54 </xsl:variable>
55-->
56 <xsl:apply-templates select="dependency"/>
57<!--
58 <xsl:if test="number($install_it)">
59-->
60 <xsl:choose>
61 <xsl:when test="@type='link'">
62 <xsl:text>4</xsl:text>
63 </xsl:when>
64 <xsl:when test="@status='required'">
65 <xsl:text>1</xsl:text>
66 </xsl:when>
67 <xsl:when test="@status='recommended'">
68 <xsl:text>2</xsl:text>
69 </xsl:when>
70 <xsl:otherwise>
71 <xsl:text>3</xsl:text>
72 </xsl:otherwise>
73 </xsl:choose>
74 <xsl:text> </xsl:text>
75 <xsl:choose>
76 <xsl:when test="@build='first'">
77 <xsl:text>f</xsl:text>
78 </xsl:when>
79 <xsl:when test="@build='before'">
80 <xsl:text>b</xsl:text>
81 </xsl:when>
82 <xsl:otherwise>
83 <xsl:text>a</xsl:text>
84 </xsl:otherwise>
85 </xsl:choose>
86 <xsl:text> </xsl:text>
87 <xsl:value-of select="$depname"/>
88 <xsl:text>&#xA;</xsl:text>
89<!--
90 </xsl:if>
91-->
92 </xsl:template>
93
94<!-- lexicographic Comparison of strings. There is no way to directly
95 compare strings in XPath. So find the position of the character
96 in the following string. On the other hand, for numeric form style
97 xx.yy.zz, we have to compare xx and x'x', which is not always
98 lexicographic: think of 2.2 vs 2.10 -->
99
100 <xsl:variable name="char-table" select="' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
101 <xsl:variable name= "dot-table" select="'.....................................................'"/>
102
103 <xsl:template name="compare-versions">
104<!-- returns non-zero if version is greater than inst-version -->
105 <xsl:param name="version"/>
106 <xsl:param name="inst-version"/>
107<!-- first make all separators (-_) into dots -->
108 <xsl:variable name="mod-ver" select="translate($version,'-_','..')"/>
109 <xsl:variable name="mod-inst-ver" select="translate($inst-version,'-_','..')"/>
110<!-- Then let us find the position of the first chars in char-table (0 if numeric or dot) -->
111 <xsl:variable name="pos-ver" select="string-length(substring-before($char-table,substring($version,1,1)))"/>
112 <xsl:variable name="pos-inst-ver" select="string-length(substring-before($char-table,substring($inst-version,1,1)))"/>
113 <xsl:choose>
114 <xsl:when test="string-length($inst-version)=0">
115 <xsl:value-of select="string-length($version)"/>
116 </xsl:when>
117 <xsl:when test="string-length($version)=0">
118 0
119 </xsl:when>
120 <xsl:when test="$pos-ver != 0">
121 <xsl:choose>
122 <xsl:when test="$pos-ver = $pos-inst-ver">
123 <xsl:call-template name="compare-versions">
124 <xsl:with-param name="version" select="substring($version,2)"/>
125 <xsl:with-param name="inst-version" select="substring($inst-version,2)"/>
126 </xsl:call-template>
127 </xsl:when>
128 <xsl:otherwise>
129 <xsl:copy-of select="number($pos-ver &gt; $pos-inst-ver)"/>
130 </xsl:otherwise>
131 </xsl:choose>
132 </xsl:when>
133 <xsl:when test="substring($mod-ver,1,1)='.'">
134 <xsl:choose>
135 <xsl:when test="substring($mod-inst-ver,1,1)='.'">
136 <xsl:call-template name="compare-versions">
137 <xsl:with-param name="version" select="substring($version,2)"/>
138 <xsl:with-param name="inst-version" select="substring($inst-version,2)"/>
139 </xsl:call-template>
140 </xsl:when>
141 <xsl:otherwise>
142 0
143 </xsl:otherwise>
144 </xsl:choose>
145 </xsl:when>
146 <xsl:otherwise>
147 <xsl:choose>
148 <xsl:when test="$pos-inst-ver &gt; 0 or substring($mod-inst-ver,1,1)='.'">
149<!-- do not know what to do: do not install -->
150 0
151 </xsl:when>
152 <xsl:otherwise>
153 <xsl:variable name="tok" select="substring-before(concat(translate($mod-ver,$char-table,$dot-table),'.'),'.')"/>
154 <xsl:variable name="inst-tok" select="substring-before(concat(translate($mod-inst-ver,$char-table,$dot-table),'.'),'.')"/>
155 <xsl:choose>
156 <xsl:when test="number($tok)=number($inst-tok)">
157 <xsl:call-template name="compare-versions">
158 <xsl:with-param name="version" select="substring($version,string-length($tok)+1)"/>
159 <xsl:with-param name="inst-version" select="substring($inst-version,string-length($inst-tok)+1)"/>
160 </xsl:call-template>
161 </xsl:when>
162 <xsl:otherwise>
163 <xsl:copy-of select="number(number($tok) &gt; number($inst-tok))"/>
164 </xsl:otherwise>
165 </xsl:choose>
166 </xsl:otherwise>
167 </xsl:choose>
168 </xsl:otherwise>
169 </xsl:choose>
170 </xsl:template>
171
172</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.