source: CLFS2/clfs2.xsl@ 5e1d9dd

ablfs-more legacy trunk
Last change on this file since 5e1d9dd was fd4a798, checked in by Pierre Labastie <pierre.labastie@…>, 3 years ago

Remove $Id$ comments, they are useless with git

  • Property mode set to 100644
File size: 5.8 KB
Line 
1<?xml version="1.0"?>
2<!DOCTYPE xsl:stylesheet [
3 <!ENTITY % general-entities SYSTEM "FAKEDIR/general.ent">
4 %general-entities;
5]>
6
7<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
8 xmlns:exsl="http://exslt.org/common"
9 extension-element-prefixes="exsl"
10 version="1.0">
11
12<!-- XSLT stylesheet to create shell scripts from CLFS2 books. -->
13
14 <!-- Time zone -->
15 <xsl:param name="timezone" select="GMT"/>
16
17 <!-- Page size -->
18 <xsl:param name="page" select="letter"/>
19
20 <!-- Locale settings -->
21 <xsl:param name="lang" select="C"/>
22
23 <xsl:template match="/">
24 <xsl:apply-templates select="//sect1"/>
25 </xsl:template>
26
27 <xsl:template match="sect1">
28 <xsl:choose>
29 <xsl:when test="../@id='chapter-partitioning' or
30 ../@id='chapter-getting-materials' or
31 ../@id='chapter-final-preps'"/>
32 <xsl:otherwise>
33 <xsl:if test="count(descendant::screen/userinput) &gt; 0 and
34 count(descendant::screen/userinput) &gt;
35 count(descendant::screen[@role='nodump'])">
36 <!-- The dirs names -->
37 <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
38 <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
39 <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
40 <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
41 <!-- The file names -->
42 <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
43 <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
44 <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
45 <!-- The build order -->
46 <xsl:variable name="position" select="position()"/>
47 <xsl:variable name="order">
48 <xsl:choose>
49 <xsl:when test="string-length($position) = 1">
50 <xsl:text>00</xsl:text>
51 <xsl:value-of select="$position"/>
52 </xsl:when>
53 <xsl:when test="string-length($position) = 2">
54 <xsl:text>0</xsl:text>
55 <xsl:value-of select="$position"/>
56 </xsl:when>
57 <xsl:otherwise>
58 <xsl:value-of select="$position"/>
59 </xsl:otherwise>
60 </xsl:choose>
61 </xsl:variable>
62 <!-- Creating dirs and files -->
63 <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
64 <xsl:text>#!/bin/bash&#xA;set +h&#xA;</xsl:text>
65 <xsl:if test="not(@id='ch-system-stripping')">
66 <xsl:text>set -e&#xA;</xsl:text>
67 </xsl:if>
68 <xsl:text>&#xA;</xsl:text>
69 <xsl:if test="sect2[@role='installation'] and
70 not(@id='ch-cross-tools-sysroot-wrapper')">
71 <xsl:text>cd $PKGDIR&#xA;</xsl:text>
72 </xsl:if>
73 <xsl:apply-templates select=".//para/userinput | .//screen"/>
74 <xsl:text>exit</xsl:text>
75 </exsl:document>
76 </xsl:if>
77 </xsl:otherwise>
78 </xsl:choose>
79 </xsl:template>
80
81 <xsl:template match="screen">
82 <xsl:if test="child::* = userinput and not(@role = 'nodump')">
83 <xsl:apply-templates select="userinput" mode="screen"/>
84 </xsl:if>
85 </xsl:template>
86
87 <xsl:template match="para/userinput"/>
88
89 <xsl:template match="userinput" mode="screen">
90 <xsl:choose>
91 <!-- Estandarized package formats -->
92 <xsl:when test="contains(string(),'tar.gz')">
93 <xsl:value-of select="substring-before(string(),'tar.gz')"/>
94 <xsl:text>tar.*</xsl:text>
95 <xsl:value-of select="substring-after(string(),'tar.gz')"/>
96 <xsl:text>&#xA;</xsl:text>
97 </xsl:when>
98 <!-- Setting $LANG for /etc/profile -->
99 <xsl:when test="ancestor::sect1[@id='ch-scripts-profile'] and
100 contains(string(),'export LANG=')">
101 <xsl:value-of select="substring-before(string(),'export LANG=')"/>
102 <xsl:text>export LANG=</xsl:text>
103 <xsl:value-of select="$lang"/>
104 <xsl:value-of select="substring-after(string(),'charmap]')"/>
105 <xsl:text>&#xA;</xsl:text>
106 </xsl:when>
107 <!-- Compile the keymap into the kernel has been disabled -->
108 <xsl:when test="contains(string(),'defkeymap')"/>
109 <!-- Copying the kernel config file -->
110 <xsl:when test="string() = 'make mrproper'">
111 <xsl:text>make mrproper&#xA;</xsl:text>
112 <xsl:text>cp -v ../kernel-config .config&#xA;</xsl:text>
113 </xsl:when>
114 <!-- No interactive commands are needed if the .config file is the proper one -->
115 <xsl:when test="contains(string(),'menuconfig')"/>
116 <!-- Don't stop on strip run -->
117 <xsl:when test="contains(string(),'strip ')">
118 <xsl:apply-templates/>
119 <xsl:text> || true&#xA;</xsl:text>
120 </xsl:when>
121 <!-- The rest of commands -->
122 <xsl:otherwise>
123 <xsl:apply-templates/>
124 <xsl:text>&#xA;</xsl:text>
125 </xsl:otherwise>
126 </xsl:choose>
127 </xsl:template>
128
129 <xsl:template match="replaceable">
130 <xsl:choose>
131 <xsl:when test="ancestor::sect1[@id='ch-cross-tools-glibc']">
132 <xsl:value-of select="$timezone"/>
133 </xsl:when>
134 <xsl:when test="ancestor::sect1[@id='ch-cross-tools-eglibc']">
135 <xsl:value-of select="$timezone"/>
136 </xsl:when>
137 <xsl:when test="ancestor::sect1[@id='ch-cross-tools-groff'] or
138 ancestor::sect1[@id='ch-system-groff']">
139 <xsl:value-of select="$page"/>
140 </xsl:when>
141 <xsl:otherwise>
142 <xsl:text>**EDITME</xsl:text>
143 <xsl:apply-templates/>
144 <xsl:text>EDITME**</xsl:text>
145 </xsl:otherwise>
146 </xsl:choose>
147 </xsl:template>
148
149</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.