source: BLFS/xsl/dependencies.xsl@ b0965fa

ablfs-more legacy trunk
Last change on this file since b0965fa was fd4a798, checked in by Pierre Labastie <pierre.labastie@…>, 3 years ago

Remove $Id$ comments, they are useless with git

  • 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 <xsl:variable name="install_it">
41 <xsl:choose>
42 <xsl:when test="@type='link'">
43<!-- No way to track versions: install ! -->
44 1
45 </xsl:when>
46 <xsl:otherwise>
47 <xsl:call-template name="compare-versions">
48 <xsl:with-param name="version" select="key('depnode',$depname)/version"/>
49 <xsl:with-param name="inst-version" select="key('depnode',$depname)/inst-version"/>
50 </xsl:call-template>
51 </xsl:otherwise>
52 </xsl:choose>
53 </xsl:variable>
54 <xsl:apply-templates select="dependency"/>
55 <xsl:if test="number($install_it)">
56 <xsl:choose>
57 <xsl:when test="@type='link'">
58 <xsl:text>4</xsl:text>
59 </xsl:when>
60 <xsl:when test="@status='required'">
61 <xsl:text>1</xsl:text>
62 </xsl:when>
63 <xsl:when test="@status='recommended'">
64 <xsl:text>2</xsl:text>
65 </xsl:when>
66 <xsl:otherwise>
67 <xsl:text>3</xsl:text>
68 </xsl:otherwise>
69 </xsl:choose>
70 <xsl:text> </xsl:text>
71 <xsl:choose>
72 <xsl:when test="@build='first'">
73 <xsl:text>f</xsl:text>
74 </xsl:when>
75 <xsl:when test="@build='before'">
76 <xsl:text>b</xsl:text>
77 </xsl:when>
78 <xsl:otherwise>
79 <xsl:text>a</xsl:text>
80 </xsl:otherwise>
81 </xsl:choose>
82 <xsl:text> </xsl:text>
83 <xsl:value-of select="$depname"/>
84 <xsl:text>&#xA;</xsl:text>
85 </xsl:if>
86 </xsl:template>
87
88<!-- lexicographic Comparison of strings. There is no way to directly
89 compare strings in XPath. So find the position of the character
90 in the following string. On the other hand, for numeric form style
91 xx.yy.zz, we have to compare xx and x'x', which is not always
92 lexicographic: think of 2.2 vs 2.10 -->
93
94 <xsl:variable name="char-table" select="' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
95 <xsl:variable name= "dot-table" select="'.....................................................'"/>
96
97 <xsl:template name="compare-versions">
98<!-- returns non-zero if version is greater than inst-version -->
99 <xsl:param name="version"/>
100 <xsl:param name="inst-version"/>
101<!-- first make all separators (-_) into dots -->
102 <xsl:variable name="mod-ver" select="translate($version,'-_','..')"/>
103 <xsl:variable name="mod-inst-ver" select="translate($inst-version,'-_','..')"/>
104<!-- Then let us find the position of the first chars in char-table (0 if numeric or dot) -->
105 <xsl:variable name="pos-ver" select="string-length(substring-before($char-table,substring($version,1,1)))"/>
106 <xsl:variable name="pos-inst-ver" select="string-length(substring-before($char-table,substring($inst-version,1,1)))"/>
107 <xsl:choose>
108 <xsl:when test="string-length($inst-version)=0">
109 <xsl:value-of select="string-length($version)"/>
110 </xsl:when>
111 <xsl:when test="string-length($version)=0">
112 0
113 </xsl:when>
114 <xsl:when test="$pos-ver != 0">
115 <xsl:choose>
116 <xsl:when test="$pos-ver = $pos-inst-ver">
117 <xsl:call-template name="compare-versions">
118 <xsl:with-param name="version" select="substring($version,2)"/>
119 <xsl:with-param name="inst-version" select="substring($inst-version,2)"/>
120 </xsl:call-template>
121 </xsl:when>
122 <xsl:otherwise>
123 <xsl:copy-of select="number($pos-ver &gt; $pos-inst-ver)"/>
124 </xsl:otherwise>
125 </xsl:choose>
126 </xsl:when>
127 <xsl:when test="substring($mod-ver,1,1)='.'">
128 <xsl:choose>
129 <xsl:when test="substring($mod-inst-ver,1,1)='.'">
130 <xsl:call-template name="compare-versions">
131 <xsl:with-param name="version" select="substring($version,2)"/>
132 <xsl:with-param name="inst-version" select="substring($inst-version,2)"/>
133 </xsl:call-template>
134 </xsl:when>
135 <xsl:otherwise>
136 0
137 </xsl:otherwise>
138 </xsl:choose>
139 </xsl:when>
140 <xsl:otherwise>
141 <xsl:choose>
142 <xsl:when test="$pos-inst-ver &gt; 0 or substring($mod-inst-ver,1,1)='.'">
143<!-- do not know what to do: do not install -->
144 0
145 </xsl:when>
146 <xsl:otherwise>
147 <xsl:variable name="tok" select="substring-before(concat(translate($mod-ver,$char-table,$dot-table),'.'),'.')"/>
148 <xsl:variable name="inst-tok" select="substring-before(concat(translate($mod-inst-ver,$char-table,$dot-table),'.'),'.')"/>
149 <xsl:choose>
150 <xsl:when test="number($tok)=number($inst-tok)">
151 <xsl:call-template name="compare-versions">
152 <xsl:with-param name="version" select="substring($version,string-length($tok)+1)"/>
153 <xsl:with-param name="inst-version" select="substring($inst-version,string-length($inst-tok)+1)"/>
154 </xsl:call-template>
155 </xsl:when>
156 <xsl:otherwise>
157 <xsl:copy-of select="number(number($tok) &gt; number($inst-tok))"/>
158 </xsl:otherwise>
159 </xsl:choose>
160 </xsl:otherwise>
161 </xsl:choose>
162 </xsl:otherwise>
163 </xsl:choose>
164 </xsl:template>
165
166</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.