Index: LFS/lfs.xsl
===================================================================
--- LFS/lfs.xsl	(revision 33ff403b334717c6e29e5c239fe5a6b166fe5805)
+++ LFS/lfs.xsl	(revision df42c7cff73442e4051dbb71541c51a3e7a7d330)
@@ -15,5 +15,12 @@
        y = yes, add PKG_DEST to scripts in install commands of chapter06-08
   -->
-  <xsl:param name="pkgmngt" select="n"/>
+  <xsl:param name="pkgmngt" select="'n'"/>
+
+  <!-- Package management with "porg style" ?
+       n = no,  same as pkgmngt description above
+       y = yes, wrap install commands of chapter06-08 into a bash function.
+                note that pkgmngt must be 'y' in this case
+  -->
+  <xsl:param name="wrap-install" select='"n"'/>
  
   <!-- Run test suites?
@@ -29,20 +36,20 @@
        y = yes, bomb at the first test suite failure to can review the build dir
   -->
-  <xsl:param name="bomb-testsuite" select="n"/>
+  <xsl:param name="bomb-testsuite" select="'n'"/>
 
   <!-- Install vim-lang package? OBSOLETE should always be 'n'-->
-  <xsl:param name="vim-lang" select="n"/>
+  <xsl:param name="vim-lang" select="'n'"/>
   
   <!-- Time zone -->
-  <xsl:param name="timezone" select="GMT"/>
+  <xsl:param name="timezone" select="'GMT'"/>
   
   <!-- Page size -->
-  <xsl:param name="page" select="letter"/>
+  <xsl:param name="page" select="'letter'"/>
   
   <!-- Locale settings -->
-  <xsl:param name="lang" select="C"/>
+  <xsl:param name="lang" select="'C'"/>
 
   <!-- Install the whole set of locales -->
-  <xsl:param name='full-locale' select='n'/>
+  <xsl:param name='full-locale' select='"n"'/>
   
   <!-- Hostname -->
@@ -51,5 +58,5 @@
   <!-- Network parameters: interface, ip, gateway, prefix, broadcast, domain
        and nameservers -->
-  <xsl:param name='interface'   select='eth0'/>
+  <xsl:param name='interface'   select="'eth0'"/>
   <xsl:param name='ip'          select='"10.0.2.9"'/>
   <xsl:param name='gateway'     select='"10.0.2.2"'/>
@@ -181,5 +188,11 @@
                                   @role != 'nodump']/userinput[
                                                     @remap='install']">
-      <xsl:text>mkdir -pv $PKG_DEST/{boot,etc,lib,bin,sbin}
+      <xsl:choose>
+        <xsl:when test="$wrap-install='y'">
+          <xsl:text>wrapInstall '
+</xsl:text>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:text>mkdir -pv $PKG_DEST/{boot,etc,lib,bin,sbin}
 mkdir -pv $PKG_DEST/usr/{lib,bin,sbin,include}
 mkdir -pv $PKG_DEST/usr/share/{doc,info,man}
@@ -190,8 +203,11 @@
 esac
 </xsl:text>
+        </xsl:otherwise>
+      </xsl:choose>
     </xsl:if>
     <xsl:if test="../@id = 'ch-system-glibc' and
                   @role='installation' and
-                  $pkgmngt = 'y'">
+                  $pkgmngt = 'y' and
+                  $wrap-install = 'n'">
       <xsl:text>mkdir -pv $PKG_DEST/usr/include/{rpc,rpcsvc}
 </xsl:text>
@@ -205,25 +221,52 @@
                                      @role != 'nodump']/userinput[
                                                        @remap='install']">
-      <xsl:if test="../@id = 'ch-system-man-pages'">
+      <xsl:choose>
+        <xsl:when test="$wrap-install='y'">
+          <xsl:if test="../@id = 'ch-system-man-pages'">
 <!-- these files are provided by the shadow package -->
-  <xsl:text>rm -fv $PKG_DEST/usr/share/man/{man3/getspnam.3,man5/passwd.5}
-</xsl:text>
-      </xsl:if>
+            <xsl:text>rm -fv /usr/share/man/{man3/getspnam.3,man5/passwd.5}
+</xsl:text>
+          </xsl:if>
 <!-- Attr man/man2 pages are already installed by man-pages. As of
      March 2013, they are the same pages.
      November 2015: now they are more accurate
      in man-pages, and the man5 section is also in man-pages... -->
-      <xsl:if test="../@id = 'ch-system-attr'">
-        <xsl:text>rm -fv $PKG_DEST/usr/share/man/man2/*
+          <xsl:if test="../@id = 'ch-system-attr'">
+            <xsl:text>rm -fv /usr/share/man/man2/*
+rm -fv /usr/share/man/man5/*
+</xsl:text>
+          </xsl:if>
+<!-- nologin is installed by util-linux. remove it from shadow -->
+          <xsl:if test="../@id = 'ch-system-shadow'">
+            <xsl:text>rm -fv /usr/share/man/man8/nologin.8
+rm -fv /sbin/nologin
+</xsl:text>
+          </xsl:if>
+          <xsl:text>'
+packInstall
+</xsl:text>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:if test="../@id = 'ch-system-man-pages'">
+<!-- these files are provided by the shadow package -->
+            <xsl:text>rm -fv $PKG_DEST/usr/share/man/{man3/getspnam.3,man5/passwd.5}
+</xsl:text>
+          </xsl:if>
+<!-- Attr man/man2 pages are already installed by man-pages. As of
+     March 2013, they are the same pages.
+     November 2015: now they are more accurate
+     in man-pages, and the man5 section is also in man-pages... -->
+          <xsl:if test="../@id = 'ch-system-attr'">
+            <xsl:text>rm -fv $PKG_DEST/usr/share/man/man2/*
 rm -fv $PKG_DEST/usr/share/man/man5/*
 </xsl:text>
-      </xsl:if>
+          </xsl:if>
 <!-- nologin is installed by util-linux. remove it from shadow -->
-      <xsl:if test="../@id = 'ch-system-shadow'">
-        <xsl:text>rm -fv $PKG_DEST/usr/share/man/man8/nologin.8
+          <xsl:if test="../@id = 'ch-system-shadow'">
+            <xsl:text>rm -fv $PKG_DEST/usr/share/man/man8/nologin.8
 rm -fv $PKG_DEST/sbin/nologin
 </xsl:text>
-      </xsl:if>
-      <xsl:text>rm -fv $PKG_DEST/{,usr/}lib64
+          </xsl:if>
+          <xsl:text>rm -fv $PKG_DEST/{,usr/}lib64
 rm -fv $PKG_DEST/usr/{man,doc,info}
 for dir in $PKG_DEST/usr/share/man/man{1..8}; do
@@ -242,4 +285,6 @@
 rm -rf $PKG_DEST
 </xsl:text>
+        </xsl:otherwise>
+      </xsl:choose>
     </xsl:if>
     <xsl:if test="$testsuite='3' and
@@ -310,5 +355,5 @@
         <xsl:if test="$dirname = 'chapter06'">
           <xsl:text>packInstall
-rm -rf $PKG_DEST
+rm -rf "$PKG_DEST"
 </xsl:text>
         </xsl:if>
@@ -453,5 +498,24 @@
             </xsl:choose>
           </xsl:when>
-          <xsl:otherwise><!--pkgmngt = 'y'-->
+          <xsl:when test="$wrap-install='y'">
+            <xsl:choose>
+              <xsl:when test="./literal">
+                <xsl:call-template name="output-wrap">
+                  <xsl:with-param name="commands" select="text()[1]"/>
+                </xsl:call-template>
+                <xsl:apply-templates select="literal"/>
+                <xsl:call-template name="output-wrap">
+                  <xsl:with-param name="commands" select="text()[2]"/>
+                </xsl:call-template>
+              </xsl:when>
+              <xsl:otherwise>
+                <xsl:call-template name="output-wrap">
+                  <xsl:with-param name="commands" select="string()"/>
+                </xsl:call-template>
+              </xsl:otherwise>
+            </xsl:choose>
+            <xsl:text>&#xA;</xsl:text>
+          </xsl:when>
+          <xsl:otherwise><!--pkgmngt = 'y' and wrap-install='n'-->
             <xsl:choose>
               <xsl:when test="./literal">
@@ -477,5 +541,5 @@
       <xsl:when test="contains(string(),'tzdata') and $pkgmngt='y'">
         <xsl:text>
-OLD_PKG_DEST=$PKG_DEST
+OLD_PKG_DEST="$PKG_DEST"
 OLD_PKGDIR=$PKGDIR
 PKG_DEST=$(dirname $OLD_PKG_DEST)/001-tzdata
@@ -486,10 +550,26 @@
         <xsl:text>
 </xsl:text>
-        <xsl:copy-of select="substring-before(string(),'ZONEINFO=')"/>
-        <xsl:text>ZONEINFO=$PKG_DEST</xsl:text>
-        <xsl:copy-of select="substring-after(string(),'ZONEINFO=')"/>
-        <xsl:text>
+        <xsl:choose>
+          <xsl:when test="$wrap-install='n'">
+            <xsl:copy-of select="substring-before(string(),'ZONEINFO=')"/>
+            <xsl:text>ZONEINFO=$PKG_DEST</xsl:text>
+            <xsl:copy-of select="substring-after(string(),'ZONEINFO=')"/>
+            <xsl:text>
 packInstall
 rm -rf $PKG_DEST
+</xsl:text>
+          </xsl:when>
+          <xsl:otherwise><!-- wrap-install='y' -->
+            <xsl:copy-of select="substring-before(string(),'ZONEINFO=')"/>
+            <xsl:text>
+wrapInstall '
+ZONEINFO=</xsl:text>
+            <xsl:copy-of select="substring-after(string(),'ZONEINFO=')"/>
+            <xsl:text>'
+packInstall
+</xsl:text>
+          </xsl:otherwise>
+        </xsl:choose>
+        <xsl:text>
 PKG_DEST=$OLD_PKG_DEST
 unset OLD_PKG_DEST
@@ -733,3 +813,25 @@
     </xsl:choose>
   </xsl:template>
+
+  <xsl:variable name="APOS">'</xsl:variable>
+  <xsl:template name="output-wrap">
+    <xsl:param name="commands" select="''"/>
+    <xsl:choose>
+      <xsl:when test="contains($commands,string($APOS))">
+        <xsl:call-template name="output-wrap">
+          <xsl:with-param name="commands"
+                          select="substring-before($commands,string($APOS))"/>
+        </xsl:call-template>
+        <xsl:text>'\''</xsl:text>
+        <xsl:call-template name="output-wrap">
+          <xsl:with-param name="commands"
+                          select="substring-after($commands,string($APOS))"/>
+        </xsl:call-template>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="$commands"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
 </xsl:stylesheet>
