source: dump-lfs-scripts.xsl@ 6a06bee

1.0 2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since 6a06bee was be9970b, checked in by Manuel Canales Esparcia <manuel@…>, 19 years ago

Now packages in tar.gz format are supported also.

  • Property mode set to 100644
File size: 6.9 KB
Line 
1<?xml version="1.0"?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:exsl="http://exslt.org/common"
4 extension-element-prefixes="exsl"
5 version="1.0">
6
7<!-- XSLT stylesheet to create shell scripts from LFS books. -->
8
9 <!-- Run optional test suites? -->
10 <xsl:param name="testsuite" select="0"/>
11
12 <!-- Run toolchain test suites? -->
13 <xsl:param name="toolchaintest" select="1"/>
14
15 <xsl:template match="/">
16 <xsl:apply-templates select="//sect1"/>
17 </xsl:template>
18
19 <xsl:template match="sect1">
20 <xsl:if test="count(descendant::screen/userinput) &gt; 0 and
21 count(descendant::screen/userinput) &gt; count(descendant::screen[@role='nodump'])">
22 <!-- The dirs names -->
23 <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
24 <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
25 <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
26 <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
27 <!-- The file names -->
28 <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
29 <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
30 <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
31 <!-- The build order -->
32 <xsl:variable name="position" select="position()"/>
33 <xsl:variable name="order">
34 <xsl:choose>
35 <xsl:when test="string-length($position) = 1">
36 <xsl:text>00</xsl:text>
37 <xsl:value-of select="$position"/>
38 </xsl:when>
39 <xsl:when test="string-length($position) = 2">
40 <xsl:text>0</xsl:text>
41 <xsl:value-of select="$position"/>
42 </xsl:when>
43 <xsl:otherwise>
44 <xsl:value-of select="$position"/>
45 </xsl:otherwise>
46 </xsl:choose>
47 </xsl:variable>
48 <!-- Creating dirs and files -->
49 <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
50 <xsl:choose>
51 <xsl:when test="@id='ch-system-changingowner' or
52 @id='ch-system-creatingdirs' or
53 @id='ch-system-createfiles'">
54 <xsl:text>#!/tools/bin/bash&#xA;set -e&#xA;&#xA;</xsl:text>
55 </xsl:when>
56 <xsl:when test="@id='ch-tools-stripping' or
57 @id='ch-system-strippingagain'">
58 <xsl:text>#!/bin/sh&#xA;</xsl:text>
59 </xsl:when>
60 <xsl:otherwise>
61 <xsl:text>#!/bin/sh&#xA;set -e&#xA;&#xA;</xsl:text>
62 </xsl:otherwise>
63 </xsl:choose>
64 <xsl:if test="sect2[@role='installation'] or
65 @id='ch-tools-adjusting' or
66 @id='ch-system-readjusting'">
67 <xsl:text>cd $PKGDIR&#xA;</xsl:text>
68 </xsl:if>
69 <xsl:apply-templates select=".//para/userinput | .//screen"/>
70 <xsl:text>exit</xsl:text>
71 </exsl:document>
72 </xsl:if>
73 </xsl:template>
74
75 <xsl:template match="screen">
76 <xsl:if test="child::* = userinput">
77 <xsl:choose>
78 <xsl:when test="@role = 'nodump'"/>
79 <xsl:otherwise>
80 <xsl:apply-templates select="userinput" mode="screen"/>
81 </xsl:otherwise>
82 </xsl:choose>
83 </xsl:if>
84 </xsl:template>
85
86 <xsl:template match="para/userinput">
87 <xsl:if test="$testsuite != '0' and
88 (contains(string(),'test') or
89 contains(string(),'check'))">
90 <xsl:value-of select="substring-before(string(),'make')"/>
91 <xsl:text>make -k</xsl:text>
92 <xsl:value-of select="substring-after(string(),'make')"/>
93 <xsl:text> || true&#xA;</xsl:text>
94 </xsl:if>
95 </xsl:template>
96
97 <xsl:template match="userinput" mode="screen">
98 <xsl:choose>
99 <!-- Estandarized package formats -->
100 <xsl:when test="contains(string(),'tar.gz')">
101 <xsl:value-of select="substring-before(string(),'tar.gz')"/>
102 <xsl:text>tar.*</xsl:text>
103 <xsl:value-of select="substring-after(string(),'tar.gz')"/>
104 <xsl:text>&#xA;</xsl:text>
105 </xsl:when>
106 <!-- Avoiding a race condition in a patch -->
107 <xsl:when test="contains(string(),'debian_fixes')">
108 <xsl:value-of select="substring-before(string(),'patch')"/>
109 <xsl:text>patch -Z</xsl:text>
110 <xsl:value-of select="substring-after(string(),'patch')"/>
111 <xsl:text>&#xA;</xsl:text>
112 </xsl:when>
113 <!-- Copying the kernel config file -->
114 <xsl:when test="string() = 'make mrproper'">
115 <xsl:text>make mrproper&#xA;</xsl:text>
116 <xsl:text>cp -v ../kernel-config .config&#xA;</xsl:text>
117 </xsl:when>
118 <!-- The Coreutils test suite is optional -->
119 <xsl:when test="$testsuite = '0' and
120 ancestor::sect1[@id='ch-system-coreutils'] and
121 (contains(string(),'check') or
122 contains(string(),'dummy'))"/>
123 <!-- Fixing toolchain test suites run -->
124 <xsl:when test="string() = 'make check' or
125 string() = 'make -k check'">
126 <xsl:choose>
127 <xsl:when test="$toolchaintest = '0'"/>
128 <xsl:otherwise>
129 <xsl:text>make -k check || true</xsl:text>
130 <xsl:text>&#xA;</xsl:text>
131 </xsl:otherwise>
132 </xsl:choose>
133 </xsl:when>
134 <xsl:when test="contains(string(),'glibc-check-log')">
135 <xsl:choose>
136 <xsl:when test="$toolchaintest = '0'"/>
137 <xsl:otherwise>
138 <xsl:value-of select="substring-before(string(),'&#xA;')"/>
139 <xsl:text> || true&#xA;</xsl:text>
140 <xsl:value-of select="substring-after(string(),'&#xA;')"/>
141 <xsl:text>&#xA;</xsl:text>
142 </xsl:otherwise>
143 </xsl:choose>
144 </xsl:when>
145 <xsl:when test="contains(string(),'test_summary') or
146 contains(string(),'expect -c')">
147 <xsl:choose>
148 <xsl:when test="$toolchaintest = '0'"/>
149 <xsl:otherwise>
150 <xsl:apply-templates/>
151 <xsl:text>&#xA;</xsl:text>
152 </xsl:otherwise>
153 </xsl:choose>
154 </xsl:when>
155 <!-- Don't stop on strip run -->
156 <xsl:when test="contains(string(),'strip ')">
157 <xsl:apply-templates/>
158 <xsl:text> || true&#xA;</xsl:text>
159 </xsl:when>
160 <!-- The rest of commands -->
161 <xsl:otherwise>
162 <xsl:apply-templates/>
163 <xsl:text>&#xA;</xsl:text>
164 </xsl:otherwise>
165 </xsl:choose>
166 </xsl:template>
167
168 <xsl:template match="replaceable">
169 <xsl:choose>
170 <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
171 <xsl:text>$TIMEZONE</xsl:text>
172 </xsl:when>
173 <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
174 <xsl:text>$PAGE</xsl:text>
175 </xsl:when>
176 <xsl:otherwise>
177 <xsl:text>**EDITME</xsl:text>
178 <xsl:apply-templates/>
179 <xsl:text>EDITME**</xsl:text>
180 </xsl:otherwise>
181 </xsl:choose>
182 </xsl:template>
183
184</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.