2006-11-11 12:39:16 +01:00
|
|
|
#!/bin/bash
|
2006-04-06 21:35:22 +02:00
|
|
|
|
|
|
|
# $Id$
|
|
|
|
|
|
|
|
###################################
|
|
|
|
### FUNCTIONS ###
|
|
|
|
###################################
|
|
|
|
|
|
|
|
|
2006-10-02 21:32:06 +02:00
|
|
|
#############################################################
|
|
|
|
|
|
|
|
|
2006-04-06 21:35:22 +02:00
|
|
|
#----------------------------#
|
2006-10-02 21:32:06 +02:00
|
|
|
chapter4_Makefiles() { #
|
2006-04-06 21:35:22 +02:00
|
|
|
#----------------------------#
|
2006-10-02 21:32:06 +02:00
|
|
|
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter4 ( 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-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 && \\
|
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)
|
2013-03-27 15:50:42 +01: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 "LFS=\$(MOUNT_PT)" >> \$(LUSER_HOME)/.bashrc && \\
|
|
|
|
echo "LC_ALL=POSIX" >> \$(LUSER_HOME)/.bashrc && \\
|
2008-12-06 16:05:59 +01:00
|
|
|
echo "LFS_TGT=`uname -m`-lfs-linux-gnu" >> \$(LUSER_HOME)/.bashrc && \\
|
2007-04-13 22:40:38 +02:00
|
|
|
echo "PATH=/tools/bin:/bin:/usr/bin" >> \$(LUSER_HOME)/.bashrc && \\
|
2008-12-06 16:05:59 +01:00
|
|
|
echo "export LFS LC_ALL LFS_TGT PATH" >> \$(LUSER_HOME)/.bashrc && \\
|
2007-04-13 22:40:38 +02:00
|
|
|
echo "source $JHALFSDIR/envars" >> \$(LUSER_HOME)/.bashrc && \\
|
|
|
|
chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bashrc && \\
|
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
|
2006-10-02 21:32:06 +02:00
|
|
|
) > $MKFILE.tmp
|
|
|
|
|
|
|
|
chapter4=" 020-creatingtoolsdir 021-addinguser 022-settingenvironment"
|
2006-04-06 21:35:22 +02:00
|
|
|
}
|
|
|
|
|
2006-10-02 21:32:06 +02:00
|
|
|
|
|
|
|
|
2006-04-06 21:35:22 +02:00
|
|
|
#----------------------------#
|
|
|
|
chapter5_Makefiles() {
|
|
|
|
#----------------------------#
|
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`
|
|
|
|
|
2012-02-09 14:45:22 +01:00
|
|
|
# If no testsuites are run, then TCL, Expect, DejaGNU and Check
|
2013-09-19 17:44:49 +02:00
|
|
|
# aren't needed (but building them does not hurt).
|
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
|
2013-09-19 17:44:49 +02:00
|
|
|
# *tcl) [[ "${TEST}" = "0" ]] && continue ;;
|
|
|
|
# *expect) [[ "${TEST}" = "0" ]] && continue ;;
|
|
|
|
# *dejagnu) [[ "${TEST}" = "0" ]] && continue ;;
|
|
|
|
# *check) [[ "${TEST}" = "0" ]] && continue ;;
|
2006-08-16 19:42:54 +02:00
|
|
|
*stripping) [[ "${STRIP}" = "n" ]] && 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
|
2006-12-04 12:49:51 +01:00
|
|
|
# DO NOT append the changingowner script, it need be run as root.
|
2006-10-02 21:32:06 +02:00
|
|
|
# A hack is necessary: create script in chap5 BUT run as a dependency for
|
2006-12-04 12:49:51 +01:00
|
|
|
# SUDO target
|
2006-10-02 21:32:06 +02:00
|
|
|
case "${this_script}" in
|
2006-12-04 12:49:51 +01:00
|
|
|
*changingowner) runasroot="$runasroot ${this_script}" ;;
|
2006-10-02 21:32:06 +02:00
|
|
|
*) chapter5="$chapter5 ${this_script}" ;;
|
|
|
|
esac
|
2006-04-06 21:35:22 +02:00
|
|
|
|
|
|
|
# Grab the name of the target (minus the -pass1 or -pass2 in the case of gcc
|
|
|
|
# and binutils in chapter 5)
|
2013-03-27 15:50:42 +01:00
|
|
|
name=`echo ${this_script} | sed -e 's@[0-9]\{3\}-@@' \
|
|
|
|
-e 's@-pass[0-9]\{1\}@@' \
|
|
|
|
-e 's@-libstdc++@@'`
|
2006-04-06 21:35:22 +02:00
|
|
|
|
|
|
|
# Set the dependency for the first target.
|
|
|
|
if [ -z $PREV ] ; then PREV=022-settingenvironment ; fi
|
|
|
|
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
#
|
2013-10-05 19:45:52 +02:00
|
|
|
# Find the name of the tarball and the version of the package
|
|
|
|
pkg_tarball=$(get_package_tarball_name $name)
|
|
|
|
pkg_version=$(get_package_version $pkg_tarball)
|
|
|
|
|
2006-04-06 21:35:22 +02: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.
|
2013-10-05 19:45:52 +02:00
|
|
|
LUSER_wrt_target "${this_script}" "$PREV" "$pkg_version"
|
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-10-02 21:32:06 +02:00
|
|
|
LUSER_wrt_unpack "$pkg_tarball"
|
2006-06-04 19:56:01 +02:00
|
|
|
# If the testsuites must be run, initialize the log file
|
2013-10-05 19:45:52 +02:00
|
|
|
[[ "$TEST" = "3" ]] && LUSER_wrt_test_log "${this_script}" "$pkg_version"
|
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"
|
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
|
2013-10-05 19:45:52 +02:00
|
|
|
*changingowner) wrt_RunAsRoot "$file" "$pkg_version" ;;
|
|
|
|
*) LUSER_wrt_RunAsUser "$file" "$pkg_version" ;;
|
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
|
2011-01-08 01:17:08 +01:00
|
|
|
case "${name}" in
|
|
|
|
*xz-utils) LUSER_RemoveBuildDirs "xz" ;;
|
|
|
|
*) LUSER_RemoveBuildDirs "$name" ;;
|
|
|
|
esac
|
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 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/*
|
|
|
|
}
|
|
|
|
|
2006-10-02 21:32:06 +02:00
|
|
|
|
2006-04-06 21:35:22 +02:00
|
|
|
#----------------------------#
|
|
|
|
chapter6_Makefiles() {
|
|
|
|
#----------------------------#
|
2006-10-02 21:32:06 +02:00
|
|
|
|
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
|
2012-02-07 23:30:26 +01:00
|
|
|
sed -e 's/ln *-sv/&f/g' \
|
|
|
|
-e 's/mv *-v/&f/g' \
|
|
|
|
-e 's/mkdir *-v/&p/g' -i ${script}
|
|
|
|
# Suppress the mod of "test-installation.pl" because now
|
|
|
|
# the library path points to /usr/lib
|
|
|
|
if [[ ${script} =~ glibc ]]; then
|
|
|
|
sed '/DL=/,/unset DL/d' -i ${script}
|
|
|
|
fi
|
2006-12-05 16:25:00 +01:00
|
|
|
# Rename the scripts
|
|
|
|
mv ${script} ${script}$N
|
2006-04-29 16:44:29 +02:00
|
|
|
done
|
2007-02-24 17:35:58 +01:00
|
|
|
# Remove Bzip2 binaries before make install (LFS-6.2 compatibility)
|
|
|
|
sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i chapter06$N/*-bzip2$N
|
2006-04-29 16:44:29 +02:00
|
|
|
fi
|
|
|
|
|
2006-10-02 21:32:06 +02:00
|
|
|
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N ( CHROOT ) ${R_arrow}"
|
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`
|
|
|
|
|
2014-01-12 22:40:20 +01:00
|
|
|
# Skip the "stripping" scripts if the user does not want to strip.
|
2006-12-07 11:51:26 +01:00
|
|
|
# Skip also linux-headers in iterative builds.
|
2006-04-06 21:35:22 +02:00
|
|
|
case "${this_script}" in
|
2006-08-16 19:42:54 +02:00
|
|
|
*stripping*) [[ "${STRIP}" = "n" ]] && continue ;;
|
2006-12-07 11:51:26 +01:00
|
|
|
*linux-headers*) [[ -n "$N" ]] && continue ;;
|
2006-04-06 21:35:22 +02:00
|
|
|
esac
|
|
|
|
|
2006-12-04 12:49:51 +01:00
|
|
|
# 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
|
|
|
|
2014-01-12 22:40:20 +01:00
|
|
|
# Find the tarball corresponding to our script.
|
|
|
|
# If it doesn't, we skip it in iterations rebuilds (except stripping).
|
2006-06-20 23:14:44 +02:00
|
|
|
pkg_tarball=$(get_package_tarball_name $name)
|
2013-10-05 19:45:52 +02:00
|
|
|
pkg_version=$(get_package_version $pkg_tarball)
|
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-04 12:49:51 +01:00
|
|
|
# The kernfs script must be run as part of SUDO target.
|
|
|
|
case "${this_script}" in
|
|
|
|
*kernfs) runasroot="$runasroot ${this_script}" ;;
|
2006-12-05 16:25:00 +01:00
|
|
|
*) chapter6="$chapter6 ${this_script}" ;;
|
2006-12-04 12:49:51 +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
|
|
|
|
# as a dependency. Also call the echo_message function.
|
2006-11-01 16:41:52 +01:00
|
|
|
# In the mount of kernel filesystems we need to set LFS
|
|
|
|
# and not to use chroot.
|
|
|
|
case "${this_script}" in
|
2013-10-05 19:45:52 +02:00
|
|
|
*kernfs) LUSER_wrt_target "${this_script}" "$PREV" "$pkg_version" ;;
|
|
|
|
*) CHROOT_wrt_target "${this_script}" "$PREV" "$pkg_version" ;;
|
2006-11-01 16:41:52 +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-04-28 17:49:34 +02:00
|
|
|
# Touch timestamp file if installed files logs will be created.
|
2007-05-26 12:55:46 +02:00
|
|
|
# But only for the firt build when running iterative builds.
|
|
|
|
if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
|
2007-04-28 17:24:20 +02:00
|
|
|
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
|
|
|
|
case $name in
|
2012-02-02 00:29:37 +01:00
|
|
|
binutils | gcc | glibc | gmp | mpfr )
|
2014-01-12 22:40:20 +01:00
|
|
|
[[ "$TEST" != "0" ]] &&
|
|
|
|
CHROOT_wrt_test_log "${this_script}" "$pkg_version"
|
2006-06-04 19:56:01 +02:00
|
|
|
;;
|
|
|
|
* )
|
2014-01-12 22:40:20 +01:00
|
|
|
[[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] &&
|
|
|
|
CHROOT_wrt_test_log "${this_script}" "$pkg_version"
|
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
|
|
|
|
|
|
|
|
# In the mount of kernel filesystems we need to set LFS
|
|
|
|
# and not to use chroot.
|
|
|
|
case "${this_script}" in
|
2013-10-05 19:45:52 +02:00
|
|
|
*kernfs) wrt_RunAsRoot "$file" "$pkg_version" ;;
|
|
|
|
*) CHROOT_wrt_RunAsRoot "$file" "$pkg_version" ;;
|
2006-04-06 21:35:22 +02:00
|
|
|
esac
|
|
|
|
|
2007-04-28 17:24:20 +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
|
2011-01-08 01:17:08 +01:00
|
|
|
case "${name}" in
|
|
|
|
*xz-utils) CHROOT_wrt_RemoveBuildDirs "xz" ;;
|
|
|
|
*) CHROOT_wrt_RemoveBuildDirs "$name" ;;
|
|
|
|
esac
|
2007-05-26 12:55:46 +02:00
|
|
|
if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
|
2007-04-28 17:24:20 +02:00
|
|
|
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 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-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/*
|
|
|
|
}
|
|
|
|
|
|
|
|
#----------------------------#
|
2006-12-04 14:48:48 +01:00
|
|
|
chapter78_Makefiles() {
|
2006-04-06 21:35:22 +02:00
|
|
|
#----------------------------#
|
2007-03-21 03:34:14 +01:00
|
|
|
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7/8 ( BOOT ) ${R_arrow}"
|
2006-04-06 21:35:22 +02:00
|
|
|
|
2006-12-04 14:48:48 +01:00
|
|
|
for file in chapter0{7,8}/* ; do
|
2006-04-06 21:35:22 +02:00
|
|
|
# Keep the script file name
|
|
|
|
this_script=`basename $file`
|
|
|
|
|
|
|
|
# Grub must be configured manually.
|
2006-12-04 14:48:48 +01:00
|
|
|
# Handle fstab creation.
|
2006-04-06 21:35:22 +02:00
|
|
|
# If no .config file is supplied, the kernel build is skipped
|
|
|
|
case ${this_script} in
|
|
|
|
*grub) continue ;;
|
2006-10-02 21:32:06 +02:00
|
|
|
*fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
|
2006-04-06 21:35:22 +02:00
|
|
|
*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
|
2006-12-04 14:48:48 +01:00
|
|
|
chapter78="$chapter78 ${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-10-02 21:32:06 +02:00
|
|
|
CHROOT_wrt_target "${this_script}" "$PREV"
|
2006-04-06 21:35:22 +02:00
|
|
|
|
2013-12-22 09:04:06 +01:00
|
|
|
# Find the bootscripts or networkscripts (for systemd)
|
|
|
|
# and kernel package names
|
2006-04-06 21:35:22 +02:00
|
|
|
case "${this_script}" in
|
|
|
|
*bootscripts)
|
2006-06-20 23:14:44 +02:00
|
|
|
name="lfs-bootscripts"
|
|
|
|
pkg_tarball=$(get_package_tarball_name $name)
|
2007-04-28 17:24:20 +02:00
|
|
|
if [ "${INSTALL_LOG}" = "y" ] ; then
|
|
|
|
CHROOT_wrt_TouchTimestamp
|
|
|
|
fi
|
2007-05-26 12:55:46 +02:00
|
|
|
CHROOT_Unpack "$pkg_tarball"
|
2006-04-06 21:35:22 +02:00
|
|
|
;;
|
2013-12-22 09:04:06 +01:00
|
|
|
*network-scripts)
|
|
|
|
name="lfs-network-scripts"
|
|
|
|
pkg_tarball=$(get_package_tarball_name $name)
|
|
|
|
if [ "${INSTALL_LOG}" = "y" ] ; then
|
|
|
|
CHROOT_wrt_TouchTimestamp
|
|
|
|
fi
|
|
|
|
CHROOT_Unpack "$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)
|
2007-04-28 17:24:20 +02:00
|
|
|
if [ "${INSTALL_LOG}" = "y" ] ; then
|
|
|
|
CHROOT_wrt_TouchTimestamp
|
|
|
|
fi
|
2007-05-26 12:55:46 +02:00
|
|
|
CHROOT_Unpack "$pkg_tarball"
|
2012-02-07 23:30:26 +01:00
|
|
|
# If using optimizations, use MAKEFLAGS (unless blacklisted)
|
|
|
|
# no setting of CFLAGS and friends.
|
|
|
|
[[ "$OPTIMIZE" != "0" ]] && wrt_makeflags "$name"
|
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
|
2006-10-02 21:32:06 +02:00
|
|
|
CHROOT_wrt_CopyFstab
|
2006-04-06 21:35:22 +02:00
|
|
|
else
|
2006-10-02 21:32:06 +02:00
|
|
|
CHROOT_wrt_RunAsRoot "$file"
|
2006-04-06 21:35:22 +02:00
|
|
|
fi
|
|
|
|
;;
|
2006-10-02 21:32:06 +02:00
|
|
|
*) CHROOT_wrt_RunAsRoot "$file"
|
2006-04-06 21:35:22 +02:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
case "${this_script}" in
|
2013-12-22 09:04:06 +01:00
|
|
|
*bootscripts) CHROOT_wrt_RemoveBuildDirs "dummy"
|
|
|
|
if [ "${INSTALL_LOG}" = "y" ] ; then
|
|
|
|
CHROOT_wrt_LogNewFiles "$name"
|
|
|
|
fi ;;
|
|
|
|
*network-scripts) CHROOT_wrt_RemoveBuildDirs "dummy"
|
|
|
|
if [ "${INSTALL_LOG}" = "y" ] ; then
|
|
|
|
CHROOT_wrt_LogNewFiles "$name"
|
|
|
|
fi ;;
|
|
|
|
*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 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}
|
2006-12-04 14:48:48 +01:00
|
|
|
done # for file in chapter0{7,8}/*
|
2006-04-26 21:59:19 +02:00
|
|
|
|
2006-04-06 21:35:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-02 21:32:06 +02:00
|
|
|
|
2006-04-06 21:35:22 +02:00
|
|
|
#----------------------------#
|
2006-10-02 21:32:06 +02:00
|
|
|
build_Makefile() { #
|
2006-04-06 21:35:22 +02:00
|
|
|
#----------------------------#
|
2006-10-02 21:32:06 +02:00
|
|
|
|
2006-04-29 16:08:43 +02:00
|
|
|
echo "Creating Makefile... ${BOLD}START${OFF}"
|
2006-10-02 21:32:06 +02:00
|
|
|
|
2006-04-06 21:35:22 +02:00
|
|
|
cd $JHALFSDIR/${PROGNAME}-commands
|
|
|
|
|
|
|
|
# Start with a clean Makefile.tmp file
|
2006-10-02 21:32:06 +02:00
|
|
|
>$MKFILE
|
2006-04-06 21:35:22 +02:00
|
|
|
|
|
|
|
chapter4_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-12-04 14:48:48 +01:00
|
|
|
chapter78_Makefiles
|
2006-12-15 11:53:10 +01:00
|
|
|
# Add the CUSTOM_TOOLS targets, if needed
|
|
|
|
[[ "$CUSTOM_TOOLS" = "y" ]] && wrt_CustomTools_target
|
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
|
2014-01-12 22:40:20 +01:00
|
|
|
for file in ../chroot-scripts/*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 's@ \\\@ @g' | \
|
|
|
|
tr -d '\n' | \
|
|
|
|
sed -e 's/ */ /g' \
|
|
|
|
-e 's|\\$|&&|g' \
|
|
|
|
-e 's|exit||g' \
|
|
|
|
-e 's|"$$LFS"|$(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
|
|
|
|
2012-03-24 11:52:07 +01:00
|
|
|
all: ck_UID mk_SETUP mk_LUSER mk_SUDO mk_CHROOT mk_BOOT create-sbu_du-report mk_BLFS_TOOL mk_CUSTOM_TOOLS
|
2006-10-02 21:32:06 +02:00
|
|
|
@sudo make do_housekeeping
|
2012-05-13 11:18:19 +02:00
|
|
|
@echo $VERSION > lfs-release && \\
|
2012-05-12 22:51:34 +02:00
|
|
|
sudo mv lfs-release \$(MOUNT_PT)/etc && \\
|
|
|
|
sudo chown root:root \$(MOUNT_PT)/etc/lfs-release
|
2012-05-13 11:18:19 +02:00
|
|
|
@/bin/echo -e -n \\
|
|
|
|
DISTRIB_ID=\\"Linux From Scratch\\"\\\\n\\
|
|
|
|
DISTRIB_RELEASE=\\"$VERSION\\"\\\\n\\
|
|
|
|
DISTRIB_CODENAME=\\"$(whoami)-jhalfs\\"\\\\n\\
|
|
|
|
DISTRIB_DESCRIPTION=\\"Linux From Scratch\\"\\\\n\\
|
|
|
|
> lsb-release && \\
|
|
|
|
sudo mv lsb-release \$(MOUNT_PT)/etc && \\
|
|
|
|
sudo chown root:root \$(MOUNT_PT)/etc/lsb-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)
|
2013-11-01 15:15:43 +01:00
|
|
|
@( \$(SU_LUSER) "make -C \$(MOUNT_PT)/\$(SCRIPT_ROOT) BREAKPOINT=\$(BREAKPOINT) LUSER" )
|
2006-10-02 21:32:06 +02:00
|
|
|
@sudo make restore-luser-env
|
|
|
|
@touch \$@
|
|
|
|
|
|
|
|
mk_SUDO: mk_LUSER
|
2007-03-18 11:14:04 +01:00
|
|
|
@sudo make BREAKPOINT=\$(BREAKPOINT) SUDO
|
2007-02-17 03:08:46 +01:00
|
|
|
@touch \$@
|
|
|
|
|
2006-10-02 21:32:06 +02:00
|
|
|
mk_CHROOT: mk_SUDO
|
|
|
|
@\$(call echo_CHROOT_request)
|
2014-01-12 22:40:20 +01:00
|
|
|
@( sudo \$(CHROOT1) -c "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)
|
2014-01-12 22:40:20 +01:00
|
|
|
@( sudo \$(CHROOT2) -c "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BOOT")
|
2006-10-02 21:32:06 +02:00
|
|
|
@touch \$@
|
2006-04-06 21:35:22 +02:00
|
|
|
|
2012-03-24 11:52:07 +01:00
|
|
|
mk_BLFS_TOOL: create-sbu_du-report
|
|
|
|
@if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
|
|
|
|
\$(call sh_echo_PHASE,Building BLFS_TOOL); \\
|
2014-01-12 22:40:20 +01:00
|
|
|
(sudo \$(CHROOT2) -c "make -C $BLFS_ROOT/work"); \\
|
2012-03-24 11:52:07 +01:00
|
|
|
fi;
|
|
|
|
@touch \$@
|
|
|
|
|
|
|
|
mk_CUSTOM_TOOLS: mk_BLFS_TOOL
|
2006-12-15 11:53:10 +01:00
|
|
|
@if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
|
2007-03-03 13:18:07 +01:00
|
|
|
\$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
|
2006-12-15 11:53:10 +01:00
|
|
|
sudo mkdir -p ${BUILDDIR}${TRACKING_DIR}; \\
|
2014-01-12 22:40:20 +01:00
|
|
|
(sudo \$(CHROOT2) -c "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
|
2006-12-15 11:53:10 +01:00
|
|
|
fi;
|
|
|
|
@touch \$@
|
|
|
|
|
2013-11-12 14:57:09 +01:00
|
|
|
devices: ck_UID
|
|
|
|
sudo mount -v --bind /dev \$(MOUNT_PT)/dev
|
|
|
|
sudo mount -vt devpts devpts \$(MOUNT_PT)/dev/pts
|
|
|
|
sudo mount -vt proc proc \$(MOUNT_PT)/proc
|
|
|
|
sudo mount -vt sysfs sysfs \$(MOUNT_PT)/sys
|
2014-01-23 10:15:05 +01:00
|
|
|
sudo mount -vt tmpfs tmpfs \$(MOUNT_PT)/run
|
2013-11-12 14:57:09 +01:00
|
|
|
if [ -h \$(MOUNT_PT)/dev/shm ]; then \\
|
2014-01-23 10:15:05 +01:00
|
|
|
sudo mkdir -p \$(MOUNT_PT)/\$\$(readlink \$(MOUNT_PT)/dev/shm); \\
|
2012-12-30 17:30:44 +01:00
|
|
|
fi
|
2008-10-21 23:29:13 +02:00
|
|
|
|
2013-11-12 14:57:09 +01:00
|
|
|
teardown:
|
|
|
|
sudo umount -v \$(MOUNT_PT)/sys
|
|
|
|
sudo umount -v \$(MOUNT_PT)/proc
|
|
|
|
sudo umount -v \$(MOUNT_PT)/dev/pts
|
2014-01-28 14:29:06 +01:00
|
|
|
if mountpoint -q \$(MOUNT_PT)/run; then \\
|
|
|
|
sudo umount -v \$(MOUNT_PT)/run; \\
|
2014-01-23 10:15:05 +01:00
|
|
|
elif [ -h \$(MOUNT_PT)/dev/shm ]; then \\
|
2013-11-12 14:57:09 +01:00
|
|
|
link=\$\$(readlink \$(MOUNT_PT)/dev/shm); \\
|
|
|
|
sudo umount -v \$(MOUNT_PT)/\$\$link; \\
|
2012-12-30 17:30:44 +01:00
|
|
|
unset link; \\
|
|
|
|
else \\
|
2013-11-12 14:57:09 +01:00
|
|
|
sudo umount -v \$(MOUNT_PT)/dev/shm; \\
|
2012-12-30 17:30:44 +01:00
|
|
|
fi
|
2013-11-12 14:57:09 +01:00
|
|
|
sudo umount -v \$(MOUNT_PT)/dev
|
2008-10-21 23:29:13 +02:00
|
|
|
|
|
|
|
chroot: devices
|
2014-01-12 22:40:20 +01:00
|
|
|
sudo \$(CHROOT2)
|
2008-10-21 23:29:13 +02:00
|
|
|
\$(MAKE) teardown
|
2006-04-06 21:35:22 +02:00
|
|
|
|
2006-12-15 11:53:10 +01:00
|
|
|
SETUP: $chapter4
|
|
|
|
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: $chapter78
|
|
|
|
CUSTOM_TOOLS: $custom_list
|
2006-06-09 15:31:22 +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 \\
|
2012-03-24 11:52:07 +01:00
|
|
|
sudo ./create-sbu_du-report.sh logs $VERSION; \\
|
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*
|
2007-03-18 11:14:04 +01:00
|
|
|
@\$(call housekeeping)
|
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
|
2014-01-23 10:15:05 +01:00
|
|
|
@-if mountpoint -q \$(MOUNT_PT)/run; then \\
|
|
|
|
umount \$(MOUNT_PT)/run; \\
|
|
|
|
elif [ -h \$(MOUNT_PT)/dev/shm ]; then \\
|
2012-12-30 17:30:44 +01:00
|
|
|
link=\$\$(readlink \$(MOUNT_PT)/dev/shm); \\
|
|
|
|
umount \$(MOUNT_PT)/\$\$link; \\
|
|
|
|
unset link; \\
|
|
|
|
else \\
|
|
|
|
umount \$(MOUNT_PT)/dev/shm; \\
|
|
|
|
fi
|
2006-06-10 18:11:58 +02:00
|
|
|
@-umount \$(MOUNT_PT)/dev/pts
|
|
|
|
@-umount \$(MOUNT_PT)/dev
|
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-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}"
|
|
|
|
}
|