2007-09-19 18:50:48 +02:00
|
|
|
#!/bin/bash
|
2006-03-07 21:02:53 +01:00
|
|
|
|
2006-03-08 21:40:47 +01:00
|
|
|
# $Id$
|
2006-03-07 21:02:53 +01:00
|
|
|
|
|
|
|
###################################
|
|
|
|
### FUNCTIONS ###
|
|
|
|
###################################
|
|
|
|
|
|
|
|
|
2006-08-30 04:01:04 +02:00
|
|
|
#############################################################
|
|
|
|
|
|
|
|
|
2006-03-07 21:02:53 +01:00
|
|
|
#----------------------------#
|
2006-08-30 04:01:04 +02:00
|
|
|
chapter4_Makefiles() { #
|
2006-03-07 21:02:53 +01:00
|
|
|
#----------------------------#
|
2006-08-30 04:01:04 +02:00
|
|
|
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter4 ( SETUP ) ${R_arrow}"
|
2006-03-07 21:02:53 +01:00
|
|
|
|
2007-09-19 18:50:48 +02:00
|
|
|
# If $LUSER_HOME is already present in the host, we asume that the
|
2006-03-07 21:02:53 +01:00
|
|
|
# lfs user and group are also presents in the host, and a backup
|
|
|
|
# of their bash init files is made.
|
|
|
|
(
|
|
|
|
cat << EOF
|
2007-09-25 19:50:20 +02:00
|
|
|
04_02-creatingtoolsdir:
|
2006-03-07 21:02:53 +01:00
|
|
|
@\$(call echo_message, Building)
|
2006-06-10 18:48:25 +02:00
|
|
|
@mkdir \$(MOUNT_PT)/tools && \\
|
|
|
|
rm -f /tools && \\
|
2007-09-19 18:50:48 +02:00
|
|
|
ln -s \$(MOUNT_PT)/tools /
|
|
|
|
@\$(call housekeeping)
|
2006-03-07 21:02:53 +01:00
|
|
|
|
2007-09-26 19:49:07 +02:00
|
|
|
04_03-addinguser: 04_02-creatingtoolsdir
|
2006-03-07 21:02:53 +01:00
|
|
|
@\$(call echo_message, Building)
|
2007-09-19 18:50:48 +02:00
|
|
|
@if [ ! -d \$(LUSER_HOME) ]; then \\
|
2006-08-04 22:06:15 +02:00
|
|
|
groupadd \$(LGROUP); \\
|
|
|
|
useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\
|
2006-03-07 21:02:53 +01:00
|
|
|
else \\
|
2006-08-06 12:59:36 +02:00
|
|
|
touch luser-exist; \\
|
2006-03-07 21:02:53 +01:00
|
|
|
fi;
|
2006-08-04 22:06:15 +02:00
|
|
|
@chown \$(LUSER) \$(MOUNT_PT)/tools && \\
|
2007-09-19 18:50:48 +02:00
|
|
|
chmod -R a+wt \$(MOUNT_PT)/\$(SCRIPT_ROOT) && \\
|
|
|
|
chmod a+wt \$(SRCSDIR)
|
|
|
|
@\$(call housekeeping)
|
2006-03-07 21:02:53 +01:00
|
|
|
|
2007-09-26 19:49:07 +02:00
|
|
|
04_04-settingenvironment: 04_03-addinguser
|
2006-03-07 21:02:53 +01:00
|
|
|
@\$(call echo_message, Building)
|
2007-09-19 18:50:48 +02:00
|
|
|
@if [ -f \$(LUSER_HOME)/.bashrc -a ! -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
|
|
|
|
mv \$(LUSER_HOME)/.bashrc \$(LUSER_HOME)/.bashrc.XXX; \\
|
2006-03-07 21:02:53 +01:00
|
|
|
fi;
|
2007-09-19 18:50:48 +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-03-07 21:02:53 +01:00
|
|
|
fi;
|
2007-09-19 18:50:48 +02:00
|
|
|
@echo "set +h" > \$(LUSER_HOME)/.bashrc && \\
|
|
|
|
echo "umask 022" >> \$(LUSER_HOME)/.bashrc && \\
|
|
|
|
echo "LFS=\$(MOUNT_PT)" >> \$(LUSER_HOME)/.bashrc && \\
|
|
|
|
echo "LC_ALL=POSIX" >> \$(LUSER_HOME)/.bashrc && \\
|
|
|
|
echo "PATH=/tools/bin:/bin:/usr/bin" >> \$(LUSER_HOME)/.bashrc && \\
|
|
|
|
echo "export LFS LC_ALL PATH" >> \$(LUSER_HOME)/.bashrc && \\
|
2007-09-25 23:34:03 +02:00
|
|
|
chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bashrc
|
2007-09-19 18:50:48 +02:00
|
|
|
@\$(call housekeeping)
|
2006-03-07 21:02:53 +01:00
|
|
|
EOF
|
2006-08-30 04:01:04 +02:00
|
|
|
) > $MKFILE.tmp
|
|
|
|
|
2007-09-25 19:50:20 +02:00
|
|
|
chapter4=" 04_02-creatingtoolsdir 04_03-addinguser 04_04-settingenvironment"
|
2006-03-07 21:02:53 +01:00
|
|
|
}
|
|
|
|
|
2006-08-30 04:01:04 +02:00
|
|
|
|
|
|
|
|
2006-03-07 21:02:53 +01:00
|
|
|
#----------------------------#
|
|
|
|
chapter5_Makefiles() {
|
|
|
|
#----------------------------#
|
2006-08-30 04:01:04 +02:00
|
|
|
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter5 ( LUSER ) ${R_arrow}"
|
2006-03-10 02:44:55 +01:00
|
|
|
|
2006-03-07 21:02:53 +01:00
|
|
|
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-03-29 06:29:47 +02:00
|
|
|
case "${this_script}" in
|
|
|
|
*tcl) [[ "${TEST}" = "0" ]] && continue ;;
|
|
|
|
*expect) [[ "${TEST}" = "0" ]] && continue ;;
|
|
|
|
*dejagnu) [[ "${TEST}" = "0" ]] && continue ;;
|
2006-08-12 21:59:11 +02:00
|
|
|
*stripping) [[ "${STRIP}" = "n" ]] && continue ;;
|
2006-03-29 06:29:47 +02:00
|
|
|
esac
|
2006-03-29 20:48:47 +02:00
|
|
|
|
2006-03-07 21:02:53 +01:00
|
|
|
# First append each name of the script files to a list (this will become
|
|
|
|
# the names of the targets in the Makefile
|
2007-09-19 18:50:48 +02:00
|
|
|
# DO NOT append the changingowner script, it need be run as root.
|
2006-08-30 04:01:04 +02:00
|
|
|
# A hack is necessary: create script in chap5 BUT run as a dependency for
|
2007-09-19 18:50:48 +02:00
|
|
|
# SUDO target
|
2006-08-30 04:01:04 +02:00
|
|
|
case "${this_script}" in
|
2007-09-19 18:50:48 +02:00
|
|
|
*changingowner) runasroot="$runasroot ${this_script}" ;;
|
2006-08-30 04:01:04 +02:00
|
|
|
*) chapter5="$chapter5 ${this_script}" ;;
|
|
|
|
esac
|
2006-03-07 21:02:53 +01:00
|
|
|
|
|
|
|
# Set the dependency for the first target.
|
2007-09-25 19:50:20 +02:00
|
|
|
if [ -z $PREV ] ; then PREV=04_04-settingenvironment ; fi
|
2006-03-07 21:02:53 +01:00
|
|
|
|
2006-03-10 15:27:12 +01:00
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
#
|
2006-03-07 21:02:53 +01:00
|
|
|
# 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-08-30 04:01:04 +02:00
|
|
|
LUSER_wrt_target "${this_script}" "$PREV"
|
2006-03-07 21:02:53 +01:00
|
|
|
|
2007-09-25 19:50:20 +02:00
|
|
|
# Run the script.
|
2006-04-07 19:27:23 +02:00
|
|
|
# The changingowner script must be run as root.
|
|
|
|
case "${this_script}" in
|
2007-09-19 18:50:48 +02:00
|
|
|
*changingowner) wrt_RunAsRoot "$file" ;;
|
2006-08-30 04:01:04 +02:00
|
|
|
*) LUSER_wrt_RunAsUser "$file" ;;
|
2006-04-07 19:27:23 +02:00
|
|
|
esac
|
2006-03-07 21:02:53 +01:00
|
|
|
|
|
|
|
# Include a touch of the target name so make can check
|
|
|
|
# if it's already been made.
|
2006-06-10 18:48:25 +02:00
|
|
|
wrt_touch
|
2006-03-10 15:27:12 +01:00
|
|
|
#
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
|
|
|
#--------------------------------------------------------------------#
|
2006-03-07 21:02:53 +01:00
|
|
|
|
|
|
|
# Keep the script file name for Makefile dependencies.
|
|
|
|
PREV=${this_script}
|
|
|
|
done # end for file in chapter05/*
|
|
|
|
}
|
|
|
|
|
2006-08-30 04:01:04 +02:00
|
|
|
|
2006-03-07 21:02:53 +01:00
|
|
|
#----------------------------#
|
|
|
|
chapter6_Makefiles() {
|
|
|
|
#----------------------------#
|
2006-08-30 04:01:04 +02:00
|
|
|
|
2006-04-13 22:13:24 +02:00
|
|
|
# Set envars and scripts for iteration targets
|
2006-04-12 22:23:12 +02:00
|
|
|
if [[ -z "$1" ]] ; then
|
2006-04-12 21:38:42 +02:00
|
|
|
local N=""
|
|
|
|
else
|
|
|
|
local N=-build_$1
|
|
|
|
local chapter6=""
|
2006-04-13 22:13:24 +02:00
|
|
|
mkdir chapter06$N
|
|
|
|
cp chapter06/* chapter06$N
|
|
|
|
for script in chapter06$N/* ; do
|
2006-04-14 14:02:05 +02:00
|
|
|
# Overwrite existing symlinks, files, and dirs
|
2006-04-13 22:13:24 +02:00
|
|
|
sed -e 's/ln -sv/&f/g' \
|
|
|
|
-e 's/mv -v/&f/g' \
|
2006-04-14 14:02:05 +02:00
|
|
|
-e 's/mkdir -v/&p/g' -i ${script}
|
2007-09-19 18:50:48 +02:00
|
|
|
# Rename the scripts
|
|
|
|
mv ${script} ${script}$N
|
2006-04-13 22:13:24 +02:00
|
|
|
done
|
2006-04-12 21:38:42 +02:00
|
|
|
fi
|
|
|
|
|
2006-08-30 04:01:04 +02:00
|
|
|
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N ( CHROOT ) ${R_arrow}"
|
2006-03-29 06:29:47 +02:00
|
|
|
|
2006-04-13 22:13:24 +02:00
|
|
|
for file in chapter06$N/* ; do
|
2006-03-07 21:02:53 +01: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.
|
2007-09-19 18:50:48 +02:00
|
|
|
# Skip also linux-headers in iterative builds.
|
2006-03-29 06:29:47 +02:00
|
|
|
case "${this_script}" in
|
|
|
|
*chroot) continue ;;
|
2006-08-12 21:59:11 +02:00
|
|
|
*stripping*) [[ "${STRIP}" = "n" ]] && continue ;;
|
2007-09-19 18:50:48 +02:00
|
|
|
*linux-headers*) [[ -n "$N" ]] && continue ;;
|
2006-03-29 06:29:47 +02:00
|
|
|
esac
|
2006-03-07 21:02:53 +01:00
|
|
|
|
2007-09-26 19:58:54 +02:00
|
|
|
# If building a package, grab the phase name to be used with INSTALL_LOG
|
|
|
|
name=`grep "^PKG_PHASE=" ${file} | sed -e 's@PKG_PHASE=@@'`
|
2006-04-12 22:23:12 +02:00
|
|
|
|
2007-09-25 19:50:20 +02:00
|
|
|
# Skip scripts not needed for iterations rebuilds
|
|
|
|
if [[ "$name" = "" ]] && [[ -n "$N" ]] ; then
|
2006-04-12 22:23:12 +02:00
|
|
|
case "${this_script}" in
|
|
|
|
*stripping*) ;;
|
|
|
|
*) continue ;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2006-04-24 20:25:56 +02:00
|
|
|
# Append each name of the script files to a list (this will become
|
|
|
|
# the names of the targets in the Makefile)
|
2007-09-19 18:50:48 +02:00
|
|
|
# The kernfs script must be run as part of SUDO target.
|
|
|
|
case "${this_script}" in
|
|
|
|
*kernfs) runasroot="$runasroot ${this_script}" ;;
|
|
|
|
*) chapter6="$chapter6 ${this_script}" ;;
|
|
|
|
esac
|
2006-04-24 20:25:56 +02:00
|
|
|
|
2006-03-10 15:27:12 +01:00
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
#
|
2006-03-07 21:02:53 +01:00
|
|
|
# Drop in the name of the target on a new line, and the previous target
|
|
|
|
# as a dependency. Also call the echo_message function.
|
2007-09-19 18:50:48 +02:00
|
|
|
# In the mount of kernel filesystems we need to set LFS
|
|
|
|
# and not to use chroot.
|
|
|
|
case "${this_script}" in
|
|
|
|
*kernfs) LUSER_wrt_target "${this_script}" "$PREV" ;;
|
|
|
|
*) CHROOT_wrt_target "${this_script}" "$PREV" ;;
|
|
|
|
esac
|
2006-03-07 21:02:53 +01:00
|
|
|
|
2007-09-25 23:34:03 +02:00
|
|
|
# Touch timestamp file if installed files logs will be created.
|
|
|
|
# But only for the firt build when running iterative builds.
|
|
|
|
if [ "$name" != "" ] && [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
|
|
|
|
CHROOT_wrt_TouchTimestamp
|
2006-03-07 21:02:53 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# In the mount of kernel filesystems we need to set LFS
|
|
|
|
# and not to use chroot.
|
2006-03-29 06:29:47 +02:00
|
|
|
case "${this_script}" in
|
2007-09-19 18:50:48 +02:00
|
|
|
*kernfs) wrt_RunAsRoot "$file" ;;
|
2006-08-30 04:01:04 +02:00
|
|
|
*) CHROOT_wrt_RunAsRoot "$file" ;;
|
2006-03-29 06:29:47 +02:00
|
|
|
esac
|
2006-03-07 21:02:53 +01:00
|
|
|
|
2007-09-25 19:50:20 +02:00
|
|
|
# Write installed files log
|
|
|
|
if [ "$name" != "" ] && [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
|
|
|
|
CHROOT_wrt_LogNewFiles "$name"
|
2006-03-07 21:02:53 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Include a touch of the target name so make can check
|
|
|
|
# if it's already been made.
|
2006-06-10 18:48:25 +02:00
|
|
|
wrt_touch
|
2006-03-10 15:27:12 +01:00
|
|
|
#
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
|
|
|
#--------------------------------------------------------------------#
|
2006-03-07 21:02:53 +01:00
|
|
|
|
|
|
|
# Keep the script file name for Makefile dependencies.
|
2007-09-19 18:50:48 +02:00
|
|
|
PREV=${this_script}
|
2006-04-12 21:38:42 +02:00
|
|
|
# Set system_build envar for iteration targets
|
|
|
|
system_build=$chapter6
|
2006-03-07 21:02:53 +01:00
|
|
|
done # end for file in chapter06/*
|
|
|
|
}
|
|
|
|
|
|
|
|
#----------------------------#
|
2007-09-19 18:50:48 +02:00
|
|
|
chapter78_Makefiles() {
|
2006-03-07 21:02:53 +01:00
|
|
|
#----------------------------#
|
2007-09-19 18:50:48 +02:00
|
|
|
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7/8 ( BOOT ) ${R_arrow}"
|
2006-03-29 06:29:47 +02:00
|
|
|
|
2007-09-19 18:50:48 +02:00
|
|
|
for file in chapter0{7,8}/* ; do
|
2006-03-07 21:02:53 +01:00
|
|
|
# Keep the script file name
|
|
|
|
this_script=`basename $file`
|
|
|
|
|
|
|
|
# Grub must be configured manually.
|
2007-09-19 18:50:48 +02:00
|
|
|
# Handle fstab creation.
|
2006-03-07 21:02:53 +01:00
|
|
|
# If no .config file is supplied, the kernel build is skipped
|
2006-03-21 14:25:20 +01:00
|
|
|
case ${this_script} in
|
|
|
|
*grub) continue ;;
|
2006-08-30 04:01:04 +02:00
|
|
|
*fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
|
2006-03-21 14:25:20 +01:00
|
|
|
*kernel) [[ -z ${CONFIG} ]] && continue
|
|
|
|
cp ${CONFIG} $BUILDDIR/sources/kernel-config ;;
|
|
|
|
esac
|
2006-03-07 21:02:53 +01:00
|
|
|
|
|
|
|
# First append each name of the script files to a list (this will become
|
|
|
|
# the names of the targets in the Makefile
|
2007-09-19 18:50:48 +02:00
|
|
|
chapter78="$chapter78 ${this_script}"
|
2006-03-07 21:02:53 +01:00
|
|
|
|
2006-03-10 15:27:12 +01:00
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
#
|
2006-03-07 21:02:53 +01:00
|
|
|
# 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-08-30 04:01:04 +02:00
|
|
|
CHROOT_wrt_target "${this_script}" "$PREV"
|
2006-03-07 21:02:53 +01:00
|
|
|
|
2007-09-25 19:50:20 +02:00
|
|
|
# For bootscripts and kernel, start INSTALL_LOG if requested
|
2006-03-29 06:29:47 +02:00
|
|
|
case "${this_script}" in
|
2007-09-25 19:50:20 +02:00
|
|
|
*bootscripts | *kernel ) if [ "${INSTALL_LOG}" = "y" ] ; then
|
|
|
|
CHROOT_wrt_TouchTimestamp
|
|
|
|
fi ;;
|
2006-03-29 06:29:47 +02:00
|
|
|
esac
|
2006-03-29 20:48:47 +02:00
|
|
|
|
2006-03-07 21:02:53 +01:00
|
|
|
# Check if we have a real /etc/fstab file
|
2006-03-29 06:29:47 +02:00
|
|
|
case "${this_script}" in
|
|
|
|
*fstab) if [[ -n $FSTAB ]]; then
|
2006-08-30 04:01:04 +02:00
|
|
|
CHROOT_wrt_CopyFstab
|
2006-03-29 06:29:47 +02:00
|
|
|
else
|
2006-08-30 04:01:04 +02:00
|
|
|
CHROOT_wrt_RunAsRoot "$file"
|
2006-03-29 06:29:47 +02:00
|
|
|
fi
|
|
|
|
;;
|
2006-08-30 04:01:04 +02:00
|
|
|
*) CHROOT_wrt_RunAsRoot "$file"
|
2006-03-29 06:29:47 +02:00
|
|
|
;;
|
|
|
|
esac
|
2006-03-07 21:02:53 +01:00
|
|
|
|
2006-03-29 06:29:47 +02:00
|
|
|
case "${this_script}" in
|
2007-09-25 19:50:20 +02:00
|
|
|
*bootscripts) if [ "${INSTALL_LOG}" = "y" ] ; then
|
|
|
|
CHROOT_wrt_LogNewFiles "lfs-bootscripts"
|
2007-09-19 18:50:48 +02:00
|
|
|
fi ;;
|
2007-09-25 19:50:20 +02:00
|
|
|
*kernel) if [ "${INSTALL_LOG}" = "y" ] ; then
|
|
|
|
CHROOT_wrt_LogNewFiles "linux"
|
2007-09-19 18:50:48 +02:00
|
|
|
fi ;;
|
2006-03-29 06:29:47 +02:00
|
|
|
esac
|
2006-03-29 20:48:47 +02:00
|
|
|
|
2006-03-07 21:02:53 +01:00
|
|
|
# Include a touch of the target name so make can check
|
|
|
|
# if it's already been made.
|
2006-06-10 18:48:25 +02:00
|
|
|
wrt_touch
|
2006-03-10 15:27:12 +01:00
|
|
|
#
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
|
|
|
#--------------------------------------------------------------------#
|
2006-03-07 21:02:53 +01:00
|
|
|
|
|
|
|
# Keep the script file name for Makefile dependencies.
|
|
|
|
PREV=${this_script}
|
2007-09-19 18:50:48 +02:00
|
|
|
done # for file in chapter0{7,8}/*
|
2006-04-26 22:24:58 +02:00
|
|
|
|
2006-03-07 21:02:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-30 04:01:04 +02:00
|
|
|
|
2006-03-07 21:02:53 +01:00
|
|
|
#----------------------------#
|
2006-08-30 04:01:04 +02:00
|
|
|
build_Makefile() { #
|
2006-03-07 21:02:53 +01:00
|
|
|
#----------------------------#
|
2006-08-30 04:01:04 +02:00
|
|
|
|
2006-04-29 16:14:45 +02:00
|
|
|
echo "Creating Makefile... ${BOLD}START${OFF}"
|
2006-09-11 13:18:01 +02:00
|
|
|
|
2006-03-07 21:02:53 +01:00
|
|
|
cd $JHALFSDIR/${PROGNAME}-commands
|
|
|
|
|
|
|
|
# Start with a clean Makefile.tmp file
|
2006-08-30 04:01:04 +02:00
|
|
|
>$MKFILE
|
2006-09-11 13:18:01 +02:00
|
|
|
|
2006-03-07 21:02:53 +01:00
|
|
|
chapter4_Makefiles
|
|
|
|
chapter5_Makefiles
|
|
|
|
chapter6_Makefiles
|
2006-04-24 20:25:56 +02:00
|
|
|
# Add the iterations targets, if needed
|
2006-08-12 21:59:11 +02:00
|
|
|
[[ "$COMPARE" = "y" ]] && wrt_compare_targets
|
2007-09-19 18:50:48 +02:00
|
|
|
chapter78_Makefiles
|
|
|
|
# Add the CUSTOM_TOOLS targets, if needed
|
|
|
|
[[ "$CUSTOM_TOOLS" = "y" ]] && wrt_CustomTools_target
|
2006-10-01 12:49:13 +02:00
|
|
|
# Add the BLFS_TOOL targets, if needed
|
|
|
|
[[ "$BLFS_TOOL" = "y" ]] && wrt_blfs_tool_targets
|
2006-03-07 21:02:53 +01:00
|
|
|
|
|
|
|
# Add a header, some variables and include the function file
|
|
|
|
# to the top of the real Makefile.
|
2007-09-19 18:50:48 +02:00
|
|
|
wrt_Makefile_header
|
2006-03-07 21:02:53 +01:00
|
|
|
|
|
|
|
# Add chroot commands
|
2006-08-06 11:53:10 +02:00
|
|
|
CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
|
2006-03-07 21:02:53 +01:00
|
|
|
i=1
|
|
|
|
for file in chapter06/*chroot* ; do
|
2007-09-25 19:50:20 +02:00
|
|
|
chroot=`cat $file | tr -d '\n' | \
|
2006-08-06 11:53:10 +02:00
|
|
|
sed -e "s@chroot@$CHROOT_LOC@" \
|
2007-09-25 19:50:20 +02:00
|
|
|
-e 's@ \\\@ @g' \
|
2007-09-25 23:34:03 +02:00
|
|
|
-e 's/ */ /g' \
|
2006-08-06 11:53:10 +02:00
|
|
|
-e 's|\\$|&&|g' \
|
|
|
|
-e 's|"$$LFS"|$(MOUNT_PT)|' \
|
2007-09-25 19:50:20 +02:00
|
|
|
-e 's|$| -c|'`
|
2006-03-07 21:02:53 +01: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-08-30 04:01:04 +02:00
|
|
|
|
2007-09-19 18:50:48 +02: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-09-14 06:01:26 +02:00
|
|
|
@sudo make do_housekeeping
|
2007-09-19 18:50:48 +02:00
|
|
|
@echo "$VERSION - jhalfs build" > lfs-release && \\
|
|
|
|
sudo mv lfs-release \$(MOUNT_PT)/etc
|
2006-03-07 21:02:53 +01:00
|
|
|
@\$(call echo_finished,$VERSION)
|
|
|
|
|
2006-09-13 22:04:46 +02:00
|
|
|
ck_UID:
|
|
|
|
@if [ \`id -u\` = "0" ]; then \\
|
|
|
|
echo "--------------------------------------------------"; \\
|
|
|
|
echo "You cannot run this makefile from the root account"; \\
|
|
|
|
echo "--------------------------------------------------"; \\
|
|
|
|
exit 1; \\
|
|
|
|
fi
|
2006-09-15 21:01:44 +02:00
|
|
|
|
2006-08-30 04:01:04 +02:00
|
|
|
mk_SETUP:
|
|
|
|
@\$(call echo_SU_request)
|
2007-09-19 18:50:48 +02:00
|
|
|
@sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
|
2006-08-30 04:01:04 +02:00
|
|
|
@touch \$@
|
2006-09-11 13:18:01 +02:00
|
|
|
|
2006-08-30 04:01:04 +02:00
|
|
|
mk_LUSER: mk_SETUP
|
|
|
|
@\$(call echo_SULUSER_request)
|
2007-09-19 18:50:48 +02:00
|
|
|
@( sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) LUSER" )
|
2006-09-16 19:45:58 +02:00
|
|
|
@sudo make restore-luser-env
|
2006-08-30 04:01:04 +02:00
|
|
|
@touch \$@
|
2006-09-13 22:04:46 +02:00
|
|
|
|
|
|
|
mk_SUDO: mk_LUSER
|
2007-09-19 18:50:48 +02:00
|
|
|
@sudo make BREAKPOINT=\$(BREAKPOINT) SUDO
|
|
|
|
@touch \$@
|
|
|
|
|
2006-09-14 02:14:37 +02:00
|
|
|
mk_CHROOT: mk_SUDO
|
2006-08-30 04:01:04 +02:00
|
|
|
@\$(call echo_CHROOT_request)
|
2007-09-19 18:50:48 +02:00
|
|
|
@( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CHROOT")
|
2006-08-30 04:01:04 +02:00
|
|
|
@touch \$@
|
|
|
|
|
2006-09-11 13:18:01 +02:00
|
|
|
mk_BOOT: mk_CHROOT
|
2006-08-30 04:01:04 +02:00
|
|
|
@\$(call echo_CHROOT_request)
|
2007-09-19 18:50:48 +02:00
|
|
|
@( sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BOOT")
|
2006-08-30 04:01:04 +02:00
|
|
|
@touch \$@
|
2006-09-11 13:18:01 +02:00
|
|
|
|
2007-09-19 18:50:48 +02:00
|
|
|
mk_CUSTOM_TOOLS: create-sbu_du-report
|
|
|
|
@if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
|
|
|
|
\$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
|
|
|
|
sudo mkdir -p ${BUILDDIR}${TRACKING_DIR}; \\
|
|
|
|
(sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
|
|
|
|
fi;
|
|
|
|
@touch \$@
|
2006-08-30 04:01:04 +02:00
|
|
|
|
2007-09-19 18:50:48 +02:00
|
|
|
mk_BLFS_TOOL: mk_CUSTOM_TOOLS
|
|
|
|
@if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
|
|
|
|
\$(call sh_echo_PHASE,Building BLFS_TOOL); \\
|
|
|
|
sudo mkdir -p $BUILDDIR$TRACKING_DIR; \\
|
|
|
|
(sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BLFS_TOOL"); \\
|
|
|
|
fi;
|
|
|
|
@touch \$@
|
2006-08-30 04:01:04 +02:00
|
|
|
|
2006-09-13 22:04:46 +02:00
|
|
|
|
2007-09-19 18:50:48 +02:00
|
|
|
SETUP: $chapter4
|
|
|
|
LUSER: $chapter5
|
|
|
|
SUDO: $runasroot
|
|
|
|
CHROOT: SHELL=/tools/bin/bash
|
|
|
|
CHROOT: $chapter6
|
|
|
|
BOOT: $chapter78
|
|
|
|
CUSTOM_TOOLS: $custom_list
|
|
|
|
BLFS_TOOL: $blfs_tool
|
2006-08-30 04:01:04 +02:00
|
|
|
|
2006-03-07 21:02:53 +01:00
|
|
|
|
2007-09-19 18:50:48 +02:00
|
|
|
create-sbu_du-report: mk_BOOT
|
|
|
|
@\$(call echo_message, Building)
|
|
|
|
@if [ "\$(ADD_REPORT)" = "y" ]; then \\
|
|
|
|
./create-sbu_du-report.sh logs $VERSION; \\
|
|
|
|
\$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
|
|
|
|
fi;
|
|
|
|
@touch \$@
|
2006-03-07 21:02:53 +01:00
|
|
|
|
2006-08-06 12:59:36 +02:00
|
|
|
restore-luser-env:
|
2006-03-07 21:02:53 +01:00
|
|
|
@\$(call echo_message, Building)
|
2007-09-19 18:50:48 +02:00
|
|
|
@if [ -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
|
|
|
|
mv -f \$(LUSER_HOME)/.bashrc.XXX \$(LUSER_HOME)/.bashrc; \\
|
2006-03-07 21:02:53 +01:00
|
|
|
fi;
|
2007-09-19 18:50:48 +02:00
|
|
|
@if [ -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
|
|
|
|
mv \$(LUSER_HOME)/.bash_profile.XXX \$(LUSER_HOME)/.bash_profile; \\
|
2006-03-07 21:02:53 +01:00
|
|
|
fi;
|
2007-09-19 18:50:48 +02:00
|
|
|
@chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bash*
|
|
|
|
@\$(call housekeeping)
|
2006-06-02 19:53:17 +02:00
|
|
|
|
2006-05-16 20:27:02 +02:00
|
|
|
do_housekeeping:
|
2006-06-10 18:48:25 +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-09-15 21:01:44 +02:00
|
|
|
@-rm /tools
|
2006-08-06 12:59:36 +02:00
|
|
|
@-if [ ! -f luser-exist ]; then \\
|
2006-08-04 22:06:15 +02:00
|
|
|
userdel \$(LUSER); \\
|
2007-09-19 18:50:48 +02:00
|
|
|
rm -rf \$(LUSER_HOME); \\
|
2006-05-16 20:27:02 +02:00
|
|
|
fi;
|
2006-06-02 19:53:17 +02:00
|
|
|
|
2006-06-10 18:48:25 +02:00
|
|
|
|
2006-04-08 14:21:34 +02:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE
|
|
|
|
|
2006-03-07 21:02:53 +01:00
|
|
|
# Bring over the items from the Makefile.tmp
|
|
|
|
cat $MKFILE.tmp >> $MKFILE
|
|
|
|
rm $MKFILE.tmp
|
2006-04-29 16:14:45 +02:00
|
|
|
echo "Creating Makefile... ${BOLD}DONE${OFF}"
|
|
|
|
}
|