r3607 - jhalfs/branches/ablfs/BLFS/xsl

pierre at linuxfromscratch.org pierre at linuxfromscratch.org
Tue Mar 20 10:12:33 PDT 2012


Author: pierre
Date: 2012-03-20 11:12:26 -0600 (Tue, 20 Mar 2012)
New Revision: 3607

Modified:
   jhalfs/branches/ablfs/BLFS/xsl/scripts.xsl
Log:
Change script generation of root command: replace fragile construct
sudo sh -c '<commands>'
with slightly less fragile construct
sudo sh << ROOT_EOF
<commands with ` and \ escaped>
ROOT_EOF
Note: $ are not escaped, which is usually what is intended, but not always


Modified: jhalfs/branches/ablfs/BLFS/xsl/scripts.xsl
===================================================================
--- jhalfs/branches/ablfs/BLFS/xsl/scripts.xsl	2012-03-20 13:37:52 UTC (rev 3606)
+++ jhalfs/branches/ablfs/BLFS/xsl/scripts.xsl	2012-03-20 17:12:26 UTC (rev 3607)
@@ -436,11 +436,11 @@
       <xsl:choose>
         <xsl:when test="@role = 'root'">
           <xsl:if test="$sudo = 'y'">
-            <xsl:text>sudo sh -c '</xsl:text>
+            <xsl:text>sudo sh << ROOT_EOF&#xA;</xsl:text>
           </xsl:if>
           <xsl:apply-templates select="userinput" mode="root"/>
           <xsl:if test="$sudo = 'y'">
-            <xsl:text>'</xsl:text>
+            <xsl:text>&#xA;ROOT_EOF</xsl:text>
           </xsl:if>
         </xsl:when>
         <xsl:otherwise>
@@ -507,10 +507,10 @@
   <xsl:template match="userinput" mode="root">
     <xsl:for-each select="child::node()">
       <xsl:choose>
-        <xsl:when test="self::text() and contains(string(),'make')">
-          <xsl:value-of select="substring-before(string(),'make')"/>
-          <xsl:text>make -j1</xsl:text>
-          <xsl:value-of select="substring-after(string(),'make')"/>
+        <xsl:when test="self::text()">
+          <xsl:call-template name="output-root">
+            <xsl:with-param name="out-string" select="string()"/>
+          </xsl:call-template>
         </xsl:when>
         <xsl:otherwise>
           <xsl:apply-templates select="self::node()"/>
@@ -519,18 +519,52 @@
     </xsl:for-each>
   </xsl:template>
 
-  <xsl:template match="replaceable">
-<!-- Not needed anymore
+  <xsl:template name="output-root">
+    <xsl:param name="out-string" select="''"/>
     <xsl:choose>
-      <xsl:when test="ancestor::sect1[@id='xorg7-server']">
-        <xsl:text>$SRC_DIR/MesaLib</xsl:text>
+      <xsl:when test="contains($out-string,'make')">
+        <xsl:call-template name="output-root">
+          <xsl:with-param name="out-string"
+                          select="substring-before($out-string,'make')"/>
+        </xsl:call-template>
+        <xsl:text>make -j1</xsl:text>
+        <xsl:call-template name="output-root">
+          <xsl:with-param name="out-string"
+                          select="substring-after($out-string,'make')"/>
+        </xsl:call-template>
       </xsl:when>
-      <xsl:otherwise> -->
+      <xsl:when test="contains($out-string,'`')">
+        <xsl:call-template name="output-root">
+          <xsl:with-param name="out-string"
+                          select="substring-before($out-string,'`')"/>
+        </xsl:call-template>
+        <xsl:text>\`</xsl:text>
+        <xsl:call-template name="output-root">
+          <xsl:with-param name="out-string"
+                          select="substring-after($out-string,'`')"/>
+        </xsl:call-template>
+      </xsl:when>
+      <xsl:when test="contains($out-string,'\')">
+        <xsl:call-template name="output-root">
+          <xsl:with-param name="out-string"
+                          select="substring-before($out-string,'\')"/>
+        </xsl:call-template>
+        <xsl:text>\\</xsl:text>
+        <xsl:call-template name="output-root">
+          <xsl:with-param name="out-string"
+                          select="substring-after($out-string,'\')"/>
+        </xsl:call-template>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="$out-string"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
+  <xsl:template match="replaceable">
         <xsl:text>**EDITME</xsl:text>
         <xsl:apply-templates/>
         <xsl:text>EDITME**</xsl:text>
-<!--      </xsl:otherwise>
-    </xsl:choose> -->
   </xsl:template>
 
 </xsl:stylesheet>




More information about the alfs-log mailing list