r3870 - in jhalfs/branches/new_features/BLFS: . xsl

pierre at higgs.linuxfromscratch.org pierre at higgs.linuxfromscratch.org
Wed Aug 24 08:15:14 PDT 2016


Author: pierre
Date: Wed Aug 24 08:15:14 2016
New Revision: 3870

Log:
BLFS porg style package management:
- update envarc.conf so that the system is made aware of the wrapInstall
and packInstall functions
- update scripts.xsl for wrapping install commands
- update gen_config.xsl to add the variable WRAP_INSTALL
- use the variable WRAP_INSTALL in gen_pkg_book
TODO: install the correct pack - wrap functions when installing BLFS tools

Modified:
   jhalfs/branches/new_features/BLFS/envars.conf
   jhalfs/branches/new_features/BLFS/gen_pkg_book.sh
   jhalfs/branches/new_features/BLFS/xsl/gen_config.xsl
   jhalfs/branches/new_features/BLFS/xsl/scripts.xsl

Modified: jhalfs/branches/new_features/BLFS/envars.conf
==============================================================================
--- jhalfs/branches/new_features/BLFS/envars.conf	Thu Jul 21 09:43:35 2016	(r3869)
+++ jhalfs/branches/new_features/BLFS/envars.conf	Wed Aug 24 08:15:14 2016	(r3870)
@@ -150,3 +150,16 @@
 # up to date
 
 if [ -r /etc/profile ]; then source /etc/profile; fi
+
+#======== Package management ========
+
+# We need the functions in "packInstall.sh" when installing a package,
+# if package management is requested. Note that we have no way to know
+# whether package management is requested for a given build.
+# Furthermore, "sudo -E" exports varaubales, but not functions from
+# the environment, and sudo needs to be called before porg, due
+# to porg limitations. So we just export the location of the file
+# where the functions are dfined, and we'll source it just before
+# installing.
+
+export PACK_INSTALL=${HOME}/blfs_root/packInstall.sh # change as needed

Modified: jhalfs/branches/new_features/BLFS/gen_pkg_book.sh
==============================================================================
--- jhalfs/branches/new_features/BLFS/gen_pkg_book.sh	Thu Jul 21 09:43:35 2016	(r3869)
+++ jhalfs/branches/new_features/BLFS/gen_pkg_book.sh	Wed Aug 24 08:15:14 2016	(r3870)
@@ -26,6 +26,7 @@
 declare -a TARGET
 declare DEP_LEVEL
 declare SUDO
+declare WRAP_INSTALL
 
 #--------------------------#
 parse_configuration() {    #
@@ -44,6 +45,7 @@
       # Create global variables for these parameters.
       optDependency=* | \
       MAIL_SERVER=*   | \
+      WRAP_INSTALL=*  | \
       SUDO=*  )  eval ${REPLY} # Define/set a global variable..
                       continue ;;
     esac
@@ -62,13 +64,14 @@
   TARGET=(${optTARGET[*]})
   DEP_LEVEL=$optDependency
   SUDO=${SUDO:-n}
+  WRAP_INSTALL=${WRAP_INSTALL:-n}
 }
 
 #--------------------------#
 validate_configuration() { #
 #--------------------------#
   local -r dotSTR=".................."
-  local -r PARAM_LIST="DEP_LEVEL SUDO MAIL_SERVER"
+  local -r PARAM_LIST="DEP_LEVEL SUDO MAIL_SERVER WRAP_INSTALL"
   local -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
   local config_param
   local -i index
@@ -179,6 +182,7 @@
 rm -rf scripts
 xsltproc --xinclude --nonet \
          --stringparam sudo $SUDO \
+         --stringparam wrap-install $WRAP_INSTALL \
          -o ./scripts/ ${MakeScripts} \
          ${BookXml}
 # Make the scripts executable.

Modified: jhalfs/branches/new_features/BLFS/xsl/gen_config.xsl
==============================================================================
--- jhalfs/branches/new_features/BLFS/xsl/gen_config.xsl	Thu Jul 21 09:43:35 2016	(r3869)
+++ jhalfs/branches/new_features/BLFS/xsl/gen_config.xsl	Wed Aug 24 08:15:14 2016	(r3870)
@@ -58,6 +58,16 @@
         help
                 Select if sudo will be used (you build as a normal user)
                         otherwise sudo is not needed (you build as root)
+
+
+config  WRAP_INSTALL
+        bool "Use `porg style' package management"
+        default n
+        help
+                Select if you want the installation commands to be wrapped
+		between "wrapInstall '" and "' ; packInstall" functions,
+		where wrapInstall is used to set up a LD_PRELOAD library (for
+		example using porg), and packInstall makes the package tarball
 </xsl:text>
   </xsl:template>
 

Modified: jhalfs/branches/new_features/BLFS/xsl/scripts.xsl
==============================================================================
--- jhalfs/branches/new_features/BLFS/xsl/scripts.xsl	Thu Jul 21 09:43:35 2016	(r3869)
+++ jhalfs/branches/new_features/BLFS/xsl/scripts.xsl	Wed Aug 24 08:15:14 2016	(r3870)
@@ -9,6 +9,10 @@
 
 <!-- XSLT stylesheet to create shell scripts from "linear build" BLFS books. -->
 
+  <!-- Wrap "root" commands inside a wrapper function, allowing
+       "porg style" package management -->
+  <xsl:param name="wrap-install" select="'n'"/>
+
   <!-- Build as user (y) or as root (n)? -->
   <xsl:param name="sudo" select="'y'"/>
 
@@ -57,8 +61,10 @@
         <xsl:choose>
           <!-- Package page -->
           <xsl:when test="sect2[@role='package']">
-            <!-- We build in a subdirectory -->
-            <xsl:text>PKG_DIR=</xsl:text>
+            <!-- We build in a subdirectory, whose name may be needed
+                 if using package management (see envars.conf), so
+                 "export" it -->
+            <xsl:text>export PKG_DIR=</xsl:text>
             <xsl:value-of select="$filename"/>
             <xsl:text>&#xA;</xsl:text>
             <!-- Download code and build commands -->
@@ -124,6 +130,7 @@
      cp $PACKAGE $UNPACKDIR
      ;;
 esac
+export UNPACKDIR
 cd $UNPACKDIR&#xA;
 </xsl:text>
         <xsl:apply-templates select=".//screen | .//para/command"/>
@@ -380,12 +387,30 @@
     <xsl:if test="child::* = userinput and not(@role = 'nodump')">
       <xsl:choose>
         <xsl:when test="@role = 'root'">
-          <xsl:if test="$sudo = 'y'">
-            <xsl:text>sudo -E sh << ROOT_EOF&#xA;</xsl:text>
+          <xsl:if test="not(preceding-sibling::screen[@role='root'])">
+            <xsl:if test="$sudo = 'y'">
+              <xsl:text>sudo -E sh << ROOT_EOF&#xA;</xsl:text>
+            </xsl:if>
+            <xsl:if test="$wrap-install = 'y' and
+                          ancestor::sect2[@role='installation']">
+              <xsl:text>if [ -r "$PACK_INSTALL" ]; then
+  source $PACK_INSTALL
+  export -f wrapInstall
+  export -f packInstall
+fi
+wrapInstall '
+</xsl:text>
+            </xsl:if>
           </xsl:if>
           <xsl:apply-templates mode="root"/>
-          <xsl:if test="$sudo = 'y'">
-            <xsl:text>&#xA;ROOT_EOF</xsl:text>
+          <xsl:if test="not(following-sibling::screen[@role='root'])">
+            <xsl:if test="$wrap-install = 'y' and
+                          ancestor::sect2[@role='installation']">
+              <xsl:text>'&#xA;packInstall</xsl:text>
+            </xsl:if>
+            <xsl:if test="$sudo = 'y'">
+              <xsl:text>&#xA;ROOT_EOF</xsl:text>
+            </xsl:if>
           </xsl:if>
         </xsl:when>
         <xsl:otherwise>
@@ -462,6 +487,8 @@
     </xsl:call-template>
   </xsl:template>
 
+  <xsl:variable name="APOS">'</xsl:variable>
+
   <xsl:template name="output-root">
     <xsl:param name="out-string" select="''"/>
     <xsl:choose>
@@ -509,6 +536,18 @@
                           select="substring-after($out-string,'\')"/>
         </xsl:call-template>
       </xsl:when>
+      <xsl:when test="contains($out-string,string($APOS))
+                      and $wrap-install = 'y'">
+        <xsl:call-template name="output-root">
+          <xsl:with-param name="out-string"
+                          select="substring-before($out-string,string($APOS))"/>
+        </xsl:call-template>
+        <xsl:text>'\''</xsl:text>
+        <xsl:call-template name="output-root">
+          <xsl:with-param name="out-string"
+                          select="substring-after($out-string,string($APOS))"/>
+        </xsl:call-template>
+      </xsl:when>
       <xsl:otherwise>
         <xsl:value-of select="$out-string"/>
       </xsl:otherwise>


More information about the alfs-log mailing list