Changeset f5f857d


Ignore:
Timestamp:
09/25/2007 09:34:03 PM (17 years ago)
Author:
Manuel Canales Esparcia <manuel@…>
Branches:
experimental
Children:
c5ae20a
Parents:
5a4f6a7
Message:

Set $TEST_LOG from inside the build scripts.
There is no need now to use the envars file.
Optimize support must be moved to an XSL-based code.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • LFS/lfs.xsl

    r5a4f6a7 rf5f857d  
    4848
    4949<!-- ########### NAMED USER TEMPLATES TO ALLOW CUSTOMIZATIONS ############## -->
     50<!-- ############ Maybe should be placed on a separate file ################ -->
    5051
    5152    <!-- Hock for user header additions -->
     
    145146
    146147    <!-- Hock for creating a custom tools directory containing scripts
    147          to be run after the system has been built -->
     148         to be run after the system has been built
     149         (to be moved to a separate file) -->
    148150  <xsl:template name="custom-tools">
    149151      <!-- Fixed directory and ch_order values -->
     
    246248         and reset the seconds counter -->
    247249  <xsl:template name="unpack">
    248     <xsl:choose>
    249       <xsl:when test="ancestor::chapter[@id='chapter-temporary-tools']">
    250         <xsl:text>cd $SRCDIR</xsl:text>
    251       </xsl:when>
    252       <xsl:otherwise>
    253         <xsl:text>cd /sources</xsl:text>
    254       </xsl:otherwise>
    255     </xsl:choose>
    256     <xsl:text>
     250    <xsl:text>cd </xsl:text>
     251    <xsl:if test="ancestor::chapter[@id='chapter-temporary-tools']">
     252      <xsl:text>$LFS</xsl:text>
     253    </xsl:if>
     254    <xsl:text>/sources
    257255PKGDIR=`tar -tf $TARBALL | head -n1 | sed -e 's@^./@@;s@/.*@@'`
    258256if [ -d $PKGDIR ]; then
     
    292290    <!-- Remove sources and build dirs, skipping it from seconds meassurament -->
    293291  <xsl:template name="clean_sources">
    294     <xsl:choose>
    295       <xsl:when test="ancestor::chapter[@id='chapter-temporary-tools']">
    296         <xsl:text>cd $SRCDIR</xsl:text>
    297       </xsl:when>
    298       <xsl:otherwise>
    299         <xsl:text>cd /sources</xsl:text>
    300       </xsl:otherwise>
    301     </xsl:choose>
    302     <xsl:text>
     292    <xsl:text>cd </xsl:text>
     293    <xsl:if test="ancestor::chapter[@id='chapter-temporary-tools']">
     294      <xsl:text>$LFS</xsl:text>
     295    </xsl:if>
     296    <xsl:text>/sources
    303297SECS=$SECONDS
    304298rm -rf $PKGDIR
     
    368362
    369363
    370     <!-- Adds blfs-tool support scripts -->
     364    <!-- Check if a package testsuite must be run -->
     365  <xsl:template name="run_this_test">
     366    <xsl:choose>
     367      <xsl:when test=".//userinput[@remap='test']">
     368        <xsl:choose>
     369            <!-- No testsuites run on level 0 -->
     370          <xsl:when test="$testsuite = '0'">0</xsl:when>
     371            <!-- On level 1, only final system toolchain testsuites are run -->
     372          <xsl:when test="$testsuite = '1' and
     373                          not(@id='ch-system-gcc') and
     374                          not(@id='ch-system-glibc') and
     375                          not(@id='ch-system-binutils')">0</xsl:when>
     376            <!-- On level 2, temp tools testsuites are not run -->
     377          <xsl:when test="$testsuite = '2' and
     378                          ../@id='chapter-temporary-tools'">0</xsl:when>
     379          <xsl:otherwise>1</xsl:otherwise>
     380        </xsl:choose>
     381      </xsl:when>
     382      <xsl:otherwise>0</xsl:otherwise>
     383    </xsl:choose>
     384  </xsl:template>
     385
     386
     387    <!-- Adds blfs-tool support scripts (to be moved to a separate file) -->
    371388  <xsl:template name="blfs-tool">
    372389      <!-- Fixed directory and ch_order values -->
     
    476493        <!-- Script build order -->
    477494      <xsl:variable name="order" select="concat($dirname,'/',$ch_order,'_',$sect1_order)"/>
     495        <!-- Must the package test suite, if any, be run? -->
     496      <xsl:variable name="run_this_test">
     497        <xsl:call-template name="run_this_test"/>
     498      </xsl:variable>
    478499        <!-- Hock to insert scripts before the current one -->
    479500      <xsl:call-template name="insert_script_before">
     
    487508        <xsl:apply-templates select="sect1info[@condition='script']">
    488509          <xsl:with-param name="phase" select="$filename"/>
     510          <xsl:with-param name="run_this_test" select="$run_this_test"/>
     511          <xsl:with-param name="testlogfile" select="concat($ch_order,'_',$sect1_order,'-',$filename)"/>
    489512        </xsl:apply-templates>
    490513        <xsl:call-template name="disk_usage"/>
     
    494517        <xsl:call-template name="user_pre_commands"/>
    495518        <xsl:call-template name="pre_commands"/>
    496         <xsl:apply-templates select=".//screen"/>
     519        <xsl:apply-templates select=".//screen">
     520          <xsl:with-param name="run_this_test" select="$run_this_test"/>
     521        </xsl:apply-templates>
    497522        <xsl:call-template name="post_commands"/>
    498523        <xsl:call-template name="user_footer"/>
     
    514539    <!-- sect1info -->
    515540  <xsl:template match="sect1info">
     541      <!-- Used to set and initialize the testuite log file -->
     542    <xsl:param name="testlogfile" select="foo"/>
     543    <xsl:param name="run_this_test" select="foo"/>
    516544      <!-- Build phase (base file name) to be used for PM -->
    517545    <xsl:param name="phase" select="foo"/>
     
    524552      <!-- Tarball name -->
    525553    <xsl:apply-templates select="address"/>
     554    <xsl:if test="$run_this_test = '1'">
     555      <xsl:text>&#xA;TEST_LOG=</xsl:text>
     556      <xsl:if test="ancestor::chapter[@id='chapter-temporary-tools']">
     557        <xsl:text>$LFS</xsl:text>
     558      </xsl:if>
     559      <xsl:text>/jhalfs/test-logs/</xsl:text>
     560      <xsl:value-of select="$testlogfile"/>
     561      <xsl:text>&#xA;echo -e "\n`date`\n" > $TEST_LOG</xsl:text>
     562    </xsl:if>
    526563    <xsl:text>&#xA;&#xA;</xsl:text>
    527564  </xsl:template>
     
    568605    <!-- screen -->
    569606  <xsl:template match="screen">
     607    <xsl:param name="run_this_test" select="foo"/>
    570608    <xsl:if test="child::* = userinput and not(@role = 'nodump')">
    571609      <xsl:call-template name="top_screen_build_fixes"/>
    572       <xsl:apply-templates/>
     610      <xsl:apply-templates>
     611        <xsl:with-param name="run_this_test" select="$run_this_test"/>
     612      </xsl:apply-templates>
    573613      <xsl:call-template name="bottom_screen_build_fixes"/>
    574614      <xsl:text>&#xA;</xsl:text>
    575615    </xsl:if>
     616  </xsl:template>
     617
     618
     619    <!-- userinput @remap='test' -->
     620  <xsl:template match="userinput[@remap='test']">
     621    <xsl:param name="run_this_test" select="foo"/>
     622    <xsl:apply-templates select="." mode="test">
     623      <xsl:with-param name="run_this_test" select="$run_this_test"/>
     624    </xsl:apply-templates>
    576625  </xsl:template>
    577626
     
    592641  <xsl:template match="userinput[@remap='make']">
    593642    <xsl:apply-templates select="." mode="make"/>
    594   </xsl:template>
    595 
    596 
    597     <!-- userinput @remap='test' -->
    598   <xsl:template match="userinput[@remap='test']">
    599     <xsl:apply-templates select="." mode="test"/>
    600643  </xsl:template>
    601644
     
    670713    <!-- mode test  -->
    671714  <xsl:template match="userinput" mode="test">
    672     <xsl:choose>
    673         <!-- No testsuites run on level 0 -->
    674       <xsl:when test="$testsuite = '0'"/>
    675         <!-- On level 1, only final system toolchain testsuites are run -->
    676       <xsl:when test="$testsuite = '1' and
    677                       not(ancestor::sect1[@id='ch-system-gcc']) and
    678                       not(ancestor::sect1[@id='ch-system-glibc']) and
    679                       not(ancestor::sect1[@id='ch-system-binutils'])"/>
    680         <!-- On level 2, temp tools testsuites are not run -->
    681       <xsl:when test="$testsuite = '2' and
    682                       ancestor::chapter[@id='chapter-temporary-tools']"/>
    683         <!-- Start testsuites command fixes -->
    684       <xsl:otherwise>
    685         <xsl:choose>
    686             <!-- Final system Glibc -->
    687           <xsl:when test="contains(string(),'glibc-check-log')">
    688             <xsl:value-of select="substring-before(string(),'2&gt;&amp;1')"/>
    689             <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 || true</xsl:text>
    690           </xsl:when>
    691             <!-- Module-Init-Tools -->
    692           <xsl:when test="ancestor::sect1[@id='ch-system-module-init-tools']
    693                           and contains(string(),'make check')">
    694             <xsl:value-of select="substring-before(string(),' check')"/>
    695             <xsl:if test="$bomb-testsuite = 'n'">
    696               <xsl:text> -k</xsl:text>
    697             </xsl:if>
    698             <xsl:text> check &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
    699             <xsl:if test="$bomb-testsuite = 'n'">
    700               <xsl:text> || true</xsl:text>
    701             </xsl:if>
    702             <xsl:value-of select="substring-after(string(),' check')"/>
    703           </xsl:when>
    704             <!-- If the book uses -k, the testsuite should never bomb -->
    705           <xsl:when test="contains(string(),'make -k ')">
    706             <xsl:apply-templates select="." mode="default"/>
    707             <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true</xsl:text>
    708           </xsl:when>
    709             <!-- Extra commands in Binutils and GCC -->
    710           <xsl:when test="contains(string(),'test_summary') or
    711                           contains(string(),'expect -c')">
    712             <xsl:apply-templates select="." mode="default"/>
    713             <xsl:text> &gt;&gt; $TEST_LOG</xsl:text>
    714           </xsl:when>
    715             <!-- Remaining extra testsuite commads that don't need be hacked -->
    716           <xsl:when test="not(contains(string(),'make '))">
    717             <xsl:apply-templates select="." mode="default"/>
    718           </xsl:when>
    719             <!-- Normal testsites run -->
    720           <xsl:otherwise>
    721             <xsl:choose>
    722                 <!-- No bomb on failures -->
    723               <xsl:when test="$bomb-testsuite = 'n'">
    724                 <xsl:value-of select="substring-before(string(),'make ')"/>
    725                 <xsl:text>make -k </xsl:text>
    726                 <xsl:value-of select="substring-after(string(),'make ')"/>
    727                 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true</xsl:text>
    728               </xsl:when>
    729                 <!-- Bomb at the first failure -->
    730               <xsl:otherwise>
    731                 <xsl:apply-templates select="." mode="default"/>
    732                 <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
    733               </xsl:otherwise>
    734             </xsl:choose>
    735           </xsl:otherwise>
    736         </xsl:choose>
    737       </xsl:otherwise>
    738     </xsl:choose>
     715    <xsl:param name="run_this_test" select="foo"/>
     716    <xsl:if test="$run_this_test = '1'">
     717      <xsl:choose>
     718          <!-- Final system Glibc -->
     719        <xsl:when test="contains(string(),'glibc-check-log')">
     720          <xsl:value-of select="substring-before(string(),'2&gt;&amp;1')"/>
     721          <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 || true</xsl:text>
     722        </xsl:when>
     723          <!-- Module-Init-Tools -->
     724        <xsl:when test="ancestor::sect1[@id='ch-system-module-init-tools']
     725                        and contains(string(),'make check')">
     726          <xsl:value-of select="substring-before(string(),' check')"/>
     727          <xsl:if test="$bomb-testsuite = 'n'">
     728            <xsl:text> -k</xsl:text>
     729          </xsl:if>
     730          <xsl:text> check &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
     731          <xsl:if test="$bomb-testsuite = 'n'">
     732            <xsl:text> || true</xsl:text>
     733          </xsl:if>
     734          <xsl:value-of select="substring-after(string(),' check')"/>
     735        </xsl:when>
     736          <!-- If the book uses -k, the testsuite should never bomb -->
     737        <xsl:when test="contains(string(),'make -k ')">
     738          <xsl:apply-templates select="." mode="default"/>
     739          <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true</xsl:text>
     740        </xsl:when>
     741          <!-- Extra commands in Binutils and GCC -->
     742        <xsl:when test="contains(string(),'test_summary') or
     743                        contains(string(),'expect -c')">
     744          <xsl:apply-templates select="." mode="default"/>
     745          <xsl:text> &gt;&gt; $TEST_LOG</xsl:text>
     746        </xsl:when>
     747          <!-- Remaining extra testsuite commads that don't need be hacked -->
     748        <xsl:when test="not(contains(string(),'make '))">
     749          <xsl:apply-templates select="." mode="default"/>
     750        </xsl:when>
     751          <!-- Normal testsites run -->
     752        <xsl:otherwise>
     753          <xsl:choose>
     754              <!-- No bomb on failures -->
     755            <xsl:when test="$bomb-testsuite = 'n'">
     756              <xsl:value-of select="substring-before(string(),'make ')"/>
     757              <xsl:text>make -k </xsl:text>
     758              <xsl:value-of select="substring-after(string(),'make ')"/>
     759              <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true</xsl:text>
     760            </xsl:when>
     761              <!-- Bomb at the first failure -->
     762            <xsl:otherwise>
     763              <xsl:apply-templates select="." mode="default"/>
     764              <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
     765            </xsl:otherwise>
     766          </xsl:choose>
     767        </xsl:otherwise>
     768      </xsl:choose>
     769    </xsl:if>
    739770  </xsl:template>
    740771
  • LFS/master.sh

    r5a4f6a7 rf5f857d  
    5252        echo "umask 022" >> \$(LUSER_HOME)/.bashrc && \\
    5353        echo "LFS=\$(MOUNT_PT)" >> \$(LUSER_HOME)/.bashrc && \\
    54         echo "SRCDIR=\$(MOUNT_PT)/sources" >> \$(LUSER_HOME)/.bashrc && \\
    5554        echo "LC_ALL=POSIX" >> \$(LUSER_HOME)/.bashrc && \\
    5655        echo "PATH=/tools/bin:/bin:/usr/bin" >> \$(LUSER_HOME)/.bashrc && \\
    5756        echo "export LFS LC_ALL PATH" >> \$(LUSER_HOME)/.bashrc && \\
    5857        echo "source $JHALFSDIR/envars" >> \$(LUSER_HOME)/.bashrc && \\
    59         chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bashrc && \\
    60         touch envars && \\
    61         chown \$(LUSER) envars
     58        chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bashrc
    6259        @\$(call housekeeping)
    6360EOF
     
    9693    esac
    9794
    98     # Grab the package name, if the script is building a package
    99     name=`grep "^PACKAGE=" ${file} | sed -e 's@PACKAGE=@@'`
    100 
    10195    # Set the dependency for the first target.
    10296    if [ -z $PREV ] ; then PREV=04_04-settingenvironment ; fi
     
    109103    # as a dependency. Also call the echo_message function.
    110104    LUSER_wrt_target "${this_script}" "$PREV"
    111 
    112     # If $name isn't empty, we've got a package...
    113     if [ "$name" != "" ] ; then
    114       # If the testsuites must be run, initialize the log file
    115       [[ "$TEST" = "3" ]] && LUSER_wrt_test_log "${this_script}"
    116       # If using optimizations, write the instructions
    117       [[ "$OPTIMIZE" = "2" ]] &&  wrt_optimize "$name" && wrt_makeflags "$name"
    118     fi
    119105
    120106    # Run the script.
     
    176162    esac
    177163
    178     # Grab the name of the target.
     164    # Grab the name of the package, if any.
    179165    name=`grep "^PACKAGE=" ${file} | sed -e 's@PACKAGE=@@'`
    180166
     
    208194    esac
    209195
    210     # If $name isn't empty, we've got a package...
    211     if [ "$name" != "" ] ; then
    212       # Touch timestamp file if installed files logs will be created.
    213       # But only for the firt build when running iterative builds.
    214       if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
    215         CHROOT_wrt_TouchTimestamp
    216       fi
    217       # If the testsuites must be run, initialize the log file
    218       case $name in
    219         binutils | gcc | glibc )
    220           [[ "$TEST" != "0" ]] && CHROOT_wrt_test_log "${this_script}"
    221           ;;
    222         * )
    223           [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && CHROOT_wrt_test_log "${this_script}"
    224           ;;
    225       esac
    226       # If using optimizations, write the instructions
    227       [[ "$OPTIMIZE" != "0" ]] &&  wrt_optimize "$name" && wrt_makeflags "$name"
     196    # Touch timestamp file if installed files logs will be created.
     197    # But only for the firt build when running iterative builds.
     198    if [ "$name" != "" ] && [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
     199      CHROOT_wrt_TouchTimestamp
    228200    fi
    229201
     
    363335            sed -e "s@chroot@$CHROOT_LOC@" \
    364336                -e 's@ \\\@ @g' \
     337                -e 's/  */ /g' \
    365338                -e 's|\\$|&&|g' \
    366339                -e 's|"$$LFS"|$(MOUNT_PT)|' \
  • common/libs/func_wrt_Makefile

    r5a4f6a7 rf5f857d  
    5959
    6060#----------------------------------#
    61 LUSER_wrt_target() {               # Create target and initialize envars file
     61LUSER_wrt_target() {               # Create target
    6262#----------------------------------#
    6363  local i=$1
     
    6969        @\$(call echo_message, Building)
    7070        @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
    71         @rm -f envars && touch envars
    7271EOF
    7372) >> $MKFILE.tmp
     
    8584        @\$(call echo_message, Building)
    8685        @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
    87         @rm -f envars && touch envars
    88 EOF
    89 ) >> $MKFILE.tmp
    90 }
    91 
    92 #=======================
    93 
    94 
    95 #===== TESTS LOGS ======
    96 
    97 #----------------------------------#
    98 LUSER_wrt_test_log() {             # Initialize testsuite log file
    99 #----------------------------------#
    100   local TESTLOGFILE=$1
    101 (
    102 cat  << EOF
    103         @echo "export  TEST_LOG=\$(TESTLOGDIR)/$TESTLOGFILE" >> envars && \\
    104         echo "\$(nl_)\`date\`\$(nl_)" > \$(TESTLOGDIR)/\$@
    105 EOF
    106 ) >> $MKFILE.tmp
    107 }
    108 
    109 #----------------------------------#
    110 CHROOT_wrt_test_log() {            #
    111 #----------------------------------#
    112   local TESTLOGFILE=$1
    113 (
    114 cat  << EOF
    115         @echo "export TEST_LOG=\$(crTESTLOGDIR)/$TESTLOGFILE" >> envars && \\
    116         echo "\$(nl_)\`date\`\$(nl_)" > test-logs/\$@
    11786EOF
    11887) >> $MKFILE.tmp
     
    153122(
    154123cat << EOF
    155         @source ~/.bashrc && \$(CMDSDIR)/`dirname $file`/\$@ > logs/\$@ 2>&1
     124        @\$(CMDSDIR)/`dirname $file`/\$@ > logs/\$@ 2>&1
    156125EOF
    157126) >> $MKFILE.tmp
     
    164133(
    165134cat << EOF
    166         @source envars && \$(crCMDSDIR)/`dirname $file`/\$@ > logs/\$@ 2>&1
     135        @\$(crCMDSDIR)/`dirname $file`/\$@ > logs/\$@ 2>&1
    167136EOF
    168137) >> $MKFILE.tmp
Note: See TracChangeset for help on using the changeset viewer.