1 | <?xml version='1.0' encoding='ISO-8859-1'?>
|
---|
2 |
|
---|
3 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
---|
4 | version="1.0">
|
---|
5 |
|
---|
6 | <xsl:output method="text"/>
|
---|
7 |
|
---|
8 | <!-- The FTP server used as fallback -->
|
---|
9 | <xsl:param name="server">ftp://ftp.osuosl.org</xsl:param>
|
---|
10 |
|
---|
11 | <!-- The libc model used for HLFS -->
|
---|
12 | <xsl:param name="model" select="glibc"/>
|
---|
13 |
|
---|
14 | <xsl:template match="/">
|
---|
15 | <xsl:apply-templates select="//ulink"/>
|
---|
16 | </xsl:template>
|
---|
17 |
|
---|
18 | <xsl:template match="ulink">
|
---|
19 | <!-- If some package don't have the predefined strings in their
|
---|
20 | name, the next test must be fixed to match it also. Skip possible
|
---|
21 | duplicated URLs due that may be splitted for PDF output -->
|
---|
22 | <xsl:if test="(ancestor::varlistentry[@condition=$model]
|
---|
23 | or not(ancestor::varlistentry[@condition])) and
|
---|
24 | (contains(@url, '.tar.') or contains(@url, '.tgz')
|
---|
25 | or contains(@url, '.patch') or contains(@url, '.rules')) and
|
---|
26 | not(ancestor-or-self::*/@condition = 'pdf')">
|
---|
27 | <!-- Extract the package name -->
|
---|
28 | <xsl:variable name="package">
|
---|
29 | <xsl:call-template name="package.name">
|
---|
30 | <xsl:with-param name="url" select="@url"/>
|
---|
31 | </xsl:call-template>
|
---|
32 | </xsl:variable>
|
---|
33 | <!-- Extract the directory for that package -->
|
---|
34 | <xsl:variable name="cut"
|
---|
35 | select="translate(substring-after($package, '-'),
|
---|
36 | '0123456789', '0000000000')"/>
|
---|
37 | <xsl:variable name="package2">
|
---|
38 | <xsl:value-of select="substring-before($package, '-')"/>
|
---|
39 | <xsl:text>-</xsl:text>
|
---|
40 | <xsl:value-of select="$cut"/>
|
---|
41 | </xsl:variable>
|
---|
42 | <xsl:variable name="dirname" select="substring-before($package2, '-0')"/>
|
---|
43 | <!-- Write the upstream URLs, except the redirected ones -->
|
---|
44 | <xsl:if test="not(contains(@url,'?'))">
|
---|
45 | <xsl:value-of select="@url"/>
|
---|
46 | </xsl:if>
|
---|
47 | <!-- Using a tab character as fields separator -->
|
---|
48 | <xsl:text> </xsl:text>
|
---|
49 | <xsl:value-of select="$server"/>
|
---|
50 | <xsl:text>/pub/lfs/conglomeration/</xsl:text>
|
---|
51 | <xsl:choose>
|
---|
52 | <!-- Fix some directories. Test against package2 to be sure that we
|
---|
53 | are matching the start of a package name, not a string in a patch name -->
|
---|
54 | <xsl:when test="contains($package2, 'bash')">
|
---|
55 | <xsl:text>bash/</xsl:text>
|
---|
56 | </xsl:when>
|
---|
57 | <xsl:when test="contains($package2, 'gcc')">
|
---|
58 | <xsl:text>gcc/</xsl:text>
|
---|
59 | </xsl:when>
|
---|
60 | <xsl:when test="contains($package2, 'glibc')">
|
---|
61 | <xsl:text>glibc/</xsl:text>
|
---|
62 | </xsl:when>
|
---|
63 | <xsl:when test="contains($package2, 'tcl')">
|
---|
64 | <xsl:text>tcl/</xsl:text>
|
---|
65 | </xsl:when>
|
---|
66 | <xsl:when test="contains($package2, 'uClibc')">
|
---|
67 | <xsl:text>uClibc/</xsl:text>
|
---|
68 | </xsl:when>
|
---|
69 | <xsl:when test="contains($package2, 'udev')">
|
---|
70 | <xsl:text>udev/</xsl:text>
|
---|
71 | </xsl:when>
|
---|
72 | <xsl:otherwise>
|
---|
73 | <xsl:value-of select="$dirname"/>
|
---|
74 | <xsl:text>/</xsl:text>
|
---|
75 | </xsl:otherwise>
|
---|
76 | </xsl:choose>
|
---|
77 | <xsl:value-of select="$package"/>
|
---|
78 | <xsl:text>
</xsl:text>
|
---|
79 | </xsl:if>
|
---|
80 | </xsl:template>
|
---|
81 |
|
---|
82 | <xsl:template name="package.name">
|
---|
83 | <xsl:param name="url"/>
|
---|
84 | <xsl:choose>
|
---|
85 | <xsl:when test="contains($url, '/')">
|
---|
86 | <xsl:call-template name="package.name">
|
---|
87 | <xsl:with-param name="url" select="substring-after($url, '/')"/>
|
---|
88 | </xsl:call-template>
|
---|
89 | </xsl:when>
|
---|
90 | <xsl:otherwise>
|
---|
91 | <xsl:choose>
|
---|
92 | <xsl:when test="contains($url, '?')">
|
---|
93 | <xsl:value-of select="substring-before($url, '?')"/>
|
---|
94 | </xsl:when>
|
---|
95 | <xsl:otherwise>
|
---|
96 | <xsl:value-of select="$url"/>
|
---|
97 | </xsl:otherwise>
|
---|
98 | </xsl:choose>
|
---|
99 | </xsl:otherwise>
|
---|
100 | </xsl:choose>
|
---|
101 | </xsl:template>
|
---|
102 |
|
---|
103 | </xsl:stylesheet>
|
---|