source: dump-lfs-scripts.xsl@ 299b7e0

1.0 2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since 299b7e0 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
RevLine 
[557fe91]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
[63b2859]7<!-- XSLT stylesheet to create shell scripts from LFS books. -->
[557fe91]8
[01e51a1]9 <!-- Run optional test suites? -->
[db9cec6]10 <xsl:param name="testsuite" select="0"/>
11
[01e51a1]12 <!-- Run toolchain test suites? -->
13 <xsl:param name="toolchaintest" select="1"/>
14
[557fe91]15 <xsl:template match="/">
16 <xsl:apply-templates select="//sect1"/>
17 </xsl:template>
18
19 <xsl:template match="sect1">
[c4cf6de]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">
[76fad58]50 <xsl:choose>
51 <xsl:when test="@id='ch-system-changingowner' or
52 @id='ch-system-creatingdirs' or
53 @id='ch-system-createfiles'">
[fd691b4]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>
[76fad58]59 </xsl:when>
60 <xsl:otherwise>
[fd691b4]61 <xsl:text>#!/bin/sh&#xA;set -e&#xA;&#xA;</xsl:text>
[76fad58]62 </xsl:otherwise>
63 </xsl:choose>
[56dd1e2]64 <xsl:if test="sect2[@role='installation'] or
65 @id='ch-tools-adjusting' or
66 @id='ch-system-readjusting'">
[fd691b4]67 <xsl:text>cd $PKGDIR&#xA;</xsl:text>
[44f88e3]68 </xsl:if>
[db9cec6]69 <xsl:apply-templates select=".//para/userinput | .//screen"/>
[816f3f43]70 <xsl:text>exit</xsl:text>
[c4cf6de]71 </exsl:document>
72 </xsl:if>
[557fe91]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>
[db9cec6]80 <xsl:apply-templates select="userinput" mode="screen"/>
[557fe91]81 </xsl:otherwise>
82 </xsl:choose>
83 </xsl:if>
84 </xsl:template>
85
[db9cec6]86 <xsl:template match="para/userinput">
[56dd1e2]87 <xsl:if test="$testsuite != '0' and
88 (contains(string(),'test') or
89 contains(string(),'check'))">
[3eb60fa]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')"/>
[fd691b4]93 <xsl:text> || true&#xA;</xsl:text>
[db9cec6]94 </xsl:if>
95 </xsl:template>
96
97 <xsl:template match="userinput" mode="screen">
[3eb60fa]98 <xsl:choose>
[fd691b4]99 <!-- Estandarized package formats -->
[92568bf]100 <xsl:when test="contains(string(),'tar.gz')">
101 <xsl:value-of select="substring-before(string(),'tar.gz')"/>
[be9970b]102 <xsl:text>tar.*</xsl:text>
[92568bf]103 <xsl:value-of select="substring-after(string(),'tar.gz')"/>
[fd691b4]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>
[92568bf]117 </xsl:when>
[fd691b4]118 <!-- The Coreutils test suite is optional -->
[79f7cf9]119 <xsl:when test="$testsuite = '0' and
120 ancestor::sect1[@id='ch-system-coreutils'] and
121 (contains(string(),'check') or
122 contains(string(),'dummy'))"/>
[fd691b4]123 <!-- Fixing toolchain test suites run -->
[01e51a1]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>
[fd691b4]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;')"/>
[01e51a1]141 <xsl:text>&#xA;</xsl:text>
142 </xsl:otherwise>
143 </xsl:choose>
144 </xsl:when>
[fd691b4]145 <xsl:when test="contains(string(),'test_summary') or
[92568bf]146 contains(string(),'expect -c')">
[01e51a1]147 <xsl:choose>
148 <xsl:when test="$toolchaintest = '0'"/>
149 <xsl:otherwise>
150 <xsl:apply-templates/>
[fd691b4]151 <xsl:text>&#xA;</xsl:text>
[01e51a1]152 </xsl:otherwise>
153 </xsl:choose>
[3eb60fa]154 </xsl:when>
[fd691b4]155 <!-- Don't stop on strip run -->
156 <xsl:when test="contains(string(),'strip ')">
[3eb60fa]157 <xsl:apply-templates/>
[fd691b4]158 <xsl:text> || true&#xA;</xsl:text>
[1f025ca]159 </xsl:when>
[fd691b4]160 <!-- The rest of commands -->
[1f025ca]161 <xsl:otherwise>
162 <xsl:apply-templates/>
[fd691b4]163 <xsl:text>&#xA;</xsl:text>
[1f025ca]164 </xsl:otherwise>
165 </xsl:choose>
166 </xsl:template>
167
[557fe91]168 <xsl:template match="replaceable">
[a41ce58]169 <xsl:choose>
[2a54650]170 <xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
171 <xsl:text>$TIMEZONE</xsl:text>
172 </xsl:when>
[a41ce58]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>
[557fe91]182 </xsl:template>
183
184</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.