source: common/urls.xsl@ 82bd7a6

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

Fix 2 minor bugs:

  • the tzdata DESTDIR should not be tzdata, because some package managers use

$PACKAGE as their working directory, and this may conflicts with this one.
tzdata DESTDIR is now 001-tzdata

  • when reading md5sums, the current code assumes that there is only one

<para><literal> node reachable from ../.. (relative to <ulink>). This is true
for the "official" book, but not necessarily for the snippets written for
package management. The following change only assumes that the md5sum
<para><literal> for a given <ulink> is the first one after <para><ulink>,
which does not change anything for the book, and is better for user
written snippets.

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