diff options
-rw-r--r-- | chapter7/backup.sh | 24 | ||||
-rw-r--r-- | chapter7/bison.sh | 5 | ||||
-rw-r--r-- | chapter7/cleanup.sh | 23 | ||||
-rw-r--r-- | chapter7/gettext.sh | 7 | ||||
-rw-r--r-- | chapter7/libstdc++.sh | 14 | ||||
-rw-r--r-- | chapter7/perl.sh | 15 | ||||
-rw-r--r-- | chapter7/python.sh | 7 | ||||
-rw-r--r-- | chapter7/texinfo.sh | 5 | ||||
-rw-r--r-- | chapter7/util-linux.sh | 17 | ||||
-rw-r--r-- | insidechroot.sh | 15 | ||||
-rwxr-xr-x | lfs.sh | 37 |
11 files changed, 169 insertions, 0 deletions
diff --git a/chapter7/backup.sh b/chapter7/backup.sh new file mode 100644 index 0000000..2aac08e --- /dev/null +++ b/chapter7/backup.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +file="${LFS_VER}-ch7-backup.tar.xz" +directories=(bin dev etc lib lib64 proc run sbin sys tools usr var) + +if [ -f "${LFS}/sources/chapter7/backup" ]; then + echo -e " ${IGRN}Backup found. Remove manually to backup again.${RST}" +else + + echo -ne "${GRN}Backing up ${YLW}${LFS}${GRN} to ${YLW}${file}${RST}... " + pushd "${LFS}" > /dev/null || exit 1 + sudo XZ_OPTS="-T${NUMPROCS} -e" tar cJpf "${HOME}"/"${file}" "${directories[@]}" >/dev/null 2>&1 & pid=$! + spinner "$pid" "${SPINNER}" + retval=$? + if [ "${retval}" -ne 0 ]; then + echo -e "${IRED}FAILED!${RST}\n" + exit "${retval}" + else + echo -e "${IGRN}OK${RST}\n" + fi + popd > /dev/null || exit 1 + + touch "${LFS}/sources/chapter7/backup" +fi diff --git a/chapter7/bison.sh b/chapter7/bison.sh new file mode 100644 index 0000000..2385d22 --- /dev/null +++ b/chapter7/bison.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +./configure --prefix=/usr --docdir=/usr/share/doc/bison-"${VERSION}" && +make && +make -j1 install diff --git a/chapter7/cleanup.sh b/chapter7/cleanup.sh new file mode 100644 index 0000000..60a934f --- /dev/null +++ b/chapter7/cleanup.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +if [ -f "${LFS}/sources/chapter7/cleanup" ]; then + echo -e " ${IGRN}Cleanup already performed.${RST}" +else + + echo -ne "${GRN}Cleaning up ${YLW}${LFS}${RST}... " + + sudo find "${LFS}"/usr/lib -name \*.la -delete >/dev/null 2>&1 + sudo find "${LFS}"/usr/libexec -name \*.la -delete >/dev/null 2>&1 + + sudo rm -rf "${LFS}"/usr/share/doc >/dev/null 2>&1 + sudo rm -rf "${LFS}"/usr/share/info >/dev/null 2>&1 + sudo rm -rf "${LFS}"/usr/share/man >/dev/null 2>&1 + + sudo strip --strip-debug "${LFS}"/usr/lib/* >/dev/null 2>&1 + sudo strip --strip-unneeded "${LFS}"/usr/bin/* >/dev/null 2>&1 + sudo strip --strip-unneeded "${LFS}"/usr/sbin/* >/dev/null 2>&1 + sudo strip --strip-unneeded "${LFS}"/tools/bin/* >/dev/null 2>&1 + + echo -e "${IGRN}OK${RST}\n" + touch "${LFS}"/sources/chapter7/cleanup >/dev/null 2>&1 +fi diff --git a/chapter7/gettext.sh b/chapter7/gettext.sh new file mode 100644 index 0000000..49fbf15 --- /dev/null +++ b/chapter7/gettext.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +./configure --disable-shared +make && +cp -v gettext-tools/src/msgfmt /usr/bin +cp -v gettext-tools/src/msgmerge /usr/bin +cp -v gettext-tools/src/xgettext /usr/bin diff --git a/chapter7/libstdc++.sh b/chapter7/libstdc++.sh new file mode 100644 index 0000000..c2ef63b --- /dev/null +++ b/chapter7/libstdc++.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +ln -s gthr-posix.h libgcc/gthr-default.h +mkdir build +cd build || exit 1 +../libstdc++-v3/configure \ + CXXFLAGS="-g -O2 -D_GNU_SOURCE" \ + --prefix=/usr \ + --disable-multilib \ + --disable-nls \ + --host="$(uname -m)"-lfs-linux-gnu \ + --disable-libstdcxx-pch && +make && +make -j1 install diff --git a/chapter7/perl.sh b/chapter7/perl.sh new file mode 100644 index 0000000..970e17c --- /dev/null +++ b/chapter7/perl.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +MAJMIN="$(cut -d\. -f1,2 <<< "${VERSION}")" + +sh Configure -des \ + -Dprefix=/usr \ + -Dvendorprefix=/usr \ + -Dprivlib=/usr/lib/perl5/"${MAJMIN}"/core_perl \ + -Darchlib=/usr/lib/perl5/"${MAJMIN}"/core_perl \ + -Dsitelib=/usr/lib/perl5/"${MAJMIN}"/site_perl \ + -Dsitearch=/usr/lib/perl5/"${MAJMIN}"/site_perl \ + -Dvendorlib=/usr/lib/perl5/"${MAJMIN}"/vendor_perl \ + -Dvendorarch=/usr/lib/perl5/"${MAJMIN}"/vendor_perl && +make && +make -j1 install diff --git a/chapter7/python.sh b/chapter7/python.sh new file mode 100644 index 0000000..daf1677 --- /dev/null +++ b/chapter7/python.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +./configure --prefix=/usr \ + --enable-shared \ + --without-ensurepip && +make && +make -j1 install diff --git a/chapter7/texinfo.sh b/chapter7/texinfo.sh new file mode 100644 index 0000000..1935156 --- /dev/null +++ b/chapter7/texinfo.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +./configure --prefix=/usr && +make && +make -j1 install diff --git a/chapter7/util-linux.sh b/chapter7/util-linux.sh new file mode 100644 index 0000000..7a00c8c --- /dev/null +++ b/chapter7/util-linux.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +mkdir -p /var/lib/hwclock && +./configure ADJTIME_PATH=/var/lib/hwclock/adjtime \ + --docdir=/usr/share/doc/util-linux-"${VERSION}" \ + --disable-chfn-chsh \ + --disable-login \ + --disable-nologin \ + --disable-su \ + --disable-setpriv \ + --disable-runuser \ + --disable-pylibmount \ + --disable-static \ + --without-python \ + runstatedir=/run && +make && +make -j1 install diff --git a/insidechroot.sh b/insidechroot.sh index b4a743a..486c252 100644 --- a/insidechroot.sh +++ b/insidechroot.sh @@ -149,4 +149,19 @@ EOF cd /sources || exit 1 + # Chapter 7 + printf "%b" "\n${IWHT}============ ${IGRN}Building ${IYLW}Chapter 7${IWHT} \ +============${RST}\n" + + for package in libstdc++ gettext bison perl python texinfo util-linux; do + source packageinstall.sh 7 $package + retval=$? + if [[ "${retval}" -ne 0 ]]; then + exit 1 + fi + done + + exit 7 +else + printf "%b" "Do Chapter 8, 9 and 10 stuff here.\n" fi @@ -154,7 +154,44 @@ sudo chroot "${LFS}" /usr/bin/env \ PATH=/bin:/usr/bin:/sbin:/usr/sbin \ NUMPROCS="${NUMPROCS}" \ MAKEFLAGS="${MAKEFLAGS}" \ + SPINNER="${SPINNER}" \ TESTERUID="$(id -u)" \ /bin/bash --login +h -c "/sources/insidechroot.sh 7" +retval=$? + +printf "%b" "\n${CYN}EXITED ${RED}CHROOT${RST} ENVIRONMENT...${RST}\n" +# Cleanup and Backup if chapter 7 successfully finished +if [[ "$retval" -eq 7 ]]; then + printf "%b" "${GRN}Unmounting Virtual Kernel Filesystems...\n" + sudo umount "${LFS}"/dev/pts + sudo umount "${LFS}"/dev/ + sudo umount "${LFS}"/run + sudo umount "${LFS}"/sys + sudo umount "${LFS}"/proc + + printf "%b" "\n${YLW}Chapter 7 ${GRN}cleanup and backup${RST}\n" + source "${LFS}"/sources/chapter7/cleanup.sh + source "${LFS}"/sources/chapter7/backup.sh +else + exit "$retval" +fi + +# Mount virtual kernel filesystems after cleanup and backup +source mountvirtfs.sh + +printf "%b" "\n${CYN}ENTERING ${RED}CHROOT${CYN} ENVIRONMENT...${RST}\n" +sleep 3 + +# Enter CHROOT for chapter 8, 9 and 10 +sudo chroot "${LFS}" /usr/bin/env \ + HOME=/root \ + TERM="${TERM}" \ + PS1='(lfs chroot) \u:\w\$ ' \ + PATH=/bin:/usr/bin:/sbin:/usr/sbin \ + NUMPROCS="${NUMPROCS}" \ + MAKEFLAGS="${MAKEFLAGS}" \ + SPINNER="${SPINNER}" \ + TESTERUID="$(id -u)" \ + /bin/bash --login +h -c "/sources/insidechroot.sh 8" printf "%b" "\n${CYN}EXITED ${RED}CHROOT${CYN} ENVIRONMENT${RST}...\n" |