Index: LFS/lfs.xsl
===================================================================
--- LFS/lfs.xsl	(revision c0f82564804550ad6e3bd4d980ebd440bbf1eb87)
+++ LFS/lfs.xsl	(revision 097df005a8431d4dc799e72f6e1fb29435a5b200)
@@ -67,10 +67,77 @@
 
 
+    <!-- Hock for inserting scripts before a selected one -->
+  <xsl:template name="insert_script_before">
+      <!-- Inherited values -->
+    <xsl:param name="reference" select="foo"/>
+    <xsl:param name="order" select="foo"/>
+      <!-- Add a string to be sure that this scripts are run
+           before the selected one -->
+    <xsl:variable name="insert_order" select="concat($order,'_0')"/>
+      <!-- Add an xsl:if block for each referenced sect1 you want
+           to insert scripts before -->
+    <xsl:if test="$reference = 'ID_of_selected_sect1'">
+        <!-- Add an exsl:document block for each script to be inserted
+             at this point of the build. This one is only a dummy example.
+             You must replace "dummy" by the script name and increase "01" -->
+      <exsl:document href="{$insert_order}01-dummy" method="text">
+        <xsl:call-template name="header"/>
+        <xsl:text>
+PKG_PHASE=dummy
+PACKAGE=dummy
+VERSION=0.0.0
+TARBALL=dummy-0.0.0.tar.bz2
+
+cd $PKGDIR
+./configure --prefix=/usr
+make
+make check
+make install
+        </xsl:text>
+        <xsl:call-template name="footer"/>
+      </exsl:document>
+    </xsl:if>
+  </xsl:template>
+
+
+    <!-- Hock for inserting scripts after a selected one -->
+  <xsl:template name="insert_script_after">
+      <!-- Inherited values -->
+    <xsl:param name="reference" select="foo"/>
+    <xsl:param name="order" select="foo"/>
+      <!-- Add a string to be sure that this scripts are run
+           after the selected one -->
+    <xsl:variable name="insert_order" select="concat($order,'_z')"/>
+      <!-- Add an xsl:if block for each referenced sect1 you want
+           to insert scripts after -->
+    <xsl:if test="$reference = 'ID_of_selected_sect1'">
+        <!-- Add an exsl:document block for each script to be inserted
+             at this point of the build. This one is only a dummy example. -->
+      <exsl:document href="{$insert_order}01-dummy" method="text">
+        <xsl:call-template name="header"/>
+        <xsl:text>
+PKG_PHASE=dummy
+PACKAGE=dummy
+VERSION=0.0.0
+TARBALL=dummy-0.0.0.tar.bz2
+
+cd $PKGDIR
+./configure --prefix=/usr
+make
+make check
+make install
+        </xsl:text>
+        <xsl:call-template name="footer"/>
+      </exsl:document>
+    </xsl:if>
+  </xsl:template>
+
+
     <!-- Hock for creating a custom tools directory containing scripts
          to be run after the system has been built -->
   <xsl:template name="custom-tools">
-      <!-- Fixed value -->
+      <!-- Fixed directory and ch_order values -->
     <xsl:variable name="basedir">custom-tools/20_</xsl:variable>
-      <!-- Add an exsl:document block for each script to be created,
+      <!-- Add an exsl:document block for each script to be created.
            This one is only a dummy example. You must replace "01" by
            the proper build order and "dummy" by the script name -->
@@ -220,5 +287,5 @@
     <!-- Adds blfs-tool support scripts -->
   <xsl:template name="blfs-tool">
-      <!-- Fixed values -->
+      <!-- Fixed directory and ch_order values -->
     <xsl:variable name="basedir">blfs-tool-deps/30_</xsl:variable>
       <!-- One exsl:document block for each blfs-tool dependency
@@ -320,7 +387,12 @@
       </xsl:variable>
         <!-- Script build order -->
-      <xsl:variable name="order" select="concat($ch_order,'_',$sect1_order)"/>
+      <xsl:variable name="order" select="concat($dirname,'/',$ch_order,'_',$sect1_order)"/>
+        <!-- Hock to insert scripts before the current one -->
+      <xsl:call-template name="insert_script_before">
+        <xsl:with-param name="reference" select="@id"/>
+        <xsl:with-param name="order" select="$order"/>
+      </xsl:call-template>
         <!-- Creating dirs and files -->
-      <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
+      <exsl:document href="{$order}-{$filename}" method="text">
         <xsl:call-template name="header"/>
         <xsl:call-template name="user_header"/>
@@ -335,4 +407,9 @@
         <xsl:call-template name="footer"/>
       </exsl:document>
+        <!-- Hock to insert scripts after the current one -->
+      <xsl:call-template name="insert_script_after">
+        <xsl:with-param name="reference" select="@id"/>
+        <xsl:with-param name="order" select="$order"/>
+      </xsl:call-template>
     </xsl:if>
   </xsl:template>
