mirror of
https://git.adityakumar.xyz/lfs-scripts.git
synced 2024-11-13 00:39:46 +00:00
165 lines
2.5 KiB
Bash
165 lines
2.5 KiB
Bash
#!/bin/bash
|
|
|
|
# Set SU
|
|
# ======
|
|
command -v sudo > /dev/null
|
|
if [ $? -eq 1 ]
|
|
then
|
|
SU=doas
|
|
else
|
|
SU=sudo
|
|
fi
|
|
|
|
# Exit on error
|
|
# =============
|
|
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
|
|
}
|
|
|
|
|
|
# Chapter 2
|
|
# =========
|
|
echo "Chapter 2"
|
|
echo "Checking required packages"
|
|
bash ./chapter2/2.2-version-check.sh
|
|
|
|
# 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
|
|
# ===========
|
|
echo "Creating filesystem"
|
|
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
|
|
|
|
|
|
# Chapter 2.7
|
|
# ===========
|
|
echo "Mounting filesystem"
|
|
su -c "bash ./chapter2/2.7-mount.sh"
|
|
|
|
# Exit on error
|
|
check_exit_code
|
|
if [ $exit_status -ne 0 ]
|
|
then
|
|
stop_script "chapter2/2.7-mount.sh"
|
|
fi
|
|
|
|
|
|
# Chapter 3
|
|
# =========
|
|
echo "Chapter 3"
|
|
echo "Downloading sources"
|
|
bash ./chapter3/3.1-sources.sh
|
|
|
|
# Exit on error
|
|
check_exit_code
|
|
if [ $exit_status -ne 0 ]
|
|
then
|
|
stop_script "chapter3/3.1-sources.sh"
|
|
fi
|
|
|
|
|
|
# Chapter 4
|
|
# =========
|
|
echo "Chapter 4"
|
|
echo "Creating direcctories"
|
|
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
|
|
|
|
|
|
# Chapter 4.3
|
|
# ===========
|
|
echo "Adding LFS user"
|
|
su -c "bash ./chapter4/4.3-add-user.sh"
|
|
|
|
# Exit on error
|
|
check_exit_code
|
|
if [ $exit_status -ne 0 ]
|
|
then
|
|
stop_script "chapter4/4.3-add-user.sh"
|
|
fi
|
|
|
|
PWD=$(pwd)
|
|
|
|
# Chapter 4.4
|
|
# ===========
|
|
echo "Setting Up the Environment"
|
|
su - lfs -c "$PWD/chapter4/4.4-set-up-env.sh"
|
|
|
|
# Exit on error
|
|
check_exit_code
|
|
if [ $exit_status -ne 0 ]
|
|
then
|
|
stop_script "chapter4/4.4-set-up-env.sh"
|
|
fi
|
|
|
|
# Chapter 5.2
|
|
# ===========
|
|
echo "Building binutils"
|
|
su - lfs -c "$PWD/chapter5/5.2-binutils.sh"
|
|
|
|
# Exit on error
|
|
check_exit_code
|
|
if [ $exit_status -ne 0 ]
|
|
then
|
|
stop_script "chapter5/5.2-binutils.sh"
|
|
fi
|
|
|
|
# Chapter 5.3
|
|
# ===========
|
|
echo "Building gcc"
|
|
su - lfs -c "$PWD/chapter5/5.3-gcc.sh"
|
|
|
|
# Exit on error
|
|
check_exit_code
|
|
if [ $exit_status -ne 0 ]
|
|
then
|
|
stop_script "chapter5/5.3-gcc.sh"
|
|
fi
|
|
|
|
# Chapter 5.4
|
|
# ===========
|
|
echo "Building Linux API Headers"
|
|
su - lfs -c "$PWD/chapter5/5.4-linux-headers.sh"
|
|
|
|
# Exit on error
|
|
check_exit_code
|
|
if [ $exit_status -ne 0 ]
|
|
then
|
|
stop_script "chapter5/5.4-linux-headers.sh"
|
|
fi
|