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.
This commit is contained in:
Pierre Labastie 2014-01-12 21:40:20 +00:00
parent 7735c7ae5e
commit d68eb1b205
5 changed files with 111 additions and 69 deletions

View file

@ -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>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[

View file

@ -197,11 +197,9 @@ chapter6_Makefiles() {
# 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 @@ chapter6_Makefiles() {
# 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 @@ chapter6_Makefiles() {
# 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 @@ build_Makefile() { #
# 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@chroot@$CHROOT_LOC@" \
-e '/#!\/bin\/bash/d' \
@ -441,7 +440,6 @@ build_Makefile() { #
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_SUDO: mk_LUSER
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 @@ mk_CUSTOM_TOOLS: mk_BLFS_TOOL
@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 @@ teardown:
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

52
common/chroot.xsl Normal file
View file

@ -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>

View file

@ -16,7 +16,7 @@ get_book() { #
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 @@ get_book() { #
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 @@ extract_commands() { #
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
# Clean
rm -rf ${PROGNAME}-commands
mkdir -v ${PROGNAME}-commands
fi
echo -n "Extracting commands for"
# 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 @@ extract_commands() { #
--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 @@ extract_commands() { #
# 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 @@ create_package_list() { #
*)
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"
}

4
jhalfs
View file

@ -357,7 +357,9 @@ if [[ "$REBUILD_MAKEFILE" = "n" ]] ; then
>$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