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}"
|
2020-03-29 16:06:41 +02:00
|
|
|
# Ensure the first dependency is empty
|
|
|
|
unset PREV
|
2006-04-06 21:35:22 +02:00
|
|
|
|
2020-03-29 16:06:41 +02:00
|
|
|
for file in chapter04/* ; do
|
|
|
|
# Keep the script file name
|
|
|
|
this_script=`basename $file`
|
2006-04-06 21:35:22 +02:00
|
|
|
|
2020-03-29 16:06:41 +02:00
|
|
|
# First append each name of the script files to a list (this will become
|
|
|
|
# the names of the targets in the Makefile
|
|
|
|
# DO NOT append the settingenvironment script, it need be run as luser.
|
|
|
|
# A hack is necessary: create script in chap4 BUT run as a dependency for
|
|
|
|
# LUSER target
|
|
|
|
case "${this_script}" in
|
|
|
|
*settingenvironment) chapter5="$chapter5 ${this_script}" ;;
|
|
|
|
*) chapter4="$chapter4 ${this_script}" ;;
|
|
|
|
esac
|
2006-04-06 21:35:22 +02:00
|
|
|
|
2020-03-29 16:06:41 +02:00
|
|
|
# Grab the name of the target
|
|
|
|
name=`echo ${this_script} | sed -e 's@[0-9]\{3\}-@@'`
|
|
|
|
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
# >>>>>>>> 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.
|
|
|
|
LUSER_wrt_target "${this_script}" "$PREV"
|
|
|
|
|
|
|
|
case "${this_script}" in
|
|
|
|
*settingenvironment)
|
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@cd && \\
|
|
|
|
function source() { true; } && \\
|
|
|
|
export -f source && \\
|
|
|
|
\$(CMDSDIR)/`dirname $file`/\$@ >> \$(LOGDIR)/\$@ 2>&1 && \\
|
|
|
|
sed 's|/mnt/lfs|\$(MOUNT_PT)|' -i .bashrc && \\
|
|
|
|
echo source $JHALFSDIR/envars >> .bashrc
|
|
|
|
@\$(PRT_DU) >>logs/\$@
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
;;
|
|
|
|
*addinguser)
|
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@if [ -f luser-id ]; then \\
|
|
|
|
function useradd() { true; }; \\
|
|
|
|
function groupadd() { true; }; \\
|
|
|
|
export -f useradd groupadd; \\
|
|
|
|
fi; \\
|
|
|
|
export LFS=\$(MOUNT_PT) && \\
|
|
|
|
\$(CMDSDIR)/`dirname $file`/\$@ >> \$(LOGDIR)/\$@ 2>&1; \\
|
|
|
|
\$(PRT_DU) >>logs/\$@
|
|
|
|
@chown \$(LUSER):\$(LGROUP) envars
|
|
|
|
@chmod -R a+wt $JHALFSDIR
|
|
|
|
@chmod a+wt \$(SRCSDIR)
|
2006-04-06 21:35:22 +02:00
|
|
|
EOF
|
2020-03-29 16:06:41 +02:00
|
|
|
) >> $MKFILE.tmp
|
|
|
|
;;
|
|
|
|
*) wrt_RunAsRoot "$file" ;;
|
|
|
|
esac
|
2006-10-02 21:32:06 +02:00
|
|
|
|
2020-03-29 16:06:41 +02:00
|
|
|
# Include a touch of the target name so make can check
|
|
|
|
# if it's already been made.
|
|
|
|
wrt_touch
|
|
|
|
#
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
|
|
|
|
# Keep the script file name for Makefile dependencies.
|
|
|
|
PREV=${this_script}
|
|
|
|
done # end for file in chapter04/*
|
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
|
|
|
|
2020-03-29 19:16:09 +02:00
|
|
|
# Initialize the Makefile target: it'll change during chapter
|
|
|
|
# For vanilla lfs, the "changingowner" script should be run as root. So
|
|
|
|
# it belongs to the "SUDO" target, with list in the "runasroot" variable.
|
2020-05-01 16:24:32 +02:00
|
|
|
# For new lfs, changingowner and kernfs are in "runasroot", then the following,
|
2020-03-29 19:16:09 +02:00
|
|
|
# starting at creatingdirs, are in the "CHROOT" target, in variable "chapter6".
|
|
|
|
# Makefile_target records the variable, not really the target!
|
|
|
|
# We use a case statement on that variable, because instructions in the
|
|
|
|
# Makefile change according to the phase of the build (LUSER, SUDO, CHROOT).
|
|
|
|
Makefile_target=chapter5
|
|
|
|
|
|
|
|
# Start loop
|
2006-04-06 21:35:22 +02:00
|
|
|
for file in chapter05/* ; do
|
|
|
|
# Keep the script file name
|
|
|
|
this_script=`basename $file`
|
|
|
|
|
2020-03-29 19:16:09 +02:00
|
|
|
# Fix locales creation when running chapter05 testsuites (ugly)
|
2006-04-06 21:35:22 +02:00
|
|
|
case "${this_script}" in
|
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
|
|
|
|
|
2020-03-29 19:16:09 +02:00
|
|
|
# Append each name of the script files to a list that Makefile_target
|
|
|
|
# points to. But before that, change Makefile_target at the first script
|
|
|
|
# of each target.
|
2006-10-02 21:32:06 +02:00
|
|
|
case "${this_script}" in
|
2020-03-29 19:16:09 +02:00
|
|
|
*changingowner) Makefile_target=runasroot ;;
|
|
|
|
*creatingdirs ) Makefile_target=chapter6 ;; # only run for new lfs
|
2006-10-02 21:32:06 +02:00
|
|
|
esac
|
2020-03-29 19:16:09 +02:00
|
|
|
eval $Makefile_target=\"\$$Makefile_target ${this_script}\"
|
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
|
|
|
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
# >>>>>>>> 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
|
2019-04-11 09:40:50 +02:00
|
|
|
pkg_tarball=$(sed -n 's/tar -xf \(.*\)/\1/p' $file)
|
|
|
|
pkg_version=$(sed -n 's/VERSION=\(.*\)/\1/p' $file)
|
2013-10-05 19:45:52 +02:00
|
|
|
|
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.
|
2020-03-29 19:16:09 +02:00
|
|
|
case $Makefile_target in
|
|
|
|
chapter6) CHROOT_wrt_target "${this_script}" "$PREV" "$pkg_version" ;;
|
|
|
|
*) LUSER_wrt_target "${this_script}" "$PREV" "$pkg_version" ;;
|
|
|
|
esac
|
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
|
2018-01-12 10:40:59 +01:00
|
|
|
# Always initialize the log file, since the test instructions may be
|
|
|
|
# "uncommented" by the user
|
2020-03-29 19:16:09 +02:00
|
|
|
case $Makefile_target in
|
|
|
|
chapter6) CHROOT_wrt_test_log "${this_script}" "$pkg_version" ;;
|
|
|
|
*) LUSER_wrt_test_log "${this_script}" "$pkg_version" ;;
|
|
|
|
esac
|
|
|
|
|
2006-06-04 19:56:01 +02:00
|
|
|
# If using optimizations, write the instructions
|
2018-01-14 11:26:43 +01:00
|
|
|
case "${OPTIMIZE}${this_script}${REALSBU}" in
|
|
|
|
*binutils-pass1y) ;;
|
|
|
|
2*) wrt_optimize "$name" && wrt_makeflags "$name" ;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
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.
|
2020-03-29 19:16:09 +02:00
|
|
|
case "${Makefile_target}" in
|
|
|
|
runasroot) wrt_RunAsRoot "$file" "$pkg_version" ;;
|
|
|
|
chapter5) LUSER_wrt_RunAsUser "$file" "$pkg_version" ;;
|
|
|
|
chapter6) CHROOT_wrt_RunAsRoot "$file" "$pkg_version" ;;
|
2006-04-07 00:41:47 +02:00
|
|
|
esac
|
2006-04-06 21:35:22 +02:00
|
|
|
|
|
|
|
# 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
|
2020-04-07 19:08:30 +02:00
|
|
|
# Remove openssl-<version> from /usr/share/doc (LFS-9.x), because
|
|
|
|
# otherwise the mv command creates an openssl directory.
|
|
|
|
sed -e 's@mv -v@rm -rfv /usr/share/doc/openssl-*\n&@' \
|
|
|
|
-i chapter06$N/*-openssl$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
|
|
|
|
2020-03-29 19:16:09 +02:00
|
|
|
# Initialize the Makefile target. In vanilla lfs, kernfs should be run as root,
|
|
|
|
# then the others are run in chroot. If in new lfs, we should start in chroot.
|
|
|
|
# this will be changed later because man-pages is the first script in
|
|
|
|
# chapter 6. Note that this Makefile_target business is not really needed here
|
|
|
|
# but we do it to have a similar structure to chapter 5 (we may merge all
|
|
|
|
# those functions at some point).
|
2020-04-02 11:56:51 +02:00
|
|
|
case "$N" in
|
|
|
|
-build*) Makefile_target=chapter6 ;;
|
|
|
|
*) Makefile_target=runasroot ;;
|
|
|
|
esac
|
2020-03-29 19:16:09 +02:00
|
|
|
|
|
|
|
# Start loop
|
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.
|
2020-04-08 10:37:54 +02:00
|
|
|
# If it doesn't exist, we skip it in iterations rebuilds (except stripping
|
|
|
|
# and revisedchroot, where .a and .la files are removed).
|
2019-04-11 09:40:50 +02:00
|
|
|
pkg_tarball=$(sed -n 's/tar -xf \(.*\)/\1/p' $file)
|
|
|
|
pkg_version=$(sed -n 's/VERSION=\(.*\)/\1/p' $file)
|
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
|
2020-04-08 10:37:54 +02:00
|
|
|
*stripping*|*revised*) ;;
|
2006-04-29 16:44:29 +02:00
|
|
|
*) 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
|
2020-03-29 19:16:09 +02:00
|
|
|
*creatingdirs) Makefile_target=chapter6 ;;
|
|
|
|
*man-pages ) Makefile_target=chapter6 ;;
|
2006-12-04 12:49:51 +01:00
|
|
|
esac
|
2020-03-29 19:16:09 +02:00
|
|
|
eval $Makefile_target=\"\$$Makefile_target ${this_script}\"
|
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.
|
2020-03-29 19:16:09 +02:00
|
|
|
case "${Makefile_target}" in
|
|
|
|
runasroot) 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
|
2020-03-29 19:16:09 +02:00
|
|
|
# Always initialize the log file, so that the user may reinstate a
|
2018-01-12 10:40:59 +01:00
|
|
|
# commented out test
|
|
|
|
CHROOT_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" != "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.
|
2020-03-29 19:16:09 +02:00
|
|
|
case "${Makefile_target}" in
|
|
|
|
runasroot) 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
|
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
|
2020-04-02 11:56:51 +02:00
|
|
|
if [ -z "$N" ]; then
|
|
|
|
system_build="$system_build $this_script"
|
|
|
|
fi
|
2006-04-06 21:35:22 +02:00
|
|
|
done # end for file in chapter06/*
|
2020-04-02 11:56:51 +02:00
|
|
|
if [ -n "$N" ]; then
|
|
|
|
system_build="$chapter6"
|
|
|
|
fi
|
2006-04-06 21:35:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#----------------------------#
|
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 ;;
|
2017-03-10 21:23:57 +01:00
|
|
|
*fstab) [[ -z "${FSTAB}" ]] ||
|
2017-03-05 09:38:09 +01:00
|
|
|
[[ ${FSTAB} == $BUILDDIR/sources/fstab ]] ||
|
|
|
|
cp ${FSTAB} $BUILDDIR/sources/fstab ;;
|
2006-04-06 21:35:22 +02:00
|
|
|
*kernel) [[ -z ${CONFIG} ]] && continue
|
2017-03-05 09:38:09 +01:00
|
|
|
[[ ${CONFIG} == $BUILDDIR/sources/kernel-config ]] ||
|
2006-04-06 21:35:22 +02:00
|
|
|
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"
|
2007-04-28 17:24:20 +02:00
|
|
|
if [ "${INSTALL_LOG}" = "y" ] ; then
|
|
|
|
CHROOT_wrt_TouchTimestamp
|
|
|
|
fi
|
2006-04-06 21:35:22 +02:00
|
|
|
;;
|
2013-12-22 09:04:06 +01:00
|
|
|
*network-scripts)
|
|
|
|
name="lfs-network-scripts"
|
|
|
|
if [ "${INSTALL_LOG}" = "y" ] ; then
|
|
|
|
CHROOT_wrt_TouchTimestamp
|
|
|
|
fi
|
|
|
|
;;
|
2006-04-06 21:35:22 +02:00
|
|
|
*kernel)
|
2006-06-20 23:14:44 +02:00
|
|
|
name="linux"
|
2007-04-28 17:24:20 +02:00
|
|
|
if [ "${INSTALL_LOG}" = "y" ] ; then
|
|
|
|
CHROOT_wrt_TouchTimestamp
|
|
|
|
fi
|
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
|
2017-03-10 21:23:57 +01:00
|
|
|
*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
|
2019-04-11 09:40:50 +02:00
|
|
|
*bootscripts|*network-scripts|*kernel)
|
2013-12-22 09:04:06 +01:00
|
|
|
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
|
2020-05-01 16:24:32 +02:00
|
|
|
# Add the save target, if needed
|
|
|
|
[[ "$SAVE_CH5" = "y" ]] && wrt_save_target $Makefile_target
|
2006-04-06 21:35:22 +02:00
|
|
|
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 | \
|
2014-08-29 18:43:10 +02:00
|
|
|
perl -pe 's|\\\\\n||g' | \
|
|
|
|
tr -s [:space:] | \
|
|
|
|
grep chroot | \
|
|
|
|
sed -e "s|chroot|$CHROOT_LOC|" \
|
2006-08-08 19:26:40 +02:00
|
|
|
-e 's|\\$|&&|g' \
|
2014-08-29 18:43:10 +02:00
|
|
|
-e 's|"$$LFS"|$(MOUNT_PT)|'`
|
2006-04-06 21:35:22 +02:00
|
|
|
echo -e "CHROOT$i= $chroot\n" >> $MKFILE
|
|
|
|
i=`expr $i + 1`
|
|
|
|
done
|
|
|
|
|
2019-03-13 07:31:55 +01:00
|
|
|
# Store virtual kernel file systems commands:
|
|
|
|
devices=`cat ../kernfs-scripts/devices.sh | \
|
|
|
|
sed -e 's|^| |' \
|
|
|
|
-e 's|mount|sudo &|' \
|
|
|
|
-e 's|mkdir|sudo &|' \
|
|
|
|
-e 's|\\$|&&|g' \
|
2019-03-14 22:02:58 +01:00
|
|
|
-e 's|\$|; \\\\|' \
|
|
|
|
-e 's|then|& :|' \
|
2019-03-13 07:31:55 +01:00
|
|
|
-e 's|\$\$LFS|$(MOUNT_PT)|g'`
|
|
|
|
teardown=`cat ../kernfs-scripts/teardown.sh | \
|
|
|
|
sed -e 's|^| |' \
|
|
|
|
-e 's|umount|sudo &|' \
|
|
|
|
-e 's|\$LFS|$(MOUNT_PT)|'`
|
|
|
|
teardownat=`cat ../kernfs-scripts/teardown.sh | \
|
|
|
|
sed -e 's|^| |' \
|
|
|
|
-e 's|umount|@-sudo &|' \
|
|
|
|
-e 's|\$LFS|$(MOUNT_PT)|'`
|
2006-04-06 21:35:22 +02:00
|
|
|
# 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
|
2019-03-13 07:31:55 +01:00
|
|
|
$teardownat
|
2006-10-02 21:32:06 +02:00
|
|
|
@sudo make do_housekeeping
|
2017-03-03 22:16:40 +01:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE
|
|
|
|
if [ "$INITSYS" = systemd ]; then
|
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@/bin/echo -e -n \\
|
|
|
|
NAME=\\"Linux From Scratch\\"\\\\n\\
|
|
|
|
VERSION=\\"$VERSION\\"\\\\n\\
|
|
|
|
ID=lfs\\\\n\\
|
|
|
|
PRETTY_NAME=\\"Linux From Scratch $VERSION\\"\\\\n\\
|
|
|
|
VERSION_CODENAME=\\"$(whoami)-jhalfs\\"\\\\n\\
|
|
|
|
> os-release && \\
|
|
|
|
sudo mv os-release \$(MOUNT_PT)/etc && \\
|
|
|
|
sudo chown root:root \$(MOUNT_PT)/etc/os-release
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE
|
|
|
|
fi
|
|
|
|
(
|
|
|
|
cat << EOF
|
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)
|
2020-04-02 13:46:36 +02:00
|
|
|
@sudo make save-luser
|
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)
|
2020-03-29 16:06:41 +02:00
|
|
|
@\$(SU_LUSER) "make -C \$(MOUNT_PT)/\$(SCRIPT_ROOT) BREAKPOINT=\$(BREAKPOINT) LUSER"
|
|
|
|
@sudo make restore-luser
|
2006-10-02 21:32:06 +02:00
|
|
|
@touch \$@
|
|
|
|
|
|
|
|
mk_SUDO: mk_LUSER
|
2020-03-31 10:47:52 +02:00
|
|
|
@sudo rm -f envars
|
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
|
2019-03-13 07:31:55 +01:00
|
|
|
$devices
|
2019-03-09 08:15:41 +01:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE
|
|
|
|
if [ "$INITSYS" = systemd ]; then
|
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
sudo mkdir -pv \$(MOUNT_PT)/run/systemd/resolve
|
2019-03-09 21:27:44 +01:00
|
|
|
sudo cp -v /etc/resolv.conf \$(MOUNT_PT)/run/systemd/resolve
|
2019-03-09 08:15:41 +01:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE
|
|
|
|
fi
|
|
|
|
(
|
|
|
|
cat << EOF
|
2019-03-13 07:31:55 +01:00
|
|
|
|
2018-01-13 10:08:56 +01:00
|
|
|
teardown:
|
2019-03-13 07:31:55 +01:00
|
|
|
$teardown
|
2019-03-09 08:15:41 +01:00
|
|
|
|
|
|
|
chroot1: devices
|
|
|
|
sudo \$(CHROOT1)
|
|
|
|
\$(MAKE) teardown
|
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
|
2019-03-13 07:31:55 +01:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE
|
|
|
|
if [ "$INITSYS" = systemd ]; then
|
|
|
|
(
|
|
|
|
cat << EOF
|
2019-03-15 09:55:01 +01:00
|
|
|
mkdir -pv \$(MOUNT_PT)/run/systemd/resolve
|
|
|
|
cp -v /etc/resolv.conf \$(MOUNT_PT)/run/systemd/resolve
|
2019-03-13 07:31:55 +01:00
|
|
|
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE
|
|
|
|
fi
|
|
|
|
(
|
|
|
|
cat << EOF
|
2020-03-31 10:47:52 +02:00
|
|
|
CHROOT: SHELL=\$(filter %bash,\$(CHROOT1))
|
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 \\
|
2017-06-29 18:45:31 +02:00
|
|
|
sudo ./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); \\
|
2020-03-29 16:06:41 +02:00
|
|
|
fi
|
2006-11-12 14:50:34 +01:00
|
|
|
@touch \$@
|
2006-10-02 21:32:06 +02:00
|
|
|
|
2020-03-29 16:06:41 +02:00
|
|
|
save-luser:
|
2006-04-06 21:35:22 +02:00
|
|
|
@\$(call echo_message, Building)
|
2020-04-02 13:54:50 +02:00
|
|
|
@LUSER_ID=\$\$(grep '^\$(LUSER):' /etc/passwd | cut -d: -f3); \\
|
2020-04-02 13:46:36 +02:00
|
|
|
if [ -n "\$\$LUSER_ID" ]; then \\
|
2020-03-29 16:06:41 +02:00
|
|
|
if [ ! -d \$(LUSER_HOME).XXX ]; then \\
|
|
|
|
mv \$(LUSER_HOME){,.XXX}; \\
|
|
|
|
mkdir \$(LUSER_HOME); \\
|
|
|
|
chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME); \\
|
|
|
|
fi; \\
|
2020-04-02 13:46:36 +02:00
|
|
|
echo "\$\$LUSER_ID" > luser-id; \\
|
|
|
|
echo User \$(LUSER) exists with ID \$\$LUSER_ID; \\
|
2020-03-29 16:06:41 +02:00
|
|
|
else \\
|
2020-04-02 13:54:50 +02:00
|
|
|
rm -f luser-id; \\
|
2020-04-02 13:46:36 +02:00
|
|
|
echo User \$(LUSER) does not exist; \\
|
|
|
|
echo It will be created with book instructions.; \\
|
2020-03-29 16:06:41 +02:00
|
|
|
fi
|
2007-03-18 11:14:04 +01:00
|
|
|
@\$(call housekeeping)
|
2006-05-31 22:43:41 +02:00
|
|
|
|
2020-03-29 16:06:41 +02:00
|
|
|
restore-luser:
|
|
|
|
@\$(call echo_message, Building)
|
|
|
|
@if [ -f luser-id ]; then \\
|
|
|
|
rm -rf \$(LUSER_HOME); \\
|
|
|
|
mv \$(LUSER_HOME){.XXX,}; \\
|
|
|
|
rm luser-id; \\
|
|
|
|
else \\
|
2006-08-08 19:26:40 +02:00
|
|
|
userdel \$(LUSER); \\
|
2020-03-29 16:06:41 +02:00
|
|
|
groupdel \$(LGROUP); \\
|
2007-04-13 22:40:38 +02:00
|
|
|
rm -rf \$(LUSER_HOME); \\
|
2020-03-29 16:06:41 +02:00
|
|
|
fi
|
|
|
|
@\$(call housekeeping)
|
|
|
|
|
|
|
|
do_housekeeping:
|
|
|
|
@-rm /tools
|
2006-05-31 22:43:41 +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}"
|
|
|
|
}
|