source: BLFS/xsl/gen-install.xsl@ c048987

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

BLFS: fix generation of install and test instructions (ticket #1721):

  • add a gen-install.xsl stylesheet for grouping all cases
  • add a mode="installation" attribute for templates
  • rewrite sect2 template so that the right templates are applied
  • adapt other templates so that they are compatible
  • rewording of some comments (no direct relation with the ticket)
  • Property mode set to 100644
File size: 9.0 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2
3<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 version="1.0">
5
6<!-- $Id$ -->
7
8
9 <xsl:template match="screen" mode="installation">
10<!-- "nature" variables:
11 - 'non-root': executable as user
12 - 'config': execute as root, with no special formatting
13 - 'install': execute as root, with PKG_DEST or escape instructions
14 - 'none': does not exist (for preceding of following uniquely)
15-->
16 <xsl:variable name="my-nature">
17 <xsl:choose>
18 <xsl:when test="not(@role)">
19 <xsl:text>non-root</xsl:text>
20 </xsl:when>
21 <xsl:when test="contains(string(),'useradd') or
22 contains(string(),'groupadd') or
23 contains(string(),'usermod') or
24 contains(string(),'icon-cache') or
25 contains(string(),'desktop-database') or
26 contains(string(),'compile-schemas') or
27 contains(string(),'query-loaders') or
28 contains(string(),'pam.d') or
29 contains(string(),'query-immodules')">
30 <xsl:text>config</xsl:text>
31 </xsl:when>
32 <xsl:otherwise>
33 <xsl:text>install</xsl:text>
34 </xsl:otherwise>
35 </xsl:choose>
36 </xsl:variable>
37
38 <xsl:variable
39 name="prec-string"
40 select="string(preceding-sibling::screen[not(@role='nodump') and
41 ./userinput][1])"/>
42<!--
43 <xsl:message>
44 <xsl:text>
45==============================
46List of preceding siblings for "</xsl:text>
47 <xsl:value-of select="./userinput"/>
48 <xsl:text>":
49</xsl:text>
50 <xsl:for-each select="preceding-sibling::screen[not(@role='nodump') and
51 ./userinput] |
52 preceding-sibling::para/command">
53 <xsl:copy-of select=".//text()"/>
54 <xsl:text>
55===
56</xsl:text>
57 </xsl:for-each>
58 </xsl:message>
59-->
60 <xsl:variable name="prec-nature">
61 <xsl:choose>
62 <xsl:when
63 test="$prec-string='' or
64 (preceding-sibling::screen[not(@role='nodump') and
65 ./userinput] |
66 preceding-sibling::para/command[contains(text(),'check') or
67 contains(text(),'test')]
68 )[last()][self::command]">
69 <xsl:text>none</xsl:text>
70 </xsl:when>
71 <xsl:when
72 test="preceding-sibling::screen
73 [not(@role='nodump') and ./userinput][1][not(@role)]">
74 <xsl:text>non-root</xsl:text>
75 </xsl:when>
76 <xsl:when test="contains($prec-string,'useradd') or
77 contains($prec-string,'groupadd') or
78 contains($prec-string,'usermod') or
79 contains($prec-string,'icon-cache') or
80 contains($prec-string,'desktop-database') or
81 contains($prec-string,'compile-schemas') or
82 contains($prec-string,'query-loaders') or
83 contains($prec-string,'pam.d') or
84 contains($prec-string,'query-immodules')">
85 <xsl:text>config</xsl:text>
86 </xsl:when>
87 <xsl:otherwise>
88 <xsl:text>install</xsl:text>
89 </xsl:otherwise>
90 </xsl:choose>
91 </xsl:variable>
92
93 <xsl:variable
94 name="follow-string"
95 select="string(following-sibling::screen[not(@role='nodump') and
96 ./userinput][1])"/>
97
98 <xsl:variable name="follow-nature">
99 <xsl:choose>
100 <xsl:when
101 test="$follow-string='' or
102 (following-sibling::screen[not(@role='nodump') and
103 ./userinput] |
104 following-sibling::para/command[contains(text(),'check') or
105 contains(text(),'test')]
106 )[1][self::command]">
107 <xsl:text>none</xsl:text>
108 </xsl:when>
109 <xsl:when
110 test="following-sibling::screen
111 [not(@role='nodump') and ./userinput][1][not(@role)]">
112 <xsl:text>non-root</xsl:text>
113 </xsl:when>
114 <xsl:when test="contains($follow-string,'useradd') or
115 contains($follow-string,'groupadd') or
116 contains($follow-string,'usermod') or
117 contains($follow-string,'icon-cache') or
118 contains($follow-string,'desktop-database') or
119 contains($follow-string,'compile-schemas') or
120 contains($follow-string,'query-loaders') or
121 contains($follow-string,'pam.d') or
122 contains($follow-string,'query-immodules')">
123 <xsl:text>config</xsl:text>
124 </xsl:when>
125 <xsl:otherwise>
126 <xsl:text>install</xsl:text>
127 </xsl:otherwise>
128 </xsl:choose>
129 </xsl:variable>
130
131 <xsl:choose>
132 <xsl:when test="$my-nature='non-root'">
133 <xsl:if test="$prec-nature='install'">
134 <xsl:call-template name="end-install"/>
135 <xsl:call-template name="end-root"/>
136 </xsl:if>
137 <xsl:if test="$prec-nature='config'">
138 <xsl:call-template name="end-root"/>
139 </xsl:if>
140 <xsl:apply-templates/>
141 <xsl:text>
142</xsl:text>
143 </xsl:when>
144
145 <xsl:when test="$my-nature='config'">
146 <xsl:if test="$prec-nature='none' or $prec-nature='non-root'">
147 <xsl:call-template name="begin-root"/>
148 </xsl:if>
149 <xsl:if test="$prec-nature='install'">
150 <xsl:call-template name="end-install"/>
151 </xsl:if>
152 <xsl:apply-templates mode="root"/>
153 <xsl:text>
154</xsl:text>
155 <xsl:if test="$follow-nature='none'">
156 <xsl:call-template name="end-root"/>
157 </xsl:if>
158 </xsl:when>
159
160 <xsl:when test="$my-nature='install'">
161 <xsl:if test="$prec-nature='none' or $prec-nature='non-root'">
162 <xsl:if test="contains($list-stat-norm,
163 concat(' ',ancestor::sect1/@id,' '))">
164 <xsl:call-template name="output-destdir"/>
165 </xsl:if>
166 <xsl:call-template name="begin-root"/>
167 <xsl:call-template name="begin-install"/>
168 </xsl:if>
169 <xsl:if test="$prec-nature='config'">
170 <xsl:if test="contains($list-stat-norm,
171 concat(' ',ancestor::sect1/@id,' '))">
172 <xsl:call-template name="end-root"/>
173 <xsl:call-template name="output-destdir"/>
174 <xsl:call-template name="begin-root"/>
175 </xsl:if>
176 <xsl:call-template name="begin-install"/>
177 </xsl:if>
178 <xsl:apply-templates mode="install"/>
179 <xsl:text>
180</xsl:text>
181 <xsl:if test="$follow-nature='none'">
182 <xsl:call-template name="end-install"/>
183 <xsl:call-template name="end-root"/>
184 </xsl:if>
185 </xsl:when>
186
187 </xsl:choose>
188 </xsl:template>
189
190 <xsl:template name="begin-root">
191 <xsl:if test="$sudo='y'">
192 <xsl:text>sudo -E sh &lt;&lt; ROOT_EOF
193</xsl:text>
194 </xsl:if>
195 </xsl:template>
196
197 <xsl:template name="begin-install">
198 <xsl:if test="$wrap-install = 'y'">
199 <xsl:text>if [ -r "$JH_PACK_INSTALL" ]; then
200 source $JH_PACK_INSTALL
201 export -f wrapInstall
202 export -f packInstall
203fi
204wrapInstall '
205</xsl:text>
206 </xsl:if>
207 </xsl:template>
208
209 <xsl:template name="end-root">
210 <xsl:if test="$sudo='y'">
211 <xsl:text>ROOT_EOF
212</xsl:text>
213 </xsl:if>
214 </xsl:template>
215
216 <xsl:template name="end-install">
217 <xsl:if test="$del-la-files = 'y'">
218 <xsl:call-template name="output-root">
219 <xsl:with-param name="out-string" select="$la-files-instr"/>
220 </xsl:call-template>
221 </xsl:if>
222 <xsl:if test="$wrap-install = 'y'">
223 <xsl:text>'&#xA;packInstall&#xA;</xsl:text>
224 </xsl:if>
225 </xsl:template>
226
227 <xsl:template match="text()" mode="install">
228 <xsl:call-template name="output-install">
229 <xsl:with-param name="out-string" select="."/>
230 </xsl:call-template>
231 </xsl:template>
232
233 <xsl:template name="output-install">
234 <xsl:param name="out-string" select="''"/>
235 <xsl:choose>
236 <xsl:when test="contains($out-string,string($APOS))
237 and $wrap-install = 'y'">
238 <xsl:call-template name="output-root">
239 <xsl:with-param
240 name="out-string"
241 select="substring-before($out-string,string($APOS))"/>
242 </xsl:call-template>
243 <xsl:text>'\''</xsl:text>
244 <xsl:call-template name="output-install">
245 <xsl:with-param name="out-string"
246 select="substring-after($out-string,string($APOS))"/>
247 </xsl:call-template>
248 </xsl:when>
249 <xsl:otherwise>
250 <xsl:call-template name="output-root">
251 <xsl:with-param name="out-string" select="."/>
252 </xsl:call-template>
253 </xsl:otherwise>
254 </xsl:choose>
255 </xsl:template>
256
257</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.