2023-01-05 06:17:49 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-01-05 09:26:40 +00:00
|
|
|
# Set SU
|
2023-01-06 08:59:14 +00:00
|
|
|
# ======
|
|
|
|
command -v sudo > /dev/null
|
2023-01-05 09:26:40 +00:00
|
|
|
if [ $? -eq 1 ]
|
|
|
|
then
|
|
|
|
SU=doas
|
|
|
|
else
|
|
|
|
SU=sudo
|
|
|
|
fi
|
|
|
|
|
2023-01-06 08:59:14 +00:00
|
|
|
# Exit on error
|
|
|
|
# =============
|
2023-01-05 06:17:49 +00:00
|
|
|
exit_status=0
|
|
|
|
|
|
|
|
function check_exit_code() {
|
|
|
|
if [ $? -ne 0 ]
|
|
|
|
then
|
|
|
|
exit_status=1
|
|
|
|
else
|
|
|
|
exit_status=0
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function stop_script() {
|
|
|
|
echo "Script failed in $(pwd)/$1"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2023-01-06 08:59:14 +00:00
|
|
|
|
|
|
|
# Chapter 2
|
|
|
|
# =========
|
2023-01-05 06:17:49 +00:00
|
|
|
echo "Chapter 2"
|
|
|
|
echo "Checking required packages"
|
|
|
|
bash ./chapter2/2.2-version-check.sh
|
|
|
|
|
2023-01-06 08:59:14 +00:00
|
|
|
# Exit on error
|
|
|
|
check_exit_code
|
|
|
|
if [ $exit_status -ne 0 ]
|
|
|
|
then
|
|
|
|
stop_script "chapter2/2.2-version-check.sh"
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Set LFS variable
|
|
|
|
# ================
|
|
|
|
export LFS=/mnt/lfs
|
|
|
|
echo "LFS is $LFS"
|
|
|
|
|
|
|
|
# Chapter 2.5
|
|
|
|
# ===========
|
2023-01-06 04:55:59 +00:00
|
|
|
echo "Creating filesystem"
|
2023-01-06 08:59:14 +00:00
|
|
|
su -c "bash ./chapter2/2.5-create-filesystem.sh"
|
|
|
|
|
|
|
|
# Exit on error
|
|
|
|
check_exit_code
|
|
|
|
if [ $exit_status -ne 0 ]
|
|
|
|
then
|
|
|
|
stop_script "chapter2/2.5-create-filesystem.sh"
|
|
|
|
fi
|
2023-01-06 04:55:59 +00:00
|
|
|
|
2023-01-06 08:59:14 +00:00
|
|
|
|
|
|
|
# Chapter 2.7
|
|
|
|
# ===========
|
2023-01-06 04:55:59 +00:00
|
|
|
echo "Mounting filesystem"
|
2023-01-06 08:59:14 +00:00
|
|
|
su -c "bash ./chapter2/2.7-mount.sh"
|
2023-01-06 04:55:59 +00:00
|
|
|
|
2023-01-06 08:59:14 +00:00
|
|
|
# Exit on error
|
|
|
|
check_exit_code
|
|
|
|
if [ $exit_status -ne 0 ]
|
|
|
|
then
|
|
|
|
stop_script "chapter2/2.7-mount.sh"
|
|
|
|
fi
|
2023-01-06 04:55:59 +00:00
|
|
|
|
2023-01-06 08:59:14 +00:00
|
|
|
|
|
|
|
# Chapter 3
|
|
|
|
# =========
|
2023-01-06 04:55:59 +00:00
|
|
|
echo "Chapter 3"
|
|
|
|
echo "Downloading sources"
|
|
|
|
bash ./chapter3/3.1-sources.sh
|
|
|
|
|
2023-01-06 08:59:14 +00:00
|
|
|
# Exit on error
|
|
|
|
check_exit_code
|
|
|
|
if [ $exit_status -ne 0 ]
|
|
|
|
then
|
|
|
|
stop_script "chapter3/3.1-sources.sh"
|
|
|
|
fi
|
|
|
|
|
2023-01-06 04:55:59 +00:00
|
|
|
|
2023-01-06 08:59:14 +00:00
|
|
|
# Chapter 4
|
|
|
|
# =========
|
2023-01-06 04:55:59 +00:00
|
|
|
echo "Chapter 4"
|
|
|
|
echo "Creating direcctories"
|
2023-01-06 08:59:14 +00:00
|
|
|
su -c "bash ./chapter4/4.2-create-dir.sh"
|
|
|
|
|
|
|
|
# Exit on error
|
|
|
|
check_exit_code
|
|
|
|
if [ $exit_status -ne 0 ]
|
|
|
|
then
|
|
|
|
stop_script "chapter4/4.2-create-dir.sh"
|
|
|
|
fi
|
2023-01-06 04:55:59 +00:00
|
|
|
|
|
|
|
|
2023-01-06 08:59:14 +00:00
|
|
|
# Chapter 4.3
|
|
|
|
# ===========
|
|
|
|
echo "Adding LFS user"
|
|
|
|
su -c "bash ./chapter4/4.3-add-user.sh"
|
|
|
|
|
|
|
|
# Exit on error
|
2023-01-05 06:17:49 +00:00
|
|
|
check_exit_code
|
|
|
|
if [ $exit_status -ne 0 ]
|
|
|
|
then
|
2023-01-06 08:59:14 +00:00
|
|
|
stop_script "chapter4/4.3-add-user.sh"
|
2023-01-05 06:17:49 +00:00
|
|
|
fi
|
2023-01-08 10:27:40 +00:00
|
|
|
<<<<<<< HEAD
|
2023-01-05 06:17:49 +00:00
|
|
|
|
2023-01-06 08:59:14 +00:00
|
|
|
PWD=$(pwd)
|
2023-01-05 09:28:27 +00:00
|
|
|
|
2023-01-06 08:59:14 +00:00
|
|
|
# Chapter 4.4
|
|
|
|
# ===========
|
|
|
|
echo "Setting Up the Environment"
|
2023-01-09 04:51:24 +00:00
|
|
|
su - lfs -c "bash $PWD/chapter4/4.4-set-up-env.sh"
|
2023-01-05 09:28:27 +00:00
|
|
|
|
2023-01-06 08:59:14 +00:00
|
|
|
# Exit on error
|
|
|
|
check_exit_code
|
|
|
|
if [ $exit_status -ne 0 ]
|
|
|
|
then
|
|
|
|
stop_script "chapter4/4.4-set-up-env.sh"
|
|
|
|
fi
|
2023-01-06 09:13:50 +00:00
|
|
|
|
|
|
|
# Chapter 5.2
|
|
|
|
# ===========
|
2023-01-09 05:17:03 +00:00
|
|
|
echo "Chapter 5"
|
2023-01-06 09:13:50 +00:00
|
|
|
echo "Building binutils"
|
2023-01-09 04:51:24 +00:00
|
|
|
su - lfs -c "bash $PWD/chapter5/5.2-binutils.sh"
|
2023-01-06 09:13:50 +00:00
|
|
|
|
|
|
|
# Exit on error
|
|
|
|
check_exit_code
|
|
|
|
if [ $exit_status -ne 0 ]
|
|
|
|
then
|
|
|
|
stop_script "chapter5/5.2-binutils.sh"
|
|
|
|
fi
|
|
|
|
|
2023-01-08 09:21:58 +00:00
|
|
|
# Chapter 5.3
|
|
|
|
# ===========
|
|
|
|
echo "Building gcc"
|
2023-01-09 04:51:24 +00:00
|
|
|
su - lfs -c "bash $PWD/chapter5/5.3-gcc.sh"
|
2023-01-06 09:13:50 +00:00
|
|
|
|
2023-01-08 09:21:58 +00:00
|
|
|
# Exit on error
|
|
|
|
check_exit_code
|
|
|
|
if [ $exit_status -ne 0 ]
|
|
|
|
then
|
|
|
|
stop_script "chapter5/5.3-gcc.sh"
|
|
|
|
fi
|
2023-01-08 09:54:09 +00:00
|
|
|
|
|
|
|
# Chapter 5.4
|
|
|
|
# ===========
|
|
|
|
echo "Building Linux API Headers"
|
2023-01-09 04:51:24 +00:00
|
|
|
su - lfs -c "bash $PWD/chapter5/5.4-linux-headers.sh"
|
2023-01-08 09:54:09 +00:00
|
|
|
|
|
|
|
# Exit on error
|
|
|
|
check_exit_code
|
|
|
|
if [ $exit_status -ne 0 ]
|
|
|
|
then
|
|
|
|
stop_script "chapter5/5.4-linux-headers.sh"
|
|
|
|
fi
|
2023-01-08 10:07:41 +00:00
|
|
|
|
|
|
|
# Chapter 5.5
|
|
|
|
# ===========
|
|
|
|
echo "Building glibc"
|
2023-01-09 04:51:24 +00:00
|
|
|
su - lfs -c "bash $PWD/chapter5/5.5-glibc.sh"
|
2023-01-08 10:07:41 +00:00
|
|
|
|
|
|
|
# Exit on error
|
|
|
|
check_exit_code
|
|
|
|
if [ $exit_status -ne 0 ]
|
|
|
|
then
|
|
|
|
stop_script "chapter5/5.5-glibc.sh"
|
|
|
|
fi
|
|
|
|
|
2023-01-09 04:53:36 +00:00
|
|
|
# Chapter 5.6
|
|
|
|
# ===========
|
|
|
|
echo "Building listdc++"
|
2023-01-09 05:17:03 +00:00
|
|
|
su - lfs -c "bash $PWD/chapter5/5.6-libstdc++.sh"
|
2023-01-09 04:53:36 +00:00
|
|
|
|
|
|
|
# Exit on error
|
|
|
|
check_exit_code
|
|
|
|
if [ $exit_status -ne 0 ]
|
|
|
|
then
|
|
|
|
stop_script "chapter5/5.6-libstdc++.sh"
|
|
|
|
fi
|
|
|
|
|
2023-01-09 05:17:03 +00:00
|
|
|
# Chapter 6.2
|
|
|
|
# ===========
|
|
|
|
echo "Chapter 6"
|
|
|
|
echo "Building m4"
|
|
|
|
su - lfs -c "bash $PWD/chapter6/6.2-m4.sh"
|
|
|
|
|
|
|
|
# Exit on error
|
|
|
|
check_exit_code
|
|
|
|
if [ $exit_status -ne 0 ]
|
|
|
|
then
|
2023-01-09 05:26:56 +00:00
|
|
|
stop_script "chapter6/6.2-m4.sh"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Chapter 6.3
|
|
|
|
# ===========
|
|
|
|
echo "Building ncurses"
|
|
|
|
su - lfs -c "bash $PWD/chapter6/6.3-ncurses.sh"
|
|
|
|
|
|
|
|
# Exit onn error
|
|
|
|
check_exit_code
|
|
|
|
if [ $exit_status -ne 0 ]
|
|
|
|
then
|
|
|
|
stop_script "chapter6/6.3-ncurses.sh"
|
2023-01-09 05:17:03 +00:00
|
|
|
fi
|
|
|
|
|
2023-01-09 05:36:59 +00:00
|
|
|
# Chapter 6.4
|
|
|
|
# ===========
|
|
|
|
echo "Building bash"
|
|
|
|
su - lfs -c "bash $PWD/chapter6/6.4-bash.sh"
|
|
|
|
|
|
|
|
# Exit on error
|
|
|
|
check_exit_code
|
|
|
|
if [ $exit_status -ne 0 ]
|
|
|
|
then
|
|
|
|
stop_script "chapter6/6.4-bash.sh"
|
|
|
|
fi
|
|
|
|
|
2023-01-09 05:44:30 +00:00
|
|
|
# Chapter 6.5
|
|
|
|
# ===========
|
|
|
|
echo "Building coreutils"
|
|
|
|
su - lfs -c "bash $PWD/chapter6/6.5-coreutils.sh"
|
|
|
|
|
|
|
|
# Exit on error
|
|
|
|
check_exit_code
|
|
|
|
if [ $exit_status -ne 0 ]
|
|
|
|
then
|
|
|
|
stop_script "chapter6/6.5-ncurses.sh"
|
|
|
|
fi
|
2023-01-09 06:14:30 +00:00
|
|
|
|
2023-01-09 05:48:23 +00:00
|
|
|
# Chapter 6.6
|
|
|
|
# ===========
|
|
|
|
echo "Building diffutils"
|
|
|
|
su - lfs -c "bash $PWD/chapter6/6.6-diffutils.sh"
|
|
|
|
|
|
|
|
# Exit on error
|
|
|
|
check_exit_code
|
|
|
|
if [ $exit_status -ne 0 ]
|
|
|
|
then
|
|
|
|
stop_script "chapter6/6.6-diffutils.sh"
|
|
|
|
fi
|
2023-01-09 05:36:59 +00:00
|
|
|
|
2023-01-09 06:14:30 +00:00
|
|
|
# Chapter 6.7
|
|
|
|
# ===========
|
|
|
|
echo "Building file"
|
|
|
|
su - lfs -c "bash $PWD/chapter6/6.7-file.sh"
|
|
|
|
|
|
|
|
# Exit on error
|
|
|
|
check_exit_code
|
|
|
|
if [ $exit_status -ne 0 ]
|
|
|
|
then
|
|
|
|
stop_script "chapter6/6.7-file.sh"
|
|
|
|
fi
|
|
|
|
|