#!/bin/bash source vars.sh echo "8.3 ""$MANPAGES""" tar xf "$MANPAGES".tar.xz && cd "$MANPAGES" && make prefix=/usr install && cd .. && rm -rf "$MANPAGES" && echo "Finished 8.3 ""$MANPAGES""" >> build.log && echo "$MANPAGES" >> /installed.txt echo "8.4 ""$IANAETC""" tar xz "$IANAETC".tar.gz && cd "$IANAETC" && cp services protocols /etc && cd .. && rm -rf "$IANAETC" && echo "Finished 8.4 ""$IANAETC""" >> build.log echo "$IANAETC" >> /installed.txt echo "8.5 ""$GLIBC""" tar xf "$GLIBC".tar.xz && cd "$GLIBC" && patch -Np1 -i ../glibc-2.37-fhs-1.patch && sed '/width -=/s/workend - string/number_length/' \ -i stdio-common/vfprintf-process-arg.c && mkdir -v build && cd build && echo "rootsbindir=/usr/sbin" > configparms && ../configure --prefix=/usr \ --disable-werror \ --enable-kernel=3.2 \ --enable-stack-protector=strong \ --with-headers=/usr/include \ libc_cv_slibdir=/usr/lib && make && make check | tee ../../check-log_"$GLIBC".log; touch /etc/ld.so.conf && sed '/test-installation/s@$(PERL)@echo not running@' -i ../Makefile && make install && sed '/RTLDLIST=/s@/usr@@g' -i /usr/bin/ldd && cp -v ../nscd/nscd.conf /etc/nscd.conf && mkdir -pv /var/cache/nscd && install -v -Dm644 ../nscd/nscd.tmpfiles /usr/lib/tmpfiles.d/nscd.conf && install -v -Dm644 ../nscd/nscd.service /usr/lib/systemd/system/nscd.service && make localedata/install-locales localedef -i POSIX -f UTF-8 C.UTF-8 2> /dev/null || true localedef -i ja_JP -f SHIFT_JIS ja_JP.SJIS 2> /dev/null || true cat > /etc/nsswitch.conf << "EOF" # Begin /etc/nsswitch.conf passwd: files group: files shadow: files hosts: files dns networks: files protocols: files services: files ethers: files rpc: files # End /etc/nsswitch.conf EOF tar -xf ../../tzdata2022g.tar.gz && ZONEINFO=/usr/share/zoneinfo && mkdir -pv $ZONEINFO/{posix,right} && for tz in etcetera southamerica northamerica europe africa antarctica \ asia australasia backward; do zic -L /dev/null -d $ZONEINFO ${tz} zic -L /dev/null -d $ZONEINFO/posix ${tz} zic -L leapseconds -d $ZONEINFO/right ${tz} done && cp -v zone.tab zone1970.tab iso3166.tab $ZONEINFO && zic -d $ZONEINFO -p America/New_York && unset ZONEINFO && ln -sfv /usr/share/zoneinfo/UTC /etc/localtime && cat > /etc/ld.so.conf << "EOF" # Begin /etc/ld.so.conf /usr/local/lib /opt/lib EOF cat >> /etc/ld.so.conf << "EOF" # Add an include directory include /etc/ld.so.conf.d/*.conf EOF mkdir -pv /etc/ld.so.conf.d && cd ../.. && rm -rf "$GLIBC" && echo "Finished 8.5 ""$GLIBC""" >> build.log && echo "$GLIBC" >> /installed.txt echo "8.6 ""$ZLIB""" tar xf "$ZLIB".tar.xz && cd "$ZLIB" && ./configure --prefix=/usr && make && make check | tee ../check-log_"$ZLIB".log; make install && rm -fv /usr/lib/libz.a && cd .. && rm -rf "$ZLIB" && echo "Finished 8.6 ""$ZLIB""" >> build.log && echo "$ZLIB" >> /installed.txt echo "8.7 ""$BZIP2""" tar xf "$BZIP2".tar.gz && cd "$BZIP2" && patch -Np1 -i ../bzip2-1.0.8-install_docs-1.patch && sed -i 's@\(ln -s -f \)$(PREFIX)/bin/@\1@' Makefile && sed -i "s@(PREFIX)/man@(PREFIX)/share/man@g" Makefile && make -f Makefile-libbz2_so && make clean && make && make PREFIX=/usr install && cp -av libbz2.so.* /usr/lib && ln -sv libbz2.so.1.0.8 /usr/lib/libbz2.so && cp -v bzip2-shared /usr/bin/bzip2 && for i in /usr/bin/{bzcat,bunzip2}; do ln -sfv bzip2 $i done && rm -fv /usr/lib/libbz2.a && cd .. && rm -rf "$BZIP2" && echo " Finished 8.7 ""$BZIP2""" >> build.log && echo "$BZIP2" >> /installed.txt echo "8.8 ""$XZ""" tar xf "$XZ".tar.xz && cd "$XZ" && ./configure --prefix=/usr \ --disable-static \ --docdir=/usr/share/doc/xz-5.4.1 && make && make check | tee ../check-log_"$XZ".log; make install && cd .. && rm -rf "XZ" && echo "Finished 8.8 ""$XZ""" >> build.log && echo "$XZ" >> /installed.txt echo "8.9 ""$ZSTD""" tar xf "$ZSTD".tar.gz && cd "$ZSTD" && make prefix=/usr && make check | tee ../check-log_"$ZSTD".log; make prefix=/usr install && rm -v /usr/lib/libzstd.a && cd .. && rm -rf "$ZSTD" && echo "Finished 8.9 ""$ZSTD""" >> build.log && echo "$ZSTD" >> /installed.txt echo "8.10 ""$FILE""" tar xf "$FILE".tar.gz && cd "$FILE" && ./configure --prefix=/usr && make && make check | tee ../check-log_"$FILE".log; make install && cd .. && rm -rf "$FILE" && echo "Finished 8.10 ""$FILE""" >> build.log && echo "$FILE" >> /installed.txt echo "8.11 ""$READLINE""" tar xf "$READLINE".tar.gz && cd "$READLINE" && sed -i '/MV.*old/d' Makefile.in && sed -i '/{OLDSUFF}/c:' support/shlib-install && patch -Np1 -i ../readline-8.2-upstream_fix-1.patch && ./configure --prefix=/usr \ --disable-static \ --with-curses \ --docdir=/usr/share/doc/readline-8.2 && make SHLIB_LIBS="-lncursesw" && make SHLIB_LIBS="-lncursesw" install && install -v -m644 doc/*.{ps,pdf,html,dvi} /usr/share/doc/readline-8.2 && cd .. && rm -rf "$READLINE" && echo "Finished 8.11 ""$READLINE""" >> build.log && echo "$READLINE" >> /installed.txt echo "8.12 ""$M4""" tar xf "$M4".tar.xz && cd "$M4" && ./configure --prefix=/usr && make && make check | tee ../check-log_"$M4".log; make install && cd .. && rm -rf "$M4" && echo "Finished 8.12 ""$M4""" >> build.log && echo "$M4" >> /installed.txt echo "8.13 ""$BC""" tar xf "$BC".tar.xz && cd "$BC" && CC=gcc ./configure --prefix=/usr -G -O3 -r && make && make test | tee ../check-log_"$BC".log; make install && cd .. && rm -rf "$BC" && echo "Finished 8.13 ""$BC""" >> build.log echo "$BC" >> /installed.txt echo "8.14 ""$FLEX""" tar xf "$FLEX".tar.gz && cd "$FLEX" && ./configure --prefix=/usr \ --docdir=/usr/share/doc/flex-2.6.4 \ --disable-static && make && make check | tee ../check-log_"$FLEX".log; make install && ln -sv flex /usr/bin/lex && cd .. && rm -rf "$FLEX" && echo "Finished 8.14 ""$FLEX""" >> build.log && echo "$FLEX" >> /installed.txt echo "8.15 ""$TCL""" tar xf "$TCL"-src.tar.gz && cd "$TCL" && SRCDIR=$(pwd) && cd unix && ./configure --prefix=/usr \ --mandir=/usr/share/man && make && sed -e "s|$SRCDIR/unix|/usr/lib|" \ -e "s|$SRCDIR|/usr/include|" \ -i tclConfig.sh && sed -e "s|$SRCDIR/unix/pkgs/tdbc1.1.5|/usr/lib/tdbc1.1.5|" \ -e "s|$SRCDIR/pkgs/tdbc1.1.5/generic|/usr/include|" \ -e "s|$SRCDIR/pkgs/tdbc1.1.5/library|/usr/lib/tcl8.6|" \ -e "s|$SRCDIR/pkgs/tdbc1.1.5|/usr/include|" \ -i pkgs/tdbc1.1.5/tdbcConfig.sh && sed -e "s|$SRCDIR/unix/pkgs/itcl4.2.3|/usr/lib/itcl4.2.3|" \ -e "s|$SRCDIR/pkgs/itcl4.2.3/generic|/usr/include|" \ -e "s|$SRCDIR/pkgs/itcl4.2.3|/usr/include|" \ -i pkgs/itcl4.2.3/itclConfig.sh && unset SRCDIR && make test | tee ../../check-log_"$TCL".log; make install && chmod -v u+w /usr/lib/libtcl8.6.so && make install-private-headers && ln -sfv tclsh8.6 /usr/bin/tclsh && mv /usr/share/man/man3/{Thread,Tcl_Thread}.3 && cd .. && tar -xf ../tcl8.6.13-html.tar.gz --strip-components=1 && mkdir -v -p /usr/share/doc/tcl-8.6.13 && cp -v -r ./html/* /usr/share/doc/tcl-8.6.13 && cd .. && rm -rf "$TCL" && echo "Finished 8.15 ""$TCL""" >> build.log && echo "$TCL" >> /installed.txt echo "8.16 ""$EXPECT""" tar xf "$EXPECT".tar.gz && cd "$EXPECT" && ./configure --prefix=/usr \ --with-tcl=/usr/lib \ --enable-shared \ --mandir=/usr/share/man \ --with-tclinclude=/usr/include && make && make test | tee ../check-log_"$EXPECT".log; make install && ln -svf expect5.45.4/libexpect5.45.4.so /usr/lib && cd .. && rm -rf "$EXPECT" && echo "Finished 8.16 ""$EXPECT""" >> build.log && echo "$EXPECT" >> /installed.txt echo "8.17 ""$DEJAGNU""" tar xf "$DEJAGNU".tar.gz && cd "$DEJAGNU" && mkdir -v build && cd build && ../configure --prefix=/usr && makeinfo --html --no-split -o doc/dejagnu.html ../doc/dejagnu.texi && makeinfo --plaintext -o doc/dejagnu.txt ../doc/dejagnu.texi && make install && install -v -dm755 /usr/share/doc/dejagnu-1.6.3 && install -v -m644 doc/dejagnu.{html,txt} /usr/share/doc/dejagnu-1.6.3 && make check | tee ../../check-log_"$DEJAGNU".log; cd .. && rm -rf "$DEJAGNU" && echo "Finished 8.17 ""$DEJAGNU""" >> build.log && echo "$DEJAGNU" >> /installed.txt echo "8.18 ""$BINUTILS""" tar xf "$BINUTILS".tar.xz && cd "$BINUTILS" && echo "Verify that the PTYs are working properly inside the chroot environment" echo "The output should be: spawn ls" expect -c "spawn ls" sleep 5; mkdir -v build && cd build && ../configure --prefix=/usr \ --sysconfdir=/etc \ --enable-gold \ --enable-ld=default \ --enable-plugins \ --enable-shared \ --disable-werror \ --enable-64-bit-bfd \ --with-system-zlib && make tooldir=/usr && make -k check | tee ../../check-log_"$BINUTILS".log; grep '^FAIL:' $(find -name '*.log') && make tooldir=/usr install && rm -fv /usr/lib/lib{bfd,ctf,ctf-nobfd,sframe,opcodes}.a && rm -fv /usr/share/man/man1/{gprofng,gp-*}.1 && cd ../.. && rm -rf "$BINUTILS" && echo "Finished 8.18 ""$BINUTILS""" >> build.log && echo "$BINUTILS" >> /installed.txt echo "8.19 ""$GMP""" tar xf "$GMP".tar.xz && cd "$GMP" && ./configure --prefix=/usr \ --enable-cxx \ --disable-static \ --docdir=/usr/share/doc/gmp-6.2.1 && make && make html && make check 2>&1 | tee gmp-check-log; awk '/# PASS:/{total+=$3} ; END{print total}' gmp-check-log && cp gmp-check-log ../check-log_"$GMP".log && make install && make install-html && cd .. && rm -rf "$GMP" && echo "Finished 8.19 ""$GMP""" >> build.txt && echo "$GMP" >> /installed.txt echo "8.20 ""$MPFR""" tar xf "$MPFR".tar.xz && cd "$MPFR" && sed -e 's/+01,234,567/+1,234,567 /' \ -e 's/13.10Pd/13Pd/' \ -i tests/tsprintf.c && ./configure --prefix=/usr \ --disable-static \ --enable-thread-safe \ --docdir=/usr/share/doc/mpfr-4.2.0 && make && make html && make check | tee ../check-log_"$MPFR".log; make install && make install-html && cd .. && rm -rf "$MPFR" && echo "Finished 8.20 ""$MPFR""" >> build.log && echo "$MPFR" >> /installed.txt echo "8.21 ""$MPC""" tar xf "$MPC".tar,gz && cd "$MPC" && ./configure --prefix=/usr \ --disable-static \ --docdir=/usr/share/doc/mpc-1.3.1 && make && make html && make check | tee ../check-log_"$MPC".log; make install && make install-html && cd .. && rm -rf "$MPC" && echo "Finished 8.21 ""$MPC""" >> build.log && echo "$MPC" >> /installed.txt echo "8.22 ""$ATTR""" tar xf "$ATTR".tar.gz && cd "$ATTR" && ./configure --prefix=/usr \ --disable-static \ --sysconfdir=/etc \ --docdir=/usr/share/doc/attr-2.5.1 && make && make check | tee ../check-log_"$ATTR".log; make install && cd .. && rm -rf "$ATTR" && echo "Finished 8.22 ""$ATTR""" >> build.log && echo "$ATTR" >> /installed.txt echo "8.23 ""$ACL""" tar xf "$ACL".tar.xz && cd "$ACL" && ./configure --prefix=/usr \ --disable-static \ --docdir=/usr/share/doc/acl-2.3.1 && make && make install && cd .. && rm -rf "$ACL" && echo "Finished 8.23 ""$ACL""" >> build.log && echo "$ACL" >> /installed.txt echo "8.24 ""$LIBCAP""" tar xf "$LIBCAP".tar.xz && cd "$LIBCAP" && sed -i '/install -m.*STA/d' libcap/Makefile && make prefix=/usr lib=lib && make test | tee ../check-log_"$LIBCAP".log; make prefix=/usr lib=lib install && cd .. && rm -rf "$LIBCAP" && echo "Finished 8.24 ""$LIBCAP""" >> build.log && echo "$LIBCAP" >> /installed.txt echo "8.25 ""$SHADOW""" tar xf "$SHADOW".tar.xz && cd "$SHADOW" && sed -i 's/groups$(EXEEXT) //' src/Makefile.in && find man -name Makefile.in -exec sed -i 's/groups\.1 / /' {} \; find man -name Makefile.in -exec sed -i 's/getspnam\.3 / /' {} \; find man -name Makefile.in -exec sed -i 's/passwd\.5 / /' {} \; sed -e 's:#ENCRYPT_METHOD DES:ENCRYPT_METHOD SHA512:' \ -e 's@#\(SHA_CRYPT_..._ROUNDS 5000\)@\100@' \ -e 's:/var/spool/mail:/var/mail:' \ -e '/PATH=/{s@/sbin:@@;s@/bin:@@}' \ -i etc/login.defs && touch /usr/bin/passwd && ./configure --sysconfdir=/etc \ --disable-static \ --with-group-name-max-length=32 && make && make exec_prefix=/usr install && make -C man install-man && pwconv && grpconv && mkdir -p /etc/default && useradd -D --gid 999 && # sed -i '/MAIL/s/yes/no/' /etc/default/useradd echo root:root | chpasswd #Set the root password echo "The password for the user root has been set to 'root'" sleep 5 cd .. && rm -rf "$SHADOW" && echo "Finished 8.25 ""$SHADOW""" >> build.log && echo "$SHADOW" >> /installed.txt echo "8.26 ""$GCC""" tar xf "$GCC".tar.xz && cd "$GCC" && case $(uname -m) in x86_64) sed -e '/m64=/s/lib64/lib/' \ -i.orig gcc/config/i386/t-linux64 ;; esac && mkdir -v build && cd build && ../configure --prefix=/usr \ LD=ld \ --enable-languages=c,c++ \ --enable-default-pie \ --enable-default-ssp \ --disable-multilib \ --disable-bootstrap \ --with-system-zlib && make && ulimit -s 32768 && chown -Rv tester . && su tester -c "PATH=$PATH make -k -j""$JOBS"" check"; ../contrib/test_summary | tee ../../check-log_"$GCC".log && ../contrib/test_summary | grep -A7 Summ && make install && chown -v -R root:root \ /usr/lib/gcc/$(gcc -dumpmachine)/12.2.0/include{,-fixed} && ln -svr /usr/bin/cpp /usr/lib && ln -sfv ../../libexec/gcc/$(gcc -dumpmachine)/12.2.0/liblto_plugin.so \ /usr/lib/bfd-plugins/ && echo "Now that our final toolchain is in place, it is important to again ensure that compiling and linking will work as expected. We do this by performing some sanity checks" echo "There should be no errors, and the output of the last command will be (allowing for platform-specific differences in the dynamic linker name):" echo "[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]" echo 'int main(){}' > dummy.c && cc dummy.c -v -Wl,--verbose &> dummy.log && readelf -l a.out | grep ': /lib' echo "Now make sure that we're set up to use the correct start files" echo "The output should be:" echo "/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../lib/Scrt1.o succeeded" echo "/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../lib/crti.o succeeded" echo "/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../lib/crtn.o succeeded" grep -E -o '/usr/lib.*/S?crt[1in].*succeeded' dummy.log echo "Verify that the compiler is searching for the correct header files" echo "The output should be:" echo "#include <...> search starts here:" echo" /usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include" echo" /usr/local/include" echo" /usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include-fixed" echo" /usr/include" grep -B4 '^ /usr/include' dummy.log echo "Verify that the new linker is being used with the correct search paths" echo "References to paths that have components with '-linux-gnu' should be ignored, but otherwise the output should be:" echo 'SEARCH_DIR("/usr/x86_64-pc-linux-gnu/lib64")' echo 'SEARCH_DIR("/usr/local/lib64")' echo 'SEARCH_DIR("/lib64")' echo 'SEARCH_DIR("/usr/lib64")' echo 'SEARCH_DIR("/usr/x86_64-pc-linux-gnu/lib")' echo 'SEARCH_DIR("/usr/local/lib")' echo 'SEARCH_DIR("/lib")"' echo 'SEARCH_DIR("/usr/lib");' grep 'SEARCH.*/usr/lib' dummy.log |sed 's|; |\n|g' echo "Next make sure that we're using the correct libc" echo "The output should be:" echo "attempt to open /usr/lib/libc.so.6 succeeded" grep "/lib.*/libc.so.6 " dummy.log echo "Make sure GCC is using the correct dynamic linker" echo "The output should be (allowing for platform-specific differences in dynamic linker name):" echo "found ld-linux-x86-64.so.2 at /usr/lib/ld-linux-x86-64.so.2" grep found dummy.log sleep 5 rm -v dummy.c a.out dummy.log && mkdir -pv /usr/share/gdb/auto-load/usr/lib && mv -v /usr/lib/*gdb.py /usr/share/gdb/auto-load/usr/lib && cd ../.. && rm -rf "$GCC" && echo "Finished 8.26 ""$GCC""" >> build.log && echo "$GCC" >> /installed.txt echo "8.27 ""$PKGCONFIG""" tar xf "$PKGONFIG".tar.gz cd "$PKGCONFIG" && ./configure --prefix=/usr \ --with-internal-glib \ --disable-host-tool \ --docdir=/usr/share/doc/pkg-config-0.29.2 && make && make check | tee ../check-log_"$PKGCONFIG".log; make install && cd .. && rm -rf "$PKGCONFIG" && echo "Finished 8.27 ""$PKGCONFIG""" >> build.log && echo "$PKGCONFIG" >> /installed.txt echo "8.28 ""$NCURSES""" tar xf "$NCURSES".tar.gz && cd "$NCURSES" && ./configure --prefix=/usr \ --mandir=/usr/share/man \ --with-shared \ --without-debug \ --without-normal \ --with-cxx-shared \ --enable-pc-files \ --enable-widec \ --with-pkg-config-libdir=/usr/lib/pkgconfig && make && make DESTDIR=$PWD/dest install && install -vm755 dest/usr/lib/libncursesw.so.6.4 /usr/lib && rm -v dest/usr/lib/libncursesw.so.6.4 && cp -av dest/* / && for lib in ncurses form panel menu ; do rm -vf /usr/lib/lib${lib}.so echo "INPUT(-l${lib}w)" > /usr/lib/lib${lib}.so ln -sfv ${lib}w.pc /usr/lib/pkgconfig/${lib}.pc done && rm -vf /usr/lib/libcursesw.so && echo "INPUT(-lncursesw)" > /usr/lib/libcursesw.so && ln -sfv libncurses.so /usr/lib/libcurses.so && mkdir -pv /usr/share/doc/ncurses-6.4 && cp -v -R doc/* /usr/share/doc/ncurses-6.4 && cd .. && rm -rf "$NCURSES" && echo "Finished 8.28 ""$NCURSES""" >> build.log && echo "$NCURSES" >> /installed.txt echo "8.29 ""$SED""" tar xf "$SED".tar.xz && cd "$SED" && ./configure --prefix=/usr && make && make html && chown -Rv tester . && su tester -c "PATH=$PATH make check" | tee ../check-log_"$GCC".log; make install && install -d -m755 /usr/share/doc/sed-4.9 && install -m644 doc/sed.html /usr/share/doc/sed-4.9 && cd .. && rm -rf "$SED" && echo "Finished 8.29 ""$SED""" >> build.txt && echo "$SED" >> /installed.txt echo "8.30 ""$PSMISC""" tar xf "$PSMISC".tar.xz && cd "$PSMISC" && ./configure --prefix=/usr && make && make install && cd .. && rm -rf "$PSMISC" && echo "Finished 8.30 ""$PSMISC""" >> build.txt && echo "$PSMISC" >> /installed.txt echo "8.31 ""$GETTEXT""" tar xf "$GETTEXT".tar.xz && cd "$GETTEXT" && ./configure --prefix=/usr \ --disable-static \ --docdir=/usr/share/doc/gettext-0.21.1 && make && make check | tee ../check-log_"$GCC".log; make install && chmod -v 0755 /usr/lib/preloadable_libintl.so && cd .. && rm -rf "$GETTEXT" && echo "Finished 8.31 ""$GETTEXT""" >> build.log && echo "$GETTEXT" >> /installed.txt echo "8.32 ""$BISON""" tar xf "$BISON".tar.xz && cd "$BISON" && ./configure --prefix=/usr --docdir=/usr/share/doc/bison-3.8.2 && make && make check | tee ../check-log_"$BISON".log; make install && cd .. && rm -rf "$BISON" && echo "Finished 8.32 ""$BISON""" >> build.log && echo "$BISON" >> /installed.txt echo "8.33 ""$GREP""" tar xf "$GREP".tar.xz && cd "$GREP" && sed -i "s/echo/#echo/" src/egrep.sh && ./configure --prefix=/usr && make && make check | tee ../check-log_"$GREP".log; make install && cd .. && rm -rf "$GREP" && echo "Finished 8.33 ""$GREP""" >> build.log && echo "$GREP" >> /installed.txt echo "8.34 ""$BASH""" tar xf "$BASH".tar.gz && cd "$BASH" && ./configure --prefix=/usr \ --without-bash-malloc \ --with-installed-readline \ --docdir=/usr/share/doc/bash-5.2.15 && make && chown -Rv tester . && su -s /usr/bin/expect tester << EOF | tee ../check-log_"$BASH".log; set timeout -1 spawn make tests expect eof lassign [wait] _ _ _ value exit $value EOF make install && cd .. && rm -rf "$BASH" && echo "Finished 8.34 ""$BASH""" && echo "$GREP" >> /installed.txt echo "Executing new bash, continue with chapter 8 p2" exec /usr/bin/bash --login