r3775 - in jhalfs/trunk: . LFS common common/libs

pierre at higgs.linuxfromscratch.org pierre at higgs.linuxfromscratch.org
Sun Jan 12 13:40:20 PST 2014


Author: pierre
Date: Sun Jan 12 13:40:20 2014
New Revision: 3775

Log:
Major change to th scripts layout:
- Do not put the chroot commands in $PROGNAME-commands, but rather
  in a separate directory chroot-scripts
- Use the commands in the chroot-scripts directory to generate the CHROOT
  variables in Makefile
- The commands are extracted to $PROGNAME-commands only if they do not
  have role="nodump attribute and they do not begin with "chroot" (for
  compatibility with previous books where chroot commands did not have
  the role="nodump" attribute.

Added:
   jhalfs/trunk/common/chroot.xsl   (contents, props changed)
Modified:
   jhalfs/trunk/LFS/lfs.xsl
   jhalfs/trunk/LFS/master.sh
   jhalfs/trunk/common/libs/func_book_parser
   jhalfs/trunk/jhalfs

Modified: jhalfs/trunk/LFS/lfs.xsl
==============================================================================
--- jhalfs/trunk/LFS/lfs.xsl	Wed Jan  1 01:49:25 2014	(r3774)
+++ jhalfs/trunk/LFS/lfs.xsl	Sun Jan 12 13:40:20 2014	(r3775)
@@ -54,7 +54,12 @@
                   ../@id='chapter-bootable') and
                   count(descendant::screen/userinput) > 0 and
                   count(descendant::screen/userinput) >
-                      count(descendant::screen[@role='nodump'])">
+                      count(descendant::screen[@role='nodump']) and
+                  count(descendant::screen/userinput) >
+                      count(descendant::screen/userinput[starts-with(string(),'chroot')])">
+<!-- The last condition is a hack to allow previous versions of the
+     book where the chroot commands did not have role="nodump".
+     It only works if the chroot command is the only one on the page -->
         <!-- The dirs names -->
       <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
       <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
@@ -133,27 +138,13 @@
                                        @id='ch-pkgmngt-createfiles'
                                                         ]//userinput"/>
       </xsl:if>
-      <xsl:if test="not(@id='ch-system-chroot') and
-                    not(@id='ch-system-revisedchroot')">
-        <xsl:text>echo -e "\n\nTotalseconds: $SECONDS\n"&#xA;</xsl:text>
-      </xsl:if>
+      <xsl:text>echo -e "\n\nTotalseconds: $SECONDS\n"&#xA;</xsl:text>
       <xsl:text>exit&#xA;</xsl:text>
     </exsl:document>
     </xsl:if>
   </xsl:template>
 
   <xsl:template match="sect2">
-    <!--XML::Parser is on the same page as Perl. The present code is OK
-        except for PKG_DEST and PKGDIR, which would be the same as for Perl.
-        so set them to valid values.
-        Since rev 10281, that is no more true. So comment out.
-    <xsl:if test="contains(string(./title),'XML::Parser')">
-      <xsl:text>PKGDIR=$(dirname $PKGDIR)/</xsl:text>
-      <xsl:copy-of select="substring-after(.//userinput[@remap='pre'], 'cd ')"/>
-      <xsl:text>
-PKG_DEST=$(dirname $PKGDIR)/000-xml-parser
-</xsl:text>
-    </xsl:if>-->
     <xsl:apply-templates
       select=".//screen[not(@role) or
                         @role != 'nodump']/userinput[

Modified: jhalfs/trunk/LFS/master.sh
==============================================================================
--- jhalfs/trunk/LFS/master.sh	Wed Jan  1 01:49:25 2014	(r3774)
+++ jhalfs/trunk/LFS/master.sh	Sun Jan 12 13:40:20 2014	(r3775)
@@ -197,11 +197,9 @@
     # Keep the script file name
     this_script=`basename $file`
 
-    # We'll run the chroot commands differently than the others, so skip them in the
-    # dependencies and target creation.
+    # Skip the "stripping" scripts if the user does not want to strip.
     # Skip also linux-headers in iterative builds.
     case "${this_script}" in
-      *chroot)      continue ;;
       *stripping*) [[ "${STRIP}" = "n" ]] && continue ;;
       *linux-headers*) [[ -n "$N" ]] && continue ;;
     esac
@@ -209,9 +207,8 @@
     # Grab the name of the target.
     name=`echo ${this_script} | sed -e 's@[0-9]\{3\}-@@' -e 's,'$N',,'`
 
-    # Find the version of the command files, if it corresponds with the building of
-    # a specific package. We need this here to can skip scripts not needed for
-    # iterations rebuilds
+    # Find the tarball corresponding to our script.
+    # If it doesn't, we skip it in iterations rebuilds (except stripping).
     pkg_tarball=$(get_package_tarball_name $name)
     pkg_version=$(get_package_version $pkg_tarball)
 
@@ -255,10 +252,12 @@
       # If the testsuites must be run, initialize the log file
       case $name in
         binutils | gcc | glibc | gmp | mpfr )
-          [[ "$TEST" != "0" ]] && CHROOT_wrt_test_log "${this_script}" "$pkg_version"
+          [[ "$TEST" != "0" ]] &&
+             CHROOT_wrt_test_log "${this_script}" "$pkg_version"
           ;;
         * )
-          [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && CHROOT_wrt_test_log "${this_script}" "$pkg_version"
+          [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] &&
+             CHROOT_wrt_test_log "${this_script}" "$pkg_version"
           ;;
       esac
       # If using optimizations, write the instructions
@@ -432,7 +431,7 @@
   # Add chroot commands
   CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
   i=1
-  for file in chapter06/*chroot* ; do
+  for file in ../chroot-scripts/*chroot* ; do
     chroot=`cat $file | \
             sed -e "s at chroot@$CHROOT_LOC@" \
                 -e '/#!\/bin\/bash/d' \
@@ -441,7 +440,6 @@
             sed -e 's/  */ /g' \
                 -e 's|\\$|&&|g' \
                 -e 's|exit||g' \
-                -e 's|$| -c|' \
                 -e 's|"$$LFS"|$(MOUNT_PT)|' \
                 -e 's|set -e||' \
                 -e 's|set +h||'`
@@ -494,18 +492,18 @@
 
 mk_CHROOT: mk_SUDO
 	@\$(call echo_CHROOT_request)
-	@( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CHROOT")
+	@( sudo \$(CHROOT1) -c "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CHROOT")
 	@touch \$@
 
 mk_BOOT: mk_CHROOT
 	@\$(call echo_CHROOT_request)
-	@( sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BOOT")
+	@( sudo \$(CHROOT2) -c "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BOOT")
 	@touch \$@
 
 mk_BLFS_TOOL: create-sbu_du-report
 	@if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
 	  \$(call sh_echo_PHASE,Building BLFS_TOOL); \\
-	  (sudo \$(CHROOT2) "make -C $BLFS_ROOT/work"); \\
+	  (sudo \$(CHROOT2) -c "make -C $BLFS_ROOT/work"); \\
 	fi;
 	@touch \$@
 
@@ -513,7 +511,7 @@
 	@if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
 	  \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
 	  sudo mkdir -p ${BUILDDIR}${TRACKING_DIR}; \\
-	  (sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
+	  (sudo \$(CHROOT2) -c "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
 	fi;
 	@touch \$@
 
@@ -545,10 +543,7 @@
 	sudo umount -v \$(MOUNT_PT)/dev
 
 chroot: devices
-	sudo /usr/sbin/chroot \$(MOUNT_PT) /tools/bin/env -i \\
-      HOME=/root TERM=\$(TERM) PS1='\\u:\\w\\\$\$ ' \\
-      PATH=/bin:/usr/bin:/sbin:/usr/sbin \\
-      /tools/bin/bash --login
+	sudo \$(CHROOT2)
 	\$(MAKE) teardown
 
 SETUP:        $chapter4

Added: jhalfs/trunk/common/chroot.xsl
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ jhalfs/trunk/common/chroot.xsl	Sun Jan 12 13:40:20 2014	(r3775)
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!-- $Id: lfs.xsl 3705 2013-05-21 20:20:24Z pierre $ -->
+
+<xsl:stylesheet
+      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+      xmlns:exsl="http://exslt.org/common"
+      extension-element-prefixes="exsl"
+      version="1.0">
+
+  <xsl:template match="/">
+    <xsl:apply-templates select="//sect1"/>
+  </xsl:template>
+
+  <xsl:template match="sect1">
+    <xsl:if
+         test="descendant::screen/userinput[starts-with(string(),'chroot')]">
+   <!-- The file names -->
+      <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
+      <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
+      <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
+      <!-- The build order -->
+      <xsl:variable name="position" select="position()"/>
+      <xsl:variable name="order">
+        <xsl:choose>
+          <xsl:when test="string-length($position) = 1">
+            <xsl:text>00</xsl:text>
+            <xsl:value-of select="$position"/>
+          </xsl:when>
+          <xsl:when test="string-length($position) = 2">
+            <xsl:text>0</xsl:text>
+            <xsl:value-of select="$position"/>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:value-of select="$position"/>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:variable>
+      <!-- Creating dirs and files -->
+      <exsl:document href="{$order}-{$filename}" method="text">
+        <xsl:text>#!/bin/bash&#xA;</xsl:text>
+      <xsl:apply-templates select=".//userinput[starts-with(string(),'chroot')]"/>
+      <xsl:text>exit&#xA;</xsl:text>
+    </exsl:document>
+    </xsl:if>
+  </xsl:template>
+
+  <xsl:template match="userinput">
+    <xsl:apply-templates/>
+    <xsl:text>&#xA;</xsl:text>
+  </xsl:template>
+</xsl:stylesheet>

Modified: jhalfs/trunk/common/libs/func_book_parser
==============================================================================
--- jhalfs/trunk/common/libs/func_book_parser	Wed Jan  1 01:49:25 2014	(r3774)
+++ jhalfs/trunk/common/libs/func_book_parser	Sun Jan 12 13:40:20 2014	(r3775)
@@ -16,7 +16,7 @@
     case $PROGNAME in
       lfs) svn_root="LFS" ;;
       hlfs) svn_root="HLFS" ;;
-      clfs*) svn_root="cross-lfs" ;;
+      clfs*) ;;
       *) echo "BOOK not defined in function <get_book>"
           exit 1 ;;
     esac
@@ -56,10 +56,6 @@
 extract_commands() {         #
 #----------------------------#
 
-  # Check for libxslt instead of just letting the script hit 'xsltproc' and fail.
-  test `type -p xsltproc` || eval "echo \"This feature requires libxslt.\"
-  exit 1"
-
   cd $JHALFSDIR
   case $PROGNAME in
     clfs*)
@@ -68,14 +64,11 @@
       VERSION=$(xmllint --noent $BOOK/prologue/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //'  -e 's/<\/.*//')  ;;
   esac
 
-  # Start clean
-  if [ -d ${PROGNAME}-commands ]; then
-    rm -rf ${PROGNAME}-commands
-    mkdir -v ${PROGNAME}-commands
-  fi
-  echo -n "Extracting commands for"
+  # Clean
+  rm -rf ${PROGNAME}-commands
 
-  # Dump the commands in shell script form from the HLFS book.
+  # Extract the commands
+  echo -n "Extracting commands for"
   case ${PROGNAME} in
     clfs)
         echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
@@ -148,7 +141,7 @@
                  --stringparam pkgmngt $PKGMNGT \
                  -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
       ;;
-    *)  echo -n " ${L_arrow}${BOLD}${PROGNAME}${R_arrow} book invalid, terminate build... "
+    *)  echo -n " ${L_arrow}${PROGNAME}${R_arrow} book invalid, terminate build... "
         exit 1 ;;
   esac
 
@@ -159,6 +152,7 @@
 
   # Create the packages file. We need it for proper Makefile creation
   create_package_list
+  create_chroot_scripts
 
   # Done. Moving on...
   get_sources
@@ -195,28 +189,36 @@
     *)
   esac
 
-  if [[ "${BLFS_TOOL}" = "y" ]] ; then
-(
-cat << EOF
-$LIBXML_PKG
-$LIBXSLT_PKG
-$TIDY_PKG
-$UNZIP_PKG
-$DBXML_PKG
-$DBXSL_PKG
-$LYNX_PKG
-$SUDO_PKG
-$WGET_PKG
-$SQLITE_PKG
-$APR_PKG
-$APR_U_PKG
-$SVN_PKG
-$GPM_PKG
-EOF
-) >> pkg_tarball_list
-  fi
-
   echo "done"
 
 }
 
+#----------------------------#
+create_chroot_scripts() {      #
+#----------------------------#
+
+  rm -rf chroot_scripts
+  echo -n "Creating chroot commands scripts from $BOOK"
+  if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
+  echo -n "... "
+  case ${PROGNAME} in
+    clfs*)
+      xsltproc --nonet --xinclude \
+               -o chroot-scripts/ chroot.xsl \
+               $BOOK/BOOK/${ARCH}-index.xml >> $LOGDIR/$LOG 2>&1
+      ;;
+    hlfs)
+      xsltproc --nonet --xinclude \
+               -o chroot-scripts/ chroot.xsl \
+               $BOOK/index.xml >> $LOGDIR/$LOG 2>&1
+      ;;
+    lfs)
+      xsltproc --nonet --xinclude \
+               -o chroot-scripts/ chroot.xsl \
+               $BOOK/chapter06/chapter06.xml >> $LOGDIR/$LOG 2>&1
+      ;;
+    *)
+  esac
+  echo "done"
+
+}

Modified: jhalfs/trunk/jhalfs
==============================================================================
--- jhalfs/trunk/jhalfs	Wed Jan  1 01:49:25 2014	(r3774)
+++ jhalfs/trunk/jhalfs	Sun Jan 12 13:40:20 2014	(r3775)
@@ -357,7 +357,9 @@
   >$LOGDIR/$LOG
   #
   # Copy common helper files
-  cp $COMMON_DIR/{makefile-functions,progress_bar.sh,packages.xsl} $JHALFSDIR/
+  cp $COMMON_DIR/{makefile-functions,progress_bar.sh} $JHALFSDIR/
+  # Copy needed stylesheets
+  cp $COMMON_DIR/{packages.xsl,chroot.xsl} $JHALFSDIR/
   #
   # Fix the XSL book parser
   case $PROGNAME in



More information about the alfs-log mailing list