2006-11-11 12:39:16 +01:00
|
|
|
#!/bin/bash
|
2006-04-06 21:35:22 +02:00
|
|
|
|
|
|
|
###################################
|
|
|
|
### FUNCTIONS ###
|
|
|
|
###################################
|
|
|
|
|
|
|
|
|
2006-10-02 21:32:06 +02:00
|
|
|
#############################################################
|
|
|
|
|
|
|
|
|
2020-06-10 22:01:17 +02:00
|
|
|
#-------------------------#
|
|
|
|
chapter_targets() { #
|
|
|
|
#-------------------------#
|
|
|
|
# $1 is the chapter number. Pad it with 0 to the left to obtain a 2-digit
|
|
|
|
# number:
|
|
|
|
printf -v dir chapter%02d $1
|
|
|
|
|
2020-06-14 09:08:19 +02:00
|
|
|
# $2 contains the build number if rebuilding for ICA
|
|
|
|
if [[ -z "$2" ]] ; then
|
|
|
|
local N=""
|
|
|
|
else
|
|
|
|
local N=-build_$2
|
|
|
|
local CHROOT_TGT=""
|
|
|
|
mkdir ${dir}$N
|
|
|
|
cp ${dir}/* ${dir}$N
|
|
|
|
for script in ${dir}$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}
|
|
|
|
# Rename the scripts
|
|
|
|
mv ${script} ${script}$N
|
|
|
|
done
|
|
|
|
# Remove Bzip2 binaries before make install (LFS-6.2 compatibility)
|
|
|
|
sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i ${dir}$N/*-bzip2$N
|
|
|
|
# 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 ${dir}$N/*-openssl$N
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter $1$N${R_arrow}"
|
2006-04-06 21:35:22 +02:00
|
|
|
|
2020-06-14 09:08:19 +02:00
|
|
|
for file in ${dir}$N/* ; do
|
2020-03-29 16:06:41 +02:00
|
|
|
# Keep the script file name
|
|
|
|
this_script=`basename $file`
|
2006-04-06 21:35:22 +02:00
|
|
|
|
2020-06-10 22:01:17 +02:00
|
|
|
# Some scripts need peculiar actions:
|
2020-06-14 09:08:19 +02:00
|
|
|
# - glibc chap 5: fix locales creation when running chapter05 testsuites
|
2020-06-10 22:01:17 +02:00
|
|
|
# - Stripping at the end of system build: lfs.xsl does not generate
|
|
|
|
# correct commands if the user does not want to strip, so skip it
|
|
|
|
# in this case
|
2020-06-14 09:08:19 +02:00
|
|
|
# - do not reinstall linux-headers when rebuilding
|
2020-06-10 22:01:17 +02:00
|
|
|
# - grub config: must be done manually; skip it
|
|
|
|
# - handle fstab and .config. Skip kernel if .config not supplied
|
2020-03-29 16:06:41 +02:00
|
|
|
case "${this_script}" in
|
2020-06-10 22:01:17 +02:00
|
|
|
5*glibc) [[ "${TEST}" = "3" ]] && \
|
|
|
|
sed -i 's@/usr/lib/locale@/tools/lib/locale@' $file ;;
|
2021-08-18 01:23:24 +02:00
|
|
|
*strippingagain) [[ "${STRIP}" = "n" ]] && continue ;;
|
2021-08-13 07:51:13 +02:00
|
|
|
*stripping) [[ "${STRIP}" = "n" ]] && continue ;;
|
2020-06-14 09:08:19 +02:00
|
|
|
*linux-headers*) [[ -n "$N" ]] && continue ;;
|
2020-06-10 22:01:17 +02:00
|
|
|
8*grub) (( nb_chaps == 5 )) && continue ;;
|
|
|
|
10*grub) continue ;;
|
|
|
|
*fstab) [[ -z "${FSTAB}" ]] ||
|
|
|
|
[[ ${FSTAB} == $BUILDDIR/sources/fstab ]] ||
|
|
|
|
cp ${FSTAB} $BUILDDIR/sources/fstab ;;
|
|
|
|
*kernel) [[ -z ${CONFIG} ]] && continue
|
|
|
|
[[ ${CONFIG} == $BUILDDIR/sources/kernel-config ]] ||
|
|
|
|
cp ${CONFIG} $BUILDDIR/sources/kernel-config ;;
|
2020-03-29 16:06:41 +02:00
|
|
|
esac
|
2020-06-14 09:08:19 +02:00
|
|
|
# Grab the name of the target
|
2020-09-17 17:30:29 +02:00
|
|
|
# This is only used to check the name in "opt_override" or "BLACKIST"
|
2020-06-14 09:08:19 +02:00
|
|
|
name=`echo ${this_script} | sed -e 's@[0-9]\{3,4\}-@@' \
|
|
|
|
-e 's@-pass[0-9]\{1\}@@' \
|
|
|
|
-e 's@-libstdc++@@' \
|
2020-06-20 19:01:23 +02:00
|
|
|
-e 's,'$N',,' \
|
|
|
|
-e 's@-32@@'`
|
2020-06-14 09:08:19 +02:00
|
|
|
|
|
|
|
# Find the name of the tarball and the version of the package
|
|
|
|
# If it doesn't exist, we skip it in iterations rebuilds (except stripping
|
|
|
|
# and revisedchroot, where .a and .la files are removed).
|
|
|
|
pkg_tarball=$(sed -n 's/tar -xf \(.*\)/\1/p' $file)
|
|
|
|
pkg_version=$(sed -n 's/VERSION=\(.*\)/\1/p' $file)
|
|
|
|
|
|
|
|
if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
|
|
|
|
case "${this_script}" in
|
2021-08-13 08:18:05 +02:00
|
|
|
*stripping*|*cleanup*|*revised*) ;;
|
2020-06-14 09:08:19 +02:00
|
|
|
*) continue ;;
|
|
|
|
esac
|
|
|
|
fi
|
2006-04-06 21:35:22 +02:00
|
|
|
|
2020-06-10 22:01:17 +02:00
|
|
|
# Append the name of the script to a list. The name of the
|
|
|
|
# list is contained in the variable Makefile_target. We adjust this
|
|
|
|
# variable at various points. Note that it is initialized to "SETUP"
|
|
|
|
# in the main function, before calling this function for the first time.
|
|
|
|
case "${this_script}" in
|
|
|
|
*settingenvironment) Makefile_target=LUSER_TGT ;;
|
|
|
|
*changingowner ) Makefile_target=SUDO_TGT ;;
|
|
|
|
*creatingdirs ) Makefile_target=CHROOT_TGT ;;
|
|
|
|
*bootscripts ) Makefile_target=BOOT_TGT ;; # case of sysv book
|
|
|
|
*network ) Makefile_target=BOOT_TGT ;; # case of systemd book
|
|
|
|
esac
|
|
|
|
eval $Makefile_target=\"\$$Makefile_target ${this_script}\"
|
|
|
|
|
2020-03-29 16:06:41 +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.
|
2020-06-10 22:01:17 +02:00
|
|
|
case $Makefile_target in
|
|
|
|
CHROOT_TGT) CHROOT_wrt_target "${this_script}" "$PREV" "$pkg_version" ;;
|
|
|
|
*) LUSER_wrt_target "${this_script}" "$PREV" "$pkg_version" ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# If $pkg_tarball isn't empty, we've got a package...
|
|
|
|
if [ "$pkg_tarball" != "" ] ; then
|
|
|
|
# Touch timestamp file if installed files logs shall be created.
|
2020-06-14 09:08:19 +02:00
|
|
|
# But only for the final install chapter and not when rebuilding it
|
|
|
|
if [ "${INSTALL_LOG}" = "y" ] &&
|
|
|
|
(( 1+nb_chaps <= $1 )) &&
|
|
|
|
[ "x$N" = x ] ; then
|
2020-06-10 22:01:17 +02:00
|
|
|
CHROOT_wrt_TouchTimestamp
|
|
|
|
fi
|
|
|
|
# Always initialize the test log file, since the test instructions may
|
|
|
|
# be "uncommented" by the user
|
|
|
|
case $Makefile_target in
|
|
|
|
CHROOT_TGT) CHROOT_wrt_test_log "${this_script}" "$pkg_version" ;;
|
|
|
|
LUSER_TGT ) LUSER_wrt_test_log "${this_script}" "$pkg_version" ;;
|
|
|
|
esac
|
2020-03-29 16:06:41 +02:00
|
|
|
|
2020-06-10 22:01:17 +02:00
|
|
|
# If using optimizations, write the instructions
|
|
|
|
case "${OPTIMIZE}$1${nb_chaps}${this_script}${REALSBU}" in
|
|
|
|
0* | *binutils-pass1y | 15* | 167* | 177*) ;;
|
2020-06-11 22:43:33 +02:00
|
|
|
*kernel*) wrt_makeflags "$name" ;; # No CFLAGS for kernel
|
2020-06-10 22:01:17 +02:00
|
|
|
*) wrt_optimize "$name" && wrt_makeflags "$name" ;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Some scriptlet have a special treatment; otherwise standard
|
2020-03-29 16:06:41 +02:00
|
|
|
case "${this_script}" in
|
|
|
|
*addinguser)
|
|
|
|
(
|
2020-09-17 17:30:29 +02:00
|
|
|
# /var/lib may already exist and be owned by root if blfs tools
|
|
|
|
# have been installed.
|
2020-03-29 16:06:41 +02:00
|
|
|
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
|
2020-09-30 07:43:59 +02:00
|
|
|
@if [ -d "\$(MOUNT_PT)/var/lib" ]; then \\
|
|
|
|
chown \$(LUSER):\$(LGROUP) \$(MOUNT_PT)/var/lib; \\
|
|
|
|
fi
|
2020-03-29 16:06:41 +02:00
|
|
|
@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
|
|
|
|
;;
|
2020-06-10 22:01:17 +02:00
|
|
|
*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
|
|
|
|
;;
|
|
|
|
*fstab) if [[ -n "$FSTAB" ]]; then
|
|
|
|
CHROOT_wrt_CopyFstab
|
|
|
|
else
|
|
|
|
CHROOT_wrt_RunAsRoot "$file"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
2020-06-19 16:25:52 +02:00
|
|
|
*)
|
2020-06-10 22:01:17 +02:00
|
|
|
# Insert date and disk usage at the top of the log file, the script
|
|
|
|
# run and date and disk usage again at the bottom of the log file.
|
|
|
|
case "${Makefile_target}" in
|
|
|
|
SETUP_TGT | SUDO_TGT) wrt_RunAsRoot "$file" "$pkg_version" ;;
|
|
|
|
LUSER_TGT) LUSER_wrt_RunAsUser "$file" "$pkg_version" ;;
|
|
|
|
CHROOT_TGT | BOOT_TGT) CHROOT_wrt_RunAsRoot "$file" "$pkg_version" ;;
|
|
|
|
esac
|
|
|
|
;;
|
2020-03-29 16:06:41 +02:00
|
|
|
esac
|
2006-10-02 21:32:06 +02:00
|
|
|
|
2020-06-10 22:01:17 +02:00
|
|
|
# Write installed files log and remove the build directory(ies)
|
|
|
|
# except if the package build fails.
|
|
|
|
if [ "$pkg_tarball" != "" ] ; then
|
2020-06-14 09:08:19 +02:00
|
|
|
if [ "${INSTALL_LOG}" = "y" ] &&
|
|
|
|
(( 1+nb_chaps <= $1 )) &&
|
|
|
|
[ "x${N}" = "x" ] ; then
|
2020-06-20 19:01:23 +02:00
|
|
|
CHROOT_wrt_LogNewFiles "${this_script}"
|
2020-06-10 22:01:17 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
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}
|
2020-06-14 09:08:19 +02:00
|
|
|
# Set "system_build" var for iteration targets
|
|
|
|
if [ -z "$N" ] && (( 1+nb_chaps == $1 )); then
|
|
|
|
system_build="$system_build $this_script"
|
|
|
|
fi
|
|
|
|
|
2020-06-10 22:01:17 +02:00
|
|
|
done # end for file in $dir/*
|
2020-06-14 09:08:19 +02:00
|
|
|
# Set "system_build" when rebuilding: note the CHROOT_TGT is local
|
|
|
|
# in that case.
|
|
|
|
if [ -n "$N" ]; then
|
|
|
|
system_build="$CHROOT_TGT"
|
|
|
|
fi
|
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
|
|
|
|
|
2020-06-10 22:01:17 +02:00
|
|
|
# Start with empty files
|
2006-10-02 21:32:06 +02:00
|
|
|
>$MKFILE
|
2020-06-10 22:01:17 +02:00
|
|
|
>$MKFILE.tmp
|
|
|
|
|
|
|
|
# Ensure the first dependency is empty
|
|
|
|
unset PREV
|
2006-04-06 21:35:22 +02:00
|
|
|
|
2020-06-10 22:01:17 +02:00
|
|
|
# We begin with the SETUP target; successive targets will be assigned in
|
|
|
|
# the chapter_targets function.
|
|
|
|
Makefile_target=SETUP_TGT
|
|
|
|
|
|
|
|
# We need to know the chapter numbering, which depends on the version
|
|
|
|
# of the book. Use the number of subdirs to know which version we have
|
2020-07-10 15:29:15 +02:00
|
|
|
chaps=($(echo chapter*))
|
2020-06-10 22:01:17 +02:00
|
|
|
nb_chaps=${#chaps[*]} # 5 if classical version, 7 if new version
|
|
|
|
# DEBUG
|
|
|
|
# echo chaps: ${chaps[*]}
|
|
|
|
# echo nb_chaps: $nb_chaps
|
|
|
|
# end DEBUG
|
|
|
|
|
|
|
|
# Make a temporary file with all script targets
|
|
|
|
for (( i = 4; i < nb_chaps+4; i++ )); do
|
|
|
|
chapter_targets $i
|
|
|
|
if (( i == nb_chaps )); then : # we have finished temporary tools
|
|
|
|
# Add the save target, if needed
|
|
|
|
[[ "$SAVE_CH5" = "y" ]] && wrt_save_target $Makefile_target
|
|
|
|
fi
|
2020-06-14 09:08:19 +02:00
|
|
|
if (( i == 1+nb_chaps )); then : # we have finished final system
|
|
|
|
# Add the iterations targets, if needed
|
|
|
|
[[ "$COMPARE" = "y" ]] && wrt_compare_targets $i
|
|
|
|
fi
|
2020-06-10 22:01:17 +02:00
|
|
|
done
|
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|^| |' \
|
2021-03-09 21:58:44 +01:00
|
|
|
-e 's|umount|-sudo &|' \
|
2019-03-13 07:31:55 +01:00
|
|
|
-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
|
|
|
|
2020-05-25 08:47:48 +02:00
|
|
|
all: ck_UID ck_terminal 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
|
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
|
2020-08-22 13:49:09 +02:00
|
|
|
@/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
|
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
|
|
|
|
|
2020-05-25 08:47:48 +02:00
|
|
|
ck_terminal:
|
2020-05-31 10:58:41 +02:00
|
|
|
@stty size | ( read L C; \\
|
|
|
|
if (( L < 24 )) || (( C < 80 )) ; then \\
|
2020-05-25 08:47:48 +02:00
|
|
|
echo "--------------------------------------------------"; \\
|
2020-05-31 10:58:41 +02:00
|
|
|
echo "Terminal too small: \$\$C columns x \$\$L lines";\\
|
2020-05-25 08:47:48 +02:00
|
|
|
echo "Minimum: 80 columns x 24 lines";\\
|
|
|
|
echo "--------------------------------------------------"; \\
|
|
|
|
exit 1; \\
|
2020-05-31 10:58:41 +02:00
|
|
|
fi )
|
2020-05-25 08:47:48 +02:00
|
|
|
|
2006-10-02 21:32:06 +02:00
|
|
|
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)
|
2022-02-05 18:48:32 +01:00
|
|
|
@( sudo \$(CHROOT1) -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); \\
|
2022-02-05 18:48:32 +01:00
|
|
|
(sudo \$(CHROOT1) -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}; \\
|
2022-02-05 18:48:32 +01:00
|
|
|
(sudo \$(CHROOT1) -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
|
2022-02-05 18:48:32 +01:00
|
|
|
sudo \$(CHROOT1)
|
2008-10-21 23:29:13 +02:00
|
|
|
\$(MAKE) teardown
|
2006-04-06 21:35:22 +02:00
|
|
|
|
2020-06-10 22:01:17 +02:00
|
|
|
SETUP: $SETUP_TGT
|
|
|
|
LUSER: $LUSER_TGT
|
|
|
|
SUDO: $SUDO_TGT
|
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))
|
2020-06-10 22:01:17 +02:00
|
|
|
CHROOT: $CHROOT_TGT
|
|
|
|
BOOT: $BOOT_TGT
|
2006-12-15 11:53:10 +01:00
|
|
|
CUSTOM_TOOLS: $custom_list
|
2006-06-09 15:31:22 +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:
|
2020-06-20 19:01:23 +02:00
|
|
|
@-rm -f /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}"
|
|
|
|
}
|