source: BLFS/xsl/dependencies.xsl@ e415656

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

Add a few forgotten keywords properties

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