source: BLFS/xsl/dependencies.xsl@ 39da010

2.4 ablfs-more legacy new_features trunk
Last change on this file since 39da010 was 82bd7a6, checked in by Pierre Labastie <pierre@…>, 9 years ago

Adjustements for non-versioned packages:

  • allows xorg-env to be a dependency although it is a sect2 id
  • remove the ban on xorg-env in dependencies.xsl
  • directly call the template mode="normal" for modules, since there are no special cases in this case.
  • treat all sect1 s, even if they do not have a xreflabel.
  • Property mode set to 100644
File size: 6.7 KB
Line 
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: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:value-of select="$priority"/>
87 <xsl:text> </xsl:text>
88 <xsl:value-of select="$depname"/>
89 <xsl:text>&#xA;</xsl:text>
90 </xsl:if>
91 </xsl:template>
92
93<!-- lexicographic Comparison of strings. There is no way to directly
94 compare strings in XPath. So find the position of the character
95 in the following string. On the other hand, for numeric form style
96 xx.yy.zz, we have to compare xx and x'x', which is not always
97 lexicographic: think of 2.2 vs 2.10 -->
98
99 <xsl:variable name="char-table" select="' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
100 <xsl:variable name= "dot-table" select="'.....................................................'"/>
101
102 <xsl:template name="compare-versions">
103<!-- returns non-zero if version is greater than inst-version -->
104 <xsl:param name="version"/>
105 <xsl:param name="inst-version"/>
106<!-- first make all separators (-_) into dots -->
107 <xsl:variable name="mod-ver" select="translate($version,'-_','..')"/>
108 <xsl:variable name="mod-inst-ver" select="translate($inst-version,'-_','..')"/>
109<!-- Then let us find the position of the first chars in char-table (0 if numeric or dot) -->
110 <xsl:variable name="pos-ver" select="string-length(substring-before($char-table,substring($version,1,1)))"/>
111 <xsl:variable name="pos-inst-ver" select="string-length(substring-before($char-table,substring($inst-version,1,1)))"/>
112 <xsl:choose>
113 <xsl:when test="string-length($inst-version)=0">
114 <xsl:value-of select="string-length($version)"/>
115 </xsl:when>
116 <xsl:when test="string-length($version)=0">
117 0
118 </xsl:when>
119 <xsl:when test="$pos-ver != 0">
120 <xsl:choose>
121 <xsl:when test="$pos-ver = $pos-inst-ver">
122 <xsl:call-template name="compare-versions">
123 <xsl:with-param name="version" select="substring($version,2)"/>
124 <xsl:with-param name="inst-version" select="substring($inst-version,2)"/>
125 </xsl:call-template>
126 </xsl:when>
127 <xsl:otherwise>
128 <xsl:copy-of select="number($pos-ver &gt; $pos-inst-ver)"/>
129 </xsl:otherwise>
130 </xsl:choose>
131 </xsl:when>
132 <xsl:when test="substring($mod-ver,1,1)='.'">
133 <xsl:choose>
134 <xsl:when test="substring($mod-inst-ver,1,1)='.'">
135 <xsl:call-template name="compare-versions">
136 <xsl:with-param name="version" select="substring($version,2)"/>
137 <xsl:with-param name="inst-version" select="substring($inst-version,2)"/>
138 </xsl:call-template>
139 </xsl:when>
140 <xsl:otherwise>
141 0
142 </xsl:otherwise>
143 </xsl:choose>
144 </xsl:when>
145 <xsl:otherwise>
146 <xsl:choose>
147 <xsl:when test="$pos-inst-ver &gt; 0 or substring($mod-inst-ver,1,1)='.'">
148<!-- do not know what to do: do not install -->
149 0
150 </xsl:when>
151 <xsl:otherwise>
152 <xsl:variable name="tok" select="substring-before(concat(translate($mod-ver,$char-table,$dot-table),'.'),'.')"/>
153 <xsl:variable name="inst-tok" select="substring-before(concat(translate($mod-inst-ver,$char-table,$dot-table),'.'),'.')"/>
154 <xsl:choose>
155 <xsl:when test="number($tok)=number($inst-tok)">
156 <xsl:call-template name="compare-versions">
157 <xsl:with-param name="version" select="substring($version,string-length($tok)+1)"/>
158 <xsl:with-param name="inst-version" select="substring($inst-version,string-length($inst-tok)+1)"/>
159 </xsl:call-template>
160 </xsl:when>
161 <xsl:otherwise>
162 <xsl:copy-of select="number(number($tok) &gt; number($inst-tok))"/>
163 </xsl:otherwise>
164 </xsl:choose>
165 </xsl:otherwise>
166 </xsl:choose>
167 </xsl:otherwise>
168 </xsl:choose>
169 </xsl:template>
170
171</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.