source: BLFS/xsl/dependencies.xsl@ 9a4c530

ablfs-more legacy trunk
Last change on this file since 9a4c530 was 2140f22, checked in by Pierre Labastie <pierre@…>, 7 years ago

New management of dependencies:

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