[alfs-log] r4064 - in jhalfs/trunk: BLFS BLFS/xsl common/libs

pierre at higgs.linuxfromscratch.org pierre at higgs.linuxfromscratch.org
Fri Sep 28 07:35:46 PDT 2018


Author: pierre
Date: Fri Sep 28 07:35:46 2018
New Revision: 4064

Log:
Add possibility to automate bash shell startup files, vimrc, and rng.
This adds a new variable to the configuration (LANGUAGE).
Also automate the generation of various <replaceable> instructions

Modified:
   jhalfs/trunk/BLFS/gen-special.sh
   jhalfs/trunk/BLFS/gen_pkg_book.sh
   jhalfs/trunk/BLFS/xsl/gen_config.xsl
   jhalfs/trunk/BLFS/xsl/scripts.xsl
   jhalfs/trunk/common/libs/func_install_blfs

Modified: jhalfs/trunk/BLFS/gen-special.sh
==============================================================================
--- jhalfs/trunk/BLFS/gen-special.sh	Tue Sep  4 03:06:09 2018	(r4063)
+++ jhalfs/trunk/BLFS/gen-special.sh	Fri Sep 28 07:35:46 2018	(r4064)
@@ -38,8 +38,9 @@
              sed 's@^[^"]*"\([^"]*\)".*@\1@')
 
 # Non-versioned packages:
-NV_LIST="cacerts xorg-env kde-pre-install-config kf5-intro lxqt-pre-install \
-lxqt-post-install ojdk-conf tex-path"
+NV_LIST="postlfs-config-profile postlfs-config-random postlfs-config-vimrc \
+xorg-env kde-pre-install-config kf5-intro \
+lxqt-pre-install lxqt-post-install ojdk-conf tex-path"
 
 # Set PATH to be sure to find udevadm
 SAVPATH=$PATH

Modified: jhalfs/trunk/BLFS/gen_pkg_book.sh
==============================================================================
--- jhalfs/trunk/BLFS/gen_pkg_book.sh	Tue Sep  4 03:06:09 2018	(r4063)
+++ jhalfs/trunk/BLFS/gen_pkg_book.sh	Fri Sep 28 07:35:46 2018	(r4064)
@@ -30,7 +30,10 @@
 declare -a TARGET
 declare DEP_LEVEL
 declare SUDO
+declare LANGUAGE
 declare WRAP_INSTALL
+declare DEL_LA_FILES
+declare STATS
 
 #--------------------------#
 parse_configuration() {    #
@@ -52,6 +55,7 @@
       WRAP_INSTALL=*  | \
       DEL_LA_FILES=*  | \
       STATS=*         | \
+      LANGUAGE=*      | \
       SUDO=*  )  eval ${REPLY} # Define/set a global variable..
                       continue ;;
     esac
@@ -79,7 +83,7 @@
 validate_configuration() { #
 #--------------------------#
   local -r dotSTR=".................."
-  local -r PARAM_LIST="DEP_LEVEL SUDO MAIL_SERVER WRAP_INSTALL DEL_LA_FILES STATS"
+  local -r PARAM_LIST="DEP_LEVEL SUDO LANGUAGE MAIL_SERVER WRAP_INSTALL DEL_LA_FILES STATS"
   local -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
   local config_param
   local -i index
@@ -211,6 +215,7 @@
          --stringparam wrap-install "$WRAP_INSTALL" \
          --stringparam del-la-files "$DEL_LA_FILES" \
          --stringparam list-stat "$LIST_STAT" \
+         --stringparam language "$LANGUAGE" \
          -o ./scripts/ ${MakeScripts} \
          ${BookXml}
 # Make the scripts executable.

Modified: jhalfs/trunk/BLFS/xsl/gen_config.xsl
==============================================================================
--- jhalfs/trunk/BLFS/xsl/gen_config.xsl	Tue Sep  4 03:06:09 2018	(r4063)
+++ jhalfs/trunk/BLFS/xsl/gen_config.xsl	Fri Sep 28 07:35:46 2018	(r4064)
@@ -55,6 +55,12 @@
         default 3       if DEPLVL_3
         default 4       if DEPLVL_4
 
+config  LANGUAGE
+        string "LANG variable in the form ll_CC.charmap[@modifiers]"
+        default "en_US.UTF-8"
+        help
+            Because of the book layout, the 3 fields, ll, CC and charmap are
+            mandatory. The @modfier is honoured if present.
 
 config  SUDO
         bool "Build as User"

Modified: jhalfs/trunk/BLFS/xsl/scripts.xsl
==============================================================================
--- jhalfs/trunk/BLFS/xsl/scripts.xsl	Tue Sep  4 03:06:09 2018	(r4063)
+++ jhalfs/trunk/BLFS/xsl/scripts.xsl	Fri Sep 28 07:35:46 2018	(r4064)
@@ -34,6 +34,41 @@
   <!-- Build as user (y) or as root (n)? -->
   <xsl:param name="sudo" select="'y'"/>
 
+  <!-- Localization in the form ll_CC.charmap at modifier (to be used in
+       bash shell startup scripts). ll, CC, and charmap must be present:
+       no way to use "C" or "POSIX". -->
+  <xsl:param name="language" select="'en_US.UTF-8'"/>
+
+  <!-- Break it in pieces -->
+  <xsl:variable name="lang-ll">
+    <xsl:copy-of select="substring-before($language,'_')"/>
+  </xsl:variable>
+  <xsl:variable name="lang-CC">
+     <xsl:copy-of
+            select="substring-before(substring-after($language,'_'),'.')"/>
+  </xsl:variable>
+  <xsl:variable name="lang-charmap">
+    <xsl:choose>
+      <xsl:when test="contains($language,'@')">
+         <xsl:copy-of
+               select="substring-before(substring-after($language,'.'),'@')"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:copy-of select="substring-after($language,'.')"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="lang-modifier">
+    <xsl:choose>
+      <xsl:when test="contains($language,'@')">
+         <xsl:copy-of select="concat('@',substring-after($language,'@'))"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:copy-of select="''"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
 <!-- simple instructions for removing .la files. -->
   <xsl:variable name="la-files-instr">
 
@@ -133,12 +168,12 @@
           </xsl:when>
           <!-- Non-package page -->
           <xsl:otherwise>
-            <xsl:apply-templates select=".//screen"/>
+            <xsl:apply-templates select=".//screen" mode="not-pack"/>
           </xsl:otherwise>
         </xsl:choose>
         <xsl:text>exit</xsl:text>
       </exsl:document>
-    </xsl:if>
+    </xsl:if><!-- id!=bootscript or id!=systemd-units -->
   </xsl:template>
 
 <!--======================= Sub-sections code =======================-->
@@ -153,7 +188,7 @@
         <xsl:text>&#xA;</xsl:text>
       </xsl:when>
       <xsl:when test="@role = 'qt4-prefix' or @role = 'qt5-prefix'">
-        <xsl:apply-templates select=".//screen"/>
+        <xsl:apply-templates select=".//screen[./userinput]"/>
       </xsl:when>
       <xsl:when test="@role = 'installation'">
         <xsl:text>
@@ -208,14 +243,17 @@
 </xsl:text>
         </xsl:if>
 
-        <xsl:apply-templates select=".//screen | .//para/command"/>
+        <xsl:apply-templates
+             select=".//screen[not(@role = 'nodump') and ./userinput] |
+                     .//para/command"/>
         <xsl:if test="$sudo = 'y'">
           <xsl:text>sudo /sbin/</xsl:text>
         </xsl:if>
         <xsl:text>ldconfig&#xA;&#xA;</xsl:text>
       </xsl:when>
       <xsl:when test="@role = 'configuration'">
-        <xsl:apply-templates select=".//screen" mode="config"/>
+        <xsl:apply-templates mode="config"
+             select=".//screen[not(@role = 'nodump') and ./userinput]"/>
       </xsl:when>
     </xsl:choose>
   </xsl:template>
@@ -455,6 +493,25 @@
       <xsl:with-param name="varname" select="$varname"/>
     </xsl:call-template>
   </xsl:template>
+
+<!--====================== Non package code =========================-->
+
+  <xsl:template match="screen" mode="not-pack">
+    <xsl:choose>
+      <xsl:when test="ancestor::sect1[@id='postlfs-config-vimrc']">
+        <xsl:text>
+cat > ~/.vimrc <<EOF
+</xsl:text>
+        <xsl:apply-templates/>
+        <xsl:text>
+EOF
+</xsl:text>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:apply-templates select="." mode="config"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
 <!--======================== Commands code ==========================-->
 
   <xsl:template match="screen">
@@ -464,6 +521,10 @@
         <xsl:when test="@role = 'root' and
                           ancestor::sect2[@role='installation'] and
                           not(contains(string(),'useradd')) and
+                          not(contains(string(),'usermod')) and
+                          not(contains(string(),'icon-cache')) and
+                          not(contains(string(),'desktop-database')) and
+                          not(contains(string(),'compile-schemas')) and
                           not(contains(string(),'groupadd'))">
           <xsl:if test="not(preceding-sibling::screen[1][@role='root'])">
             <xsl:if test="contains($list-stat-norm,
@@ -704,15 +765,63 @@
   </xsl:template>
 
   <xsl:template match="replaceable">
+    <xsl:choose>
+<!-- When adding a user to a group, the book uses "username" in a replaceable
+     tag. Replace by the user name only if not running as root -->
+      <xsl:when test="contains(string(),'username') and $sudo='y'">
+        <xsl:text>$USER</xsl:text>
+      </xsl:when>
+<!-- The next three entries are for gpm. I guess those settings are OK
+     for a laptop or desktop. -->
+      <xsl:when test="contains(string(),'yourprotocol')">
+        <xsl:text>imps2</xsl:text>
+      </xsl:when>
+      <xsl:when test="contains(string(),'yourdevice')">
+        <xsl:text>/dev/input/mice</xsl:text>
+      </xsl:when>
+      <xsl:when test="contains(string(),'additional options')"/>
+<!-- the book has four fields for language. The language param is
+     broken into four pieces above. We use the results here. -->
+      <xsl:when test="contains(string(),'<ll>')">
+        <xsl:copy-of select="$lang-ll"/>
+      </xsl:when>
+      <xsl:when test="contains(string(),'<CC>')">
+        <xsl:copy-of select="$lang-CC"/>
+      </xsl:when>
+      <xsl:when test="contains(string(),'<charmap>')">
+        <xsl:copy-of select="$lang-charmap"/>
+      </xsl:when>
+      <xsl:when test="contains(string(),'@modifier')">
+        <xsl:copy-of select="$lang-modifier"/>
+      </xsl:when>
+<!-- At several places, the number of jobs is given as "N" in a replaceable
+     tag. We either detect "N" alone or <N> Replace N with 4. -->
+      <xsl:when test="contains(string(),'<N>') or string()='N'">
+        <xsl:text>4</xsl:text>
+      </xsl:when>
+<!-- Mercurial config file uses user_name. Replace only if non root.
+     Add a bogus mail field. That works for the proposed tests anyway. -->
+      <xsl:when test="contains(string(),'user_name') and $sudo='y'">
+        <xsl:text>$USER ${USER}@mail.bogus</xsl:text>
+      </xsl:when>
+<!-- Use the config for Gtk+3 as is -->
+      <xsl:when test="ancestor::sect1[@id='gtk3']">
+        <xsl:copy-of select="string()"/>
+      </xsl:when>
+<!-- Give 1Gb to fop. Hopefully, nobody has less RAM nowadays. -->
+      <xsl:when test="contains(string(),'RAM_Installed')">
+        <xsl:text>1024</xsl:text>
+      </xsl:when>
+      <xsl:otherwise>
         <xsl:text>**EDITME</xsl:text>
         <xsl:apply-templates/>
         <xsl:text>EDITME**</xsl:text>
+      </xsl:otherwise>
+    </xsl:choose>
   </xsl:template>
 
   <xsl:template match="replaceable" mode="root">
-        <xsl:text>**EDITME</xsl:text>
-        <xsl:apply-templates/>
-        <xsl:text>EDITME**</xsl:text>
+    <xsl:apply-templates select="."/>
   </xsl:template>
 
   <xsl:template name="output-destdir">

Modified: jhalfs/trunk/common/libs/func_install_blfs
==============================================================================
--- jhalfs/trunk/common/libs/func_install_blfs	Tue Sep  4 03:06:09 2018	(r4063)
+++ jhalfs/trunk/common/libs/func_install_blfs	Fri Sep 28 07:35:46 2018	(r4064)
@@ -133,8 +133,10 @@
 MAIL_SERVER=sendmail
 optDependency=2
 SUDO=n
+LANGUAGE=$LANG
 WRAP_INSTALL=$WRAP_INSTALL
 DEL_LA_FILES=$DEL_LA_FILES
+STATS=n
 EOF
 
 # Generates the scripts for the blfs tools dependencies (in ./scripts)


More information about the alfs-log mailing list