1
0
mirror of https://github.com/krglaws/MyLFS.git synced 2025-07-26 15:46:59 +00:00

stage 3 working

This commit is contained in:
Kyle Glaws
2022-03-02 10:07:31 -05:00
parent 9da72b5f59
commit df7188bf21
16 changed files with 284 additions and 96 deletions

View File

@ -3,7 +3,9 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
set -e
source ./config.sh
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"
source $SCRIPT_DIR/config/global.sh
echo "Cleaning LFS image..."
@ -12,7 +14,6 @@ if [ -n "$(mount | grep $LFS)" ]
then
echo "Unmounting ${LFS}..."
umount $LFS
echo "Done."
fi
# detach loop device
@ -20,15 +21,16 @@ if [ -n "$(losetup | grep $LFS_IMG)" ]
then
echo "Detaching ${LFS_IMG}..."
losetup -d $(echo "$(losetup | grep $LFS_IMG)" | cut -d" " -f1)
echo "Done."
fi
# delete img
if [ -f $LFS_IMG ]
then
read -p "WARNING: This will delete ${LFS_IMG}. Continue? (Y/N): " CONFIRM
[[ $CONFIRM == [yY] || $CONFIRM == [yY][eE][sS] ]] || exit
echo "Deleting ${LFS_IMG}..."
rm $LFS_IMG
echo "Done."
fi
echo "Done."

18
config.sh → config/global.sh Executable file → Normal file
View File

@ -1,19 +1,29 @@
#!/usr/bin/bash
# LFS Build Configuration
# ~~~~~~~~~~~~~~~~~~~~~~~
# This file should be sourced by the other scripts
# that need these variables.
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
function get_script_dir {
SOURCE=$1
if [ -z "$SOURCE" ]
then
echo "ERROR: get_script_dir missing BASH_SOURCE parameter."
exit -1
fi
echo "$(cd -- "$(dirname -- "$SOURCE")" &> /dev/null && pwd)"
}
export -f get_script_dir
export PACKAGE_LIST=$(get_script_dir $BASH_SOURCE)/pkgs.sh
export LFS=/mnt/lfs
export LFS_TGT=$(uname -m)-lfs-linux-gnu
export LFS_FS=ext4
export LFS_IMG=$SCRIPT_DIR/lfs.img
export LFS_IMG=$(get_script_dir $BASH_SOURCE)/lfs.img
export LFS_IMG_SIZE=$((10*1024*1024*1024)) # 10 GiB
export LFS_USER=lfs
KEYS="LFS LFS_TGT LFS_FS LFS_IMG LFS_IMG_SIZE LFS_USER"
for KEY in $KEYS

87
config/pkgs.sh Normal file
View File

@ -0,0 +1,87 @@
PKG_ACL=https://download.savannah.gnu.org/releases/acl/acl-2.3.1.tar.xz
PKG_ATTR=https://download.savannah.gnu.org/releases/attr/attr-2.5.1.tar.gz
PKG_AUTOCONF=https://ftp.gnu.org/gnu/autoconf/autoconf-2.71.tar.xz
PKG_AUTOMAKE=https://ftp.gnu.org/gnu/automake/automake-1.16.5.tar.xz
PKG_BASH=https://ftp.gnu.org/gnu/bash/bash-5.1.16.tar.gz
PKG_BC=https://github.com/gavinhoward/bc/releases/download/5.2.2/bc-5.2.2.tar.xz
PKG_BINUTILS=https://ftp.gnu.org/gnu/binutils/binutils-2.38.tar.xz
PKG_BISON=https://ftp.gnu.org/gnu/bison/bison-3.8.2.tar.xz
PKG_BZIP2=https://www.sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz
PKG_CHECK=https://github.com/libcheck/check/releases/download/0.15.2/check-0.15.2.tar.gz
PKG_COREUTILS=https://ftp.gnu.org/gnu/coreutils/coreutils-9.0.tar.xz
PKG_DEJAGNU=https://ftp.gnu.org/gnu/dejagnu/dejagnu-1.6.3.tar.gz
PKG_DIFFUTILS=https://ftp.gnu.org/gnu/diffutils/diffutils-3.8.tar.xz
PKG_E2FSPROGS=https://downloads.sourceforge.net/project/e2fsprogs/e2fsprogs/v1.46.5/e2fsprogs-1.46.5.tar.gz
PKG_ELFUTILS=https://sourceware.org/ftp/elfutils/0.186/elfutils-0.186.tar.bz2
PKG_EUDEV=https://github.com/eudev-project/eudev/releases/download/v3.2.11/eudev-3.2.11.tar.gz
PKG_EXPAT=https://prdownloads.sourceforge.net/expat/expat-2.4.6.tar.xz
PKG_EXPECT5=https://prdownloads.sourceforge.net/expect/expect5.45.4.tar.gz
PKG_FILE=https://astron.com/pub/file/file-5.41.tar.gz
PKG_FINDUTILS=https://ftp.gnu.org/gnu/findutils/findutils-4.9.0.tar.xz
PKG_FLEX=https://github.com/westes/flex/releases/download/v2.6.4/flex-2.6.4.tar.gz
PKG_GAWK=https://ftp.gnu.org/gnu/gawk/gawk-5.1.1.tar.xz
PKG_GCC=https://ftp.gnu.org/gnu/gcc/gcc-11.2.0/gcc-11.2.0.tar.xz
PKG_GDBM=https://ftp.gnu.org/gnu/gdbm/gdbm-1.23.tar.gz
PKG_GETTEXT=https://ftp.gnu.org/gnu/gettext/gettext-0.21.tar.xz
PKG_GLIBC=https://ftp.gnu.org/gnu/glibc/glibc-2.35.tar.xz
PKG_GMP=https://ftp.gnu.org/gnu/gmp/gmp-6.2.1.tar.xz
PKG_GPERF=https://ftp.gnu.org/gnu/gperf/gperf-3.1.tar.gz
PKG_GREP=https://ftp.gnu.org/gnu/grep/grep-3.7.tar.xz
PKG_GROFF=https://ftp.gnu.org/gnu/groff/groff-1.22.4.tar.gz
PKG_GRUB=https://ftp.gnu.org/gnu/grub/grub-2.06.tar.xz
PKG_GZIP=https://ftp.gnu.org/gnu/gzip/gzip-1.11.tar.xz
PKG_IANAETC=https://github.com/Mic92/iana-etc/releases/download/20220207/iana-etc-20220207.tar.gz
PKG_INETUTILS=https://ftp.gnu.org/gnu/inetutils/inetutils-2.2.tar.xz
PKG_INTLTOOL=https://launchpad.net/intltool/trunk/0.51.0/+download/intltool-0.51.0.tar.gz
PKG_IPROUTE2=https://www.kernel.org/pub/linux/utils/net/iproute2/iproute2-5.16.0.tar.xz
PKG_KBD=https://www.kernel.org/pub/linux/utils/kbd/kbd-2.4.0.tar.xz
PKG_KMOD=https://www.kernel.org/pub/linux/utils/kernel/kmod/kmod-29.tar.xz
PKG_LESS=https://www.greenwoodsoftware.com/less/less-590.tar.gz
PKG_LFSBOOTSCRIPTS=https://www.linuxfromscratch.org/lfs/downloads/11.1/lfs-bootscripts-20210608.tar.xz
PKG_LIBCAP2=https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.63.tar.xz
PKG_LIBFFI=https://github.com/libffi/libffi/releases/download/v3.4.2/libffi-3.4.2.tar.gz
PKG_LIBPIPELINE=https://download.savannah.gnu.org/releases/libpipeline/libpipeline-1.5.5.tar.gz
PKG_LIBTOOL=https://ftp.gnu.org/gnu/libtool/libtool-2.4.6.tar.xz
PKG_LINUX=https://www.kernel.org/pub/linux/kernel/v5.x/linux-5.16.9.tar.xz
PKG_M4=https://ftp.gnu.org/gnu/m4/m4-1.4.19.tar.xz
PKG_MAKE=https://ftp.gnu.org/gnu/make/make-4.3.tar.gz
PKG_MANDB=https://download.savannah.gnu.org/releases/man-db/man-db-2.10.1.tar.xz
PKG_MANPAGES=https://www.kernel.org/pub/linux/docs/man-pages/man-pages-5.13.tar.xz
PKG_MESON=https://github.com/mesonbuild/meson/releases/download/0.61.1/meson-0.61.1.tar.gz
PKG_MPC=https://ftp.gnu.org/gnu/mpc/mpc-1.2.1.tar.gz
PKG_MPFR=https://www.mpfr.org/mpfr-4.1.0/mpfr-4.1.0.tar.xz
PKG_NCURSES=https://invisible-mirror.net/archives/ncurses/ncurses-6.3.tar.gz
PKG_NINJA=https://github.com/ninja-build/ninja/archive/v1.10.2/ninja-1.10.2.tar.gz
PKG_OPENSSL=https://www.openssl.org/source/openssl-3.0.1.tar.gz
PKG_PATCH=https://ftp.gnu.org/gnu/patch/patch-2.7.6.tar.xz
PKG_PERL=https://www.cpan.org/src/5.0/perl-5.34.0.tar.xz
PKG_PKGCONFIG=https://pkg-config.freedesktop.org/releases/pkg-config-0.29.2.tar.gz
PKG_PROCPS=https://sourceforge.net/projects/procps-ng/files/Production/procps-ng-3.3.17.tar.xz
PKG_PSMISC=https://sourceforge.net/projects/psmisc/files/psmisc/psmisc-23.4.tar.xz
PKG_PYTHON3=https://www.python.org/ftp/python/3.10.2/Python-3.10.2.tar.xz
PKG_PYTHON3DOCS=https://www.python.org/ftp/python/doc/3.10.2/python-3.10.2-docs-html.tar.bz2
PKG_READLINE=https://ftp.gnu.org/gnu/readline/readline-8.1.2.tar.gz
PKG_SED=https://ftp.gnu.org/gnu/sed/sed-4.8.tar.xz
PKG_SHADOW=https://github.com/shadow-maint/shadow/releases/download/v4.11.1/shadow-4.11.1.tar.xz
PKG_SYSKLOGD=https://www.infodrom.org/projects/sysklogd/download/sysklogd-1.5.1.tar.gz
PKG_SYSVINIT=https://download.savannah.gnu.org/releases/sysvinit/sysvinit-3.01.tar.xz
PKG_TAR=https://ftp.gnu.org/gnu/tar/tar-1.34.tar.xz
PKG_TCL=https://downloads.sourceforge.net/tcl/tcl8.6.12-src.tar.gz
PKG_TCLDOCS=https://downloads.sourceforge.net/tcl/tcl8.6.12-html.tar.gz
PKG_TEXINFO=https://ftp.gnu.org/gnu/texinfo/texinfo-6.8.tar.xz
PKG_TZDATA=https://www.iana.org/time-zones/repository/releases/tzdata2021e.tar.gz
PKG_UDEVLFS=https://anduin.linuxfromscratch.org/LFS/udev-lfs-20171102.tar.xz
PKG_UTILLINUX=https://www.kernel.org/pub/linux/utils/util-linux/v2.37/util-linux-2.37.4.tar.xz
PKG_VIM=https://anduin.linuxfromscratch.org/LFS/vim-8.2.4383.tar.gz
PKG_XMLPARSER=https://cpan.metacpan.org/authors/id/T/TO/TODDR/XML-Parser-2.46.tar.gz
PKG_XZ=https://tukaani.org/xz/xz-5.2.5.tar.xz
PKG_ZLIB=https://zlib.net/zlib-1.2.11.tar.xz
PKG_ZSTD=https://github.com/facebook/zstd/releases/download/v1.5.2/zstd-1.5.2.tar.gz
PATCH_BINUTILS=https://www.linuxfromscratch.org/patches/lfs/11.1/binutils-2.38-lto_fix-1.patch
PATCH_BZIP2=https://www.linuxfromscratch.org/patches/lfs/11.1/bzip2-1.0.8-install_docs-1.patch
PATCH_COREUTILS=https://www.linuxfromscratch.org/patches/lfs/11.1/coreutils-9.0-i18n-1.patch
PATCH_COREUTILS_CHMOD=https://www.linuxfromscratch.org/patches/lfs/11.1/coreutils-9.0-chmod_fix-1.patch
PATCH_GLIBC=https://www.linuxfromscratch.org/patches/lfs/11.1/glibc-2.35-fhs-1.patch
PATCH_KBD=https://www.linuxfromscratch.org/patches/lfs/11.1/kbd-2.4.0-backspace-1.patch
PATCH_PERL=https://www.linuxfromscratch.org/patches/lfs/11.1/perl-5.34.0-upstream_fixes-1.patch
PATCH_SYSVINIT=https://www.linuxfromscratch.org/patches/lfs/11.1/sysvinit-3.01-consolidated-1.patch

0
user_config.sh → config/user.sh Executable file → Normal file
View File

29
main.sh
View File

@ -1,4 +1,7 @@
#!/usr/bin/bash
# main.sh
# ~~~~~~~
# This is the main entry point for this project.
set -e
if [ "$UID" != "0" ]
@ -7,22 +10,32 @@ then
exit -1
fi
source ./config.sh
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source $SCRIPT_DIR/config/global.sh
echo "Starting Stage 1..."
stage1/main.sh
if ! $SCRIPT_DIR/stage1/main.sh
then
echo "Stage 1 failed."
exit -1
fi
echo "Completed Stage 1."
echo "Starting Stage 2..."
stage2/main.sh
if ! $SCRIPT_DIR/stage2/main.sh
then
echo "Stage 2 failed."
exit -1
fi
echo "Completed Stage 2."
echo "Starting Stage 3..."
set -x
su $LFS_USER --shell=/usr/bin/bash --command\
"source $SCRIPT_DIR/config.sh && source $SCRIPT_DIR/user_config.sh && $SCRIPT_DIR/stage3/main.sh"
set +x
if ! su $LFS_USER --shell=/usr/bin/bash --command\
"source $SCRIPT_DIR/config/global.sh && source $SCRIPT_DIR/config/user.sh && $SCRIPT_DIR/stage3/main.sh"
then
echo "Stage 3 failed."
exit -1
fi
echo "Completed Stage 3."

View File

@ -1,15 +1,7 @@
#!/usr/bin/bash
#!/usr/bin/env bash
# Script to create OS image file
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# This script might be considered a little bit
# dangerous since it needs to be run as root,
# and involves partitioning, creating new filesystems,
# mounting, etc. I tried to make it somewhat safer
# by operating only image files that are mounted as
# loop devices. So ideally, it won't touch any actual
# block devices.
set -e # exit if any command fails
set -e
# create image file
echo -n "Creating disk image... "
@ -69,3 +61,4 @@ then
fi
mount $LOOP_P2 $LFS
echo "done."

View File

@ -1,10 +1,6 @@
#!/usr/bin/bash
#!/usr/bin/env bash
# Script to check build dependencies
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# This is likely to break on many machines.
# If it does, just manually check that you have
# the right dependencies and versions according
# to the listing in LFS 11.0, Chapter 2.2.
EXIT_STATUS=0

View File

@ -1,4 +1,6 @@
#!/usr/bin/bash
#!/usr/bin/env bash
# Stage 1
# ~~~~~~~
set -e
if [ "$UID" != "0" ]
@ -13,13 +15,13 @@ then
exit -1
fi
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
SCRIPT_DIR=$(get_script_dir $BASH_SOURCE)
echo "Checking dependency versions..."
$SCRIPT_DIR/check_dep_versions.sh
echo "Done."
echo "Finished checking dependencies."
echo "Building image..."
$SCRIPT_DIR/build_img.sh
echo "Done."
echo "Finished building image."

View File

@ -1,4 +1,6 @@
#!/usr/bin/bash
#!/usr/bin/env bash
# Stage 2
# ~~~~~~~
set -e
if [ "$UID" != "0" ]

View File

@ -1,25 +1,40 @@
#/usr/bin/env bash
set -ex
#!/usr/bin/env bash
# Binutils pass 1
# ~~~~~~~~~~~~~~~
set -e
cd $LFS/sources
# Binutils-2.37 pass 1
tar -xf binutils-2.37.tar.xz
cd binutils-2.37
patch -p1 < ../binutils-2.37-upstream_fix-1.patch
eval "$(grep "PKG_BINUTILS\|PATCH_BINUTILS" $PACKAGE_LIST)"
curl -LO $PKG_BINUTILS -LO $PATCH_BINUTILS
PKG_BINUTILS=$(basename $PKG_BINUTILS)
PATCH_BINUTILS=$(basename $PATCH_BINUTILS)
tar -xf $PKG_BINUTILS
cd ${PKG_BINUTILS%.tar*}
patch -p1 < ../$PATCH_BINUTILS
mkdir -v build
cd build
../configure \
--prefix=$LFS/tools \
--with-sysroot=$LFS \
--target=$LFS_TGT \
--disable-nls \
--disable-werror
D1=$(date +%s)
make
../configure \
--prefix=$LFS/tools \
--with-sysroot=$LFS \
--target=$LFS_TGT \
--disable-nls \
--disable-werror
# use one thread to ensure consistent SBU calculation
make -j1
make install -j1
D2=$(date +%s)
echo "1 SBU == $((D2-D1)) seconds."
cd $LFS/sources
rm -rf binutils-2.37
rm -rf ${PKG_BINUTILS%.tar*} $PKG_BINUTILS $PATCH_BINUTILS

View File

@ -1,17 +1,30 @@
#/usr/bin/env bash
set -ex
# GCC pass 1
# ~~~~~~~~~~
set -e
cd $LFS/sources
# GCC-11.2.0 pass 1
tar -xf gcc-11.2.0.tar.xz
cd gcc-11.2.0
tar -xf ../mpfr-4.1.0.tar.xz
mv -fv mpfr-4.1.0 mpfr
tar -xf ../gmp-6.2.1.tar.xz
mv -fv gmp-6.2.1 gmp
tar -xf ../mpc-1.2.1.tar.gz
mv mpc-1.2.1 mpc
eval "$(grep "PKG_GCC\|PKG_MPFR\|PKG_GMP\|PKG_MPC" $PACKAGE_LIST)"
curl -LO $PKG_GCC -LO $PKG_MPFR -LO $PKG_GMP -LO $PKG_MPC
PKG_GCC=$(basename $PKG_GCC)
PKG_MPFR=$(basename $PKG_MPFR)
PKG_GMP=$(basename $PKG_GMP)
PKG_MPC=$(basename $PKG_MPC)
tar -xf $PKG_GCC
cd ${PKG_GCC%.tar*}
tar -xf ../$PKG_MPFR
mv ${PKG_MPFR%.tar*} mpfr
tar -xf ../$PKG_GMP
mv ${PKG_GMP%.tar*} gmp
tar -xf ../$PKG_MPC
mv ${PKG_MPC%.tar*} mpc
case $(uname -m) in
x86_64)
sed -e '/m64=/s/lib64/lib/' -i.orig gcc/config/i386/t-linux64
@ -24,7 +37,7 @@ cd build
../configure \
--target=$LFS_TGT \
--prefix=$LFS/tools \
--with-glibc-version=2.11 \
--with-glibc-version=2.35 \
--with-sysroot=$LFS \
--with-newlib \
--without-headers \
@ -50,4 +63,5 @@ cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
`dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/install-tools/include/limits.h
cd $LFS/sources
rm -rf gcc-11.2.0
rm -rf ${PKG_GCC%.tar*} $PKG_GCC $PKG_MPFR $PKG_MPC $PKG_GMP

View File

@ -1,25 +1,32 @@
#/usr/bin/env bash
set -ex
#!/usr/bin/env bash
# Glibc pass 1
# ~~~~~~~~~~~~
set -e
cd $LFS/sources
# glibc
tar -xf glibc-2.34.tar.xz
cd glibc-2.34
eval "$(grep "PKG_GLIBC\|PATCH_GLIBC" $PACKAGE_LIST)"
curl -LO $PKG_GLIBC -LO $PATCH_GLIBC
PKG_GLIBC=$(basename $PKG_GLIBC)
PATCH_GLIBC=$(basename $PATCH_GLIBC)
tar -xf $PKG_GLIBC
cd ${PKG_GLIBC%.tar*}
case $(uname -m) in
i?86)
ln -sfv ld-linux.so.2 $LFS/lib/ld-lsb.so.3
ln -sfv ld-linux.so.2 $LFS/lib/ld-lsb.so.3
;;
x86_64)
ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64
ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64/ld-lsb-x86-64.so.3
ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64
ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64/ld-lsb-x86-64.so.3
;;
esac
patch -Np1 -i ../glibc-2.34-fhs-1.patch
patch -Np1 -i ../$PATCH_GLIBC
mkdir -v build
mkdir build
cd build
echo "rootsbindir=/usr/sbin" > configparms
@ -41,10 +48,18 @@ sed '/RTLDLIST=/s@/usr@@g' -i $LFS/usr/bin/ldd
echo 'int main(){}' > dummy.c
$LFS_TGT-gcc dummy.c
OUTPUT=$(readelf -l a.out | grep '/ld-linux')
[ "$OUTPUT" != '[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]' ]
rm -v dummy.c a.out
EXPECTED='[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]'
if [[ "$OUTPUT" != *"${EXPECTED}"* ]]
then
echo "ERROR: OUTPUT does not contain expected value.\n" \
"OUTPUT=$OUTPUT\n" \
"EXPECTED=$EXPECTED"
exit -1
fi
rm dummy.c a.out
$LFS/tools/libexec/gcc/$LFS_TGT/11.2.0/install-tools/mkheaders
cd $LFS/sources
rm -rf glibc-2.34
rm -rf ${PKG_GLIBC%.tar*} $PKG_GLIBC $PATCH_GLIBC

View File

@ -1,13 +1,19 @@
#/usr/bin/env bash
set -ex
#!/usr/bin/env bash
# Libstdc++ pass 1
# ~~~~~~~~~~~~~~~~
set -e
cd $LFS/sources
# libstdc++
tar -xf gcc-11.2.0.tar.xz
cd gcc-11.2.0
eval "$(grep PKG_GCC $PACKAGE_LIST)"
curl -LO $PKG_GCC
mkdir -v build
PKG_GCC=$(basename $PKG_GCC)
tar -xf $PKG_GCC
cd ${PKG_GCC%.tar**}
mkdir build
cd build
../libstdc++-v3/configure \
@ -23,4 +29,5 @@ make
make DESTDIR=$LFS install
cd $LFS/sources
rm -rf gcc-11.2.0
rm -rf ${PKG_GCC%.tar*} $PKG_GCC

View File

@ -1,16 +1,25 @@
#!/usr/bin/env bash
set -ex
# Linux API headers
# ~~~~~~~~~~~~~~~~~
set -e
cd $LFS/sources
# linux api headers
tar -xf linux-5.13.12.tar.xz
cd linux-5.13.12
eval "$(grep PKG_LINUX $PACKAGE_LIST)"
curl -LO $PKG_LINUX
PKG_LINUX=$(basename $PKG_LINUX)
tar -xf $PKG_LINUX
cd ${PKG_LINUX%.tar*}
make mrproper
make headers
find usr/include -name '.*' -delete
rm usr/include/Makefile
cp -rv usr/include $LFS/usr
cd $LFS/sources
rm -rf linux-5.13.12
rm -rf ${PKG_LINUX%.tar*} $PKG_LINUX

View File

@ -1,7 +1,9 @@
#/usr/bin/env bash
#!/usr/bin/env bash
# Stage 3
# ~~~~~~~
set -e
if [ -z "$LFS_USER" -o -z "$LFS_USER" ]
if [ -z "$LFS" -o -z "$LFS_USER" ]
then
echo "ERROR: Missing config vars. Be sure to source config.sh before running this script."
exit -1
@ -13,13 +15,24 @@ then
exit -1
fi
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
function build_package {
PACKAGE_NAME=$1
BUILD_SCRIPT=$2
BUILD_LOG=$3
$SCRIPT_DIR/binutils.sh
$SCRIPT_DIR/gcc.sh
$SCRIPT_DIR/linux_headers.sh
$SCRIPT_DIR/glibc.sh
$SCRIPT_DIR/libstdcpp.sh
echo -n "Building ${PACKAGE_NAME}... "
if ! { $BUILD_SCRIPT &> $BUILD_LOG && rm $BUILD_LOG && echo "done."; }
then
echo "failed. Check $BUILD_LOG for more information."
exit -1
fi
}
echo "Done."
SCRIPT_DIR=$(get_script_dir $BASH_SOURCE)
build_package "Binutils pass 1" $SCRIPT_DIR/binutils.sh $LFS/sources/binutils_pass1.log
build_package "GCC pass 1" $SCRIPT_DIR/gcc.sh $LFS/sources/gcc_pass1.log
build_package "Linux headers" $SCRIPT_DIR/linux_headers.sh $LFS/sources/linux_headers.log
build_package "Glibc pass1" $SCRIPT_DIR/glibc.sh $LFS/sources/glibc_pass1.log
build_package "libstdcpp" $SCRIPT_DIR/libstdcpp.sh $LFS/sources/libstdcpp.log

10
test.sh Executable file
View File

@ -0,0 +1,10 @@
#!/usr/bin/bash
EXPECTED='[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]'
OUTPUT=" $EXPECTED "
if [[ "$OUTPUT" == *"${EXPECTED}"* ]]
then
echo all good
else
echo shit
fi