2006-04-06 21:35:22 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# $Id$
|
|
|
|
|
|
|
|
###################################
|
|
|
|
### FUNCTIONS ###
|
|
|
|
###################################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------#
|
|
|
|
chapter4_Makefiles() {
|
|
|
|
#----------------------------#
|
|
|
|
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter4${R_arrow}"
|
|
|
|
|
2006-08-08 19:26:40 +02:00
|
|
|
# If /home/$LUSER is already present in the host, we asume that the
|
2006-04-06 21:35:22 +02:00
|
|
|
# lfs user and group are also presents in the host, and a backup
|
|
|
|
# of their bash init files is made.
|
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
020-creatingtoolsdir:
|
|
|
|
@\$(call echo_message, Building)
|
2006-06-08 02:42:03 +02:00
|
|
|
@mkdir \$(MOUNT_PT)/tools && \\
|
|
|
|
rm -f /tools && \\
|
|
|
|
ln -s \$(MOUNT_PT)/tools / && \\
|
2006-06-10 01:05:39 +02:00
|
|
|
touch \$@ && \\
|
2006-06-10 01:20:31 +02:00
|
|
|
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-08-08 19:26:40 +02:00
|
|
|
@if [ ! -d /home/\$(LUSER) ]; then \\
|
|
|
|
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-04-06 21:35:22 +02:00
|
|
|
chmod a+wt \$(MOUNT_PT)/sources && \\
|
2006-06-10 01:05:39 +02:00
|
|
|
touch \$@ && \\
|
2006-06-10 01:20:31 +02:00
|
|
|
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-08-08 19:26:40 +02:00
|
|
|
@if [ -f /home/\$(LUSER)/.bashrc -a ! -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
|
|
|
|
mv /home/\$(LUSER)/.bashrc /home/\$(LUSER)/.bashrc.XXX; \\
|
2006-04-06 21:35:22 +02:00
|
|
|
fi;
|
2006-08-08 19:26:40 +02:00
|
|
|
@if [ -f /home/\$(LUSER)/.bash_profile -a ! -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
|
|
|
|
mv /home/\$(LUSER)/.bash_profile /home/\$(LUSER)/.bash_profile.XXX; \\
|
2006-04-06 21:35:22 +02:00
|
|
|
fi;
|
2006-08-08 19:26:40 +02:00
|
|
|
@echo "set +h" > /home/\$(LUSER)/.bashrc && \\
|
|
|
|
echo "umask 022" >> /home/\$(LUSER)/.bashrc && \\
|
|
|
|
echo "LFS=\$(MOUNT_PT)" >> /home/\$(LUSER)/.bashrc && \\
|
|
|
|
echo "LC_ALL=POSIX" >> /home/\$(LUSER)/.bashrc && \\
|
|
|
|
echo "PATH=/tools/bin:/bin:/usr/bin" >> /home/\$(LUSER)/.bashrc && \\
|
|
|
|
echo "export LFS LC_ALL PATH" >> /home/\$(LUSER)/.bashrc && \\
|
|
|
|
echo "source $JHALFSDIR/envars" >> /home/\$(LUSER)/.bashrc && \\
|
|
|
|
chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bashrc && \\
|
2006-04-06 21:35:22 +02:00
|
|
|
touch envars && \\
|
2006-06-10 01:05:39 +02:00
|
|
|
touch \$@ && \\
|
2006-06-10 01:20:31 +02:00
|
|
|
echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
|
|
|
echo --------------------------------------------------------------------------------\$(WHITE)
|
2006-04-06 21:35:22 +02:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
#----------------------------#
|
|
|
|
chapter5_Makefiles() {
|
|
|
|
#----------------------------#
|
|
|
|
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter5${R_arrow}"
|
|
|
|
|
|
|
|
for file in chapter05/* ; do
|
|
|
|
# Keep the script file name
|
|
|
|
this_script=`basename $file`
|
|
|
|
|
|
|
|
# If no testsuites will be run, then TCL, Expect and DejaGNU aren't needed
|
2006-04-07 00:41:47 +02:00
|
|
|
# Fix also locales creation when running chapter05 testsuites (ugly)
|
2006-04-06 21:35:22 +02:00
|
|
|
case "${this_script}" in
|
|
|
|
*tcl) [[ "${TEST}" = "0" ]] && continue ;;
|
|
|
|
*expect) [[ "${TEST}" = "0" ]] && continue ;;
|
|
|
|
*dejagnu) [[ "${TEST}" = "0" ]] && continue ;;
|
|
|
|
*stripping) [[ "${STRIP}" = "0" ]] && continue ;;
|
2006-04-07 00:41:47 +02:00
|
|
|
*glibc) [[ "${TEST}" = "3" ]] && \
|
2006-04-07 19:19:51 +02:00
|
|
|
sed -i 's@/usr/lib/locale@/tools/lib/locale@' $file ;;
|
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}"
|
|
|
|
|
|
|
|
# Grab the name of the target (minus the -pass1 or -pass2 in the case of gcc
|
|
|
|
# and binutils in chapter 5)
|
|
|
|
name=`echo ${this_script} | sed -e 's@[0-9]\{3\}-@@' -e 's@-pass[0-9]\{1\}@@'`
|
|
|
|
|
|
|
|
# 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.
|
|
|
|
wrt_target "${this_script}" "$PREV"
|
|
|
|
|
|
|
|
# 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-05-28 00:51:06 +02:00
|
|
|
|
2006-06-20 23:14:44 +02:00
|
|
|
# If $pkg_tarball isn't empty, we've got a package...
|
|
|
|
if [ "$pkg_tarball" != "" ] ; then
|
2006-04-06 21:35:22 +02:00
|
|
|
# Insert instructions for unpacking the package and to set the PKGDIR variable.
|
2006-06-20 23:14:44 +02:00
|
|
|
wrt_unpack "$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"
|
2006-04-06 21:35:22 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# 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-04-07 00:41:47 +02:00
|
|
|
# The changingowner script must be run as root.
|
|
|
|
case "${this_script}" in
|
2006-08-08 19:26:40 +02:00
|
|
|
*changingowner) wrt_RunAsRoot "${this_script}" "$file" ;;
|
|
|
|
*) wrt_RunAsUser "${this_script}" "$file" ;;
|
2006-04-07 00:41:47 +02:00
|
|
|
esac
|
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-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 01:05:39 +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() {
|
|
|
|
#----------------------------#
|
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 -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 chapter06$N/*-bzip2
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N${R_arrow}"
|
|
|
|
|
|
|
|
for file in chapter06$N/* ; do
|
2006-04-06 21:35:22 +02:00
|
|
|
# Keep the script file name
|
|
|
|
this_script=`basename $file`
|
|
|
|
|
|
|
|
# We'll run the chroot commands differently than the others, so skip them in the
|
|
|
|
# dependencies and target creation.
|
|
|
|
case "${this_script}" in
|
|
|
|
*chroot) continue ;;
|
|
|
|
*stripping*) [[ "${STRIP}" = "0" ]] && continue ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Grab the name of the target
|
|
|
|
name=`echo ${this_script} | sed -e 's@[0-9]\{3\}-@@'`
|
|
|
|
|
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. We need this here to can skip scripts not needed for
|
|
|
|
# iterations rebuilds
|
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
|
|
|
|
# as a dependency. Also call the echo_message function.
|
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
|
|
|
|
binutils | gcc | glibc )
|
|
|
|
[[ "$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
|
|
|
|
|
|
|
|
# In the mount of kernel filesystems we need to set LFS
|
|
|
|
# and not to use chroot.
|
|
|
|
case "${this_script}" in
|
2006-08-08 19:26:40 +02:00
|
|
|
*kernfs) wrt_RunAsRoot "${this_script}" "$file" ;;
|
2006-04-06 21:35:22 +02:00
|
|
|
*) 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 01:05:39 +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/*
|
|
|
|
}
|
|
|
|
|
|
|
|
#----------------------------#
|
|
|
|
chapter789_Makefiles() {
|
|
|
|
#----------------------------#
|
|
|
|
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7/8/9${R_arrow}"
|
|
|
|
|
|
|
|
for file in chapter0{7,8,9}/* ; 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.
|
|
|
|
#
|
|
|
|
# If no .config file is supplied, the kernel build is skipped
|
|
|
|
#
|
|
|
|
case ${this_script} in
|
|
|
|
*grub) continue ;;
|
|
|
|
*reboot) continue ;;
|
|
|
|
*console) continue ;; # Use the file generated by lfs-bootscripts
|
|
|
|
*kernel) [[ -z ${CONFIG} ]] && continue
|
|
|
|
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
|
|
|
|
chapter789="$chapter789 ${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"
|
|
|
|
|
|
|
|
# Find the bootscripts and kernel package names
|
|
|
|
case "${this_script}" in
|
|
|
|
*bootscripts)
|
2006-06-20 23:14:44 +02:00
|
|
|
name="lfs-bootscripts"
|
|
|
|
pkg_tarball=$(get_package_tarball_name $name)
|
|
|
|
wrt_unpack2 "$pkg_tarball"
|
2006-04-06 21:35:22 +02:00
|
|
|
;;
|
|
|
|
*kernel)
|
2006-06-20 23:14:44 +02:00
|
|
|
name="linux"
|
|
|
|
pkg_tarball=$(get_package_tarball_name $name)
|
|
|
|
wrt_unpack2 "$pkg_tarball"
|
2006-04-06 21:35:22 +02:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Check if we have a real /etc/fstab file
|
|
|
|
case "${this_script}" in
|
|
|
|
*fstab) if [[ -n $FSTAB ]]; then
|
|
|
|
wrt_copy_fstab "${this_script}"
|
|
|
|
else
|
|
|
|
wrt_run_as_chroot2 "$this_script" "$file"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*) wrt_run_as_chroot2 "$this_script" "$file"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
case "${this_script}" in
|
|
|
|
*bootscripts) wrt_remove_build_dirs "dummy" ;;
|
|
|
|
*kernel) wrt_remove_build_dirs "dummy" ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Include a touch of the target name so make can check
|
|
|
|
# if it's already been made.
|
2006-06-10 01:05:39 +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 chapter0{7,8,9}/*
|
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() {
|
|
|
|
#----------------------------#
|
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
|
|
|
|
|
|
|
|
chapter4_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
|
|
|
chapter789_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-08-08 19:26:40 +02:00
|
|
|
LUSER= $LUSER
|
|
|
|
LGROUP= $LGROUP
|
2006-04-06 21:35:22 +02:00
|
|
|
|
|
|
|
include makefile-functions
|
|
|
|
|
|
|
|
EOF
|
|
|
|
) > $MKFILE
|
|
|
|
|
|
|
|
|
|
|
|
# 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@" \
|
|
|
|
-e '/#!\/bin\/sh/d' \
|
|
|
|
-e 's@ \\\@ @g' | \
|
|
|
|
tr -d '\n' | \
|
|
|
|
sed -e 's/ */ /g' \
|
|
|
|
-e 's|\\$|&&|g' \
|
|
|
|
-e 's|exit||g' \
|
|
|
|
-e 's|$| -c|' \
|
|
|
|
-e 's|"$$LFS"|$(MOUNT_PT)|' \
|
|
|
|
-e 's|set -e||'`
|
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-05-13 17:32:39 +02:00
|
|
|
all: chapter4 chapter5 chapter6 chapter789 do_housekeeping
|
2006-04-06 21:35:22 +02:00
|
|
|
@\$(call echo_finished,$VERSION)
|
|
|
|
|
|
|
|
chapter4: 020-creatingtoolsdir 021-addinguser 022-settingenvironment
|
|
|
|
|
2006-08-08 19:26:40 +02:00
|
|
|
chapter5: chapter4 $chapter5 restore-luser-env
|
2006-04-06 21:35:22 +02:00
|
|
|
|
|
|
|
chapter6: chapter5 $chapter6
|
|
|
|
|
|
|
|
chapter789: chapter6 $chapter789
|
|
|
|
|
|
|
|
clean-all: clean
|
|
|
|
rm -rf ./{lfs-commands,logs,Makefile,*.xsl,makefile-functions,packages,patches}
|
|
|
|
|
|
|
|
clean: clean-chapter789 clean-chapter6 clean-chapter5 clean-chapter4
|
|
|
|
|
2006-06-09 15:31:22 +02:00
|
|
|
restart: restart_code all
|
|
|
|
|
2006-04-06 21:35:22 +02:00
|
|
|
clean-chapter4:
|
2006-08-08 19:26:40 +02:00
|
|
|
-if [ ! -f luser-exist ]; then \\
|
|
|
|
userdel \$(LUSER); \\
|
|
|
|
rm -rf /home/\$(LUSER); \\
|
2006-04-06 21:35:22 +02:00
|
|
|
fi;
|
|
|
|
rm -rf \$(MOUNT_PT)/tools
|
|
|
|
rm -f /tools
|
2006-08-08 19:26:40 +02:00
|
|
|
rm -f envars luser-exist
|
2006-04-06 21:35:22 +02:00
|
|
|
rm -f 02* logs/02*.log
|
|
|
|
|
|
|
|
clean-chapter5:
|
|
|
|
rm -rf \$(MOUNT_PT)/tools/*
|
2006-08-08 19:26:40 +02:00
|
|
|
rm -f $chapter5 restore-luser-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-chapter789:
|
|
|
|
rm -f $chapter789
|
|
|
|
cd logs && rm -f $chapter789 && cd ..
|
|
|
|
|
2006-08-08 19:26:40 +02:00
|
|
|
restore-luser-env:
|
2006-04-06 21:35:22 +02:00
|
|
|
@\$(call echo_message, Building)
|
2006-08-08 19:26:40 +02:00
|
|
|
@if [ -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
|
|
|
|
mv -f /home/\$(LUSER)/.bashrc.XXX /home/\$(LUSER)/.bashrc; \\
|
2006-04-06 21:35:22 +02:00
|
|
|
fi;
|
2006-08-08 19:26:40 +02:00
|
|
|
@if [ -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
|
|
|
|
mv /home/\$(LUSER)/.bash_profile.XXX /home/\$(LUSER)/.bash_profile; \\
|
2006-04-06 21:35:22 +02:00
|
|
|
fi;
|
2006-08-08 19:26:40 +02:00
|
|
|
@chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bash* && \\
|
2006-06-10 01:05:39 +02:00
|
|
|
touch \$@ && \\
|
2006-06-10 01:20:31 +02:00
|
|
|
echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
|
|
|
echo --------------------------------------------------------------------------------\$(WHITE)
|
2006-05-31 22:43:41 +02:00
|
|
|
|
2006-05-13 17:32:39 +02:00
|
|
|
do_housekeeping:
|
2006-06-10 18:11:58 +02:00
|
|
|
@-umount \$(MOUNT_PT)/sys
|
|
|
|
@-umount \$(MOUNT_PT)/proc
|
|
|
|
@-umount \$(MOUNT_PT)/dev/shm
|
|
|
|
@-umount \$(MOUNT_PT)/dev/pts
|
|
|
|
@-umount \$(MOUNT_PT)/dev
|
2006-08-08 19:26:40 +02:00
|
|
|
@-if [ ! -f luser-exist ]; then \\
|
|
|
|
userdel \$(LUSER); \\
|
|
|
|
rm -rf /home/\$(LUSER); \\
|
2006-05-13 17:32:39 +02:00
|
|
|
fi;
|
2006-05-31 22:43:41 +02:00
|
|
|
|
2006-06-09 15:31:22 +02:00
|
|
|
restart_code:
|
2006-06-09 23:07:29 +02:00
|
|
|
@echo ">>> This feature is experimental, BUGS may exist"
|
|
|
|
|
|
|
|
@if [ ! -L /tools ]; then \\
|
|
|
|
echo -e "\\nERROR::\\n /tools is NOT a symlink.. /tools must point to \$(MOUNT_PT)/tools\\n" && false;\\
|
|
|
|
fi;
|
|
|
|
|
|
|
|
@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-06-09 15:31:22 +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;\\
|
|
|
|
fi;
|
2006-06-09 23:07:29 +02:00
|
|
|
|
2006-06-09 15:31:22 +02:00
|
|
|
@if [ -f ???-kernfs ]; then \\
|
|
|
|
mkdir -pv \$(MOUNT_PT)/{dev,proc,sys};\\
|
|
|
|
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 bind >/dev/null ; then \\
|
|
|
|
mount --bind /dev \$(MOUNT_PT)/dev;\\
|
|
|
|
fi;\\
|
|
|
|
if ! mount -l | grep "\$(MOUNT_PT)/dev/pts" >/dev/null ; then \\
|
|
|
|
mount -vt devpts 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;\\
|
2006-06-20 23:14:44 +02:00
|
|
|
if ! mount -l | grep "\$(MOUNT_PT)/sys" >/dev/null ; then \\
|
2006-06-09 15:31:22 +02:00
|
|
|
mount -vt sysfs sysfs \$(MOUNT_PT)/sys;\\
|
|
|
|
fi;\\
|
2006-06-09 22:52:05 +02:00
|
|
|
fi;
|
2006-06-09 15:31:22 +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
|
|
|
|
2006-04-29 16:08:43 +02:00
|
|
|
}
|
2006-04-06 21:35:22 +02:00
|
|
|
|