Begin coding against the CLFS-2.0 book

This commit is contained in:
George Boudreau 2006-07-23 14:44:13 +00:00
parent a708b152bc
commit 7432834d16
8 changed files with 911 additions and 9 deletions

243
CLFS2/clfs2.xsl Normal file
View file

@ -0,0 +1,243 @@
<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY % general-entities SYSTEM "FAKEDIR/general.ent">
%general-entities;
]>
<!-- $Id$ -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
extension-element-prefixes="exsl"
version="1.0">
<!-- XSLT stylesheet to create shell scripts from CLFS books. -->
<!-- Build method used -->
<xsl:param name="method" select="chroot"/>
<!-- Compile the keymap into the kernel? -->
<xsl:param name="keymap" select="none"/>
<!-- Run test suites?
0 = none
1 = only Glibc, GCC and Binutils testsuites
2 = all testsuites
3 = alias to 2 -->
<xsl:param name="testsuite" select="0"/>
<!-- Install vim-lang package? -->
<xsl:param name="vim-lang" select="1"/>
<!-- Time zone -->
<xsl:param name="timezone" select="GMT"/>
<!-- Page size -->
<xsl:param name="page" select="letter"/>
<!-- Locale settings -->
<xsl:param name="lang" select="C"/>
<xsl:template match="/">
<xsl:apply-templates select="//sect1"/>
</xsl:template>
<xsl:template match="sect1">
<xsl:choose>
<xsl:when test="../@id='chapter-partitioning' or
../@id='chapter-getting-materials' or
../@id='chapter-final-preps'"/>
<xsl:when test="../@id='chapter-testsuite-tools' and $testsuite='0'"/>
<xsl:otherwise>
<xsl:if test="count(descendant::screen/userinput) &gt; 0 and
count(descendant::screen/userinput) &gt;
count(descendant::screen[@role='nodump'])">
<!-- The dirs names -->
<xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
<xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
<xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
<xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
<!-- 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="{$dirname}/{$order}-{$filename}" method="text">
<xsl:choose>
<xsl:when test="../@id='chapter-chroot'">
<xsl:text>#!/tools/bin/bash&#xA;set -e&#xA;&#xA;</xsl:text>
</xsl:when>
<xsl:when test="@id='ch-system-stripping'">
<xsl:text>#!/bin/sh&#xA;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>#!/bin/sh&#xA;set -e&#xA;&#xA;</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="sect2[@role='installation']">
<xsl:text>cd $PKGDIR&#xA;</xsl:text>
<xsl:if test="@id='ch-system-vim' and $vim-lang = '1'">
<xsl:text>tar -xvf ../vim-&vim-version;-lang.* --strip-components=1&#xA;</xsl:text>
</xsl:if>
</xsl:if>
<xsl:apply-templates select=".//para/userinput | .//screen"/>
<xsl:text>exit</xsl:text>
</exsl:document>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="screen">
<xsl:if test="child::* = userinput and not(@role = 'nodump')">
<xsl:apply-templates select="userinput" mode="screen"/>
</xsl:if>
</xsl:template>
<xsl:template match="para/userinput">
<xsl:if test="(contains(string(),'test') or
contains(string(),'check')) and
($testsuite = '2' or $testsuite = '3')">
<xsl:value-of select="substring-before(string(),'make')"/>
<xsl:text>make -k</xsl:text>
<xsl:value-of select="substring-after(string(),'make')"/>
<xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="userinput" mode="screen">
<xsl:choose>
<!-- Estandarized package formats -->
<xsl:when test="contains(string(),'tar.gz')">
<xsl:value-of select="substring-before(string(),'tar.gz')"/>
<xsl:text>tar.*</xsl:text>
<xsl:value-of select="substring-after(string(),'tar.gz')"/>
<xsl:text>&#xA;</xsl:text>
</xsl:when>
<!-- Avoiding a race condition in a patch -->
<xsl:when test="contains(string(),'debian_fixes')">
<xsl:value-of select="substring-before(string(),'patch')"/>
<xsl:text>patch -Z</xsl:text>
<xsl:value-of select="substring-after(string(),'patch')"/>
<xsl:text>&#xA;</xsl:text>
</xsl:when>
<!-- Setting $LANG for /etc/profile -->
<xsl:when test="ancestor::sect1[@id='ch-scripts-profile'] and
contains(string(),'export LANG=')">
<xsl:value-of select="substring-before(string(),'export LANG=')"/>
<xsl:text>export LANG=</xsl:text>
<xsl:value-of select="$lang"/>
<xsl:value-of select="substring-after(string(),'charmap]')"/>
<xsl:text>&#xA;</xsl:text>
</xsl:when>
<!-- Compile the keymap into the kernel? -->
<xsl:when test="contains(string(),'defkeymap') and
$keymap = 'none'"/>
<!-- Copying the kernel config file -->
<xsl:when test="string() = 'make mrproper'">
<xsl:text>make mrproper&#xA;</xsl:text>
<xsl:if test="ancestor::sect1[@id='ch-boot-kernel']">
<xsl:text>cp -v ../bootkernel-config .config&#xA;</xsl:text>
</xsl:if>
<xsl:if test="ancestor::sect1[@id='ch-bootable-kernel']">
<xsl:text>cp -v ../kernel-config .config&#xA;</xsl:text>
</xsl:if>
</xsl:when>
<!-- No interactive commands are needed if the .config file is the proper one -->
<xsl:when test="contains(string(),'menuconfig')"/>
<!-- The Coreutils and Module-Init-Tools test suites are optional -->
<xsl:when test="(ancestor::sect1[@id='ch-system-coreutils'] or
ancestor::sect1[@id='ch-system-module-init-tools']) and
(contains(string(),'check') or
contains(string(),'dummy'))">
<xsl:choose>
<xsl:when test="$testsuite = '0' or $testsuite = '1'"/>
<xsl:otherwise>
<xsl:apply-templates/>
<xsl:if test="contains(string(),'check')">
<xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true</xsl:text>
</xsl:if>
<xsl:text>&#xA;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<!-- Fixing toolchain test suites run -->
<xsl:when test="string() = 'make check' or
string() = 'make -k check'">
<xsl:choose>
<xsl:when test="$testsuite != '0'">
<xsl:text>make -k check &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:when test="contains(string(),'glibc-check-log')">
<xsl:choose>
<xsl:when test="$testsuite != '0'">
<xsl:value-of select="substring-before(string(),'&gt;g')"/>
<xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:when test="contains(string(),'test_summary') or
contains(string(),'expect -c')">
<xsl:choose>
<xsl:when test="$testsuite != '0'">
<xsl:apply-templates/>
<xsl:if test="contains(string(),'test_summary')">
<xsl:text> &gt;&gt; $TEST_LOG</xsl:text>
</xsl:if>
<xsl:text>&#xA;</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:when>
<!-- Don't stop on strip run -->
<xsl:when test="contains(string(),'strip ')">
<xsl:apply-templates/>
<xsl:text> || true&#xA;</xsl:text>
</xsl:when>
<!-- The rest of commands -->
<xsl:otherwise>
<xsl:apply-templates/>
<xsl:text>&#xA;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="replaceable">
<xsl:choose>
<xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
<xsl:value-of select="$timezone"/>
</xsl:when>
<xsl:when test="ancestor::sect1[@id='ch-system-groff']">
<xsl:value-of select="$page"/>
</xsl:when>
<xsl:when test="ancestor::sect1[@id='ch-boot-kernel'] or
ancestor::sect1[@id='ch-bootable-kernel']">
<xsl:value-of select="$keymap"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>**EDITME</xsl:text>
<xsl:apply-templates/>
<xsl:text>EDITME**</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

53
CLFS2/config Normal file
View file

@ -0,0 +1,53 @@
#####
#
# Configuration file for the CLFS module
#
# $Id$
#
#####
#--- Which target architecture you want to build for,
# used to select proper book and set TARGETS
#--------------------------------
TARGET=
TARGET32=
# >>>> 32-32 BUILD <<<<
ARCH=x86 ; TARGET="i486-pc-linux-gnu"
# ARCH=x86 ; TARGET="i586-pc-linux-gnu"
# ARCH=x86 ; TARGET="i686-pc-linux-gnu"
# ARCH=arm ; TARGET="arm-unknown-linux-gnu"
#--------------------------------
# >>>> 64-64 BUILD <<<<
#--------------------------------
# >>>> MULTILIB 32/64 <<<<
#--- Location of fstab file (if empty, a template is created)
FSTAB=
#--- Fully qualified path to a kernel config file
# If no config file is specified the kernel is NOT compiled
CONFIG=
# Get the kernel package and patches even if no configutation file
# has been supplied? 0(no)/1(yes)
GETKERNEL=0
#--- Book's sources directory
# If you have previously checked out the book from the repository
BOOK=
#==== INTERNAL VARIABLES ====
# Don't edit it unless you know what you are doing
#--- Extra files that need be copied to $JHALFSDIR
FILES=""
#--- Default stylesheet
XSL=clfs2.xsl
#--- Book version
LFSVRS=development
#--- Name of the makefile
MKFILE=$JHALFSDIR/Makefile

557
CLFS2/master.sh Executable file
View file

@ -0,0 +1,557 @@
#!/bin/sh
# $Id$
###################################
### FUNCTIONS ###
###################################
#----------------------------------#
wrt_ExecuteAsUser() { # Execute the file ($3) under the users account ($1), log in $2
#----------------------------------#
local this_user=$1
local this_script=$2
local file=$3
(
cat << EOF
@( time { su - ${this_user} -c "source /home/${this_user}/.bashrc && $JHALFSDIR/${PROGNAME}-commands/$file" >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/$this_script
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
wrt_Unpack_SetOwner() { # Unpack and set owner. Assign 'ROOT' var
#----------------------------------#
local USER_ACCT=$1
local FILE=$2
local optSAVE_PREVIOUS=$3
if [ "${optSAVE_PREVIOUS}" != "1" ]; then
wrt_remove_existing_dirs "$FILE"
fi
(
cat << EOF
@\$(call unpack,$FILE)
@ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)/\$\$ROOT" > envars && \\
chown -R ${USER_ACCT} \$(MOUNT_PT)\$(SRC)/\$\$ROOT
EOF
) >> $MKFILE.tmp
}
#----------------------------#
host_prep_Makefiles() { # Initialization of the system
#----------------------------#
local CLFS_HOST
echo "${tab_}${GREEN}Processing... ${L_arrow}host prep files${R_arrow}"
# defined here, only for ease of reading
CLFS_HOST="$(echo $MACHTYPE | sed "s/$(echo $MACHTYPE | cut -d- -f2)/cross/")"
(
cat << EOF
023-creatingtoolsdir:
@\$(call echo_message, Building)
@mkdir \$(MOUNT_PT)/tools && \\
rm -f /tools && \\
ln -s \$(MOUNT_PT)/tools /
@if [ ! -d \$(MOUNT_PT)/sources ]; then \\
mkdir \$(MOUNT_PT)/sources; \\
fi;
@chmod a+wt \$(MOUNT_PT)/sources
@touch \$@ && \\
echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
echo --------------------------------------------------------------------------------\$(WHITE)
025-addinguser: 023-creatingtoolsdir
@\$(call echo_message, Building)
@if [ ! -d /home/clfs ]; then \\
groupadd clfs; \\
useradd -s /bin/bash -g clfs -m -k /dev/null clfs; \\
else \\
touch user-clfs-exist; \\
fi;
@chown clfs \$(MOUNT_PT) && \\
chown clfs \$(MOUNT_PT)/tools && \\
chown clfs \$(MOUNT_PT)/sources
@touch \$@ && \\
echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
echo --------------------------------------------------------------------------------\$(WHITE)
026-settingenvironment: 025-addinguser
@\$(call echo_message, Building)
@if [ -f /home/clfs/.bashrc -a ! -f /home/clfs/.bashrc.XXX ]; then \\
mv /home/clfs/.bashrc /home/clfs/.bashrc.XXX; \\
fi;
@if [ -f /home/clfs/.bash_profile -a ! -f /home/clfs/.bash_profile.XXX ]; then \\
mv /home/clfs/.bash_profile /home/clfs/.bash_profile.XXX; \\
fi;
@echo "set +h" > /home/clfs/.bashrc && \\
echo "umask 022" >> /home/clfs/.bashrc && \\
echo "CLFS=\$(MOUNT_PT)" >> /home/clfs/.bashrc && \\
echo "LC_ALL=POSIX" >> /home/clfs/.bashrc && \\
echo "PATH=\$(MOUNT_PT)/cross-tools/bin:/bin:/usr/bin" >> /home/clfs/.bashrc && \\
echo "export CLFS LC_ALL PATH" >> /home/clfs/.bashrc && \\
echo "" >> /home/clfs/.bashrc && \\
echo "unset CFLAGS" >> /home/clfs/.bashrc && \\
echo "unset CXXFLAGS" >> /home/clfs/.bashrc && \\
echo "" >> /home/clfs/.bashrc && \\
echo "export CLFS_HOST=\"${CLFS_HOST}\"" >> /home/clfs/.bashrc && \\
echo "export CLFS_TARGET=\"${TARGET}\"" >> /home/clfs/.bashrc && \\
echo "export CLFS_TARGET32=\"${TARGET32}\"" >> /home/clfs/.bashrc && \\
echo "source $JHALFSDIR/envars" >> /home/clfs/.bashrc
@chown clfs:clfs /home/clfs/.bashrc && \\
touch envars
@touch \$@ && \\
echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
echo --------------------------------------------------------------------------------\$(WHITE)
027-create-directories: 026-settingenvironment
@\$(call echo_message, Building)
@mkdir -p \$(MOUNT_PT)/{bin,boot,dev,{etc/,}opt,home,lib,mnt}
@mkdir -p \$(MOUNT_PT)/{proc,media/{floppy,cdrom},sbin,srv,sys}
@mkdir -p \$(MOUNT_PT)/var/{lock,log,mail,run,spool}
@mkdir -p \$(MOUNT_PT)/var/{opt,cache,lib/{misc,locate},local}
@install -d -m 0750 \$(MOUNT_PT)/root
@install -d -m 1777 \$(MOUNT_PT){/var,}/tmp
@mkdir -p \$(MOUNT_PT)/usr/{,local/}{bin,include,lib,sbin,src}
@mkdir -p \$(MOUNT_PT)/usr/{,local/}share/{doc,info,locale,man}
@mkdir -p \$(MOUNT_PT)/usr/{,local/}share/{misc,terminfo,zoneinfo}
@mkdir -p \$(MOUNT_PT)/usr/{,local/}share/man/man{1,2,3,4,5,6,7,8}
@for dir in \$(MOUNT_PT)/usr{,/local}; do \\
ln -s share/{man,doc,info} \$\$dir ; \\
done
@touch \$@ && \\
echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
echo --------------------------------------------------------------------------------\$(WHITE)
028-creating-sysfile: 027-create-directories
@\$(call echo_message, Building)
@touch \$(MOUNT_PT)/etc/mtab
@echo "root::0:0:root:/root:/bin/bash" >> \$(MOUNT_PT)/etc/passwd
@echo "root:x:0:" >> \$(MOUNT_PT)/etc/group
@echo "bin:x:1:" >> \$(MOUNT_PT)/etc/group
@echo "sys:x:2:" >> \$(MOUNT_PT)/etc/group
@echo "kmem:x:3" >> \$(MOUNT_PT)/etc/group
@echo "tty:x:4:" >> \$(MOUNT_PT)/etc/group
@echo "tape:x:5:" >> \$(MOUNT_PT)/etc/group
@echo "daemon:x:6:" >> \$(MOUNT_PT)/etc/group
@echo "floppy:x:7:" >> \$(MOUNT_PT)/etc/group
@echo "disk:x:8:" >> \$(MOUNT_PT)/etc/group
@echo "lp:x:9:" >> \$(MOUNT_PT)/etc/group
@echo "dialout:x:10:" >> \$(MOUNT_PT)/etc/group
@echo "audio:x:11:" >> \$(MOUNT_PT)/etc/group
@echo "video:x:12:" >> \$(MOUNT_PT)/etc/group
@echo "utmp:x:13:" >> \$(MOUNT_PT)/etc/group
@echo "usb:x:14:" >> \$(MOUNT_PT)/etc/group
@echo "cdrom:x:15:" >> \$(MOUNT_PT)/etc/group
@touch \$(MOUNT_PT)/var/run/utmp \$(MOUNT_PT)/var/log/{btmp,lastlog,wtmp}
@chmod 664 \$(MOUNT_PT)/var/run/utmp \$(MOUNT_PT)/var/log/lastlog
@chown -R clfs \$(MOUNT_PT)
@touch \$@ && \\
echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
echo --------------------------------------------------------------------------------\$(WHITE)
EOF
) >> $MKFILE.tmp
}
#-----------------------------#
cross_tools_Makefiles() { #
#-----------------------------#
echo "${tab_}${GREEN}Processing... ${L_arrow}cross tools${R_arrow}"
for file in cross-tools/* ; do
# Keep the script file name
this_script=`basename $file`
#
# Skip this script...
case $this_script in
*cflags* | *variables* ) # work done in host_prep_Makefiles
continue; ;;
*) ;;
esac
#
# Set the dependency for the first target.
if [ -z $PREV ] ; then PREV=026-settingenvironment ; fi
# First append each name of the script files to a list (this will become
# the names of the targets in the Makefile
cross_tools="$cross_tools $this_script"
# Grab the name of the target (minus the -headers or -cross in the case of gcc
# and binutils in chapter 5)
name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
-e 's@-static@@' \
-e 's@-final@@' \
-e 's@-64@@' \
-e 's@-n32@@'`
case $name in
glibc-headers) name="glibc" ;;
esac
pkg_tarball=$(get_package_tarball_name $name)
#--------------------------------------------------------------------#
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Drop in the name of the target on a new line, and the previous target
# as a dependency. Also call the echo_message function.
wrt_target "${this_script}" "$PREV"
#
# If $pkg_tarball isn't empty, we've got a package...
if [ "$pkg_tarball" != "" ] ; then
wrt_Unpack_SetOwner "clfs" "$pkg_tarball"
# If using optimizations, write the instructions
[[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
fi
#
wrt_ExecuteAsUser "clfs" "${this_script}" "${file}"
#
[[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs "${name}"
#
# Include a touch of the target name so make can check if it's already been made.
wrt_touch
#
#--------------------------------------------------------------------#
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Keep the script file name for Makefile dependencies.
PREV=$this_script
done # for file in ....
}
#-----------------------------#
final_system_Makefiles() { #
#-----------------------------#
# Set envars and scripts for iteration targets
LOGS="" # Start with an empty global LOGS envar
if [[ -z "$1" ]] ; then
local N=""
else
local N=-build_$1
local basicsystem=""
mkdir final-system$N
cp final-system/* final-system$N
for script in final-system$N/* ; do
# Overwrite existing symlinks, files, and dirs
sed -e 's/ln -sv/&f/g' \
-e 's/mv -v/&f/g' \
-e 's/mkdir -v/&p/g' -i ${script}
done
# Remove Bzip2 binaries before make install
sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i final-system$N/*-bzip2
# Delete *old Readline libraries just after make install
sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i final-system$N/*-readline
fi
echo "${tab_}${GREEN}Processing... ${L_arrow}final system$N${R_arrow}"
for file in final-system$N/* ; do
# Keep the script file name
this_script=`basename $file`
# Test if the stripping phase must be skipped.
# Skip alsp temp-perl for iterative runs
case $this_script in
*stripping*) [[ "$STRIP" = "0" ]] && continue ;;
esac
# Grab the name of the target, strip id number, XXX-script
name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
-e 's@temp-@@' \
-e 's@-64bit@@' \
-e 's@-64@@' \
-e 's@64@@' \
-e 's@n32@@'`
# 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
pkg_tarball=$(get_package_tarball_name $name)
if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
case "${this_script}" in
*stripping*) ;;
*) continue ;;
esac
fi
# Append each name of the script files to a list (this will become
# the names of the targets in the Makefile
basicsystem="$basicsystem ${this_script}${N}"
# Append each name of the script files to a list (this will become
# the names of the logs to be moved for each iteration)
LOGS="$LOGS ${this_script}"
#--------------------------------------------------------------------#
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Drop in the name of the target on a new line, and the previous target
# as a dependency. Also call the echo_message function.
wrt_target "${this_script}${N}" "$PREV"
#
# If $pkg_tarball isn't empty, we've got a package...
if [ "$pkg_tarball" != "" ] ; then
wrt_Unpack_SetOwner "clfs" "$pkg_tarball"
# If using optimizations, write the instructions
[[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
fi
#
wrt_ExecuteAsUser "clfs" "${this_script}" "${file}"
#
[[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs "${name}"
#
# Include a touch of the target name so make can check if it's already been made.
wrt_touch
#
#--------------------------------------------------------------------#
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Keep the script file name for Makefile dependencies.
PREV=${this_script}${N}
# Set system_build envar for iteration targets
system_build=$basicsystem
done # for file in final-system/* ...
}
#-----------------------------#
bootscripts_Makefiles() { #
#-----------------------------#
echo "${tab_}${GREEN}Processing... ${L_arrow}bootscripts${R_arrow}"
for file in bootscripts/* ; do
# Keep the script file name
this_script=`basename $file`
case $this_script in
*udev) continue ;; # This is not a script but a commentary, we want udev-rules
*console*) continue ;; # Use the files that came with the bootscripts
*) ;;
esac
# First append each name of the script files to a list (this will become
# the names of the targets in the Makefile
bootscripttools="$bootscripttools $this_script"
# Grab the name of the target, strip id number, XXX-script
name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
-e 's@-64bit@@' \
-e 's@-64@@' \
-e 's@64@@' \
-e 's@n32@@'`
case $name in
*bootscripts*) name=bootscripts-cross-lfs ;;
*udev-rules) name=udev-cross-lfs ;;
esac
pkg_tarball=$(get_package_tarball_name $name)
#--------------------------------------------------------------------#
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Drop in the name of the target on a new line, and the previous target
# as a dependency. Also call the echo_message function.
wrt_target "${this_script}" "$PREV"
#
# If $pkg_tarball isn't empty, we've got a package...
[[ "$pkg_tarball" != "" ]] && wrt_Unpack_SetOwner "clfs" "$pkg_tarball"
#
wrt_ExecuteAsUser "clfs" "${this_script}" "${file}"
#
[[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs "${name}"
#
# Include a touch of the target name so make can check if it's already been made.
wrt_touch
#
#--------------------------------------------------------------------#
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Keep the script file name for Makefile dependencies.
PREV=$this_script
done # for file in bootscripts/* ...
}
#-----------------------------#
bootable_Makefiles() { #
#-----------------------------#
echo "${tab_}${GREEN}Processing... ${L_arrow}make bootable${R_arrow}"
for file in bootable/* ; do
# Keep the script file name
this_script=`basename $file`
# A little housekeeping on the scripts
case $this_script in
*grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
*kernel) # if there is no kernel config file do not build the kernel
[[ -z $CONFIG ]] && continue
# Copy the config file to /sources with a standardized name
cp $CONFIG $BUILDDIR/sources/kernel-config
;;
esac
#
# First append each name of the script files to a list (this will become
# the names of the targets in the Makefile
bootable="$bootable $this_script"
#
# Grab the name of the target, strip id number and misc words.
name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' `
case $this_script in
*kernel*) name=linux
;;
esac
pkg_tarball=$(get_package_tarball_name $name)
#--------------------------------------------------------------------#
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Drop in the name of the target on a new line, and the previous target
# as a dependency. Also call the echo_message function.
wrt_target "${this_script}" "$PREV"
#
# If $pkg_tarball isn't empty, we've got a package...
[[ "$pkg_tarball" != "" ]] && wrt_Unpack_SetOwner "clfs" "$pkg_tarball"
#
# Select a script execution method
case $this_script in
*fstab*) if [[ -n "$FSTAB" ]]; then
wrt_copy_fstab "${this_script}"
else
wrt_ExecuteAsUser "clfs" "${this_script}" "${file}"
fi
;;
*) wrt_ExecuteAsUser "clfs" "${this_script}" "${file}"
;;
esac
#
# Housekeeping...remove any build directory(ies) except if the package build fails.
[[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs "${name}"
#
# Include a touch of the target name so make can check if it's already been made.
wrt_touch
#
#--------------------------------------------------------------------#
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Keep the script file name for Makefile dependencies.
PREV=$this_script
done
# Add SBU-disk_usage report target if required
if [[ "$REPORT" = "1" ]] ; then wrt_report ; fi
}
#-----------------------------#
build_Makefile() { # Construct a Makefile from the book scripts
#-----------------------------#
echo "Creating Makefile... ${BOLD}START${OFF}"
cd $JHALFSDIR/${PROGNAME}-commands
# Start with a clean Makefile.tmp file
>$MKFILE.tmp
host_prep_Makefiles
cross_tools_Makefiles # $cross_tools
final_system_Makefiles # $basicsystem
bootscripts_Makefiles # $bootscripttools
bootable_Makefiles # $bootable
# Add a header, some variables and include the function file
# to the top of the real Makefile.
(
cat << EOF
$HEADER
SRC= /sources
MOUNT_PT= $BUILDDIR
PKG_LST= $PKG_LST
include makefile-functions
EOF
) > $MKFILE
# Drop in the main target 'all:' and the chapter targets with each sub-target
# as a dependency.
(
cat << EOF
all: chapter2 chapter3 chapter4 chapter5 chapter6 do-housekeeping
@\$(call echo_finished,$VERSION)
chapter2: 023-creatingtoolsdir 025-addinguser 026-settingenvironment 027-create-directories 028-creating-sysfile
chapter3: chapter2 $cross_tools
chapter4: chapter3 $basicsystem
chapter5: chapter4 $bootscripttools
chapter6: chapter5 $bootable
clean-all: clean
rm -rf ./{clfs2-commands,logs,Makefile,*.xsl,makefile-functions,packages,patches}
clean:
restart:
@echo "This feature does not exist for the CLFS makefile. (yet)"
restore-clfs-env:
@\$(call echo_message, Building)
@if [ -f /home/clfs/.bashrc.XXX ]; then \\
mv -f /home/clfs/.bashrc.XXX /home/clfs/.bashrc; \\
fi;
@if [ -f /home/clfs/.bash_profile.XXX ]; then \\
mv /home/clfs/.bash_profile.XXX /home/clfs/.bash_profile; \\
fi;
@chown clfs:clfs /home/clfs/.bash* && \\
touch \$@ && \\
echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
echo --------------------------------------------------------------------------------\$(WHITE)
do-housekeeping:
@-if [ ! -f user-clfs-exist ]; then \\
userdel clfs; \\
rm -rf /home/clfs; \\
fi;
EOF
) >> $MKFILE
# Bring over the items from the Makefile.tmp
cat $MKFILE.tmp >> $MKFILE
rm $MKFILE.tmp
echo "Creating Makefile... ${BOLD}DONE${OFF}"
}

6
README
View file

@ -101,6 +101,10 @@ $Id$
/master.sh
/xxxx.xsl
/CLFS2/config
/master.sh
/xxxx.xsl
/HLFS/config
/master.sh
/xxxx.xsl
@ -128,6 +132,7 @@ $Id$
TODO
./clfs ---|
./clfs2 ---|
./hlfs ---|+---> master.sh
./lfs ---|
@ -198,7 +203,6 @@ $Id$
understanding of host/target hardware combination. Please read the book
carefully and don't skip the easy parts (there are none..)
Authors:
George Boudreau
Manuel Canales Esparcia

1
clfs2 Symbolic link
View file

@ -0,0 +1 @@
master.sh

View file

@ -131,6 +131,18 @@ ${BOLD} --method BUILDMETHOD ${OFF}
Select the build method, chroot or boot
-EOF-
[[ ${PROGNAME} = "clfs2" ]] &&
cat <<- -EOF-
${BOLD} -A, --arch ARCH ${OFF}
Select the TARGET architecture, valid selections are:
32bit builds
arm
64bit builds
64bit multi-lib
-EOF-
[[ ${PROGNAME} = "hlfs" ]] &&
cat <<- -EOF-
@ -645,6 +657,7 @@ get_book() { #
lfs) svn_root="LFS" ;;
hlfs) svn_root="HLFS" ;;
clfs) svn_root="cross-lfs" ;;
clfs2) svn_root="cross-lfs" ;;
*) echo "BOOK not defined in function <get_book>"
exit 1 ;;
esac
@ -660,7 +673,7 @@ get_book() { #
echo -ne "done\n"
cd $JHALFSDIR
case $PROGNAME in
clfs)
clfs | clfs2)
VERSION=$(xmllint --noent $BOOK/prologue/$ARCH/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
*)
VERSION=$(xmllint --noent $BOOK/prologue/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
@ -671,7 +684,10 @@ get_book() { #
extract_commands
fi
else
svn co $SVN/${svn_root}/${TREE} ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1
case $PROGNAME in
clfs2 ) svn co $SVN/${svn_root}/branches/clfs-2.0/BOOK ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1 ;;
*) svn co $SVN/${svn_root}/${TREE} ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1 ;;
esac
echo -ne "done\n"
extract_commands
fi
@ -693,7 +709,7 @@ extract_commands() { #
cd $JHALFSDIR
case $PROGNAME in
clfs)
clfs | clfs2 )
VERSION=$(xmllint --noent $BOOK/prologue/$ARCH/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
*)
VERSION=$(xmllint --noent $BOOK/prologue/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
@ -721,6 +737,19 @@ extract_commands() { #
--stringparam keymap $KEYMAP \
-o ./${PROGNAME}-commands/ $XSL $BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
;;
clfs2)
echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture"
xsltproc --nonet \
--xinclude \
--stringparam testsuite $TEST \
--stringparam vim-lang $VIMLANG \
--stringparam timezone $TIMEZONE \
--stringparam page $PAGE \
--stringparam lang $LANG \
--stringparam keymap $KEYMAP \
-o ./${PROGNAME}-commands/ $XSL $BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
;;
hlfs)
echo -n " ${L_arrow}${BOLD}$MODEL${R_arrow} HLFS libc implementation"
xsltproc --nonet \
@ -769,7 +798,7 @@ create_package_list() { #
rm -f pkg_tarball_list
echo -n "Creating <${PROGNAME}> list of tarball names for $BOOK $ARCH"
case ${PROGNAME} in
clfs)
clfs | clfs2)
xsltproc --nonet --xinclude -o pkg_tarball_list packages.xsl \
$BOOK/materials/${ARCH}-chapter.xml >>$LOGDIR/$LOG 2>&1
;;
@ -924,6 +953,14 @@ create_urls() { #
$BOOK/materials/$ARCH-chapter.xml >>$LOGDIR/$LOG 2>&1
echo " ...OK"
;;
clfs2)
echo -n "Creating CLFS2 <${ARCH}> specific URLs file"
xsltproc --nonet --xinclude \
--stringparam server $SERVER \
-o $BUILDDIR/sources/urls.lst urls.xsl \
$BOOK/materials/$ARCH-chapter.xml >>$LOGDIR/$LOG 2>&1
echo " ...OK"
;;
hlfs)
echo -n "Creating HLFS <${MODEL}> specific URLs file"
xsltproc --nonet --xinclude \

View file

@ -58,6 +58,8 @@ validate_target() { #
"ppc64") [[ "${TARGET}" = "powerpc64-unknown-linux-gnu" ]] &&
[[ "${TARGET32}" = "powerpc-unknown-linux-gnu" ]] && return
;;
"arm") [[ "${TARGET}" = "arm-unknown-linux-gnu" ]] && return
;;
*) write_error_and_die
;;
esac
@ -86,6 +88,7 @@ inline_doc
# First internal variables, then the ones that change the book's flavour, and lastly system configuration variables
local -r hlfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE GETPKG RUNMAKE MODEL GRSECURITY_HOST TEST OPTIMIZE REPORT COMPARE RUN_ICA RUN_FARCE ITERATIONS STRIP FSTAB CONFIG GETKERNEL KEYMAP PAGE TIMEZONE LANG LC_ALL"
local -r clfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE GETPKG RUNMAKE METHOD ARCH TARGET TEST OPTIMIZE REPORT COMPARE RUN_ICA RUN_FARCE ITERATIONS STRIP FSTAB BOOT_CONFIG CONFIG GETKERNEL KEYMAP VIMLANG PAGE TIMEZONE LANG"
local -r clfs2_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE GETPKG RUNMAKE ARCH TARGET OPTIMIZE REPORT COMPARE RUN_ICA RUN_FARCE ITERATIONS STRIP FSTAB CONFIG GETKERNEL KEYMAP VIMLANG PAGE TIMEZONE LANG"
local -r lfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE GETPKG RUNMAKE TEST OPTIMIZE REPORT COMPARE RUN_ICA RUN_FARCE ITERATIONS STRIP FSTAB CONFIG GETKERNEL VIMLANG PAGE TIMEZONE LANG"
local -r ERROR_MSG_pt1='The variable \"${L_arrow}${config_param}${R_arrow}\" value ${L_arrow}${BOLD}${!config_param}${R_arrow} is invalid,'
@ -208,7 +211,7 @@ inline_doc
MODEL) validate_against_str "xglibcx xuclibcx" ;;
PAGE) validate_against_str "xletterx xA4x" ;;
METHOD) validate_against_str "xchrootx xbootx" ;;
ARCH) validate_against_str "xx86x xx86_64x xx86_64-64x xsparcx xsparc64x xsparc64-64x xmipsx xmips64x xmips64-64x xppcx xppc64x xalphax" ;;
ARCH) validate_against_str "xx86x xx86_64x xx86_64-64x xsparcx xsparc64x xsparc64-64x xmipsx xmips64x xmips64-64x xppcx xppc64x xalphax xarmx" ;;
TARGET) validate_target ;;
GRSECURITY_HOST) validate_against_str "x0x x1x" ;;

View file

@ -272,6 +272,10 @@ while test $# -gt 0 ; do
test $# = 1 && eval "$exit_missing_arg"
shift
case $1 in
arm )
ARCH=arm
TARGET="arm-unknown-linux-gnu"
;;
x86 )
ARCH=x86
TARGET="i686-pc-linux-gnu"