Ignore:
Timestamp:
09/28/2018 02:35:46 PM (6 years ago)
Author:
Pierre Labastie <pierre@…>
Branches:
ablfs-more, legacy, trunk
Children:
6e28f3c
Parents:
3b4399c9
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • BLFS/xsl/scripts.xsl

    r3b4399c9 r625cb14  
    3434  <!-- Build as user (y) or as root (n)? -->
    3535  <xsl:param name="sudo" select="'y'"/>
     36
     37  <!-- Localization in the form ll_CC.charmap@modifier (to be used in
     38       bash shell startup scripts). ll, CC, and charmap must be present:
     39       no way to use "C" or "POSIX". -->
     40  <xsl:param name="language" select="'en_US.UTF-8'"/>
     41
     42  <!-- Break it in pieces -->
     43  <xsl:variable name="lang-ll">
     44    <xsl:copy-of select="substring-before($language,'_')"/>
     45  </xsl:variable>
     46  <xsl:variable name="lang-CC">
     47     <xsl:copy-of
     48            select="substring-before(substring-after($language,'_'),'.')"/>
     49  </xsl:variable>
     50  <xsl:variable name="lang-charmap">
     51    <xsl:choose>
     52      <xsl:when test="contains($language,'@')">
     53         <xsl:copy-of
     54               select="substring-before(substring-after($language,'.'),'@')"/>
     55      </xsl:when>
     56      <xsl:otherwise>
     57        <xsl:copy-of select="substring-after($language,'.')"/>
     58      </xsl:otherwise>
     59    </xsl:choose>
     60  </xsl:variable>
     61  <xsl:variable name="lang-modifier">
     62    <xsl:choose>
     63      <xsl:when test="contains($language,'@')">
     64         <xsl:copy-of select="concat('@',substring-after($language,'@'))"/>
     65      </xsl:when>
     66      <xsl:otherwise>
     67        <xsl:copy-of select="''"/>
     68      </xsl:otherwise>
     69    </xsl:choose>
     70  </xsl:variable>
    3671
    3772<!-- simple instructions for removing .la files. -->
     
    134169          <!-- Non-package page -->
    135170          <xsl:otherwise>
    136             <xsl:apply-templates select=".//screen"/>
     171            <xsl:apply-templates select=".//screen" mode="not-pack"/>
    137172          </xsl:otherwise>
    138173        </xsl:choose>
    139174        <xsl:text>exit</xsl:text>
    140175      </exsl:document>
    141     </xsl:if>
     176    </xsl:if><!-- id!=bootscript or id!=systemd-units -->
    142177  </xsl:template>
    143178
     
    154189      </xsl:when>
    155190      <xsl:when test="@role = 'qt4-prefix' or @role = 'qt5-prefix'">
    156         <xsl:apply-templates select=".//screen"/>
     191        <xsl:apply-templates select=".//screen[./userinput]"/>
    157192      </xsl:when>
    158193      <xsl:when test="@role = 'installation'">
     
    209244        </xsl:if>
    210245
    211         <xsl:apply-templates select=".//screen | .//para/command"/>
     246        <xsl:apply-templates
     247             select=".//screen[not(@role = 'nodump') and ./userinput] |
     248                     .//para/command"/>
    212249        <xsl:if test="$sudo = 'y'">
    213250          <xsl:text>sudo /sbin/</xsl:text>
     
    216253      </xsl:when>
    217254      <xsl:when test="@role = 'configuration'">
    218         <xsl:apply-templates select=".//screen" mode="config"/>
     255        <xsl:apply-templates mode="config"
     256             select=".//screen[not(@role = 'nodump') and ./userinput]"/>
    219257      </xsl:when>
    220258    </xsl:choose>
     
    456494    </xsl:call-template>
    457495  </xsl:template>
     496
     497<!--====================== Non package code =========================-->
     498
     499  <xsl:template match="screen" mode="not-pack">
     500    <xsl:choose>
     501      <xsl:when test="ancestor::sect1[@id='postlfs-config-vimrc']">
     502        <xsl:text>
     503cat > ~/.vimrc &lt;&lt;EOF
     504</xsl:text>
     505        <xsl:apply-templates/>
     506        <xsl:text>
     507EOF
     508</xsl:text>
     509      </xsl:when>
     510      <xsl:otherwise>
     511        <xsl:apply-templates select="." mode="config"/>
     512      </xsl:otherwise>
     513    </xsl:choose>
     514  </xsl:template>
    458515<!--======================== Commands code ==========================-->
    459516
     
    465522                          ancestor::sect2[@role='installation'] and
    466523                          not(contains(string(),'useradd')) and
     524                          not(contains(string(),'usermod')) and
     525                          not(contains(string(),'icon-cache')) and
     526                          not(contains(string(),'desktop-database')) and
     527                          not(contains(string(),'compile-schemas')) and
    467528                          not(contains(string(),'groupadd'))">
    468529          <xsl:if test="not(preceding-sibling::screen[1][@role='root'])">
     
    705766
    706767  <xsl:template match="replaceable">
     768    <xsl:choose>
     769<!-- When adding a user to a group, the book uses "username" in a replaceable
     770     tag. Replace by the user name only if not running as root -->
     771      <xsl:when test="contains(string(),'username') and $sudo='y'">
     772        <xsl:text>$USER</xsl:text>
     773      </xsl:when>
     774<!-- The next three entries are for gpm. I guess those settings are OK
     775     for a laptop or desktop. -->
     776      <xsl:when test="contains(string(),'yourprotocol')">
     777        <xsl:text>imps2</xsl:text>
     778      </xsl:when>
     779      <xsl:when test="contains(string(),'yourdevice')">
     780        <xsl:text>/dev/input/mice</xsl:text>
     781      </xsl:when>
     782      <xsl:when test="contains(string(),'additional options')"/>
     783<!-- the book has four fields for language. The language param is
     784     broken into four pieces above. We use the results here. -->
     785      <xsl:when test="contains(string(),'&lt;ll&gt;')">
     786        <xsl:copy-of select="$lang-ll"/>
     787      </xsl:when>
     788      <xsl:when test="contains(string(),'&lt;CC&gt;')">
     789        <xsl:copy-of select="$lang-CC"/>
     790      </xsl:when>
     791      <xsl:when test="contains(string(),'&lt;charmap&gt;')">
     792        <xsl:copy-of select="$lang-charmap"/>
     793      </xsl:when>
     794      <xsl:when test="contains(string(),'@modifier')">
     795        <xsl:copy-of select="$lang-modifier"/>
     796      </xsl:when>
     797<!-- At several places, the number of jobs is given as "N" in a replaceable
     798     tag. We either detect "N" alone or &lt;N&gt; Replace N with 4. -->
     799      <xsl:when test="contains(string(),'&lt;N&gt;') or string()='N'">
     800        <xsl:text>4</xsl:text>
     801      </xsl:when>
     802<!-- Mercurial config file uses user_name. Replace only if non root.
     803     Add a bogus mail field. That works for the proposed tests anyway. -->
     804      <xsl:when test="contains(string(),'user_name') and $sudo='y'">
     805        <xsl:text>$USER ${USER}@mail.bogus</xsl:text>
     806      </xsl:when>
     807<!-- Use the config for Gtk+3 as is -->
     808      <xsl:when test="ancestor::sect1[@id='gtk3']">
     809        <xsl:copy-of select="string()"/>
     810      </xsl:when>
     811<!-- Give 1Gb to fop. Hopefully, nobody has less RAM nowadays. -->
     812      <xsl:when test="contains(string(),'RAM_Installed')">
     813        <xsl:text>1024</xsl:text>
     814      </xsl:when>
     815      <xsl:otherwise>
    707816        <xsl:text>**EDITME</xsl:text>
    708817        <xsl:apply-templates/>
    709818        <xsl:text>EDITME**</xsl:text>
     819      </xsl:otherwise>
     820    </xsl:choose>
    710821  </xsl:template>
    711822
    712823  <xsl:template match="replaceable" mode="root">
    713         <xsl:text>**EDITME</xsl:text>
    714         <xsl:apply-templates/>
    715         <xsl:text>EDITME**</xsl:text>
     824    <xsl:apply-templates select="."/>
    716825  </xsl:template>
    717826
Note: See TracChangeset for help on using the changeset viewer.