source: BLFS/xsl/dependencies.xsl@ b2c7742

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

Merge ablfs branch. Normally, jhalfs should not perform differently
for building LFS

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