2006-11-11 12:39:16 +01:00
|
|
|
#!/bin/bash
|
2006-04-06 21:35:22 +02:00
|
|
|
set -e # Enable error trapping
|
|
|
|
|
|
|
|
###################################
|
|
|
|
### FUNCTIONS ###
|
|
|
|
###################################
|
|
|
|
|
2006-10-02 21:32:06 +02:00
|
|
|
|
2006-07-30 12:17:29 +02:00
|
|
|
#----------------------------#
|
|
|
|
process_toolchain() { # embryo,cocoon and butterfly need special handling
|
|
|
|
#----------------------------#
|
|
|
|
local toolchain=$1
|
2006-10-02 21:32:06 +02:00
|
|
|
local this_file=$2
|
|
|
|
local tc_phase
|
2006-08-16 19:42:54 +02:00
|
|
|
local binutil_tarball
|
|
|
|
local gcc_core_tarball
|
2006-10-02 21:32:06 +02:00
|
|
|
local TC_MountPT
|
|
|
|
local remove_existing
|
|
|
|
|
2006-12-05 16:25:00 +01:00
|
|
|
tc_phase=`echo $toolchain | sed -e 's@[0-9]\{3\}-@@' -e 's@-toolchain@@' -e 's,'$N',,'`
|
2006-10-02 21:32:06 +02:00
|
|
|
case $tc_phase in
|
|
|
|
embryo | \
|
|
|
|
cocoon) # Vars for LUSER phase
|
|
|
|
remove_existing="remove_existing_dirs"
|
|
|
|
TC_MountPT="\$(MOUNT_PT)\$(SRC)"
|
|
|
|
;;
|
|
|
|
butterfly) # Vars for CHROOT phase
|
|
|
|
remove_existing="remove_existing_dirs2"
|
|
|
|
TC_MountPT="\$(SRC)"
|
|
|
|
;;
|
|
|
|
esac
|
2006-07-30 12:17:29 +02:00
|
|
|
|
2006-08-05 13:37:27 +02:00
|
|
|
#
|
|
|
|
# Safe method to remove existing toolchain dirs
|
2006-08-16 19:42:54 +02:00
|
|
|
binutil_tarball=$(get_package_tarball_name "binutils")
|
|
|
|
gcc_core_tarball=$(get_package_tarball_name "gcc-core")
|
|
|
|
(
|
|
|
|
cat << EOF
|
2006-10-02 21:32:06 +02:00
|
|
|
@\$(call ${remove_existing},$binutil_tarball)
|
|
|
|
@\$(call ${remove_existing},$gcc_core_tarball)
|
2006-08-16 19:42:54 +02:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
|
2006-08-05 13:37:27 +02:00
|
|
|
#
|
|
|
|
# Manually remove the toolchain directories..
|
|
|
|
(
|
|
|
|
cat << EOF
|
2006-10-02 21:32:06 +02:00
|
|
|
@rm -rf ${TC_MountPT}/${tc_phase}-toolchain && \\
|
|
|
|
rm -rf ${TC_MountPT}/${tc_phase}-build
|
2006-08-05 13:37:27 +02:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
|
2006-07-30 12:17:29 +02:00
|
|
|
|
|
|
|
(
|
|
|
|
cat << EOF
|
2006-10-02 21:32:06 +02:00
|
|
|
@echo "export PKGDIR=${TC_MountPT}" > envars
|
2006-07-30 12:17:29 +02:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
2006-10-02 21:32:06 +02:00
|
|
|
|
|
|
|
case ${tc_phase} in
|
|
|
|
butterfly)
|
|
|
|
[[ "$TEST" != "0" ]] && CHROOT_wrt_test_log "${toolchain}"
|
|
|
|
CHROOT_wrt_RunAsRoot "$this_file"
|
|
|
|
;;
|
|
|
|
*) LUSER_wrt_RunAsUser "$this_file"
|
2006-07-30 12:17:29 +02:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
#
|
2006-08-16 19:42:54 +02:00
|
|
|
(
|
|
|
|
cat << EOF
|
2006-10-02 21:32:06 +02:00
|
|
|
@\$(call ${remove_existing},$binutil_tarball)
|
|
|
|
@\$(call ${remove_existing},$gcc_core_tarball)
|
2006-08-16 19:42:54 +02:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
|
2006-07-30 12:17:29 +02:00
|
|
|
#
|
|
|
|
# Manually remove the toolchain directories..
|
|
|
|
(
|
|
|
|
cat << EOF
|
2006-10-02 21:32:06 +02:00
|
|
|
@rm -rf ${TC_MountPT}/${tc_phase}-toolchain && \\
|
|
|
|
rm -rf ${TC_MountPT}/${tc_phase}-build
|
2006-07-30 12:17:29 +02:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2006-04-06 21:35:22 +02:00
|
|
|
|
|
|
|
#----------------------------#
|
|
|
|
chapter3_Makefiles() { # Initialization of the system
|
|
|
|
#----------------------------#
|
|
|
|
|
2006-10-02 21:32:06 +02:00
|
|
|
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter3 ( SETUP ) ${R_arrow}"
|
2006-04-06 21:35:22 +02:00
|
|
|
|
2007-04-13 22:40:38 +02:00
|
|
|
# If $LUSER_HOME is already present in the host, we asume that the
|
2006-07-30 12:17:29 +02:00
|
|
|
# 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 && \\
|
2007-03-18 11:14:04 +01:00
|
|
|
ln -s \$(MOUNT_PT)/tools /
|
|
|
|
@\$(call housekeeping)
|
2006-04-06 21:35:22 +02:00
|
|
|
|
|
|
|
021-addinguser: 020-creatingtoolsdir
|
|
|
|
@\$(call echo_message, Building)
|
2007-04-13 22:40:38 +02:00
|
|
|
@if [ ! -d \$(LUSER_HOME) ]; then \\
|
2006-08-08 19:26:40 +02:00
|
|
|
groupadd \$(LGROUP); \\
|
|
|
|
useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\
|
2006-04-06 21:35:22 +02:00
|
|
|
else \\
|
2006-08-08 19:26:40 +02:00
|
|
|
touch luser-exist; \\
|
2006-04-06 21:35:22 +02:00
|
|
|
fi;
|
2006-08-08 19:26:40 +02:00
|
|
|
@chown \$(LUSER) \$(MOUNT_PT)/tools && \\
|
2006-12-04 20:23:26 +01:00
|
|
|
chmod -R a+wt \$(MOUNT_PT)/\$(SCRIPT_ROOT) && \\
|
2007-03-18 11:14:04 +01:00
|
|
|
chmod a+wt \$(SRCSDIR)
|
|
|
|
@\$(call housekeeping)
|
2006-04-06 21:35:22 +02:00
|
|
|
|
|
|
|
022-settingenvironment: 021-addinguser
|
|
|
|
@\$(call echo_message, Building)
|
2007-04-13 22:40:38 +02:00
|
|
|
@if [ -f \$(LUSER_HOME)/.bashrc -a ! -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
|
|
|
|
mv \$(LUSER_HOME)/.bashrc \$(LUSER_HOME)/.bashrc.XXX; \\
|
2006-04-06 21:35:22 +02:00
|
|
|
fi;
|
2007-04-13 22:40:38 +02:00
|
|
|
@if [ -f \$(LUSER_HOME)/.bash_profile -a ! -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
|
|
|
|
mv \$(LUSER_HOME)/.bash_profile \$(LUSER_HOME)/.bash_profile.XXX; \\
|
2006-04-06 21:35:22 +02:00
|
|
|
fi;
|
2007-04-13 22:40:38 +02:00
|
|
|
@echo "set +h" > \$(LUSER_HOME)/.bashrc && \\
|
|
|
|
echo "umask 022" >> \$(LUSER_HOME)/.bashrc && \\
|
|
|
|
echo "HLFS=\$(MOUNT_PT)" >> \$(LUSER_HOME)/.bashrc && \\
|
|
|
|
echo "LC_ALL=POSIX" >> \$(LUSER_HOME)/.bashrc && \\
|
|
|
|
echo "PATH=/tools/bin:/bin:/usr/bin" >> \$(LUSER_HOME)/.bashrc && \\
|
|
|
|
echo "export HLFS LC_ALL PATH" >> \$(LUSER_HOME)/.bashrc && \\
|
|
|
|
echo "" >> \$(LUSER_HOME)/.bashrc && \\
|
|
|
|
echo "source $JHALFSDIR/envars" >> \$(LUSER_HOME)/.bashrc && \\
|
|
|
|
chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bashrc && \\
|
2006-10-02 21:32:06 +02:00
|
|
|
chmod -R a+wt \$(MOUNT_PT) && \\
|
2006-04-06 21:35:22 +02:00
|
|
|
touch envars && \\
|
2007-03-18 11:14:04 +01:00
|
|
|
chown \$(LUSER) envars
|
|
|
|
@\$(call housekeeping)
|
2006-04-06 21:35:22 +02:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
2006-10-02 21:32:06 +02:00
|
|
|
chapter3=" 020-creatingtoolsdir 021-addinguser 022-settingenvironment"
|
2006-04-06 21:35:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#----------------------------#
|
|
|
|
chapter5_Makefiles() { # Bootstrap or temptools phase
|
|
|
|
#----------------------------#
|
|
|
|
local file
|
|
|
|
local this_script
|
|
|
|
|
2006-10-02 21:32:06 +02:00
|
|
|
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter5 ( LUSER ) ${R_arrow}"
|
2006-04-06 21:35:22 +02:00
|
|
|
|
|
|
|
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; ;;
|
|
|
|
# Test if the stripping phase must be skipped
|
2006-08-16 19:42:54 +02:00
|
|
|
*stripping* ) [[ "$STRIP" = "n" ]] && continue ;;
|
2006-04-06 21:35:22 +02:00
|
|
|
*) ;;
|
|
|
|
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 12:17:29 +02:00
|
|
|
# Grab the name of the target
|
2006-12-09 20:22:38 +01:00
|
|
|
name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-pass[0-9]\{1\}@@'`
|
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 12:17:29 +02:00
|
|
|
# This is a very special script and requires manual processing
|
|
|
|
# NO Optimization allowed
|
|
|
|
if [[ ${name} = "embryo-toolchain" ]] || \
|
|
|
|
[[ ${name} = "cocoon-toolchain" ]]; then
|
2006-10-02 21:32:06 +02:00
|
|
|
LUSER_wrt_target "$this_script" "$PREV"
|
2006-07-30 12:17:29 +02:00
|
|
|
process_toolchain "${this_script}" "${file}"
|
|
|
|
wrt_touch
|
|
|
|
PREV=$this_script
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
#
|
2006-10-02 21:32:06 +02:00
|
|
|
LUSER_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
|
2006-12-09 20:22:38 +01:00
|
|
|
# a specific package. Fix GCC tarball name for 2.4-branch.
|
|
|
|
case $name in
|
|
|
|
gcc ) pkg_tarball=$(get_package_tarball_name gcc-core) ;;
|
|
|
|
* ) pkg_tarball=$(get_package_tarball_name $name) ;;
|
|
|
|
esac
|
2006-06-20 23:14:44 +02:00
|
|
|
# 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-10-02 21:32:06 +02:00
|
|
|
LUSER_wrt_unpack "$pkg_tarball"
|
2006-06-04 19:56:01 +02:00
|
|
|
# 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-10-02 21:32:06 +02:00
|
|
|
LUSER_wrt_RunAsUser "${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-10-02 21:32:06 +02:00
|
|
|
LUSER_RemoveBuildDirs "$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
|
|
|
|
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' \
|
2006-12-05 16:25:00 +01:00
|
|
|
-e 's/^mv /&-f /g' \
|
|
|
|
-e 's/mkdir -v/&p/g' -i ${script}
|
|
|
|
# Rename the scripts
|
|
|
|
mv ${script} ${script}$N
|
2006-04-29 16:44:29 +02:00
|
|
|
done
|
|
|
|
# Remove Bzip2 binaries before make install
|
2006-12-05 16:25:00 +01:00
|
|
|
sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i chapter06$N/*-bzip2$N
|
2006-04-29 16:44:29 +02:00
|
|
|
# Fix how Module-Init-Tools do the install target
|
2006-12-05 16:25:00 +01:00
|
|
|
sed -e 's@make install@make INSTALL=install install@' -i chapter06$N/*-module-init-tools$N
|
2006-04-29 16:44:29 +02:00
|
|
|
# Don't readd already existing groups
|
2006-12-05 16:25:00 +01:00
|
|
|
sed -e '/groupadd/d' -i chapter06$N/*-udev$N
|
2006-04-29 16:44:29 +02:00
|
|
|
fi
|
2006-04-06 21:35:22 +02:00
|
|
|
|
2006-10-02 21:32:06 +02:00
|
|
|
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N ( CHROOT ) ${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
|
2006-08-16 19:42:54 +02:00
|
|
|
*-stripping* ) [[ "$STRIP" = "n" ]] && continue ;;
|
2006-12-07 11:51:26 +01:00
|
|
|
# Skip linux-headers in iterative builds
|
|
|
|
*linux-headers*) [[ -n "$N" ]] && continue ;;
|
2006-04-06 21:35:22 +02:00
|
|
|
esac
|
|
|
|
|
|
|
|
# Grab the name of the target
|
2006-12-05 16:25:00 +01:00
|
|
|
name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's,'$N',,'`
|
2006-04-06 21:35:22 +02:00
|
|
|
|
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
|
2006-12-09 20:22:38 +01:00
|
|
|
# a specific package. Fix GCC tarball name for 2.4-branch.
|
|
|
|
case $name in
|
|
|
|
gcc ) pkg_tarball=$(get_package_tarball_name gcc-core) ;;
|
|
|
|
* ) pkg_tarball=$(get_package_tarball_name $name) ;;
|
|
|
|
esac
|
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
|
2006-12-08 13:21:02 +01:00
|
|
|
case "${this_script}" in
|
2006-12-09 20:32:34 +01:00
|
|
|
*kernfs* ) runasroot=" ${this_script}" ;;
|
|
|
|
* ) chapter6="$chapter6 ${this_script}" ;;
|
2006-12-08 13:21:02 +01:00
|
|
|
esac
|
2006-04-29 16:44:29 +02:00
|
|
|
|
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 12:17:29 +02:00
|
|
|
# as a dependency. Also call the echo_message function.
|
|
|
|
if [[ ${name} = "butterfly-toolchain" ]]; then
|
2007-06-03 11:06:13 +02:00
|
|
|
CHROOT_wrt_target "${this_script}" "$PREV"
|
|
|
|
# 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
|
|
|
|
process_toolchain "${this_script}" "${file}"
|
|
|
|
if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
|
|
|
|
CHROOT_wrt_LogNewFiles "$name"
|
|
|
|
fi
|
|
|
|
wrt_touch
|
|
|
|
PREV=$this_script
|
|
|
|
continue
|
2006-07-30 12:17:29 +02:00
|
|
|
fi
|
2006-12-09 20:32:34 +01:00
|
|
|
# kernfs is run in SUDO target
|
2006-12-08 13:21:02 +01:00
|
|
|
case "${this_script}" in
|
2006-12-09 20:32:34 +01:00
|
|
|
*kernfs* ) LUSER_wrt_target "${this_script}" "$PREV" ;;
|
|
|
|
* ) CHROOT_wrt_target "${this_script}" "$PREV" ;;
|
2006-12-08 13:21:02 +01:00
|
|
|
esac
|
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
|
2007-06-03 11:06:13 +02:00
|
|
|
# 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
|
2006-10-02 21:32:06 +02:00
|
|
|
CHROOT_Unpack "$pkg_tarball"
|
2006-06-04 19:56:01 +02:00
|
|
|
# If the testsuites must be run, initialize the log file
|
2006-08-01 21:28:45 +02:00
|
|
|
# butterfly-toolchain tests are enabled in 'process_tookchain' function
|
2006-12-09 20:22:38 +01:00
|
|
|
# 2.4-branch toolchain is ernabled here.
|
2006-06-04 19:56:01 +02:00
|
|
|
case $name in
|
2006-12-09 20:22:38 +01:00
|
|
|
glibc | gcc | binutils)
|
|
|
|
[[ "$TEST" != "0" ]] && CHROOT_wrt_test_log "${this_script}" ;;
|
|
|
|
* ) [[ "$TEST" > "1" ]] && CHROOT_wrt_test_log "${this_script}" ;;
|
2006-06-04 19:56:01 +02:00
|
|
|
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-12-09 20:32:34 +01:00
|
|
|
# In kernfs we need to set HLFS and not to use chroot.
|
2006-04-06 21:35:22 +02:00
|
|
|
case "${this_script}" in
|
2006-12-09 20:32:34 +01:00
|
|
|
*kernfs* ) wrt_RunAsRoot "${file}" ;;
|
|
|
|
* ) CHROOT_wrt_RunAsRoot "${file}" ;;
|
2006-04-06 21:35:22 +02:00
|
|
|
esac
|
|
|
|
#
|
2007-06-03 11:06:13 +02:00
|
|
|
# Write installed files log and remove the build directory(ies)
|
|
|
|
# except if the package build fails.
|
2006-06-20 23:14:44 +02:00
|
|
|
if [ "$pkg_tarball" != "" ] ; then
|
2006-10-02 21:32:06 +02:00
|
|
|
CHROOT_wrt_RemoveBuildDirs "$name"
|
2007-06-03 11:06:13 +02:00
|
|
|
if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
|
|
|
|
CHROOT_wrt_LogNewFiles "$name"
|
|
|
|
fi
|
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.
|
2006-12-05 16:25:00 +01:00
|
|
|
PREV=${this_script}
|
2006-04-29 16:44:29 +02:00
|
|
|
# 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
|
|
|
|
|
2006-10-02 21:32:06 +02:00
|
|
|
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7 ( BOOT ) ${R_arrow}"
|
2006-04-06 21:35:22 +02:00
|
|
|
for file in chapter07/*; do
|
|
|
|
# Keep the script file name
|
|
|
|
this_script=`basename $file`
|
|
|
|
|
|
|
|
case $this_script in
|
2007-06-07 20:55:42 +02:00
|
|
|
*grub) continue ;; # Grub must be configured manually.
|
2006-12-09 13:17:20 +01:00
|
|
|
*console) continue ;; # Use the file generated by lfs-bootscripts
|
|
|
|
*fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab
|
2006-10-02 21:32:06 +02:00
|
|
|
;;
|
2006-12-09 13:17:20 +01:00
|
|
|
*kernel) # If no .config file is supplied, the kernel build is skipped
|
|
|
|
[[ -z $CONFIG ]] && continue
|
|
|
|
cp $CONFIG $BUILDDIR/sources/kernel-config
|
2006-10-02 21:32:06 +02:00
|
|
|
;;
|
2006-04-06 21:35:22 +02:00
|
|
|
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.
|
2006-10-02 21:32:06 +02:00
|
|
|
CHROOT_wrt_target "$this_script" "$PREV"
|
2006-04-06 21:35:22 +02:00
|
|
|
|
|
|
|
case "${this_script}" in
|
|
|
|
*bootscripts*)
|
2007-06-03 11:06:13 +02:00
|
|
|
if [ "${INSTALL_LOG}" = "y" ] ; then
|
|
|
|
CHROOT_wrt_TouchTimestamp
|
|
|
|
fi
|
2006-10-02 21:32:06 +02:00
|
|
|
CHROOT_Unpack $(get_package_tarball_name "lfs-bootscripts")
|
2006-06-20 23:14:44 +02:00
|
|
|
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
|
|
|
;;
|
2007-03-28 14:24:52 +02:00
|
|
|
*kernel)
|
|
|
|
name="linux"
|
|
|
|
pkg_tarball=$(get_package_tarball_name $name)
|
2007-06-03 11:06:13 +02:00
|
|
|
if [ "${INSTALL_LOG}" = "y" ] ; then
|
|
|
|
CHROOT_wrt_TouchTimestamp
|
|
|
|
fi
|
2007-03-28 14:24:52 +02:00
|
|
|
CHROOT_Unpack "$pkg_tarball"
|
2007-06-03 11:06:13 +02:00
|
|
|
;;
|
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
|
2006-10-02 21:32:06 +02:00
|
|
|
CHROOT_wrt_CopyFstab
|
|
|
|
else
|
|
|
|
CHROOT_wrt_RunAsRoot "$file"
|
2006-04-06 21:35:22 +02:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*) # All other scripts
|
2006-10-02 21:32:06 +02:00
|
|
|
CHROOT_wrt_RunAsRoot "${file}"
|
2006-04-06 21:35:22 +02:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Remove the build directory except if the package build fails.
|
|
|
|
case "${this_script}" in
|
|
|
|
*bootscripts*)
|
|
|
|
(
|
|
|
|
cat << EOF
|
2006-10-02 21:32:06 +02:00
|
|
|
@ROOT=\`head -n1 \$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
|
|
|
|
rm -r \$(SRC)/\$\$ROOT
|
2007-03-28 14:24:52 +02:00
|
|
|
@rm -rf \`cat sources-dir\` && \\
|
2006-04-06 21:35:22 +02:00
|
|
|
rm sources-dir
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
2007-06-03 11:06:13 +02:00
|
|
|
if [ "${INSTALL_LOG}" = "y" ] ; then
|
|
|
|
CHROOT_wrt_LogNewFiles "$name"
|
|
|
|
fi
|
2006-04-06 21:35:22 +02:00
|
|
|
;;
|
2007-06-03 11:06:13 +02:00
|
|
|
*kernel) CHROOT_wrt_RemoveBuildDirs "dummy"
|
|
|
|
if [ "${INSTALL_LOG}" = "y" ] ; then
|
|
|
|
CHROOT_wrt_LogNewFiles "$name"
|
|
|
|
fi ;;
|
2006-04-06 21:35:22 +02:00
|
|
|
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/*
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------#
|
|
|
|
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
|
2006-08-16 19:42:54 +02:00
|
|
|
[[ "$COMPARE" = "y" ]] && wrt_compare_targets
|
2006-04-06 21:35:22 +02:00
|
|
|
chapter7_Makefiles
|
2006-12-15 11:53:10 +01:00
|
|
|
# Add the CUSTOM_TOOLS targets, if needed
|
|
|
|
[[ "$CUSTOM_TOOLS" = "y" ]] && wrt_CustomTools_target
|
|
|
|
# Add the BLFS_TOOL targets, if needed
|
|
|
|
[[ "$BLFS_TOOL" = "y" ]] && wrt_blfs_tool_targets
|
2006-04-06 21:35:22 +02:00
|
|
|
|
|
|
|
# Add a header, some variables and include the function file
|
|
|
|
# to the top of the real Makefile.
|
2006-11-11 20:55:13 +01:00
|
|
|
wrt_Makefile_header
|
2006-04-06 21:35:22 +02:00
|
|
|
|
|
|
|
# Add chroot commands
|
2006-08-08 19:26:40 +02:00
|
|
|
CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
|
2006-04-06 21:35:22 +02:00
|
|
|
i=1
|
|
|
|
for file in chapter06/*chroot* ; do
|
2006-08-08 19:26:40 +02:00
|
|
|
chroot=`cat $file | \
|
|
|
|
sed -e "s@chroot@$CHROOT_LOC@" \
|
2006-11-11 13:00:52 +01:00
|
|
|
-e '/#!\/bin\/bash/d' \
|
2006-08-08 19:26:40 +02:00
|
|
|
-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)|'\
|
2006-12-04 12:26:39 +01:00
|
|
|
-e 's|set -e||' \
|
|
|
|
-e 's|set +h||'`
|
2006-04-06 21:35:22 +02:00
|
|
|
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-10-02 21:32:06 +02:00
|
|
|
|
2006-12-15 11:53:10 +01:00
|
|
|
all: ck_UID mk_SETUP mk_LUSER mk_SUDO mk_CHROOT mk_BOOT create-sbu_du-report mk_CUSTOM_TOOLS mk_BLFS_TOOL
|
2006-10-02 21:32:06 +02:00
|
|
|
@sudo make do-housekeeping
|
2006-12-09 13:17:20 +01:00
|
|
|
@echo "$VERSION - jhalfs build" > hlfs-release && \\
|
|
|
|
sudo install -m444 hlfs-release \$(MOUNT_PT)/etc/hlfs-release
|
2006-04-06 21:35:22 +02:00
|
|
|
@\$(call echo_finished,$VERSION)
|
|
|
|
|
2006-10-02 21:32:06 +02:00
|
|
|
ck_UID:
|
|
|
|
@if [ \`id -u\` = "0" ]; then \\
|
|
|
|
echo "--------------------------------------------------"; \\
|
|
|
|
echo "You cannot run this makefile from the root account"; \\
|
|
|
|
echo "--------------------------------------------------"; \\
|
|
|
|
exit 1; \\
|
|
|
|
fi
|
|
|
|
|
|
|
|
mk_SETUP:
|
|
|
|
@\$(call echo_SU_request)
|
2007-03-18 11:14:04 +01:00
|
|
|
@sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
|
2006-10-02 21:32:06 +02:00
|
|
|
@touch \$@
|
|
|
|
|
|
|
|
mk_LUSER: mk_SETUP
|
|
|
|
@\$(call echo_SULUSER_request)
|
2007-03-18 11:14:04 +01:00
|
|
|
@(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) LUSER" )
|
2006-10-02 21:32:06 +02:00
|
|
|
@sudo make restore-luser-env
|
|
|
|
@touch \$@
|
|
|
|
|
|
|
|
mk_SUDO: mk_LUSER
|
2007-02-16 19:24:19 +01:00
|
|
|
@sudo make SUDO
|
2006-10-02 21:32:06 +02:00
|
|
|
@touch \$@
|
|
|
|
|
|
|
|
mk_CHROOT: mk_SUDO
|
2006-12-10 11:43:20 +01:00
|
|
|
@if [ ! -e \$(MOUNT_PT)/dev ]; then \\
|
|
|
|
mkdir \$(MOUNT_PT)/dev && \\
|
|
|
|
sudo mknod -m 666 \$(MOUNT_PT)/dev/null c 1 3 && \\
|
2006-12-10 11:45:34 +01:00
|
|
|
sudo mknod -m 600 \$(MOUNT_PT)/dev/console c 5 1 && \\
|
2007-03-27 19:37:18 +02:00
|
|
|
sudo chown -R 0:0 \$(MOUNT_PT)/dev; \\
|
2006-12-10 11:43:20 +01:00
|
|
|
fi;
|
2006-10-02 21:32:06 +02:00
|
|
|
@\$(call echo_CHROOT_request)
|
2007-03-18 11:14:04 +01:00
|
|
|
@( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CHROOT")
|
2006-10-02 21:32:06 +02:00
|
|
|
@touch \$@
|
2006-04-06 21:35:22 +02:00
|
|
|
|
2006-10-02 21:32:06 +02:00
|
|
|
mk_BOOT: mk_CHROOT
|
|
|
|
@\$(call echo_CHROOT_request)
|
2007-03-18 11:14:04 +01:00
|
|
|
@( sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BOOT")
|
2006-10-02 21:32:06 +02:00
|
|
|
@touch \$@
|
2006-04-06 21:35:22 +02:00
|
|
|
|
2006-12-15 11:53:10 +01:00
|
|
|
mk_CUSTOM_TOOLS: create-sbu_du-report
|
|
|
|
@if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
|
2007-03-02 01:09:55 +01:00
|
|
|
\$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
|
2006-12-15 11:53:10 +01:00
|
|
|
sudo mkdir -p ${BUILDDIR}${TRACKING_DIR}; \\
|
2007-03-18 11:14:04 +01:00
|
|
|
(sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
|
2006-12-15 11:53:10 +01:00
|
|
|
fi;
|
|
|
|
@touch \$@
|
|
|
|
|
|
|
|
mk_BLFS_TOOL: mk_CUSTOM_TOOLS
|
2006-11-12 14:50:34 +01:00
|
|
|
@if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
|
2007-03-02 01:09:55 +01:00
|
|
|
\$(call sh_echo_PHASE,Building BLFS_TOOL); \\
|
2006-11-12 14:50:34 +01:00
|
|
|
sudo mkdir -p $BUILDDIR$TRACKING_DIR; \\
|
2007-03-18 11:14:04 +01:00
|
|
|
(sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BLFS_TOOL"); \\
|
2006-11-12 14:50:34 +01:00
|
|
|
fi;
|
|
|
|
@touch \$@
|
2006-04-06 21:35:22 +02:00
|
|
|
|
|
|
|
|
2006-12-15 11:53:10 +01:00
|
|
|
SETUP: $chapter3
|
|
|
|
LUSER: $chapter5
|
|
|
|
SUDO: $runasroot
|
2007-02-26 21:18:52 +01:00
|
|
|
CHROOT: SHELL=/tools/bin/bash
|
2006-12-15 11:53:10 +01:00
|
|
|
CHROOT: $chapter6
|
|
|
|
BOOT: $chapter7
|
|
|
|
CUSTOM_TOOLS: $custom_list
|
|
|
|
BLFS_TOOL: $blfs_tool
|
2006-06-20 23:14:44 +02:00
|
|
|
|
2006-10-02 21:32:06 +02:00
|
|
|
|
2006-11-12 14:50:34 +01:00
|
|
|
create-sbu_du-report: mk_BOOT
|
|
|
|
@\$(call echo_message, Building)
|
|
|
|
@if [ "\$(ADD_REPORT)" = "y" ]; then \\
|
2017-06-29 18:45:31 +02:00
|
|
|
./create-sbu_du-report.sh logs $VERSION $(date --iso-8601); \\
|
2006-11-12 14:50:34 +01:00
|
|
|
\$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
|
|
|
|
fi;
|
|
|
|
@touch \$@
|
2006-10-02 21:32:06 +02:00
|
|
|
|
2006-08-08 19:26:40 +02:00
|
|
|
restore-luser-env:
|
2006-04-06 21:35:22 +02:00
|
|
|
@\$(call echo_message, Building)
|
2007-04-13 22:40:38 +02:00
|
|
|
@if [ -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
|
|
|
|
mv -f \$(LUSER_HOME)/.bashrc.XXX \$(LUSER_HOME)/.bashrc; \\
|
2006-04-06 21:35:22 +02:00
|
|
|
fi;
|
2007-04-13 22:40:38 +02:00
|
|
|
@if [ -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
|
|
|
|
mv \$(LUSER_HOME)/.bash_profile.XXX \$(LUSER_HOME)/.bash_profile; \\
|
2006-04-06 21:35:22 +02:00
|
|
|
fi;
|
2007-04-13 22:40:38 +02:00
|
|
|
@chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.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-10-02 21:32:06 +02:00
|
|
|
@-rm /tools
|
2006-08-08 19:26:40 +02:00
|
|
|
@-if [ ! -f luser-exist ]; then \\
|
|
|
|
userdel \$(LUSER); \\
|
2007-04-13 22:40:38 +02:00
|
|
|
rm -rf \$(LUSER_HOME); \\
|
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
|
|
|
|
|
|
|
|
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
|
|
|
}
|