2006-04-06 21:35:22 +02:00
|
|
|
#!/bin/sh
|
|
|
|
set -e # Enable error trapping
|
|
|
|
|
|
|
|
# $Id$
|
|
|
|
|
|
|
|
###################################
|
|
|
|
### FUNCTIONS ###
|
|
|
|
###################################
|
|
|
|
|
2006-07-30 13:34:49 +02:00
|
|
|
#----------------------------------#
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
wrt_RunAsRoot() { # Some scripts must be run as root..
|
|
|
|
#----------------------------------#
|
|
|
|
local user_ACCT=$(echo $1 | tr [a-z] [A-Z])
|
|
|
|
local this_script=$2
|
|
|
|
local file=$3
|
|
|
|
|
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@( time { export ${user_ACCT}=\$(MOUNT_PT) && ${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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------#
|
|
|
|
process_toolchain() { # embryo,cocoon and butterfly need special handling
|
|
|
|
#----------------------------#
|
|
|
|
local toolchain=$1
|
|
|
|
local this_script=$2
|
|
|
|
local tc_phase
|
|
|
|
|
|
|
|
echo "${tab_}${tab_}${GREEN}toolchain ${L_arrow}${toolchain}${R_arrow}"
|
|
|
|
|
|
|
|
case ${toolchain} in
|
|
|
|
*butterfly*)
|
|
|
|
[[ "$TEST" != "0" ]] && wrt_test_log2 "${this_script}"
|
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@echo "export PKGDIR=\$(SRC)" > envars
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
wrt_run_as_chroot1 "$toolchain" "$this_script"
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)" > envars
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
wrt_ExecuteAsUser "hlfs" "$toolchain" "$this_script"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
#
|
|
|
|
# Safe method to remove packages unpacked outside the toolchain
|
|
|
|
pkg_tarball=$(get_package_tarball_name "binutils")
|
|
|
|
wrt_remove_existing_dirs "$pkg_tarball"
|
|
|
|
pkg_tarball=$(get_package_tarball_name "gcc-core")
|
|
|
|
wrt_remove_existing_dirs "$pkg_tarball"
|
|
|
|
#
|
|
|
|
# Manually remove the toolchain directories..
|
|
|
|
tc_phase=`echo $toolchain | sed -e 's@[0-9]\{3\}-@@' -e 's@-toolchain@@'`
|
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@rm -r \$(MOUNT_PT)\$(SRC)/${tc_phase}-toolchain && \\
|
|
|
|
rm -r \$(MOUNT_PT)\$(SRC)/${tc_phase}-build
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2006-04-06 21:35:22 +02:00
|
|
|
|
|
|
|
#----------------------------#
|
|
|
|
chapter3_Makefiles() { # Initialization of the system
|
|
|
|
#----------------------------#
|
|
|
|
|
|
|
|
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter3${R_arrow}"
|
|
|
|
|
|
|
|
# Define a few model dependant variables
|
|
|
|
if [[ ${MODEL} = "uclibc" ]]; then
|
2006-07-30 13:34:49 +02:00
|
|
|
TARGET="pc-linux-gnu"; LOADER="ld-uClibc.so.0"
|
2006-04-06 21:35:22 +02:00
|
|
|
else
|
2006-07-30 13:34:49 +02:00
|
|
|
TARGET="pc-linux-gnu"; LOADER="ld-linux.so.2"
|
2006-04-06 21:35:22 +02:00
|
|
|
fi
|
|
|
|
|
2006-07-30 13:34:49 +02:00
|
|
|
# If /home/hlfs is already present in the host, we asume that the
|
|
|
|
# hlfs user and group are also presents in the host, and a backup
|
2006-04-06 21:35:22 +02:00
|
|
|
# of their bash init files is made.
|
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
020-creatingtoolsdir:
|
|
|
|
@\$(call echo_message, Building)
|
2006-06-09 22:52:05 +02:00
|
|
|
@mkdir \$(MOUNT_PT)/tools && \\
|
|
|
|
rm -f /tools && \\
|
|
|
|
ln -s \$(MOUNT_PT)/tools /
|
2006-04-06 21:35:22 +02:00
|
|
|
@if [ ! -d \$(MOUNT_PT)/sources ]; then \\
|
|
|
|
mkdir \$(MOUNT_PT)/sources; \\
|
|
|
|
fi;
|
|
|
|
@chmod a+wt \$(MOUNT_PT)/sources && \\
|
2006-06-10 17:58:06 +02:00
|
|
|
touch \$@ && \\
|
|
|
|
echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
|
|
|
echo --------------------------------------------------------------------------------\$(WHITE)
|
2006-04-06 21:35:22 +02:00
|
|
|
|
|
|
|
021-addinguser: 020-creatingtoolsdir
|
|
|
|
@\$(call echo_message, Building)
|
2006-07-30 13:34:49 +02:00
|
|
|
@if [ ! -d /home/hlfs ]; then \\
|
|
|
|
groupadd hlfs; \\
|
|
|
|
useradd -s /bin/bash -g hlfs -m -k /dev/null hlfs; \\
|
2006-04-06 21:35:22 +02:00
|
|
|
else \\
|
2006-07-30 13:34:49 +02:00
|
|
|
touch user-hlfs-exist; \\
|
2006-04-06 21:35:22 +02:00
|
|
|
fi;
|
2006-07-30 13:34:49 +02:00
|
|
|
@chown hlfs \$(MOUNT_PT)/tools && \\
|
|
|
|
chown hlfs \$(MOUNT_PT)/sources && \\
|
2006-06-10 17:58:06 +02:00
|
|
|
touch \$@ && \\
|
|
|
|
echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
|
|
|
echo --------------------------------------------------------------------------------\$(WHITE)
|
2006-04-06 21:35:22 +02:00
|
|
|
|
|
|
|
022-settingenvironment: 021-addinguser
|
|
|
|
@\$(call echo_message, Building)
|
2006-07-30 13:34:49 +02:00
|
|
|
@if [ -f /home/hlfs/.bashrc -a ! -f /home/hlfs/.bashrc.XXX ]; then \\
|
|
|
|
mv /home/hlfs/.bashrc /home/hlfs/.bashrc.XXX; \\
|
2006-04-06 21:35:22 +02:00
|
|
|
fi;
|
2006-07-30 13:34:49 +02:00
|
|
|
@if [ -f /home/hlfs/.bash_profile -a ! -f /home/hlfs/.bash_profile.XXX ]; then \\
|
|
|
|
mv /home/hlfs/.bash_profile /home/hlfs/.bash_profile.XXX; \\
|
2006-04-06 21:35:22 +02:00
|
|
|
fi;
|
2006-07-30 13:34:49 +02:00
|
|
|
@echo "set +h" > /home/hlfs/.bashrc && \\
|
|
|
|
echo "umask 022" >> /home/hlfs/.bashrc && \\
|
|
|
|
echo "HLFS=\$(MOUNT_PT)" >> /home/hlfs/.bashrc && \\
|
|
|
|
echo "LC_ALL=POSIX" >> /home/hlfs/.bashrc && \\
|
|
|
|
echo "PATH=/tools/bin:/bin:/usr/bin" >> /home/hlfs/.bashrc && \\
|
|
|
|
echo "export HLFS LC_ALL PATH" >> /home/hlfs/.bashrc && \\
|
|
|
|
echo "" >> /home/hlfs/.bashrc && \\
|
2006-04-06 21:35:22 +02:00
|
|
|
echo "target=$(uname -m)-${TARGET}" >> /home/lfs/.bashrc && \\
|
|
|
|
echo "ldso=/tools/lib/${LOADER}" >> /home/lfs/.bashrc && \\
|
|
|
|
echo "export target ldso" >> /home/lfs/.bashrc && \\
|
2006-07-30 13:34:49 +02:00
|
|
|
echo "source $JHALFSDIR/envars" >> /home/hlfs/.bashrc && \\
|
|
|
|
chown hlfs:hlfs /home/hlfs/.bashrc && \\
|
2006-04-06 21:35:22 +02:00
|
|
|
touch envars && \\
|
2006-06-10 17:58:06 +02:00
|
|
|
touch \$@ && \\
|
|
|
|
echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
|
|
|
echo --------------------------------------------------------------------------------\$(WHITE)
|
2006-04-06 21:35:22 +02:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#----------------------------#
|
|
|
|
chapter5_Makefiles() { # Bootstrap or temptools phase
|
|
|
|
#----------------------------#
|
|
|
|
local file
|
|
|
|
local this_script
|
|
|
|
|
|
|
|
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter5${R_arrow}"
|
|
|
|
|
|
|
|
for file in chapter05/* ; do
|
|
|
|
# Keep the script file name
|
|
|
|
this_script=`basename $file`
|
|
|
|
|
|
|
|
# Skip this script depending on jhalfs.conf flags set.
|
|
|
|
case $this_script in
|
|
|
|
# If no testsuites will be run, then TCL, Expect and DejaGNU aren't needed
|
|
|
|
*tcl* ) [[ "$TEST" = "0" ]] && continue; ;;
|
|
|
|
*expect* ) [[ "$TEST" = "0" ]] && continue; ;;
|
|
|
|
*dejagnu* ) [[ "$TEST" = "0" ]] && continue; ;;
|
|
|
|
# Nothing interestin in this script
|
|
|
|
*introduction* ) continue ;;
|
|
|
|
# Test if the stripping phase must be skipped
|
|
|
|
*stripping* ) [[ "$STRIP" = "0" ]] && continue ;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# First append each name of the script files to a list (this will become
|
|
|
|
# the names of the targets in the Makefile
|
|
|
|
chapter5="$chapter5 $this_script"
|
|
|
|
|
2006-07-30 13:34:49 +02:00
|
|
|
# Grab the name of the target
|
|
|
|
name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
|
2006-04-06 21:35:22 +02:00
|
|
|
|
|
|
|
# Adjust 'name'
|
|
|
|
case $name in
|
2006-06-20 23:14:44 +02:00
|
|
|
uclibc) name="uClibc" ;;
|
2006-04-06 21:35:22 +02:00
|
|
|
esac
|
|
|
|
|
|
|
|
# Set the dependency for the first target.
|
|
|
|
if [ -z $PREV ] ; then PREV=022-settingenvironment ; fi
|
|
|
|
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
# >>>>>>>> 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.
|
|
|
|
|
2006-07-30 13:34:49 +02:00
|
|
|
# This is a very special script and requires manual processing
|
|
|
|
# NO Optimization allowed
|
|
|
|
if [[ ${name} = "embryo-toolchain" ]] || \
|
|
|
|
[[ ${name} = "cocoon-toolchain" ]]; then
|
|
|
|
wrt_target "$this_script" "$PREV"
|
|
|
|
process_toolchain "${this_script}" "${file}"
|
|
|
|
wrt_touch
|
|
|
|
PREV=$this_script
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
#
|
|
|
|
wrt_target "$this_script" "$PREV"
|
2006-04-06 21:35:22 +02:00
|
|
|
# Find the version of the command files, if it corresponds with the building of
|
|
|
|
# a specific package
|
2006-06-20 23:14:44 +02:00
|
|
|
pkg_tarball=$(get_package_tarball_name $name)
|
|
|
|
# If $pkg_tarball isn't empty, we've got a package...
|
|
|
|
if [ "$pkg_tarball" != "" ] ; then
|
2006-05-11 22:21:14 +02:00
|
|
|
# Insert instructions for unpacking the package and to set the PKGDIR variable.
|
2006-07-30 13:34:49 +02:00
|
|
|
wrt_Unpack_SetOwner "hlfs" "$pkg_tarball"
|
2006-06-04 19:56:01 +02:00
|
|
|
# If the testsuites must be run, initialize the log file
|
|
|
|
[[ "$TEST" = "3" ]] && wrt_test_log "${this_script}"
|
|
|
|
# If using optimizations, write the instructions
|
2006-05-11 22:21:14 +02:00
|
|
|
[[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
|
|
|
fi
|
2006-04-06 21:35:22 +02:00
|
|
|
# Insert date and disk usage at the top of the log file, the script run
|
|
|
|
# and date and disk usage again at the bottom of the log file.
|
2006-07-30 13:34:49 +02:00
|
|
|
wrt_ExecuteAsUser "hlfs" "$this_script" "${file}"
|
2006-04-06 21:35:22 +02:00
|
|
|
|
|
|
|
# Remove the build directory(ies) except if the package build fails
|
|
|
|
# (so we can review config.cache, config.log, etc.)
|
2006-06-20 23:14:44 +02:00
|
|
|
if [ "$pkg_tarball" != "" ] ; then
|
2006-07-30 13:34:49 +02:00
|
|
|
wrt_remove_build_dirs "$name"
|
2006-04-06 21:35:22 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Include a touch of the target name so make can check if it's already been made.
|
2006-06-10 17:58:06 +02:00
|
|
|
wrt_touch
|
2006-04-06 21:35:22 +02:00
|
|
|
#
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
|
|
|
|
# Keep the script file name for Makefile dependencies.
|
|
|
|
PREV=$this_script
|
|
|
|
done # end for file in chapter05/*
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------#
|
|
|
|
chapter6_Makefiles() { # sysroot or chroot build phase
|
|
|
|
#----------------------------#
|
|
|
|
local file
|
|
|
|
local this_script
|
2006-04-29 16:44:29 +02:00
|
|
|
# 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 chapter6=""
|
|
|
|
mkdir chapter06$N
|
|
|
|
cp chapter06/* chapter06$N
|
|
|
|
for script in chapter06$N/* ; do
|
|
|
|
# Overwrite existing symlinks, files, and dirs
|
|
|
|
sed -e 's/ln -s /ln -sf /g' \
|
|
|
|
-e 's/^mv /&-f/g' -i ${script}
|
|
|
|
done
|
|
|
|
# Remove Bzip2 binaries before make install
|
|
|
|
sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i chapter06$N/*-bzip2
|
|
|
|
# Fix how Module-Init-Tools do the install target
|
|
|
|
sed -e 's@make install@make INSTALL=install install@' -i chapter06$N/*-module-init-tools
|
|
|
|
# Delete *old Readline libraries just after make install
|
|
|
|
sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i chapter06$N/*-readline
|
|
|
|
# Don't readd already existing groups
|
|
|
|
sed -e '/groupadd/d' -i chapter06$N/*-udev
|
|
|
|
fi
|
2006-04-06 21:35:22 +02:00
|
|
|
|
2006-04-29 16:44:29 +02:00
|
|
|
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N${R_arrow}"
|
2006-04-06 21:35:22 +02:00
|
|
|
|
2006-04-29 16:44:29 +02:00
|
|
|
for file in chapter06$N/* ; do
|
2006-04-06 21:35:22 +02:00
|
|
|
# Keep the script file name
|
|
|
|
this_script=`basename $file`
|
|
|
|
|
|
|
|
# Skip this script depending on jhalfs.conf flags set.
|
|
|
|
case $this_script in
|
|
|
|
# We'll run the chroot commands differently than the others, so skip them in the
|
|
|
|
# dependencies and target creation.
|
|
|
|
*chroot* ) continue ;;
|
|
|
|
# Test if the stripping phase must be skipped
|
|
|
|
*-stripping* ) [[ "$STRIP" = "0" ]] && continue ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Grab the name of the target
|
|
|
|
name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
|
|
|
|
|
2006-06-20 23:14:44 +02:00
|
|
|
case $name in
|
|
|
|
uclibc) name="uClibc" ;;
|
|
|
|
esac
|
|
|
|
|
2006-04-29 16:44:29 +02:00
|
|
|
# Find the version of the command files, if it corresponds with the building of
|
|
|
|
# a specific package
|
2006-06-20 23:14:44 +02:00
|
|
|
pkg_tarball=$(get_package_tarball_name $name)
|
2006-04-29 16:44:29 +02:00
|
|
|
|
2006-06-20 23:14:44 +02:00
|
|
|
if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
|
2006-04-29 16:44:29 +02:00
|
|
|
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
|
|
|
|
chapter6="$chapter6 ${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}"
|
|
|
|
|
2006-04-06 21:35:22 +02:00
|
|
|
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
#
|
|
|
|
# Drop in the name of the target on a new line, and the previous target
|
2006-07-30 13:34:49 +02:00
|
|
|
# as a dependency. Also call the echo_message function.
|
|
|
|
if [[ ${name} = "butterfly-toolchain" ]]; then
|
|
|
|
wrt_target "$this_script" "$PREV"
|
|
|
|
process_toolchain "${this_script}" "${file}"
|
|
|
|
wrt_touch
|
|
|
|
PREV=$this_script
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2006-04-29 16:44:29 +02:00
|
|
|
wrt_target "${this_script}${N}" "$PREV"
|
2006-04-06 21:35:22 +02:00
|
|
|
|
2006-06-20 23:14:44 +02:00
|
|
|
# If $pkg_tarball isn't empty, we've got a package...
|
2006-04-06 21:35:22 +02:00
|
|
|
# Insert instructions for unpacking the package and changing directories
|
2006-06-20 23:14:44 +02:00
|
|
|
if [ "$pkg_tarball" != "" ] ; then
|
|
|
|
wrt_unpack2 "$pkg_tarball"
|
2006-06-04 19:56:01 +02:00
|
|
|
# If the testsuites must be run, initialize the log file
|
|
|
|
case $name in
|
2006-07-30 13:34:49 +02:00
|
|
|
glibc )
|
2006-06-04 19:56:01 +02:00
|
|
|
[[ "$TEST" != "0" ]] && wrt_test_log2 "${this_script}"
|
|
|
|
;;
|
|
|
|
* )
|
|
|
|
[[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && wrt_test_log2 "${this_script}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
# If using optimizations, write the instructions
|
2006-05-11 22:21:14 +02:00
|
|
|
[[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
2006-04-06 21:35:22 +02:00
|
|
|
fi
|
|
|
|
|
2006-07-30 13:34:49 +02:00
|
|
|
# In the mount of kernel filesystems we need to set HLFS and not to use chroot.
|
2006-04-06 21:35:22 +02:00
|
|
|
case "${this_script}" in
|
|
|
|
*kernfs*)
|
2006-07-30 13:34:49 +02:00
|
|
|
wrt_RunAsRoot "hlfs" "${this_script}" "${file}"
|
2006-04-06 21:35:22 +02:00
|
|
|
;;
|
|
|
|
*) # The rest of Chapter06
|
|
|
|
wrt_run_as_chroot1 "${this_script}" "${file}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
#
|
|
|
|
# Remove the build directory(ies) except if the package build fails.
|
2006-06-20 23:14:44 +02:00
|
|
|
if [ "$pkg_tarball" != "" ] ; then
|
2006-04-06 21:35:22 +02:00
|
|
|
wrt_remove_build_dirs "$name"
|
|
|
|
fi
|
|
|
|
#
|
|
|
|
# Include a touch of the target name so make can check if it's already been made.
|
2006-06-10 17:58:06 +02:00
|
|
|
wrt_touch
|
2006-04-06 21:35:22 +02:00
|
|
|
#
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
|
|
|
|
# Keep the script file name for Makefile dependencies.
|
2006-04-29 16:44:29 +02:00
|
|
|
PREV=${this_script}${N}
|
|
|
|
# Set system_build envar for iteration targets
|
|
|
|
system_build=$chapter6
|
2006-04-06 21:35:22 +02:00
|
|
|
done # end for file in chapter06/*
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#----------------------------#
|
|
|
|
chapter7_Makefiles() { # Create a bootable system.. kernel, bootscripts..etc
|
|
|
|
#----------------------------#
|
|
|
|
local file
|
|
|
|
local this_script
|
|
|
|
|
|
|
|
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7${R_arrow}"
|
|
|
|
for file in chapter07/*; do
|
|
|
|
# Keep the script file name
|
|
|
|
this_script=`basename $file`
|
|
|
|
|
|
|
|
# Grub must be configured manually.
|
|
|
|
# The filesystems can't be unmounted via Makefile and the user
|
|
|
|
# should enter the chroot environment to create the root
|
|
|
|
# password, edit several files and setup Grub.
|
|
|
|
case $this_script in
|
|
|
|
*usage) continue ;; # Contains example commands
|
|
|
|
*grub) continue ;;
|
|
|
|
*console) continue ;; # Use the file generated by lfs-bootscripts
|
|
|
|
|
|
|
|
*kernel)
|
|
|
|
# If no .config file is supplied, the kernel build is skipped
|
|
|
|
[[ -z $CONFIG ]] && continue
|
|
|
|
cp $CONFIG $BUILDDIR/sources/kernel-config
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# First append then name of the script file to a list (this will become
|
|
|
|
# the names of the targets in the Makefile
|
|
|
|
chapter7="$chapter7 $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" "$PREV"
|
|
|
|
|
|
|
|
case "${this_script}" in
|
|
|
|
*bootscripts*)
|
2006-06-20 23:14:44 +02:00
|
|
|
wrt_unpack2 $(get_package_tarball_name "lfs-bootscripts")
|
|
|
|
blfs_bootscripts=$(get_package_tarball_name "blfs-bootscripts" | sed -e 's/.tar.*//' )
|
|
|
|
echo -e "\t@echo \"\$(MOUNT_PT)\$(SRC)/$blfs_bootscripts\" >> sources-dir" >> $MKFILE.tmp
|
2006-04-06 21:35:22 +02:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
case "${this_script}" in
|
|
|
|
*fstab*) # Check if we have a real /etc/fstab file
|
|
|
|
if [[ -n "$FSTAB" ]] ; then
|
|
|
|
wrt_copy_fstab "$this_script"
|
|
|
|
else # Initialize the log and run the script
|
|
|
|
wrt_run_as_chroot2 "${this_script}" "${file}"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*) # All other scripts
|
|
|
|
wrt_run_as_chroot2 "${this_script}" "${file}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Remove the build directory except if the package build fails.
|
|
|
|
case "${this_script}" in
|
|
|
|
*bootscripts*)
|
|
|
|
(
|
|
|
|
cat << EOF
|
2006-06-01 20:42:08 +02:00
|
|
|
@ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
|
2006-04-06 21:35:22 +02:00
|
|
|
rm -r \$(MOUNT_PT)\$(SRC)/\$\$ROOT
|
|
|
|
@rm -r \`cat sources-dir\` && \\
|
|
|
|
rm sources-dir
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Include a touch of the target name so make can check if it's already been made.
|
2006-06-10 17:58:06 +02:00
|
|
|
wrt_touch
|
2006-04-06 21:35:22 +02:00
|
|
|
#
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
|
|
|
|
# Keep the script file name for Makefile dependencies.
|
|
|
|
PREV=$this_script
|
|
|
|
done # for file in chapter07/*
|
2006-04-26 21:59:19 +02:00
|
|
|
|
|
|
|
# Add SBU-disk_usage report target if required
|
|
|
|
if [[ "$REPORT" = "1" ]] ; then wrt_report ; fi
|
2006-04-06 21:35:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------#
|
|
|
|
build_Makefile() { # Construct a Makefile from the book scripts
|
|
|
|
#----------------------------#
|
2006-04-29 16:08:43 +02:00
|
|
|
echo "Creating Makefile... ${BOLD}START${OFF}"
|
2006-04-06 21:35:22 +02:00
|
|
|
|
|
|
|
cd $JHALFSDIR/${PROGNAME}-commands
|
|
|
|
# Start with a clean Makefile.tmp file
|
|
|
|
>$MKFILE.tmp
|
|
|
|
|
|
|
|
chapter3_Makefiles
|
|
|
|
chapter5_Makefiles
|
|
|
|
chapter6_Makefiles
|
2006-04-29 16:44:29 +02:00
|
|
|
# Add the iterations targets, if needed
|
|
|
|
[[ "$COMPARE" != "0" ]] && wrt_compare_targets
|
2006-04-06 21:35:22 +02:00
|
|
|
chapter7_Makefiles
|
|
|
|
|
|
|
|
# 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
|
2006-06-01 20:42:08 +02:00
|
|
|
PKG_LST= $PKG_LST
|
2006-04-06 21:35:22 +02:00
|
|
|
|
|
|
|
include makefile-functions
|
|
|
|
|
|
|
|
EOF
|
|
|
|
) > $MKFILE
|
|
|
|
|
|
|
|
|
|
|
|
# Add chroot commands
|
|
|
|
i=1
|
|
|
|
for file in chapter06/*chroot* ; do
|
|
|
|
chroot=`cat $file | sed -e '/#!\/bin\/sh/d' \
|
|
|
|
-e '/^export/d' \
|
|
|
|
-e '/^logout/d' \
|
|
|
|
-e 's@ \\\@ @g' | tr -d '\n' | sed -e 's/ */ /g' \
|
|
|
|
-e 's|\\$|&&|g' \
|
|
|
|
-e 's|exit||g' \
|
|
|
|
-e 's|$| -c|' \
|
|
|
|
-e 's|"$$HLFS"|$(MOUNT_PT)|'\
|
|
|
|
-e 's|set -e||'`
|
|
|
|
echo -e "CHROOT$i= $chroot\n" >> $MKFILE
|
|
|
|
i=`expr $i + 1`
|
|
|
|
done
|
|
|
|
|
|
|
|
# Drop in the main target 'all:' and the chapter targets with each sub-target
|
|
|
|
# as a dependency.
|
|
|
|
(
|
|
|
|
cat << EOF
|
2006-05-13 17:57:52 +02:00
|
|
|
all: chapter3 chapter5 chapter6 chapter7 do-housekeeping
|
2006-04-06 21:35:22 +02:00
|
|
|
@\$(call echo_finished,$VERSION)
|
|
|
|
|
|
|
|
chapter3: 020-creatingtoolsdir 021-addinguser 022-settingenvironment
|
|
|
|
|
2006-07-30 13:34:49 +02:00
|
|
|
chapter5: chapter3 $chapter5 restore-hlfs-env
|
2006-04-06 21:35:22 +02:00
|
|
|
|
|
|
|
chapter6: chapter5 $chapter6
|
|
|
|
|
|
|
|
chapter7: chapter6 $chapter7
|
|
|
|
|
|
|
|
clean-all: clean
|
|
|
|
rm -rf ./{hlfs-commands,logs,Makefile,*.xsl,makefile-functions,packages,patches}
|
|
|
|
|
|
|
|
clean: clean-chapter7 clean-chapter6 clean-chapter5 clean-chapter3
|
|
|
|
|
2006-06-20 23:14:44 +02:00
|
|
|
restart: restart_code all
|
|
|
|
|
2006-04-06 21:35:22 +02:00
|
|
|
clean-chapter3:
|
2006-07-30 13:34:49 +02:00
|
|
|
-if [ ! -f user-hlfs-exist ]; then \\
|
|
|
|
userdel hlfs; \\
|
|
|
|
rm -rf /home/hlfs; \\
|
2006-04-06 21:35:22 +02:00
|
|
|
fi;
|
|
|
|
rm -rf \$(MOUNT_PT)/tools
|
|
|
|
rm -f /tools
|
2006-07-30 13:34:49 +02:00
|
|
|
rm -f envars user-hlfs-exist
|
2006-04-06 21:35:22 +02:00
|
|
|
rm -f 02* logs/02*.log
|
|
|
|
|
|
|
|
clean-chapter5:
|
|
|
|
rm -rf \$(MOUNT_PT)/tools/*
|
2006-07-30 13:34:49 +02:00
|
|
|
rm -f $chapter5 restore-hlfs-env sources-dir
|
2006-04-06 21:35:22 +02:00
|
|
|
cd logs && rm -f $chapter5 && cd ..
|
|
|
|
|
|
|
|
clean-chapter6:
|
|
|
|
-umount \$(MOUNT_PT)/sys
|
|
|
|
-umount \$(MOUNT_PT)/proc
|
|
|
|
-umount \$(MOUNT_PT)/dev/shm
|
|
|
|
-umount \$(MOUNT_PT)/dev/pts
|
|
|
|
-umount \$(MOUNT_PT)/dev
|
|
|
|
rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
|
|
|
|
rm -f $chapter6
|
|
|
|
cd logs && rm -f $chapter6 && cd ..
|
|
|
|
|
|
|
|
clean-chapter7:
|
|
|
|
rm -f $chapter7
|
|
|
|
cd logs && rm -f $chapter7 && cd ..
|
|
|
|
|
2006-07-30 13:34:49 +02:00
|
|
|
restore-hlfs-env:
|
2006-04-06 21:35:22 +02:00
|
|
|
@\$(call echo_message, Building)
|
2006-07-30 13:34:49 +02:00
|
|
|
@if [ -f /home/hlfs/.bashrc.XXX ]; then \\
|
|
|
|
mv -f /home/hlfs/.bashrc.XXX /home/hlfs/.bashrc; \\
|
2006-04-06 21:35:22 +02:00
|
|
|
fi;
|
2006-07-30 13:34:49 +02:00
|
|
|
@if [ -f /home/hlfs/.bash_profile.XXX ]; then \\
|
|
|
|
mv /home/hlfs/.bash_profile.XXX /home/hlfs/.bash_profile; \\
|
2006-04-06 21:35:22 +02:00
|
|
|
fi;
|
2006-07-30 13:34:49 +02:00
|
|
|
@chown hlfs:hlfs /home/hlfs/.bash* && \\
|
2006-06-10 17:58:06 +02:00
|
|
|
touch \$@ && \\
|
|
|
|
echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
|
|
|
echo --------------------------------------------------------------------------------\$(WHITE)
|
2006-04-06 21:35:22 +02:00
|
|
|
|
2006-05-13 17:32:39 +02:00
|
|
|
do-housekeeping:
|
2006-06-10 18:11:58 +02:00
|
|
|
@-umount \$(MOUNT_PT)/dev/pts
|
|
|
|
@-umount \$(MOUNT_PT)/dev/shm
|
|
|
|
@-umount \$(MOUNT_PT)/dev
|
|
|
|
@-umount \$(MOUNT_PT)/sys
|
|
|
|
@-umount \$(MOUNT_PT)/proc
|
2006-07-30 13:34:49 +02:00
|
|
|
@-if [ ! -f user-hlfs-exist ]; then \\
|
|
|
|
userdel hlfs; \\
|
|
|
|
rm -rf /home/hlfs; \\
|
2006-05-13 17:32:39 +02:00
|
|
|
fi;
|
2006-05-31 22:43:41 +02:00
|
|
|
|
2006-06-20 23:14:44 +02:00
|
|
|
restart_code:
|
2006-07-30 13:34:49 +02:00
|
|
|
@echo ">>> This feature is experimental, BUGS may exist"
|
|
|
|
|
2006-06-20 23:14:44 +02:00
|
|
|
@if [ ! -L /tools ]; then \\
|
|
|
|
echo -e "\\nERROR::\\n /tools is NOT a symlink.. /tools must point to \$(MOUNT_PT)/tools\\n" && false;\\
|
|
|
|
fi;
|
2006-07-30 13:34:49 +02:00
|
|
|
|
2006-06-20 23:14:44 +02:00
|
|
|
@if [ ! -e /tools ]; then \\
|
|
|
|
echo -e "\\nERROR::\\nThe target /tools points to does not exist.\\nVerify the target.. \$(MOUNT_PT)/tools\\n" && false;\\
|
|
|
|
fi;
|
2006-07-30 13:34:49 +02:00
|
|
|
|
2006-06-20 23:14:44 +02:00
|
|
|
@if ! stat -c %N /tools | grep "\$(MOUNT_PT)/tools" >/dev/null ; then \\
|
|
|
|
echo -e "\\nERROR::\\nThe symlink \\"/tools\\" does not point to \\"\$(MOUNT_PT)/tools\\".\\nCorrect the problem and rerun\\n" && false;\\
|
2006-07-30 13:34:49 +02:00
|
|
|
fi;
|
2006-06-20 23:14:44 +02:00
|
|
|
|
|
|
|
@if [ -f ???-kernfs ]; then \\
|
|
|
|
mkdir -pv \$(MOUNT_PT)/{proc,sys};\\
|
|
|
|
if ! mount -l | "\$(MOUNT_PT)/dev" >/dev/null ; then \\
|
|
|
|
mount -vt ramfs ramfs \$(MOUNT_PT)/dev;\\
|
|
|
|
fi;\\
|
|
|
|
if [ ! -e \$(MOUNT_PT)/dev/console ]; then \\
|
|
|
|
mknod -m 600 \$(MOUNT_PT)/dev/console c 5 1;\\
|
|
|
|
fi;\\
|
|
|
|
if [ ! -e \$(MOUNT_PT)/dev/null ]; then \\
|
|
|
|
mknod -m 666 \$(MOUNT_PT)/dev/null c 1 3;\\
|
|
|
|
fi;\\
|
|
|
|
if ! mount -l | grep "\$(MOUNT_PT)/dev/pts" >/dev/null ; then \\
|
|
|
|
mount -vt devpts -o gid=4,mode=620 devpts \$(MOUNT_PT)/dev/pts;\\
|
|
|
|
fi;\\
|
|
|
|
if ! mount -l | grep "\$(MOUNT_PT)/dev/shm" >/dev/null ; then \\
|
|
|
|
mount -vt tmpfs shm \$(MOUNT_PT)/dev/shm;\\
|
|
|
|
fi;\\
|
|
|
|
if ! mount -l | grep "\$(MOUNT_PT)/proc" >/dev/null ; then \\
|
|
|
|
mount -vt proc proc \$(MOUNT_PT)/proc;\\
|
|
|
|
fi;\\
|
|
|
|
if ! mount -l | grep "\$(MOUNT_PT)/sys" >/dev/null ; then \\
|
|
|
|
mount -vt sysfs sysfs \$(MOUNT_PT)/sys;\\
|
|
|
|
fi;\\
|
|
|
|
fi;
|
|
|
|
|
|
|
|
|
2006-04-06 21:35:22 +02:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE
|
|
|
|
|
|
|
|
# Bring over the items from the Makefile.tmp
|
|
|
|
cat $MKFILE.tmp >> $MKFILE
|
|
|
|
rm $MKFILE.tmp
|
2006-04-29 16:08:43 +02:00
|
|
|
echo "Creating Makefile... ${BOLD}DONE${OFF}"
|
|
|
|
|
2006-04-06 21:35:22 +02:00
|
|
|
}
|