source: common/urls.xsl@ e43d0d0

new_features
Last change on this file since e43d0d0 was 7bd0866, checked in by Pierre Labastie <pierre@…>, 8 years ago

Merge trunk up to revision 3864

  • Property mode set to 100644
File size: 5.2 KB
Line 
1<?xml version='1.0' encoding='ISO-8859-1'?>
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 <!-- The FTP server used as fallback -->
11 <xsl:param name="server">ftp://ftp.osuosl.org</xsl:param>
12
13 <!-- The book family (lfs or clfs). Needed to use the proper FTP path. -->
14 <xsl:param name="family">lfs</xsl:param>
15
16 <!-- The libc model used for HLFS -->
17 <xsl:param name="model" select="'glibc'"/>
18
19 <!-- The kernel series used for HLFS -->
20 <xsl:param name="kernel" select="'2.6'"/>
21
22 <!-- Do we use a package manager? -->
23 <xsl:param name="pkgmngt" select="'n'"/>
24
25 <!-- The system for LFS: sysv of systemd -->
26 <xsl:param name="revision" select="'sysv'"/>
27
28 <xsl:template match="/">
29 <xsl:apply-templates select="//varlistentry[@revision=$revision
30 or not(@revision)]//ulink"/>
31 <xsl:if test="$pkgmngt='y'">
32 <xsl:apply-templates
33 select="document('packageManager.xml')//ulink"/>
34 </xsl:if>
35 </xsl:template>
36
37 <xsl:template match="ulink">
38 <!-- If some package doesn't have the predefined strings in their
39 name, the next test must be fixed to match it also. Skip possible
40 duplicated URLs due that may be splitted for PDF output -->
41 <xsl:if test="(ancestor::varlistentry[@condition=$model]
42 or not(ancestor::varlistentry[@condition])) and
43 (ancestor::varlistentry[@vendor=$kernel]
44 or not(ancestor::varlistentry[@vendor])) and
45 (contains(@url, '.bz2') or contains(@url, '.tar.gz') or
46 contains(@url, '.tgz') or contains(@url, '.patch') or
47 contains(@url, '.xz') or contains(@url, '.lzma')) and
48 not(ancestor-or-self::*/@condition = 'pdf')">
49 <!-- Extract the package name -->
50 <xsl:variable name="package">
51 <xsl:call-template name="package.name">
52 <xsl:with-param name="url" select="@url"/>
53 </xsl:call-template>
54 </xsl:variable>
55 <!-- Extract the directory for that package -->
56 <xsl:variable name="cut"
57 select="translate(substring-after($package, '-'),
58 '0123456789', '0000000000')"/>
59 <xsl:variable name="package2">
60 <xsl:value-of select="substring-before($package, '-')"/>
61 <xsl:text>-</xsl:text>
62 <xsl:value-of select="$cut"/>
63 </xsl:variable>
64 <xsl:variable name="dirname" select="substring-before($package2, '-0')"/>
65 <!-- Write the upstream URLs, fixing the redirected ones -->
66 <xsl:choose>
67 <xsl:when test="contains(@url,'?')">
68 <xsl:value-of select="substring-before(@url,'?')"/>
69 </xsl:when>
70 <xsl:otherwise>
71 <xsl:value-of select="@url"/>
72 </xsl:otherwise>
73 </xsl:choose>
74 <xsl:text> </xsl:text>
75 <!-- Write FTP mirror URLs -->
76 <xsl:value-of select="$server"/>
77 <xsl:text>/pub/</xsl:text>
78 <xsl:value-of select="$family"/>
79 <xsl:text>/conglomeration/</xsl:text>
80 <xsl:choose>
81 <!-- Fix some directories. Test against $dirname to be sure that we
82 are matching the start of a package name, not a string in a patch name
83 But some packages requires test against $package. -->
84 <xsl:when test="contains($dirname, 'bash')">
85 <xsl:text>bash/</xsl:text>
86 </xsl:when>
87 <xsl:when test="contains($package, 'dvhtool')">
88 <xsl:text>dvhtool/</xsl:text>
89 </xsl:when>
90 <xsl:when test="contains($dirname, 'gcc')">
91 <xsl:text>gcc/</xsl:text>
92 </xsl:when>
93 <xsl:when test="contains($dirname, 'glibc')">
94 <xsl:text>glibc/</xsl:text>
95 </xsl:when>
96 <xsl:when test="contains($package, 'powerpc-utils')">
97 <xsl:text>powerpc-utils/</xsl:text>
98 </xsl:when>
99 <xsl:when test="contains($package, 'tcl')">
100 <xsl:text>tcl/</xsl:text>
101 </xsl:when>
102 <xsl:when test="contains($package, 'uClibc')">
103 <xsl:text>uClibc/</xsl:text>
104 </xsl:when>
105 <xsl:when test="contains($dirname, 'udev')">
106 <xsl:text>udev/</xsl:text>
107 </xsl:when>
108 <xsl:otherwise>
109 <xsl:value-of select="$dirname"/>
110 <xsl:text>/</xsl:text>
111 </xsl:otherwise>
112 </xsl:choose>
113 <xsl:value-of select="$package"/>
114 <!-- Write MD5SUM value -->
115 <xsl:text> </xsl:text>
116 <xsl:value-of select="../following-sibling::para/literal"/>
117 <xsl:text>&#x0a;</xsl:text>
118 </xsl:if>
119 </xsl:template>
120
121 <xsl:template name="package.name">
122 <xsl:param name="url"/>
123 <xsl:choose>
124 <xsl:when test="contains($url, '/') and not (substring-after($url,'/')='')">
125 <xsl:call-template name="package.name">
126 <xsl:with-param name="url" select="substring-after($url, '/')"/>
127 </xsl:call-template>
128 </xsl:when>
129 <xsl:otherwise>
130 <xsl:choose>
131 <xsl:when test="contains($url, '?')">
132 <xsl:value-of select="substring-before($url, '?')"/>
133 </xsl:when>
134 <xsl:otherwise>
135 <xsl:value-of select="$url"/>
136 </xsl:otherwise>
137 </xsl:choose>
138 </xsl:otherwise>
139 </xsl:choose>
140 </xsl:template>
141
142</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.