source: common/chroot.xsl@ 7a82194

ablfs-more legacy trunk
Last change on this file since 7a82194 was b86dfaf, checked in by Pierre Labastie <pierre@…>, 7 years ago

Fix generation of chroot instructions

  • Property mode set to 100644
File size: 3.3 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2
3<!-- $Id$ -->
4
5<xsl:stylesheet
6 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
7 xmlns:exsl="http://exslt.org/common"
8 extension-element-prefixes="exsl"
9 version="1.0">
10
11 <xsl:template match="/">
12 <xsl:apply-templates select="//sect1"/>
13 </xsl:template>
14
15 <xsl:template match="sect1">
16 <xsl:if
17 test="descendant::screen/userinput[contains(string(),'&#xA;chroot') or
18 starts-with(string(),'chroot')]">
19 <!-- The file names -->
20 <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
21 <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
22 <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
23 <!-- The build order -->
24 <xsl:variable name="position" select="position()"/>
25 <xsl:variable name="order">
26 <xsl:choose>
27 <xsl:when test="string-length($position) = 1">
28 <xsl:text>00</xsl:text>
29 <xsl:value-of select="$position"/>
30 </xsl:when>
31 <xsl:when test="string-length($position) = 2">
32 <xsl:text>0</xsl:text>
33 <xsl:value-of select="$position"/>
34 </xsl:when>
35 <xsl:otherwise>
36 <xsl:value-of select="$position"/>
37 </xsl:otherwise>
38 </xsl:choose>
39 </xsl:variable>
40 <!-- Creating dirs and files -->
41 <exsl:document href="{$order}-{$filename}" method="text">
42 <xsl:text>#!/bin/bash&#xA;</xsl:text>
43 <xsl:apply-templates
44 select=".//userinput[contains(string(),'&#xA;chroot') or
45 starts-with(string(),'chroot')]"/>
46 <xsl:text>exit&#xA;</xsl:text>
47 </exsl:document>
48 </xsl:if>
49 </xsl:template>
50
51 <xsl:template match="userinput">
52 <xsl:call-template name="extract-chroot">
53 <xsl:with-param name="instructions" select="string()"/>
54 </xsl:call-template>
55 </xsl:template>
56
57 <xsl:template name="extract-chroot">
58 <xsl:param name="instructions" select="''"/>
59 <xsl:choose>
60 <xsl:when test="not(starts-with($instructions,'&#xA;chroot')) and
61 contains($instructions, '&#xA;chroot')">
62 <xsl:call-template name="extract-chroot">
63 <xsl:with-param name="instructions"
64 select="substring(substring-after($instructions,
65 substring-before($instructions,
66 '&#xA;chroot')),2)"/>
67 </xsl:call-template>
68 </xsl:when>
69 <xsl:when test="contains($instructions,'\&#xA;')">
70 <xsl:copy-of select="substring-before($instructions,'\&#xA;')"/>
71 <xsl:text>\
72</xsl:text>
73 <xsl:call-template name="extract-chroot">
74 <xsl:with-param name="instructions"
75 select="substring-after($instructions,'\&#xA;')"/>
76 </xsl:call-template>
77 </xsl:when>
78 <xsl:when test="contains($instructions,'&#xA;')">
79 <xsl:copy-of select="substring-before($instructions,'&#xA;')"/>
80 <xsl:text>
81</xsl:text>
82 </xsl:when>
83 <xsl:otherwise>
84 <xsl:copy-of select="$instructions"/>
85 <xsl:text>
86</xsl:text>
87 </xsl:otherwise>
88 </xsl:choose>
89 </xsl:template>
90</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.