Changeset bfcaaa0 for LFS/lfs.xsl


Ignore:
Timestamp:
09/29/2007 11:12:24 AM (17 years ago)
Author:
Manuel Canales Esparcia <manuel@…>
Branches:
experimental
Children:
7b50e2c
Parents:
9ba7afe
Message:

Moved custom-tools and blfs-tool templates to saparate files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • LFS/lfs.xsl

    r9ba7afe rbfcaaa0  
    1212    <!-- Including common extensions templates -->
    1313  <xsl:include href="../XSL/user.xsl"/>
     14  <xsl:include href="../XSL/custom-tools.xsl"/>
     15  <xsl:include href="../XSL/blfs-tool.xsl"/>
    1416
    1517<!-- ####################### PARAMETERS ################################### -->
     
    4951
    5052<!-- ####################################################################### -->
    51 
    52 <!-- ########### NAMED USER TEMPLATES TO ALLOW CUSTOMIZATIONS ############## -->
    53 <!-- ############ Maybe should be placed on a separate file ################ -->
    54 
    55 
    56     <!-- Hock for creating a custom tools directory containing scripts
    57          to be run after the system has been built
    58          (to be moved to a separate file) -->
    59   <xsl:template name="custom-tools">
    60       <!-- Fixed directory and ch_order values -->
    61     <xsl:variable name="basedir">custom-tools/20_</xsl:variable>
    62       <!-- Add an exsl:document block for each script to be created.
    63            This one is only a dummy example. You must replace "01" by
    64            the proper build order and "dummy" by the script name -->
    65     <exsl:document href="{$basedir}01-dummy" method="text">
    66       <xsl:call-template name="header"/>
    67       <xsl:text>
    68 PKG_PHASE=dummy
    69 PACKAGE=dummy
    70 VERSION=0.0.0
    71 TARBALL=dummy-0.0.0.tar.bz2
    72       </xsl:text>
    73       <xsl:call-template name="disk_usage"/>
    74       <xsl:call-template name="unpack"/>
    75       <xsl:text>
    76 cd $PKGDIR
    77 ./configure --prefix=/usr
    78 make
    79 make check
    80 make install
    81       </xsl:text>
    82       <xsl:call-template name="disk_usage"/>
    83       <xsl:call-template name="clean_sources"/>
    84       <xsl:call-template name="footer"/>
    85     </exsl:document>
    86   </xsl:template>
    87 
    88 
    89 <!-- ####################################################################### -->
    90 
    91 <!-- ########################### NAMED TEMPLATES ########################### -->
    92 
    93     <!-- Chapter directory name (the same used for HTML output) -->
    94   <xsl:template name="dirname">
    95     <xsl:variable name="pi-dir" select="processing-instruction('dbhtml')"/>
    96     <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
    97     <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
    98     <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
    99     <xsl:value-of select="$dirname"/>
    100   </xsl:template>
    101 
    102 
    103     <!-- Base file name (the same used for HTML output) -->
    104   <xsl:template name="filename">
    105     <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
    106     <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
    107     <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
    108     <xsl:value-of select="$filename"/>
    109   </xsl:template>
    110 
    111 
    112     <!-- Script header -->
    113   <xsl:template name="header">
    114     <xsl:if test="not(@id='ch-system-chroot') and
    115                   not(@id='ch-system-revisedchroot')">
    116         <!-- Set the shabang -->
    117       <xsl:choose>
    118         <xsl:when test="@id='ch-system-creatingdirs' or
    119                         @id='ch-system-createfiles' or
    120                         @id='ch-system-strippingagain'">
    121           <xsl:text>#!/tools/bin/bash&#xA;</xsl:text>
    122         </xsl:when>
    123         <xsl:otherwise>
    124           <xsl:text>#!/bin/bash&#xA;</xsl:text>
    125         </xsl:otherwise>
    126       </xsl:choose>
    127         <!-- Set +h -->
    128       <xsl:text>set +h&#xA;</xsl:text>
    129         <!-- Set -e -->
    130       <xsl:if test="not(@id='ch-tools-stripping') and
    131                     not(@id='ch-system-strippingagain')">
    132         <xsl:text>set -e&#xA;</xsl:text>
    133       </xsl:if>
    134         <!-- Dump a time stamp -->
    135       <xsl:text>&#xA;echo -e "\n`date`\n"&#xA;</xsl:text>
    136     </xsl:if>
    137   </xsl:template>
    138 
    139 
    140     <!-- Dump current disk usage -->
    141   <xsl:template name="disk_usage">
    142     <xsl:if test="not(@id='ch-system-chroot') and
    143                   not(@id='ch-system-revisedchroot')">
    144       <xsl:choose>
    145         <xsl:when test="ancestor::chapter[@id='chapter-temporary-tools']">
    146           <xsl:text>echo -e "\nKB: `du -skx --exclude=jhalfs --exclude=lost+found $LFS`\n"&#xA;</xsl:text>
    147         </xsl:when>
    148         <xsl:otherwise>
    149           <xsl:text>echo -e "\nKB: `du -skx --exclude=jhalfs --exclude=lost+found /`\n"&#xA;</xsl:text>
    150         </xsl:otherwise>
    151       </xsl:choose>
    152     </xsl:if>
    153   </xsl:template>
    154 
    155 
    156     <!-- Enter to the sources dir, clean it, unpack the tarball,
    157          and reset the seconds counter -->
    158   <xsl:template name="unpack">
    159     <xsl:text>cd </xsl:text>
    160     <xsl:if test="ancestor::chapter[@id='chapter-temporary-tools']">
    161       <xsl:text>$LFS</xsl:text>
    162     </xsl:if>
    163     <xsl:text>/sources
    164 PKGDIR=`tar -tf $TARBALL | head -n1 | sed -e 's@^./@@;s@/.*@@'`
    165 if [ -d $PKGDIR ]; then
    166   rm -rf $PKGDIR
    167 fi
    168 if [ -d ${PKGDIR%-*}-build ]; then
    169   rm -rf ${PKGDIR%-*}-build
    170 fi
    171 tar -xf $TARBALL
    172 SECONDS=0
    173     </xsl:text>
    174   </xsl:template>
    175 
    176 
    177     <!-- Extra previous commands needed by the book but not inside screen tags -->
    178   <xsl:template name="pre_commands">
    179     <xsl:if test="sect2[@role='installation']">
    180       <xsl:text>cd $PKGDIR&#xA;</xsl:text>
    181     </xsl:if>
    182     <xsl:if test="@id='ch-system-vim' and $vim-lang = 'y'">
    183       <xsl:text>tar -xf ../$TARBALL_1 --strip-components=1&#xA;</xsl:text>
    184     </xsl:if>
    185   </xsl:template>
    186 
    187 
    188     <!-- Extra post commands needed by the book but not inside screen tags -->
    189   <xsl:template name="post_commands">
    190     <xsl:if test="$testsuite='3' and @id='ch-tools-glibc'">
    191       <xsl:variable name="content" select="//userinput[@remap='locale-test']"/>
    192       <xsl:value-of select="substring-before($content,'/usr/lib/locale')"/>
    193       <xsl:text>/tools/lib/locale</xsl:text>
    194       <xsl:value-of select="substring-after($content,'/usr/lib/locale')"/>
    195     </xsl:if>
    196   </xsl:template>
    197 
    198 
    199     <!-- Remove sources and build dirs, skipping it from seconds meassurament -->
    200   <xsl:template name="clean_sources">
    201     <xsl:text>cd </xsl:text>
    202     <xsl:if test="ancestor::chapter[@id='chapter-temporary-tools']">
    203       <xsl:text>$LFS</xsl:text>
    204     </xsl:if>
    205     <xsl:text>/sources
    206 SECS=$SECONDS
    207 rm -rf $PKGDIR
    208 rm -rf ${PKGDIR%-*}-build
    209 SECONDS=$SECS
    210     </xsl:text>
    211   </xsl:template>
    212 
    213 
    214     <!-- Script footer -->
    215   <xsl:template name="footer">
    216       <!-- Dump the build time and exit -->
    217     <xsl:if test="not(@id='ch-system-chroot') and
    218                   not(@id='ch-system-revisedchroot')">
    219       <xsl:text>
    220 echo -e "\n\nTotalseconds: $SECONDS\n"
    221 
    222 exit
    223       </xsl:text>
    224     </xsl:if>
    225   </xsl:template>
    226 
    227 
    228     <!-- Extra commads needed at the start of some screen block
    229          to allow automatization -->
    230   <xsl:template name="top_screen_build_fixes">
    231       <!-- Fix Udev reinstallation after a build failure or on iterative builds -->
    232     <xsl:if test="contains(string(),'firmware,udev')">
    233       <xsl:text>if [[ ! -d /lib/udev/devices ]] ; then&#xA;</xsl:text>
    234     </xsl:if>
    235   </xsl:template>
    236 
    237 
    238     <!-- Extra commads needed at the end of some screen block
    239          to allow automatization -->
    240   <xsl:template name="bottom_screen_build_fixes">
    241       <!-- Fix Udev reinstallation after a build failure or on iterative builds -->
    242     <xsl:if test="contains(string(),'firmware,udev')">
    243       <xsl:text>&#xA;fi</xsl:text>
    244     </xsl:if>
    245       <!-- Copying the kernel config file -->
    246     <xsl:if test="string() = 'make mrproper'">
    247       <xsl:text>&#xA;cp -v ../kernel-config .config</xsl:text>
    248     </xsl:if>
    249       <!-- Don't stop on strip run -->
    250     <xsl:if test="contains(string(),'strip --strip')">
    251       <xsl:text> || true</xsl:text>
    252     </xsl:if>
    253   </xsl:template>
    254 
    255 
    256     <!-- Extract a package name from a package URL -->
    257   <xsl:template name="package_name">
    258     <xsl:param name="url" select="foo"/>
    259     <xsl:param name="sub-url" select="substring-after($url,'/')"/>
    260     <xsl:choose>
    261       <xsl:when test="contains($sub-url,'/')">
    262         <xsl:call-template name="package_name">
    263           <xsl:with-param name="url" select="$sub-url"/>
    264         </xsl:call-template>
    265       </xsl:when>
    266       <xsl:otherwise>
    267         <xsl:value-of select="$sub-url"/>
    268       </xsl:otherwise>
    269     </xsl:choose>
    270   </xsl:template>
    271 
    272 
    273     <!-- Check if a package testsuite must be run -->
    274   <xsl:template name="run_this_test">
    275     <xsl:choose>
    276       <xsl:when test=".//userinput[@remap='test']">
    277         <xsl:choose>
    278             <!-- No testsuites run on level 0 -->
    279           <xsl:when test="$testsuite = '0'">0</xsl:when>
    280             <!-- On level 1, only final system toolchain testsuites are run -->
    281           <xsl:when test="$testsuite = '1' and
    282                           not(@id='ch-system-gcc') and
    283                           not(@id='ch-system-glibc') and
    284                           not(@id='ch-system-binutils')">0</xsl:when>
    285             <!-- On level 2, temp tools testsuites are not run -->
    286           <xsl:when test="$testsuite = '2' and
    287                           ../@id='chapter-temporary-tools'">0</xsl:when>
    288           <xsl:otherwise>1</xsl:otherwise>
    289         </xsl:choose>
    290       </xsl:when>
    291       <xsl:otherwise>0</xsl:otherwise>
    292     </xsl:choose>
    293   </xsl:template>
    294 
    295 
    296     <!-- Adds blfs-tool support scripts (to be moved to a separate file) -->
    297   <xsl:template name="blfs-tool">
    298       <!-- Fixed directory and ch_order values -->
    299     <xsl:variable name="basedir">blfs-tool-deps/30_</xsl:variable>
    300       <!-- One exsl:document block for each blfs-tool dependency
    301            TO BE WRITTEN -->
    302     <exsl:document href="{$basedir}01-dummy" method="text">
    303       <xsl:call-template name="header"/>
    304       <xsl:text>
    305 PKG_PHASE=dummy
    306 PACKAGE=dummy
    307 VERSION=0.0.0
    308 TARBALL=dummy-0.0.0.tar.bz2
    309       </xsl:text>
    310       <xsl:call-template name="disk_usage"/>
    311       <xsl:call-template name="unpack"/>
    312       <xsl:text>
    313 cd $PKGDIR
    314 ./configure --prefix=/usr
    315 make
    316 make check
    317 make install
    318       </xsl:text>
    319       <xsl:call-template name="disk_usage"/>
    320       <xsl:call-template name="clean_sources"/>
    321       <xsl:call-template name="footer"/>
    322     </exsl:document>
    323   </xsl:template>
    324 
    325 
    326 <!-- ######################################################################## -->
    32753
    32854<!-- ############################# MATCH TEMPLATES ########################## -->
     
    468194      <xsl:text>/jhalfs/test-logs/</xsl:text>
    469195      <xsl:value-of select="$testlogfile"/>
    470       <xsl:text>&#xA;echo -e "\n`date`\n" > $TEST_LOG</xsl:text>
     196      <xsl:text>&#xA;echo -e "\n`date`\n" &gt; $TEST_LOG</xsl:text>
    471197    </xsl:if>
    472198    <xsl:text>&#xA;&#xA;</xsl:text>
     
    623349  </xsl:template>
    624350
     351
     352<!-- ######################################################################## -->
     353
     354<!-- ########################### NAMED TEMPLATES ########################### -->
     355
     356    <!-- Chapter directory name (the same used for HTML output) -->
     357  <xsl:template name="dirname">
     358    <xsl:variable name="pi-dir" select="processing-instruction('dbhtml')"/>
     359    <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
     360    <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
     361    <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
     362    <xsl:value-of select="$dirname"/>
     363  </xsl:template>
     364
     365
     366    <!-- Base file name (the same used for HTML output) -->
     367  <xsl:template name="filename">
     368    <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
     369    <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
     370    <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
     371    <xsl:value-of select="$filename"/>
     372  </xsl:template>
     373
     374
     375    <!-- Script header -->
     376  <xsl:template name="header">
     377    <xsl:if test="not(@id='ch-system-chroot') and
     378                  not(@id='ch-system-revisedchroot')">
     379        <!-- Set the shabang -->
     380      <xsl:choose>
     381        <xsl:when test="@id='ch-system-creatingdirs' or
     382                        @id='ch-system-createfiles' or
     383                        @id='ch-system-strippingagain'">
     384          <xsl:text>#!/tools/bin/bash&#xA;</xsl:text>
     385        </xsl:when>
     386        <xsl:otherwise>
     387          <xsl:text>#!/bin/bash&#xA;</xsl:text>
     388        </xsl:otherwise>
     389      </xsl:choose>
     390        <!-- Set +h -->
     391      <xsl:text>set +h&#xA;</xsl:text>
     392        <!-- Set -e -->
     393      <xsl:if test="not(@id='ch-tools-stripping') and
     394                    not(@id='ch-system-strippingagain')">
     395        <xsl:text>set -e&#xA;</xsl:text>
     396      </xsl:if>
     397        <!-- Dump a time stamp -->
     398      <xsl:text>&#xA;echo -e "\n`date`\n"&#xA;</xsl:text>
     399    </xsl:if>
     400  </xsl:template>
     401
     402
     403    <!-- Dump current disk usage -->
     404  <xsl:template name="disk_usage">
     405    <xsl:if test="not(@id='ch-system-chroot') and
     406                  not(@id='ch-system-revisedchroot')">
     407      <xsl:choose>
     408        <xsl:when test="ancestor::chapter[@id='chapter-temporary-tools']">
     409          <xsl:text>echo -e "\nKB: `du -skx --exclude=jhalfs --exclude=lost+found $LFS`\n"&#xA;</xsl:text>
     410        </xsl:when>
     411        <xsl:otherwise>
     412          <xsl:text>echo -e "\nKB: `du -skx --exclude=jhalfs --exclude=lost+found /`\n"&#xA;</xsl:text>
     413        </xsl:otherwise>
     414      </xsl:choose>
     415    </xsl:if>
     416  </xsl:template>
     417
     418
     419    <!-- Enter to the sources dir, clean it, unpack the tarball,
     420         and reset the seconds counter -->
     421  <xsl:template name="unpack">
     422    <xsl:text>cd </xsl:text>
     423    <xsl:if test="ancestor::chapter[@id='chapter-temporary-tools']">
     424      <xsl:text>$LFS</xsl:text>
     425    </xsl:if>
     426    <xsl:text>/sources
     427PKGDIR=`tar -tf $TARBALL | head -n1 | sed -e 's@^./@@;s@/.*@@'`
     428if [ -d $PKGDIR ]; then
     429  rm -rf $PKGDIR
     430fi
     431if [ -d ${PKGDIR%-*}-build ]; then
     432  rm -rf ${PKGDIR%-*}-build
     433fi
     434tar -xf $TARBALL
     435SECONDS=0
     436    </xsl:text>
     437  </xsl:template>
     438
     439
     440    <!-- Extra previous commands needed by the book but not inside screen tags -->
     441  <xsl:template name="pre_commands">
     442    <xsl:if test="sect2[@role='installation']">
     443      <xsl:text>cd $PKGDIR&#xA;</xsl:text>
     444    </xsl:if>
     445    <xsl:if test="@id='ch-system-vim' and $vim-lang = 'y'">
     446      <xsl:text>tar -xf ../$TARBALL_1 --strip-components=1&#xA;</xsl:text>
     447    </xsl:if>
     448  </xsl:template>
     449
     450
     451    <!-- Extra post commands needed by the book but not inside screen tags -->
     452  <xsl:template name="post_commands">
     453    <xsl:if test="$testsuite='3' and @id='ch-tools-glibc'">
     454      <xsl:variable name="content" select="//userinput[@remap='locale-test']"/>
     455      <xsl:value-of select="substring-before($content,'/usr/lib/locale')"/>
     456      <xsl:text>/tools/lib/locale</xsl:text>
     457      <xsl:value-of select="substring-after($content,'/usr/lib/locale')"/>
     458    </xsl:if>
     459  </xsl:template>
     460
     461
     462    <!-- Remove sources and build dirs, skipping it from seconds meassurament -->
     463  <xsl:template name="clean_sources">
     464    <xsl:text>cd </xsl:text>
     465    <xsl:if test="ancestor::chapter[@id='chapter-temporary-tools']">
     466      <xsl:text>$LFS</xsl:text>
     467    </xsl:if>
     468    <xsl:text>/sources
     469SECS=$SECONDS
     470rm -rf $PKGDIR
     471rm -rf ${PKGDIR%-*}-build
     472SECONDS=$SECS
     473    </xsl:text>
     474  </xsl:template>
     475
     476
     477    <!-- Script footer -->
     478  <xsl:template name="footer">
     479      <!-- Dump the build time and exit -->
     480    <xsl:if test="not(@id='ch-system-chroot') and
     481                  not(@id='ch-system-revisedchroot')">
     482      <xsl:text>
     483echo -e "\n\nTotalseconds: $SECONDS\n"
     484
     485exit
     486      </xsl:text>
     487    </xsl:if>
     488  </xsl:template>
     489
     490
     491    <!-- Extra commads needed at the start of some screen block
     492         to allow automatization -->
     493  <xsl:template name="top_screen_build_fixes">
     494      <!-- Fix Udev reinstallation after a build failure or on iterative builds -->
     495    <xsl:if test="contains(string(),'firmware,udev')">
     496      <xsl:text>if [[ ! -d /lib/udev/devices ]] ; then&#xA;</xsl:text>
     497    </xsl:if>
     498  </xsl:template>
     499
     500
     501    <!-- Extra commads needed at the end of some screen block
     502         to allow automatization -->
     503  <xsl:template name="bottom_screen_build_fixes">
     504      <!-- Fix Udev reinstallation after a build failure or on iterative builds -->
     505    <xsl:if test="contains(string(),'firmware,udev')">
     506      <xsl:text>&#xA;fi</xsl:text>
     507    </xsl:if>
     508      <!-- Copying the kernel config file -->
     509    <xsl:if test="string() = 'make mrproper'">
     510      <xsl:text>&#xA;cp -v ../kernel-config .config</xsl:text>
     511    </xsl:if>
     512      <!-- Don't stop on strip run -->
     513    <xsl:if test="contains(string(),'strip --strip')">
     514      <xsl:text> || true</xsl:text>
     515    </xsl:if>
     516  </xsl:template>
     517
     518
     519    <!-- Extract a package name from a package URL -->
     520  <xsl:template name="package_name">
     521    <xsl:param name="url" select="foo"/>
     522    <xsl:param name="sub-url" select="substring-after($url,'/')"/>
     523    <xsl:choose>
     524      <xsl:when test="contains($sub-url,'/')">
     525        <xsl:call-template name="package_name">
     526          <xsl:with-param name="url" select="$sub-url"/>
     527        </xsl:call-template>
     528      </xsl:when>
     529      <xsl:otherwise>
     530        <xsl:value-of select="$sub-url"/>
     531      </xsl:otherwise>
     532    </xsl:choose>
     533  </xsl:template>
     534
     535
     536    <!-- Check if a package testsuite must be run -->
     537  <xsl:template name="run_this_test">
     538    <xsl:choose>
     539      <xsl:when test=".//userinput[@remap='test']">
     540        <xsl:choose>
     541            <!-- No testsuites run on level 0 -->
     542          <xsl:when test="$testsuite = '0'">0</xsl:when>
     543            <!-- On level 1, only final system toolchain testsuites are run -->
     544          <xsl:when test="$testsuite = '1' and
     545                          not(@id='ch-system-gcc') and
     546                          not(@id='ch-system-glibc') and
     547                          not(@id='ch-system-binutils')">0</xsl:when>
     548            <!-- On level 2, temp tools testsuites are not run -->
     549          <xsl:when test="$testsuite = '2' and
     550                          ../@id='chapter-temporary-tools'">0</xsl:when>
     551          <xsl:otherwise>1</xsl:otherwise>
     552        </xsl:choose>
     553      </xsl:when>
     554      <xsl:otherwise>0</xsl:otherwise>
     555    </xsl:choose>
     556  </xsl:template>
     557
    625558</xsl:stylesheet>
Note: See TracChangeset for help on using the changeset viewer.