Changeset 77fa8ba for LFS/lfs.xsl


Ignore:
Timestamp:
12/13/2015 03:28:33 PM (9 years ago)
Author:
Pierre Labastie <pierre@…>
Branches:
new_features
Children:
6b6d54d
Parents:
2453b766
Message:

Add IP, hostname, domain, etc to the list of configuration parameters.
Font and encoding are in configuration too, but are not passed to the build
commands
Works only for LFS

File:
1 edited

Legend:

Unmodified
Added
Removed
  • LFS/lfs.xsl

    r2453b766 r77fa8ba  
    88      extension-element-prefixes="exsl"
    99      version="1.0">
     10
     11<!-- Parameters -->
    1012
    1113  <!-- use package management ?
     
    1719  <!-- Run test suites?
    1820       0 = none
    19        1 = only chapter06 Glibc, GCC and Binutils testsuites
     21       1 = only chapter06 critical testsuites
    2022       2 = all chapter06 testsuites
    2123       3 = all chapter05 and chapter06 testsuites
     
    4446  <xsl:param name='full-locale' select='n'/>
    4547 
     48  <!-- Hostname -->
     49  <xsl:param name='hostname' select='"HOSTNAME"'/>
     50
     51  <!-- Network parameters: interface, ip, gateway, prefix, broadcast, domain
     52       and nameservers -->
     53  <xsl:param name='interface'   select='eth0'/>
     54  <xsl:param name='ip'          select='"10.0.2.9"'/>
     55  <xsl:param name='gateway'     select='"10.0.2.2"'/>
     56  <xsl:param name='prefix'      select='24'/>
     57  <xsl:param name='broadcast'   select='"10.0.2.255"'/>
     58  <xsl:param name='domain'      select='"lfs.org"'/>
     59  <xsl:param name='nameserver1' select='"10.0.2.3"'/>
     60  <xsl:param name='nameserver2' select='"8.8.8.8"'/>
     61
     62<!-- End parameters -->
     63
    4664  <xsl:template match="/">
    4765    <xsl:apply-templates select="//sect1"/>
     
    500518        <xsl:value-of select="$lang"/>
    501519      </xsl:when>
     520      <xsl:when test="contains(string(.),'Domain')">
     521        <xsl:value-of select="$domain"/>
     522      </xsl:when>
     523      <xsl:when test="contains(string(.),'primary')">
     524        <xsl:value-of select="$nameserver1"/>
     525      </xsl:when>
     526      <xsl:when test="contains(string(.),'secondary')">
     527        <xsl:value-of select="$nameserver2"/>
     528      </xsl:when>
     529      <xsl:when test="contains(string(.),'192.168.1.1')">
     530        <xsl:value-of select="$ip"/>
     531      </xsl:when>
     532      <xsl:when test="contains(string(.),'HOSTNAME')">
     533        <xsl:value-of select="$hostname"/>
     534        <xsl:text>.</xsl:text>
     535        <xsl:value-of select="$domain"/>
     536      </xsl:when>
     537      <xsl:when test="contains(string(.),'alias')">
     538        <xsl:value-of select="$hostname"/>
     539      </xsl:when>
     540      <xsl:when test="contains(string(.),'&lt;lfs&gt;')">
     541        <xsl:value-of select="$hostname"/>
     542      </xsl:when>
    502543      <xsl:otherwise>
    503544        <xsl:text>**EDITME</xsl:text>
     
    508549  </xsl:template>
    509550 
     551  <xsl:template match="literal">
     552    <xsl:choose>
     553      <xsl:when test="contains(string(),'ONBOOT')">
     554        <xsl:call-template name="outputnet">
     555          <xsl:with-param name="netstring" select="string()"/>
     556        </xsl:call-template>
     557      </xsl:when>
     558      <xsl:otherwise>
     559        <xsl:apply-templates/>
     560      </xsl:otherwise>
     561    </xsl:choose>
     562  </xsl:template>
     563
     564  <xsl:template name="outputnet">
     565    <xsl:param name="netstring" select="''"/>
     566    <!-- We suppose that book example has the following values:
     567         - interface: eth0
     568         - ip: 192.168.1.1
     569         - gateway: 192.168.1.2
     570         - prefix: 24
     571         - broadcast: 192.168.1.255
     572         Change below if book changes -->
     573    <xsl:choose>
     574      <xsl:when test="contains($netstring,'eth0')">
     575        <xsl:call-template name="outputnet">
     576          <xsl:with-param name="netstring"
     577                          select="substring-before($netstring,'eth0')"/>
     578        </xsl:call-template>
     579        <xsl:value-of select="$interface"/>
     580        <xsl:call-template name="outputnet">
     581          <xsl:with-param name="netstring"
     582                          select="substring-after($netstring,'eth0')"/>
     583        </xsl:call-template>
     584      </xsl:when>
     585      <xsl:when test="contains($netstring,'192.168.1.1')">
     586        <xsl:call-template name="outputnet">
     587          <xsl:with-param name="netstring"
     588                          select="substring-before($netstring,'192.168.1.1')"/>
     589        </xsl:call-template>
     590        <xsl:value-of select="$ip"/>
     591        <xsl:call-template name="outputnet">
     592          <xsl:with-param name="netstring"
     593                          select="substring-after($netstring,'192.168.1.1')"/>
     594        </xsl:call-template>
     595      </xsl:when>
     596      <!-- must test this before the following, because 192.168.1.255 contains
     597           192.168.1.2! -->
     598      <xsl:when test="contains($netstring,'192.168.1.255')">
     599        <xsl:call-template name="outputnet">
     600          <xsl:with-param name="netstring"
     601                          select="substring-before($netstring,'192.168.1.255')"/>
     602        </xsl:call-template>
     603        <xsl:value-of select="$broadcast"/>
     604        <xsl:call-template name="outputnet">
     605          <xsl:with-param name="netstring"
     606                          select="substring-after($netstring,'192.168.1.255')"/>
     607        </xsl:call-template>
     608      </xsl:when>
     609      <xsl:when test="contains($netstring,'192.168.1.2')">
     610        <xsl:call-template name="outputnet">
     611          <xsl:with-param name="netstring"
     612                          select="substring-before($netstring,'192.168.1.2')"/>
     613        </xsl:call-template>
     614        <xsl:value-of select="$gateway"/>
     615        <xsl:call-template name="outputnet">
     616          <xsl:with-param name="netstring"
     617                          select="substring-after($netstring,'192.168.1.2')"/>
     618        </xsl:call-template>
     619      </xsl:when>
     620      <xsl:when test="contains($netstring,'24')">
     621        <xsl:call-template name="outputnet">
     622          <xsl:with-param name="netstring"
     623                          select="substring-before($netstring,'24')"/>
     624        </xsl:call-template>
     625        <xsl:value-of select="$prefix"/>
     626        <xsl:call-template name="outputnet">
     627          <xsl:with-param name="netstring"
     628                          select="substring-after($netstring,'24')"/>
     629        </xsl:call-template>
     630      </xsl:when>
     631      <xsl:otherwise>
     632        <xsl:value-of select="$netstring"/>
     633      </xsl:otherwise>
     634    </xsl:choose>
     635  </xsl:template>
     636
    510637  <xsl:template name="outputpkgdest">
    511638    <xsl:param name="outputstring" select="foo"/>
Note: See TracChangeset for help on using the changeset viewer.