r3490 - in jhalfs/branches/experimental: LFS common/libs

manuel at linuxfromscratch.org manuel at linuxfromscratch.org
Tue Sep 25 14:34:03 PDT 2007


Author: manuel
Date: 2007-09-25 15:34:03 -0600 (Tue, 25 Sep 2007)
New Revision: 3490

Modified:
   jhalfs/branches/experimental/LFS/lfs.xsl
   jhalfs/branches/experimental/LFS/master.sh
   jhalfs/branches/experimental/common/libs/func_wrt_Makefile
Log:
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.

Modified: jhalfs/branches/experimental/LFS/lfs.xsl
===================================================================
--- jhalfs/branches/experimental/LFS/lfs.xsl	2007-09-25 19:12:36 UTC (rev 3489)
+++ jhalfs/branches/experimental/LFS/lfs.xsl	2007-09-25 21:34:03 UTC (rev 3490)
@@ -47,6 +47,7 @@
 <!-- ####################################################################### -->
 
 <!-- ########### NAMED USER TEMPLATES TO ALLOW CUSTOMIZATIONS ############## -->
+<!-- ############ Maybe should be placed on a separate file ################ -->
 
     <!-- Hock for user header additions -->
   <xsl:template name="user_header">
@@ -144,7 +145,8 @@
 
 
     <!-- Hock for creating a custom tools directory containing scripts
-         to be run after the system has been built -->
+         to be run after the system has been built
+         (to be moved to a separate file) -->
   <xsl:template name="custom-tools">
       <!-- Fixed directory and ch_order values -->
     <xsl:variable name="basedir">custom-tools/20_</xsl:variable>
@@ -245,15 +247,11 @@
     <!-- Enter to the sources dir, clean it, unpack the tarball,
          and reset the seconds counter -->
   <xsl:template name="unpack">
-    <xsl:choose>
-      <xsl:when test="ancestor::chapter[@id='chapter-temporary-tools']">
-        <xsl:text>cd $SRCDIR</xsl:text>
-      </xsl:when>
-      <xsl:otherwise>
-        <xsl:text>cd /sources</xsl:text>
-      </xsl:otherwise>
-    </xsl:choose>
-    <xsl:text>
+    <xsl:text>cd </xsl:text>
+    <xsl:if test="ancestor::chapter[@id='chapter-temporary-tools']">
+      <xsl:text>$LFS</xsl:text>
+    </xsl:if>
+    <xsl:text>/sources
 PKGDIR=`tar -tf $TARBALL | head -n1 | sed -e 's@^./@@;s@/.*@@'`
 if [ -d $PKGDIR ]; then
   rm -rf $PKGDIR
@@ -291,15 +289,11 @@
 
     <!-- Remove sources and build dirs, skipping it from seconds meassurament -->
   <xsl:template name="clean_sources">
-    <xsl:choose>
-      <xsl:when test="ancestor::chapter[@id='chapter-temporary-tools']">
-        <xsl:text>cd $SRCDIR</xsl:text>
-      </xsl:when>
-      <xsl:otherwise>
-        <xsl:text>cd /sources</xsl:text>
-      </xsl:otherwise>
-    </xsl:choose>
-    <xsl:text>
+    <xsl:text>cd </xsl:text>
+    <xsl:if test="ancestor::chapter[@id='chapter-temporary-tools']">
+      <xsl:text>$LFS</xsl:text>
+    </xsl:if>
+    <xsl:text>/sources
 SECS=$SECONDS
 rm -rf $PKGDIR
 rm -rf ${PKGDIR%-*}-build
@@ -367,7 +361,30 @@
   </xsl:template>
 
 
-    <!-- Adds blfs-tool support scripts -->
+    <!-- Check if a package testsuite must be run -->
+  <xsl:template name="run_this_test">
+    <xsl:choose>
+      <xsl:when test=".//userinput[@remap='test']">
+        <xsl:choose>
+            <!-- No testsuites run on level 0 -->
+          <xsl:when test="$testsuite = '0'">0</xsl:when>
+            <!-- On level 1, only final system toolchain testsuites are run -->
+          <xsl:when test="$testsuite = '1' and
+                          not(@id='ch-system-gcc') and
+                          not(@id='ch-system-glibc') and
+                          not(@id='ch-system-binutils')">0</xsl:when>
+            <!-- On level 2, temp tools testsuites are not run -->
+          <xsl:when test="$testsuite = '2' and
+                          ../@id='chapter-temporary-tools'">0</xsl:when>
+          <xsl:otherwise>1</xsl:otherwise>
+        </xsl:choose>
+      </xsl:when>
+      <xsl:otherwise>0</xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
+
+    <!-- Adds blfs-tool support scripts (to be moved to a separate file) -->
   <xsl:template name="blfs-tool">
       <!-- Fixed directory and ch_order values -->
     <xsl:variable name="basedir">blfs-tool-deps/30_</xsl:variable>
@@ -475,6 +492,10 @@
       </xsl:variable>
         <!-- Script build order -->
       <xsl:variable name="order" select="concat($dirname,'/',$ch_order,'_',$sect1_order)"/>
+        <!-- Must the package test suite, if any, be run? -->
+      <xsl:variable name="run_this_test">
+        <xsl:call-template name="run_this_test"/>
+      </xsl:variable>
         <!-- Hock to insert scripts before the current one -->
       <xsl:call-template name="insert_script_before">
         <xsl:with-param name="reference" select="@id"/>
@@ -486,6 +507,8 @@
         <xsl:call-template name="user_header"/>
         <xsl:apply-templates select="sect1info[@condition='script']">
           <xsl:with-param name="phase" select="$filename"/>
+          <xsl:with-param name="run_this_test" select="$run_this_test"/>
+          <xsl:with-param name="testlogfile" select="concat($ch_order,'_',$sect1_order,'-',$filename)"/>
         </xsl:apply-templates>
         <xsl:call-template name="disk_usage"/>
         <xsl:if test="sect2[@role='installation']">
@@ -493,7 +516,9 @@
         </xsl:if>
         <xsl:call-template name="user_pre_commands"/>
         <xsl:call-template name="pre_commands"/>
-        <xsl:apply-templates select=".//screen"/>
+        <xsl:apply-templates select=".//screen">
+          <xsl:with-param name="run_this_test" select="$run_this_test"/>
+        </xsl:apply-templates>
         <xsl:call-template name="post_commands"/>
         <xsl:call-template name="user_footer"/>
         <xsl:call-template name="disk_usage"/>
@@ -513,6 +538,9 @@
 
     <!-- sect1info -->
   <xsl:template match="sect1info">
+      <!-- Used to set and initialize the testuite log file -->
+    <xsl:param name="testlogfile" select="foo"/>
+    <xsl:param name="run_this_test" select="foo"/>
       <!-- Build phase (base file name) to be used for PM -->
     <xsl:param name="phase" select="foo"/>
     <xsl:text>&#xA;PKG_PHASE=</xsl:text>
@@ -523,6 +551,15 @@
     <xsl:apply-templates select="productnumber"/>
       <!-- Tarball name -->
     <xsl:apply-templates select="address"/>
+    <xsl:if test="$run_this_test = '1'">
+      <xsl:text>&#xA;TEST_LOG=</xsl:text>
+      <xsl:if test="ancestor::chapter[@id='chapter-temporary-tools']">
+        <xsl:text>$LFS</xsl:text>
+      </xsl:if>
+      <xsl:text>/jhalfs/test-logs/</xsl:text>
+      <xsl:value-of select="$testlogfile"/>
+      <xsl:text>&#xA;echo -e "\n`date`\n" > $TEST_LOG</xsl:text>
+    </xsl:if>
     <xsl:text>&#xA;&#xA;</xsl:text>
   </xsl:template>
 
@@ -567,15 +604,27 @@
 
     <!-- screen -->
   <xsl:template match="screen">
+    <xsl:param name="run_this_test" select="foo"/>
     <xsl:if test="child::* = userinput and not(@role = 'nodump')">
       <xsl:call-template name="top_screen_build_fixes"/>
-      <xsl:apply-templates/>
+      <xsl:apply-templates>
+        <xsl:with-param name="run_this_test" select="$run_this_test"/>
+      </xsl:apply-templates>
       <xsl:call-template name="bottom_screen_build_fixes"/>
       <xsl:text>&#xA;</xsl:text>
     </xsl:if>
   </xsl:template>
 
 
+    <!-- userinput @remap='test' -->
+  <xsl:template match="userinput[@remap='test']">
+    <xsl:param name="run_this_test" select="foo"/>
+    <xsl:apply-templates select="." mode="test">
+      <xsl:with-param name="run_this_test" select="$run_this_test"/>
+    </xsl:apply-templates>
+  </xsl:template>
+
+
     <!-- userinput @remap='pre' -->
   <xsl:template match="userinput[@remap='pre']">
     <xsl:apply-templates select="." mode="pre"/>
@@ -594,12 +643,6 @@
   </xsl:template>
 
 
-    <!-- userinput @remap='test' -->
-  <xsl:template match="userinput[@remap='test']">
-    <xsl:apply-templates select="." mode="test"/>
-  </xsl:template>
-
-
     <!-- userinput @remap='install' -->
   <xsl:template match="userinput[@remap='install']">
     <xsl:apply-templates select="." mode="install"/>
@@ -669,73 +712,61 @@
 
     <!-- mode test  -->
   <xsl:template match="userinput" mode="test">
-    <xsl:choose>
-        <!-- No testsuites run on level 0 -->
-      <xsl:when test="$testsuite = '0'"/>
-        <!-- On level 1, only final system toolchain testsuites are run -->
-      <xsl:when test="$testsuite = '1' and
-                      not(ancestor::sect1[@id='ch-system-gcc']) and
-                      not(ancestor::sect1[@id='ch-system-glibc']) and
-                      not(ancestor::sect1[@id='ch-system-binutils'])"/>
-        <!-- On level 2, temp tools testsuites are not run -->
-      <xsl:when test="$testsuite = '2' and
-                      ancestor::chapter[@id='chapter-temporary-tools']"/>
-        <!-- Start testsuites command fixes -->
-      <xsl:otherwise>
-        <xsl:choose>
-            <!-- Final system Glibc -->
-          <xsl:when test="contains(string(),'glibc-check-log')">
-            <xsl:value-of select="substring-before(string(),'2>&1')"/>
-            <xsl:text>>> $TEST_LOG 2>&1 || true</xsl:text>
-          </xsl:when>
-            <!-- Module-Init-Tools -->
-          <xsl:when test="ancestor::sect1[@id='ch-system-module-init-tools']
-                          and contains(string(),'make check')">
-            <xsl:value-of select="substring-before(string(),' check')"/>
-            <xsl:if test="$bomb-testsuite = 'n'">
-              <xsl:text> -k</xsl:text>
-            </xsl:if>
-            <xsl:text> check >> $TEST_LOG 2>&1</xsl:text>
-            <xsl:if test="$bomb-testsuite = 'n'">
-              <xsl:text> || true</xsl:text>
-            </xsl:if>
-            <xsl:value-of select="substring-after(string(),' check')"/>
-          </xsl:when>
-            <!-- If the book uses -k, the testsuite should never bomb -->
-          <xsl:when test="contains(string(),'make -k ')">
-            <xsl:apply-templates select="." mode="default"/>
-            <xsl:text> >> $TEST_LOG 2>&1 || true</xsl:text>
-          </xsl:when>
-            <!-- Extra commands in Binutils and GCC -->
-          <xsl:when test="contains(string(),'test_summary') or
-                          contains(string(),'expect -c')">
-            <xsl:apply-templates select="." mode="default"/>
-            <xsl:text> >> $TEST_LOG</xsl:text>
-          </xsl:when>
-            <!-- Remaining extra testsuite commads that don't need be hacked -->
-          <xsl:when test="not(contains(string(),'make '))">
-            <xsl:apply-templates select="." mode="default"/>
-          </xsl:when>
-            <!-- Normal testsites run -->
-          <xsl:otherwise>
-            <xsl:choose>
-                <!-- No bomb on failures -->
-              <xsl:when test="$bomb-testsuite = 'n'">
-                <xsl:value-of select="substring-before(string(),'make ')"/>
-                <xsl:text>make -k </xsl:text>
-                <xsl:value-of select="substring-after(string(),'make ')"/>
-                <xsl:text> >> $TEST_LOG 2>&1 || true</xsl:text>
-              </xsl:when>
-                <!-- Bomb at the first failure -->
-              <xsl:otherwise>
-                <xsl:apply-templates select="." mode="default"/>
-                <xsl:text> >> $TEST_LOG 2>&1</xsl:text>
-              </xsl:otherwise>
-            </xsl:choose>
-          </xsl:otherwise>
-        </xsl:choose>
-      </xsl:otherwise>
-    </xsl:choose>
+    <xsl:param name="run_this_test" select="foo"/>
+    <xsl:if test="$run_this_test = '1'">
+      <xsl:choose>
+          <!-- Final system Glibc -->
+        <xsl:when test="contains(string(),'glibc-check-log')">
+          <xsl:value-of select="substring-before(string(),'2>&1')"/>
+          <xsl:text>>> $TEST_LOG 2>&1 || true</xsl:text>
+        </xsl:when>
+          <!-- Module-Init-Tools -->
+        <xsl:when test="ancestor::sect1[@id='ch-system-module-init-tools']
+                        and contains(string(),'make check')">
+          <xsl:value-of select="substring-before(string(),' check')"/>
+          <xsl:if test="$bomb-testsuite = 'n'">
+            <xsl:text> -k</xsl:text>
+          </xsl:if>
+          <xsl:text> check >> $TEST_LOG 2>&1</xsl:text>
+          <xsl:if test="$bomb-testsuite = 'n'">
+            <xsl:text> || true</xsl:text>
+          </xsl:if>
+          <xsl:value-of select="substring-after(string(),' check')"/>
+        </xsl:when>
+          <!-- If the book uses -k, the testsuite should never bomb -->
+        <xsl:when test="contains(string(),'make -k ')">
+          <xsl:apply-templates select="." mode="default"/>
+          <xsl:text> >> $TEST_LOG 2>&1 || true</xsl:text>
+        </xsl:when>
+          <!-- Extra commands in Binutils and GCC -->
+        <xsl:when test="contains(string(),'test_summary') or
+                        contains(string(),'expect -c')">
+          <xsl:apply-templates select="." mode="default"/>
+          <xsl:text> >> $TEST_LOG</xsl:text>
+        </xsl:when>
+          <!-- Remaining extra testsuite commads that don't need be hacked -->
+        <xsl:when test="not(contains(string(),'make '))">
+          <xsl:apply-templates select="." mode="default"/>
+        </xsl:when>
+          <!-- Normal testsites run -->
+        <xsl:otherwise>
+          <xsl:choose>
+              <!-- No bomb on failures -->
+            <xsl:when test="$bomb-testsuite = 'n'">
+              <xsl:value-of select="substring-before(string(),'make ')"/>
+              <xsl:text>make -k </xsl:text>
+              <xsl:value-of select="substring-after(string(),'make ')"/>
+              <xsl:text> >> $TEST_LOG 2>&1 || true</xsl:text>
+            </xsl:when>
+              <!-- Bomb at the first failure -->
+            <xsl:otherwise>
+              <xsl:apply-templates select="." mode="default"/>
+              <xsl:text> >> $TEST_LOG 2>&1</xsl:text>
+            </xsl:otherwise>
+          </xsl:choose>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:if>
   </xsl:template>
 
 

Modified: jhalfs/branches/experimental/LFS/master.sh
===================================================================
--- jhalfs/branches/experimental/LFS/master.sh	2007-09-25 19:12:36 UTC (rev 3489)
+++ jhalfs/branches/experimental/LFS/master.sh	2007-09-25 21:34:03 UTC (rev 3490)
@@ -51,14 +51,11 @@
 	@echo "set +h" > \$(LUSER_HOME)/.bashrc && \\
 	echo "umask 022" >> \$(LUSER_HOME)/.bashrc && \\
 	echo "LFS=\$(MOUNT_PT)" >> \$(LUSER_HOME)/.bashrc && \\
-	echo "SRCDIR=\$(MOUNT_PT)/sources" >> \$(LUSER_HOME)/.bashrc && \\
 	echo "LC_ALL=POSIX" >> \$(LUSER_HOME)/.bashrc && \\
 	echo "PATH=/tools/bin:/bin:/usr/bin" >> \$(LUSER_HOME)/.bashrc && \\
 	echo "export LFS LC_ALL PATH" >> \$(LUSER_HOME)/.bashrc && \\
 	echo "source $JHALFSDIR/envars" >> \$(LUSER_HOME)/.bashrc && \\
-	chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bashrc && \\
-	touch envars && \\
-	chown \$(LUSER) envars
+	chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bashrc
 	@\$(call housekeeping)
 EOF
 ) > $MKFILE.tmp
@@ -95,9 +92,6 @@
                    *) chapter5="$chapter5 ${this_script}" ;;
     esac
 
-    # Grab the package name, if the script is building a package
-    name=`grep "^PACKAGE=" ${file} | sed -e 's at PACKAGE=@@'`
-
     # Set the dependency for the first target.
     if [ -z $PREV ] ; then PREV=04_04-settingenvironment ; fi
 
@@ -109,14 +103,6 @@
     # as a dependency. Also call the echo_message function.
     LUSER_wrt_target "${this_script}" "$PREV"
 
-    # If $name isn't empty, we've got a package...
-    if [ "$name" != "" ] ; then
-      # If the testsuites must be run, initialize the log file
-      [[ "$TEST" = "3" ]] && LUSER_wrt_test_log "${this_script}"
-      # If using optimizations, write the instructions
-      [[ "$OPTIMIZE" = "2" ]] &&  wrt_optimize "$name" && wrt_makeflags "$name"
-    fi
-
     # Run the script.
     # The changingowner script must be run as root.
     case "${this_script}" in
@@ -175,7 +161,7 @@
       *linux-headers*) [[ -n "$N" ]] && continue ;;
     esac
 
-    # Grab the name of the target.
+    # Grab the name of the package, if any.
     name=`grep "^PACKAGE=" ${file} | sed -e 's at PACKAGE=@@'`
 
     # Skip scripts not needed for iterations rebuilds
@@ -207,24 +193,10 @@
       *)        CHROOT_wrt_target "${this_script}" "$PREV" ;;
     esac
 
-    # If $name isn't empty, we've got a package...
-    if [ "$name" != "" ] ; then
-      # Touch timestamp file if installed files logs will be created.
-      # But only for the firt build when running iterative builds.
-      if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
-        CHROOT_wrt_TouchTimestamp
-      fi
-      # If the testsuites must be run, initialize the log file
-      case $name in
-        binutils | gcc | glibc )
-          [[ "$TEST" != "0" ]] && CHROOT_wrt_test_log "${this_script}"
-          ;;
-        * )
-          [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && CHROOT_wrt_test_log "${this_script}"
-          ;;
-      esac
-      # If using optimizations, write the instructions
-      [[ "$OPTIMIZE" != "0" ]] &&  wrt_optimize "$name" && wrt_makeflags "$name"
+    # Touch timestamp file if installed files logs will be created.
+    # But only for the firt build when running iterative builds.
+    if [ "$name" != "" ] && [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
+      CHROOT_wrt_TouchTimestamp
     fi
 
     # In the mount of kernel filesystems we need to set LFS
@@ -362,6 +334,7 @@
     chroot=`cat $file | tr -d '\n' | \
             sed -e "s at chroot@$CHROOT_LOC@" \
                 -e 's@ \\\@ @g' \
+                -e 's/  */ /g' \
                 -e 's|\\$|&&|g' \
                 -e 's|"$$LFS"|$(MOUNT_PT)|' \
                 -e 's|$| -c|'`

Modified: jhalfs/branches/experimental/common/libs/func_wrt_Makefile
===================================================================
--- jhalfs/branches/experimental/common/libs/func_wrt_Makefile	2007-09-25 19:12:36 UTC (rev 3489)
+++ jhalfs/branches/experimental/common/libs/func_wrt_Makefile	2007-09-25 21:34:03 UTC (rev 3490)
@@ -58,7 +58,7 @@
 #==== TARGET HEADER ====
 
 #----------------------------------#
-LUSER_wrt_target() {               # Create target and initialize envars file
+LUSER_wrt_target() {               # Create target
 #----------------------------------#
   local i=$1
   local PREV=$2
@@ -68,7 +68,6 @@
 $i:  $PREV
 	@\$(call echo_message, Building)
 	@export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
-	@rm -f envars && touch envars
 EOF
 ) >> $MKFILE.tmp
 }
@@ -84,7 +83,6 @@
 $i:  $PREV
 	@\$(call echo_message, Building)
 	@export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
-	@rm -f envars && touch envars
 EOF
 ) >> $MKFILE.tmp
 }
@@ -92,35 +90,6 @@
 #=======================
 
 
-#===== TESTS LOGS ======
-
-#----------------------------------#
-LUSER_wrt_test_log() {             # Initialize testsuite log file
-#----------------------------------#
-  local TESTLOGFILE=$1
-(
-cat  << EOF
-	@echo "export  TEST_LOG=\$(TESTLOGDIR)/$TESTLOGFILE" >> envars && \\
-	echo "\$(nl_)\`date\`\$(nl_)" > \$(TESTLOGDIR)/\$@
-EOF
-) >> $MKFILE.tmp
-}
-
-#----------------------------------#
-CHROOT_wrt_test_log() {            #
-#----------------------------------#
-  local TESTLOGFILE=$1
-(
-cat  << EOF
-	@echo "export TEST_LOG=\$(crTESTLOGDIR)/$TESTLOGFILE" >> envars && \\
-	echo "\$(nl_)\`date\`\$(nl_)" > test-logs/\$@
-EOF
-) >> $MKFILE.tmp
-}
-
-#=======================
-
-
 #======== RUN AS =======
 
 #----------------------------------#
@@ -152,7 +121,7 @@
 
 (
 cat << EOF
-	@source ~/.bashrc && \$(CMDSDIR)/`dirname $file`/\$@ > logs/\$@ 2>&1
+	@\$(CMDSDIR)/`dirname $file`/\$@ > logs/\$@ 2>&1
 EOF
 ) >> $MKFILE.tmp
 }
@@ -163,7 +132,7 @@
   local file=$1
 (
 cat << EOF
-	@source envars && \$(crCMDSDIR)/`dirname $file`/\$@ > logs/\$@ 2>&1
+	@\$(crCMDSDIR)/`dirname $file`/\$@ > logs/\$@ 2>&1
 EOF
 ) >> $MKFILE.tmp
 




More information about the alfs-log mailing list