├── .bash_profile ├── .bashrc ├── .gitignore ├── Dockerfile ├── README.md ├── book ├── book.sh ├── chapter-3.sh ├── chapter-3 │ └── 3.1-download-tools.sh ├── chapter-5.sh ├── chapter-5 │ ├── 5.10-make-gcc.sh │ ├── 5.11-make-tcl.sh │ ├── 5.12-make-expect.sh │ ├── 5.13-make-dejagnu.sh │ ├── 5.14-make-m4.sh │ ├── 5.15-make-ncurses.sh │ ├── 5.16-make-bash.sh │ ├── 5.17-make-bison.sh │ ├── 5.18-make-bzip2.sh │ ├── 5.19-make-coreutils.sh │ ├── 5.20-make-diffutils.sh │ ├── 5.21-make-file.sh │ ├── 5.22-make-findutils.sh │ ├── 5.23-make-gawk.sh │ ├── 5.24-make-gettext.sh │ ├── 5.25-make-grep.sh │ ├── 5.26-make-gzip.sh │ ├── 5.27-make-make.sh │ ├── 5.28-make-patch.sh │ ├── 5.29-make-perl.sh │ ├── 5.30-make-sed.sh │ ├── 5.31-make-tar.sh │ ├── 5.32-make-texinfo.sh │ ├── 5.33-make-util-linux.sh │ ├── 5.34-make-xz.sh │ ├── 5.35-strip.sh │ ├── 5.4-make-binutils.sh │ ├── 5.5-make-gcc.sh │ ├── 5.6-make-linux-api-headers.sh │ ├── 5.7-make-glibc.sh │ ├── 5.8-make-libstdc.sh │ └── 5.9-make-binutils.sh ├── chapter-6-chroot.sh ├── chapter-6.sh ├── chapter-6 │ ├── 6.10-adjust-toolchain.sh │ ├── 6.11-make-zlib.sh │ ├── 6.12-make-file.sh │ ├── 6.13-make-readline.sh │ ├── 6.14-make-m4.sh │ ├── 6.15-make-bc.sh │ ├── 6.16-make-binutils.sh │ ├── 6.17-make-gmp.sh │ ├── 6.18-make-mpfr.sh │ ├── 6.19-make-mpc.sh │ ├── 6.2-prepare-vkfs.sh │ ├── 6.20-make-shadow.sh │ ├── 6.21-make-gcc.sh │ ├── 6.22-make-bzip2.sh │ ├── 6.23-make-pkg-config.sh │ ├── 6.24-make-ncurses.sh │ ├── 6.25-make-attr.sh │ ├── 6.26-make-acl.sh │ ├── 6.27-make-libcap.sh │ ├── 6.28-make-sed.sh │ ├── 6.29-make-psmisc.sh │ ├── 6.30-make-iana-etc.sh │ ├── 6.31-make-bison.sh │ ├── 6.32-make-flex.sh │ ├── 6.33-make-grep.sh │ ├── 6.34-make-bash.sh │ ├── 6.35-make-libtool.sh │ ├── 6.36-make-gdbm.sh │ ├── 6.37-make-gperf.sh │ ├── 6.38-make-expat.sh │ ├── 6.39-make-inetutils.sh │ ├── 6.40-make-perl.sh │ ├── 6.41-make-xml-parser.sh │ ├── 6.42-make-intltool.sh │ ├── 6.43-make-autoconf.sh │ ├── 6.44-make-automake.sh │ ├── 6.45-make-xz.sh │ ├── 6.46-make-kmod.sh │ ├── 6.47-make-gettext.sh │ ├── 6.48-make-libelf.sh │ ├── 6.49-make-libffi.sh │ ├── 6.5-create-directories.sh │ ├── 6.50-make-openssl.sh │ ├── 6.51-make-python.sh │ ├── 6.52-make-ninja.sh │ ├── 6.53-make-meson.sh │ ├── 6.54-make-procps-ng.sh │ ├── 6.55-make-e2fsprogs.sh │ ├── 6.56-make-coreutils.sh │ ├── 6.57-make-check.sh │ ├── 6.58-make-diffutils.sh │ ├── 6.59-make-gawk.sh │ ├── 6.6-create-essentials.sh │ ├── 6.60-make-findutils.sh │ ├── 6.61-make-groff.sh │ ├── 6.62-make-grub.sh │ ├── 6.63-make-less.sh │ ├── 6.64-make-gzip.sh │ ├── 6.65-make-iproute2.sh │ ├── 6.66-make-kbd.sh │ ├── 6.67-make-libpipeline.sh │ ├── 6.68-make-make.sh │ ├── 6.69-make-patch.sh │ ├── 6.7-make-linux-api-headers.sh │ ├── 6.70-make-sysklogd.sh │ ├── 6.71-make-sysvinit.sh │ ├── 6.72-make-eudev.sh │ ├── 6.73-make-util-linux.sh │ ├── 6.74-make-man-db.sh │ ├── 6.75-make-tar.sh │ ├── 6.76-make-texinfo.sh │ ├── 6.77-make-vim.sh │ ├── 6.79-strip.sh │ ├── 6.8-make-man-pages.sh │ ├── 6.80-clean.sh │ └── 6.9-make-glibc.sh ├── chapter-7-chroot.sh ├── chapter-7.sh ├── chapter-7 │ ├── 7.2-make-lfs-bootscripts.sh │ ├── 7.4-manage-devices.sh │ ├── 7.5-configure-network.sh │ ├── 7.6-configure-systemv.sh │ └── 7.x-configure-bash.sh ├── chapter-8-chroot.sh ├── chapter-8.sh ├── chapter-8 │ ├── 8.2-create-fstab.sh │ ├── 8.3-make-linux-kernel.sh │ └── 8.4-setup-grub.sh ├── chapter-9-chroot.sh ├── chapter-9.sh ├── chapter-9 │ ├── 9.1-the-end.sh │ └── 9.x-cleanup.sh ├── kernel.config ├── library-check.sh └── version-check.sh ├── docker-compose.yml.dist ├── image ├── 1.configure-syslinux.sh ├── 2.create-ramdisk.sh ├── 3.build-iso.sh └── image.sh └── sources └── .gitsave /.bash_profile: -------------------------------------------------------------------------------- 1 | # This ensures that no unwanted and potentially hazardous 2 | # environment variables from the host system leak into the build environment. 3 | exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash 4 | -------------------------------------------------------------------------------- /.bashrc: -------------------------------------------------------------------------------- 1 | set +h 2 | umask 022 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea/ 2 | /sources/ 3 | /tools/ 4 | /docker-compose.yml 5 | /image/isolinux/ 6 | /image/loop/ 7 | /image/lfs.* 8 | /lfs/ 9 | /dist/ 10 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:9 2 | 3 | # image info 4 | LABEL description="Automated LFS build" 5 | LABEL version="8.3" 6 | LABEL maintainer="paul@drteam.rocks" 7 | 8 | # LFS mount point 9 | ENV LFS=/lfs 10 | 11 | # Other LFS parameters 12 | ENV LC_ALL=POSIX 13 | ENV LFS_TGT=x86_64-lfs-linux-gnu 14 | ENV PATH=/tools/bin:/bin:/usr/bin:/sbin:/usr/sbin 15 | ENV MAKEFLAGS="-j 1" 16 | 17 | # set 1 to run tests; running tests takes much more time 18 | ENV LFS_TEST=0 19 | 20 | # set 1 to install documentation; slightly increases final size 21 | ENV LFS_DOCS=0 22 | 23 | # degree of parallelism for compilation 24 | ENV JOB_COUNT=1 25 | 26 | # loop device 27 | ENV LOOP=/dev/loop2 28 | 29 | # mount point of loop device, for creating the iso iamge 30 | ENV LOOP_DIR=/image/loop 31 | 32 | # inital ram disk size in KB 33 | # must be in sync with CONFIG_BLK_DEV_RAM_SIZE 34 | ENV IMAGE_SIZE=1000000 35 | 36 | # output images 37 | ENV IMAGE_RAM=/dist/lfs.ram 38 | ENV IMAGE_BZ2=/dist/lfs.bz2 39 | ENV IMAGE_ISO=/dist/lfs.iso 40 | ENV IMAGE_HDD=/dist/lfs.hdd 41 | 42 | # location of initrd tree 43 | ENV INITRD_TREE=$LFS 44 | 45 | # set bash as default shell 46 | WORKDIR /bin 47 | RUN rm sh && ln -s bash sh 48 | 49 | # install required packages 50 | RUN apt-get update && apt-get install -y \ 51 | build-essential \ 52 | bison \ 53 | file \ 54 | gawk \ 55 | texinfo \ 56 | wget \ 57 | sudo \ 58 | genisoimage \ 59 | && apt-get -q -y autoremove \ 60 | && rm -rf /var/lib/apt/lists/* 61 | 62 | # create sources directory as writable and sticky 63 | RUN mkdir -pv $LFS/sources \ 64 | && chmod -v a+wt $LFS/sources \ 65 | && ln -sv $LFS/sources / 66 | 67 | # create book directory as writable and sticky 68 | RUN mkdir -pv $LFS/book \ 69 | && chmod -v a+wt $LFS/book \ 70 | && ln -sv $LFS/book / 71 | 72 | # create image directory as writable and sticky 73 | RUN mkdir -pv $LFS/image \ 74 | && chmod -v a+wt $LFS/image \ 75 | && ln -sv $LFS/image / 76 | 77 | # Copy additional scripts and archives 78 | COPY ["book/", "$LFS/book/"] 79 | COPY ["image/", "$LFS/image/"] 80 | COPY ["sources/", "$LFS/sources/"] 81 | 82 | # create tools directory and symlink 83 | RUN mkdir -pv $LFS/tools \ 84 | && ln -sv $LFS/tools / 85 | 86 | # check environment 87 | RUN $LFS/book/version-check.sh \ 88 | && $LFS/book/library-check.sh 89 | 90 | # create lfs user with 'lfs' password 91 | RUN groupadd lfs \ 92 | && useradd -s /bin/bash -g lfs -m -k /dev/null lfs \ 93 | && echo "lfs:lfs" | chpasswd 94 | RUN adduser lfs sudo 95 | 96 | # give lfs user ownership of directories 97 | RUN chown -v lfs $LFS/tools \ 98 | && chown -v lfs $LFS/sources 99 | 100 | # avoid sudo password 101 | RUN echo 'Defaults secure_path="/tools/bin:/bin:/usr/bin:/sbin:/usr/sbin"' >> /etc/sudoers 102 | RUN echo "lfs ALL = NOPASSWD : ALL" >> /etc/sudoers 103 | RUN echo 'Defaults env_keep += "LFS LC_ALL LFS_TGT PATH MAKEFLAGS FETCH_TOOLCHAIN_MODE LFS_TEST LFS_DOCS JOB_COUNT LOOP LOOP_DIR IMAGE_SIZE INITRD_TREE IMAGE_RAM IMAGE_BZ2 IMAGE_ISO IMAGE_HDD"' >> /etc/sudoers 104 | 105 | # login as lfs user 106 | USER lfs 107 | COPY [ ".bash_profile", ".bashrc", "/home/lfs/" ] 108 | RUN source ~/.bash_profile 109 | 110 | # change path to home folder as default 111 | WORKDIR /home/lfs 112 | 113 | # Download all sources 114 | RUN /book/chapter-3.sh 115 | 116 | # let's the party begin 117 | ENTRYPOINT ["/book/book.sh"] 118 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Linux From Scratch builder in Docker container 2 | 3 | This repository is a collection of scripts created especially to 4 | automate the build process of Linux From Scratch (LFS). 5 | 6 | Current stable version of LFS is 8.3 7 | 8 | ## How to use 9 | 10 | You need to install `docker` and `docker-compose` before you begin, 11 | if you not have it yet. 12 | 13 | * https://docs.docker.com/install/#supported-platforms 14 | * https://docs.docker.com/compose/install/ 15 | 16 | ### Normal usage 17 | 18 | Clone from github and prepare the repository: 19 | 20 | git clone https://github.com/EvilFreelancer/docker-lfs-build.git 21 | cd docker-lfs-build 22 | cp docker-compose.yml.dist docker-compose.yml 23 | 24 | Start container: 25 | 26 | docker-compose up -d 27 | 28 | Then login to LFS container: 29 | 30 | docker-compose exec lfs bash 31 | 32 | Start building: 33 | 34 | /book/book.sh 35 | 36 | Result of building will be in `dist` folder. 37 | 38 | ### Download from Docker Hub 39 | 40 | docker pull evilfreelancer/docker-lfs-build 41 | 42 | ### Create your custom `docker-compose.yml` file 43 | 44 | ```yml 45 | version: '2' 46 | 47 | services: 48 | lfs: 49 | restart: unless-stopped 50 | image: evilfreelancer/docker-lfs-build 51 | volumes: 52 | - ./dist:/dist 53 | # You can set any entrypoint what you like, for example "inf sleep" 54 | # by default here is ["/book/book.sh"] 55 | entrypoint: ["sleep", "inf"] 56 | ``` 57 | 58 | ## Links 59 | 60 | * [Unofficial LFS group in Discord](https://discord.gg/NUSW8yF) 61 | * [Project on which this project is based](https://github.com/reinterpretcat/lfs) 62 | -------------------------------------------------------------------------------- /book/book.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | # prepare to build 4 | /book/chapter-3.sh 5 | 6 | # execute rest as root 7 | exec sudo -E -u root /bin/sh - <>> Chapter 3 - Download toolchain..." 4 | 5 | sh /book/chapter-3/3.1-download-tools.sh 6 | -------------------------------------------------------------------------------- /book/chapter-3/3.1-download-tools.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | cd $LFS/sources 4 | 5 | echo "Downloading LFS packages.." 6 | echo "Getting wget-list.." 7 | wget --timestamping http://www.linuxfromscratch.org/lfs/view/8.3/wget-list 8 | 9 | echo "Getting packages.." 10 | wget --timestamping --continue --input-file=wget-list 11 | 12 | echo "Getting md5.." 13 | wget --timestamping http://www.linuxfromscratch.org/lfs/downloads/8.3/md5sums 14 | 15 | echo "Check hashes.." 16 | md5sum -c md5sums 17 | 18 | echo "Downloading syslinux package.." 19 | wget --timestamping https://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.03.tar.xz 20 | echo "Check hash.." 21 | echo "26d3986d2bea109d5dc0e4f8c4822a459276cf021125e8c9f23c3cca5d8c850e $LFS/sources/syslinux-6.03.tar.xz" | sha256sum -c - 22 | -------------------------------------------------------------------------------- /book/chapter-5.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | echo ">>> Chapter 5 - Build toolchain..." 4 | 5 | /book/chapter-5/5.4-make-binutils.sh 6 | /book/chapter-5/5.5-make-gcc.sh 7 | /book/chapter-5/5.6-make-linux-api-headers.sh 8 | /book/chapter-5/5.7-make-glibc.sh 9 | /book/chapter-5/5.8-make-libstdc.sh 10 | /book/chapter-5/5.9-make-binutils.sh 11 | /book/chapter-5/5.10-make-gcc.sh 12 | /book/chapter-5/5.11-make-tcl.sh 13 | /book/chapter-5/5.12-make-expect.sh 14 | /book/chapter-5/5.13-make-dejagnu.sh 15 | /book/chapter-5/5.14-make-m4.sh 16 | /book/chapter-5/5.15-make-ncurses.sh 17 | /book/chapter-5/5.16-make-bash.sh 18 | /book/chapter-5/5.17-make-bison.sh 19 | /book/chapter-5/5.18-make-bzip2.sh 20 | /book/chapter-5/5.19-make-coreutils.sh 21 | /book/chapter-5/5.20-make-diffutils.sh 22 | /book/chapter-5/5.21-make-file.sh 23 | /book/chapter-5/5.22-make-findutils.sh 24 | /book/chapter-5/5.23-make-gawk.sh 25 | /book/chapter-5/5.24-make-gettext.sh 26 | /book/chapter-5/5.25-make-grep.sh 27 | /book/chapter-5/5.26-make-gzip.sh 28 | /book/chapter-5/5.27-make-make.sh 29 | /book/chapter-5/5.28-make-patch.sh 30 | /book/chapter-5/5.29-make-perl.sh 31 | /book/chapter-5/5.30-make-sed.sh 32 | /book/chapter-5/5.31-make-tar.sh 33 | /book/chapter-5/5.32-make-texinfo.sh 34 | /book/chapter-5/5.33-make-util-linux.sh 35 | /book/chapter-5/5.34-make-xz.sh 36 | /book/chapter-5/5.35-strip.sh 37 | -------------------------------------------------------------------------------- /book/chapter-5/5.10-make-gcc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building gcc.." 4 | echo "Approximate build time: 11 SBU" 5 | echo "Required disk space: 3.4 GB" 6 | 7 | # 5.10. Pass 2 GCC package contains the GNU compiler collection, 8 | # which includes the C and C++ compilers 9 | tar -xf /sources/gcc-*.tar.xz -C /tmp/ \ 10 | && mv /tmp/gcc-* /tmp/gcc \ 11 | && pushd /tmp/gcc \ 12 | 13 | cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \ 14 | `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/include-fixed/limits.h 15 | 16 | for file in gcc/config/{linux,i386/linux{,64}}.h 17 | do 18 | cp -uv $file{,.orig} 19 | sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \ 20 | -e 's@/usr@/tools@g' $file.orig > $file 21 | echo ' 22 | #undef STANDARD_STARTFILE_PREFIX_1 23 | #undef STANDARD_STARTFILE_PREFIX_2 24 | #define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/" 25 | #define STANDARD_STARTFILE_PREFIX_2 ""' >> $file 26 | touch $file.orig 27 | done 28 | 29 | case $(uname -m) in 30 | x86_64) 31 | sed -e '/m64=/s/lib64/lib/' \ 32 | -i.orig gcc/config/i386/t-linux64 33 | ;; 34 | esac 35 | 36 | tar -xf $LFS/sources/mpfr-*.tar.xz 37 | mv -v mpfr-* mpfr 38 | tar -xf $LFS/sources/gmp-*.tar.xz 39 | mv -v gmp-* gmp 40 | tar -xf $LFS/sources/mpc-*.tar.gz 41 | mv -v mpc-* mpc 42 | 43 | mkdir -v build 44 | cd build 45 | 46 | CC=$LFS_TGT-gcc \ 47 | CXX=$LFS_TGT-g++ \ 48 | AR=$LFS_TGT-ar \ 49 | RANLIB=$LFS_TGT-ranlib \ 50 | ../configure \ 51 | --prefix=/tools \ 52 | --with-local-prefix=/tools \ 53 | --with-native-system-header-dir=/tools/include \ 54 | --enable-languages=c,c++ \ 55 | --disable-libstdcxx-pch \ 56 | --disable-multilib \ 57 | --disable-bootstrap \ 58 | --disable-libgomp 59 | 60 | make 61 | make install 62 | ln -sv gcc /tools/bin/cc 63 | 64 | popd \ 65 | && rm -rf /tmp/gcc 66 | 67 | if [ $LFS_TEST -eq 1 ]; then 68 | # perform a sanity check 69 | echo 'int main(){}' > dummy.c \ 70 | && cc dummy.c \ 71 | && readelf -l a.out | grep ': /tools' \ 72 | && rm -v dummy.c a.out 73 | fi 74 | -------------------------------------------------------------------------------- /book/chapter-5/5.11-make-tcl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building Tcl-core.." 4 | echo "Approximate build time: 0.9 SBU" 5 | echo "Required disk space: 66 MB" 6 | 7 | # 5.11. The Tcl package contains the Tool Command Language. 8 | tar -xf /sources/tcl*-src.tar.gz -C /tmp/ \ 9 | && mv /tmp/tcl* /tmp/tcl \ 10 | && pushd /tmp/tcl 11 | 12 | # Prepare Tcl for compilation: 13 | cd unix 14 | ./configure --prefix=/tools 15 | 16 | # Build the package: 17 | make 18 | 19 | # Run tests 20 | if [ $LFS_TEST -eq 1 ]; then TZ=UTC make test; fi 21 | 22 | # Install the package: 23 | make install 24 | 25 | # Make the installed library writable so debugging symbols can be removed later: 26 | chmod -v u+w /tools/lib/libtcl8.6.so 27 | 28 | # Install Tcl's headers. The next package, Expect, requires them to build. 29 | make install-private-headers 30 | 31 | # Now make a necessary symbolic link: 32 | ln -sv tclsh8.6 /tools/bin/tclsh || true 33 | 34 | popd \ 35 | && rm -rf /tmp/tcl-core 36 | -------------------------------------------------------------------------------- /book/chapter-5/5.12-make-expect.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building expect.." 4 | echo "Approximate build time: 0.1 SBU" 5 | echo "Required disk space: 3.9 MB" 6 | 7 | # 5.12. Expect package contains a program for carrying out scripted 8 | # dialogues with other interactive programs 9 | tar -xf /sources/expect*.tar.gz -C /tmp/ \ 10 | && mv /tmp/expect* /tmp/expect \ 11 | && pushd /tmp/expect \ 12 | && cp -v configure{,.orig} \ 13 | && sed 's:/usr/local/bin:/bin:' configure.orig > configure \ 14 | && ./configure --prefix=/tools \ 15 | --with-tcl=/tools/lib \ 16 | --with-tclinclude=/tools/include \ 17 | && make \ 18 | && if [ $LFS_TEST -eq 1 ]; then make test; fi \ 19 | && make SCRIPTS="" install \ 20 | && popd \ 21 | && rm -rf /tmp/expect 22 | -------------------------------------------------------------------------------- /book/chapter-5/5.13-make-dejagnu.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building DejaGNU.." 4 | echo "Approximate build time: less than 0.1 SBU" 5 | echo "Required disk space: 3.2 MB" 6 | 7 | # 5.13. DejaGNU package contains a framework for testing other programs 8 | tar -xf /sources/dejagnu-*.tar.gz -C /tmp/ \ 9 | && mv /tmp/dejagnu-* /tmp/dejagnu \ 10 | && pushd /tmp/dejagnu \ 11 | && ./configure --prefix=/tools \ 12 | && make install \ 13 | && if [ $LFS_TEST -eq 1 ]; then make check; fi \ 14 | && popd \ 15 | && rm -rf /tmp/dejagnu 16 | -------------------------------------------------------------------------------- /book/chapter-5/5.14-make-m4.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building m4.." 4 | echo "Approximate build time: 0.2 SBU" 5 | echo "Required disk space: 20 MB" 6 | 7 | # 5.27. M4 package contains a macro processor 8 | tar -xf /sources/m4-*.tar.xz -C /tmp/ \ 9 | && mv /tmp/m4-* /tmp/m4 \ 10 | && pushd /tmp/m4 \ 11 | && sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' lib/*.c \ 12 | && echo "#define _IO_IN_BACKUP 0x100" >> lib/stdio-impl.h \ 13 | && ./configure --prefix=/tools \ 14 | && make \ 15 | && if [ $LFS_TEST -eq 1 ]; then make check; fi \ 16 | && make install \ 17 | && popd \ 18 | && rm -rf /tmp/m4 19 | -------------------------------------------------------------------------------- /book/chapter-5/5.15-make-ncurses.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building Ncurses.." 4 | echo "Approximate build time: 0.6 SBU" 5 | echo "Required disk space: 41 MB" 6 | 7 | # 5.15. Ncurses package contains libraries for terminal-independent 8 | # handling of character screens 9 | tar -xf /sources/ncurses-*.tar.gz -C /tmp/ \ 10 | && mv /tmp/ncurses-* /tmp/ncurses \ 11 | && pushd /tmp/ncurses \ 12 | && sed -i s/mawk// configure \ 13 | && ./configure \ 14 | --prefix=/tools \ 15 | --with-shared \ 16 | --without-debug \ 17 | --without-ada \ 18 | --enable-widec \ 19 | --enable-overwrite \ 20 | && make \ 21 | && make install \ 22 | && popd \ 23 | && rm -rf /tmp/ncurses 24 | -------------------------------------------------------------------------------- /book/chapter-5/5.16-make-bash.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building bash.." 4 | echo "Approximate build time: 0.4 SBU" 5 | echo "Required disk space: 63 MB" 6 | 7 | # 5.16. Bash package contains the Bourne-Again SHell 8 | tar -xf /sources/bash-*.tar.gz -C /tmp/ \ 9 | && mv /tmp/bash-* /tmp/bash \ 10 | && pushd /tmp/bash \ 11 | && ./configure --prefix=/tools --without-bash-malloc \ 12 | && make \ 13 | && if [ $LFS_TEST -eq 1 ]; then make tests; fi \ 14 | && make install \ 15 | && ln -sv bash /tools/bin/sh \ 16 | && popd \ 17 | && rm -rf /tmp/bash 18 | -------------------------------------------------------------------------------- /book/chapter-5/5.17-make-bison.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building bison.." 4 | echo "Approximate build time: 0.3 SBU" 5 | echo "Required disk space: 35 MB" 6 | 7 | # 5.17. Bison package contains a parser generator 8 | tar -xf /sources/bison-*.tar.xz -C /tmp/ \ 9 | && mv /tmp/bison-* /tmp/bison \ 10 | && pushd /tmp/bison \ 11 | && ./configure --prefix=/tools \ 12 | && make \ 13 | && make install \ 14 | && popd \ 15 | && rm -rf /tmp/bison 16 | -------------------------------------------------------------------------------- /book/chapter-5/5.18-make-bzip2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building bzip2.." 4 | echo "Approximate build time: less than 0.1 SBU" 5 | echo "Required disk space: 5.5 MB" 6 | 7 | # 5.18. Bzip2 package contains programs for compressing and decompressing files. 8 | # Compressing text files with bzip2 yields a much better compression percentage 9 | # than with the traditional gzip 10 | tar -xf /sources/bzip2-*.tar.gz -C /tmp/ \ 11 | && mv /tmp/bzip2-* /tmp/bzip2 \ 12 | && pushd /tmp/bzip2 \ 13 | && make \ 14 | && make PREFIX=/tools install \ 15 | && popd \ 16 | && rm -rf /tmp/bzip2 17 | -------------------------------------------------------------------------------- /book/chapter-5/5.19-make-coreutils.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building Coreutils.." 4 | echo "Approximate build time: 0.7 SBU" 5 | echo "Required disk space: 147 MB" 6 | 7 | # 5.19. The Coreutils package contains utilities for showing and 8 | # setting the basic system characteristics. 9 | 10 | # NOTE: has failed tests 11 | # NOTE: has workaround for deletion directories with long name 12 | 13 | tar -xf /sources/coreutils-*.tar.xz -C /tmp/ \ 14 | && mv /tmp/coreutils-* /tmp/coreutils \ 15 | && pushd /tmp/coreutils \ 16 | && FORCE_UNSAFE_CONFIGURE=1 ./configure --prefix=/tools --enable-install-program=hostname \ 17 | && FORCE_UNSAFE_CONFIGURE=1 make \ 18 | && if [ $LFS_TEST -eq 1 ]; then make RUN_EXPENSIVE_TESTS=yes check || true; fi \ 19 | && make install \ 20 | && popd \ 21 | && rm -rf /tmp/coreutils 22 | -------------------------------------------------------------------------------- /book/chapter-5/5.20-make-diffutils.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building diffutils.." 4 | echo "Approximate build time: 0.2 SBU" 5 | echo "Required disk space: 23 MB" 6 | 7 | # 5.20. Diffutils package contains programs that show the differences 8 | # between files or directories 9 | tar -xf /sources/diffutils-*.tar.xz -C /tmp/ \ 10 | && mv /tmp/diffutils-* /tmp/diffutils \ 11 | && pushd /tmp/diffutils \ 12 | && ./configure --prefix=/tools \ 13 | && make \ 14 | && if [ $LFS_TEST -eq 1 ]; then make check; fi \ 15 | && make install \ 16 | && popd \ 17 | && rm -rf /tmp/diffutils 18 | -------------------------------------------------------------------------------- /book/chapter-5/5.21-make-file.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building file.." 4 | echo "Approximate build time: 0.1 SBU" 5 | echo "Required disk space: 18 MB" 6 | 7 | # 5.21. File package contains a utility for determining the type of 8 | # a given file or files 9 | tar -xf /sources/file-*.tar.gz -C /tmp/ \ 10 | && mv /tmp/file-* /tmp/file \ 11 | && pushd /tmp/file \ 12 | && ./configure --prefix=/tools \ 13 | && make \ 14 | && if [ $LFS_TEST -eq 1 ]; then make check; fi \ 15 | && make install \ 16 | && popd \ 17 | && rm -rf /tmp/file 18 | -------------------------------------------------------------------------------- /book/chapter-5/5.22-make-findutils.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building findutils.." 4 | echo "Approximate build time: 0.3 SBU" 5 | echo "Required disk space: 36 MB" 6 | 7 | # 5.22. Findutils package contains programs to find files. These programs are 8 | # provided to recursively search through a directory tree and to create, 9 | # maintain, and search a database (often faster than the recursive find, 10 | # but unreliable if the database has not been recently updated). 11 | tar -xf /sources/findutils-*.tar.gz -C /tmp/ \ 12 | && mv /tmp/findutils-* /tmp/findutils \ 13 | && pushd /tmp/findutils \ 14 | && sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' gl/lib/*.c \ 15 | && sed -i '/unistd/a #include ' gl/lib/mountlist.c \ 16 | && echo "#define _IO_IN_BACKUP 0x100" >> gl/lib/stdio-impl.h \ 17 | && ./configure --prefix=/tools \ 18 | && make \ 19 | && if [ $LFS_TEST -eq 1 ]; then make check; fi || true \ 20 | && make install \ 21 | && popd \ 22 | && rm -rf /tmp/findutils || true 23 | -------------------------------------------------------------------------------- /book/chapter-5/5.23-make-gawk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building gawk.." 4 | echo "Approximate build time: 0.2 SBU" 5 | echo "Required disk space: 43 MB" 6 | 7 | # 5.23. Gawk package contains programs for manipulating text files 8 | tar -xf /sources/gawk-*.tar.xz -C /tmp/ \ 9 | && mv /tmp/gawk-* /tmp/gawk \ 10 | && pushd /tmp/gawk \ 11 | && ./configure --prefix=/tools \ 12 | && make \ 13 | && if [ $LFS_TEST -eq 1 ]; then make check || true; fi \ 14 | && make install \ 15 | && popd \ 16 | && rm -rf /tmp/gawk 17 | -------------------------------------------------------------------------------- /book/chapter-5/5.24-make-gettext.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building gettext.." 4 | echo "Approximate build time: 0.9 SBU" 5 | echo "Required disk space: 173 MB" 6 | 7 | # 5.24. Gettext package contains utilities for internationalization and 8 | # localization. These allow programs to be compiled with NLS (Native Language 9 | # Support), enabling them to output messages in the user's native language 10 | tar -xf /sources/gettext-*.tar.xz -C /tmp/ \ 11 | && mv /tmp/gettext-* /tmp/gettext \ 12 | && pushd /tmp/gettext \ 13 | && cd gettext-tools \ 14 | && EMACS="no" ./configure --prefix=/tools --disable-shared \ 15 | && make -C gnulib-lib \ 16 | && make -C intl pluralx.c \ 17 | && make -C src msgfmt \ 18 | && make -C src msgmerge \ 19 | && make -C src xgettext \ 20 | && cp -v src/{msgfmt,msgmerge,xgettext} /tools/bin \ 21 | && popd \ 22 | && rm -rf /tmp/gettext 23 | -------------------------------------------------------------------------------- /book/chapter-5/5.25-make-grep.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building grep.." 4 | echo "Approximate build time: 0.2 SBU" 5 | echo "Required disk space: 20 MB" 6 | 7 | # 5.25. Grep package contains programs for searching through files 8 | tar -xf /sources/grep-*.tar.xz -C /tmp/ \ 9 | && mv /tmp/grep-* /tmp/grep \ 10 | && pushd /tmp/grep \ 11 | && ./configure --prefix=/tools \ 12 | && make \ 13 | && if [ $LFS_TEST -eq 1 ]; then make check; fi \ 14 | && make install \ 15 | && popd \ 16 | && rm -rf /tmp/grep 17 | -------------------------------------------------------------------------------- /book/chapter-5/5.26-make-gzip.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building gzip.." 4 | echo "Approximate build time: 0.1 SBU" 5 | echo "Required disk space: 10 MB" 6 | 7 | # 5.26. Gzip package contains programs for compressing and decompressing files 8 | tar -xf /sources/gzip-*.tar.xz -C /tmp/ \ 9 | && mv /tmp/gzip-* /tmp/gzip \ 10 | && pushd /tmp/gzip \ 11 | && sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' lib/*.c \ 12 | && echo "#define _IO_IN_BACKUP 0x100" >> lib/stdio-impl.h \ 13 | && ./configure --prefix=/tools \ 14 | && make \ 15 | && if [ $LFS_TEST -eq 1 ]; then make check || true; fi \ 16 | && make install \ 17 | && popd \ 18 | && rm -rf /tmp/gzip 19 | -------------------------------------------------------------------------------- /book/chapter-5/5.27-make-make.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building make.." 4 | echo "Approximate build time: 0.1 SBU" 5 | echo "Required disk space: 13 MB" 6 | 7 | # 5.28. The Make package contains a program for compiling packages. 8 | tar -xf /sources/make-*.tar.bz2 -C /tmp/ \ 9 | && mv /tmp/make-* /tmp/make \ 10 | && pushd /tmp/make \ 11 | && sed -i '211,217 d; 219,229 d; 232 d' glob/glob.c \ 12 | && ./configure --prefix=/tools --without-guile \ 13 | && make \ 14 | && if [ $LFS_TEST -eq 1 ]; then make check; fi \ 15 | && make install \ 16 | && popd \ 17 | && rm -rf /tmp/make 18 | -------------------------------------------------------------------------------- /book/chapter-5/5.28-make-patch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building patch.." 4 | echo "Approximate build time: 0.2 SBU" 5 | echo "Required disk space: 12 MB" 6 | 7 | # 5.29. Patch package contains a program for modifying or creating files by 8 | # applying a “patch” file typically created by the diff program 9 | tar -xf /sources/patch-*.tar.xz -C /tmp/ \ 10 | && mv /tmp/patch-* /tmp/patch \ 11 | && pushd /tmp/patch \ 12 | && ./configure --prefix=/tools \ 13 | && make \ 14 | && if [ $LFS_TEST -eq 1 ]; then make check; fi \ 15 | && make install \ 16 | && popd \ 17 | && rm -rf /tmp/patch 18 | -------------------------------------------------------------------------------- /book/chapter-5/5.29-make-perl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building perl.." 4 | echo "Approximate build time: 1.5 SBU" 5 | echo "Required disk space: 275 MB" 6 | 7 | # 5.30. Perl package contains the Practical Extraction and Report Language 8 | tar -xf /sources/perl-5*.tar.xz -C /tmp/ \ 9 | && mv /tmp/perl-* /tmp/perl \ 10 | && pushd /tmp/perl \ 11 | && sh Configure -des -Dprefix=/tools -Dlibs=-lm -Uloclibpth -Ulocincpth \ 12 | && make \ 13 | && cp -v perl cpan/podlators/scripts/pod2man /tools/bin \ 14 | && mkdir -pv /tools/lib/perl5/5.28.0 \ 15 | && cp -Rv lib/* /tools/lib/perl5/5.28.0 \ 16 | && popd \ 17 | && rm -rf /tmp/perl 18 | -------------------------------------------------------------------------------- /book/chapter-5/5.30-make-sed.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building sed.." 4 | echo "Approximate build time: 0.2 SBU" 5 | echo "Required disk space: 17 MB" 6 | 7 | # 5.31. Sed package contains a stream editor 8 | tar -xf /sources/sed-*.tar.xz -C /tmp/ \ 9 | && mv /tmp/sed-* /tmp/sed \ 10 | && pushd /tmp/sed \ 11 | && ./configure --prefix=/tools \ 12 | && make \ 13 | && if [ $LFS_TEST -eq 1 ]; then make check || true; fi \ 14 | && make install \ 15 | && popd \ 16 | && rm -rf /tmp/sed 17 | -------------------------------------------------------------------------------- /book/chapter-5/5.31-make-tar.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building tar.." 4 | echo "Approximate build time: 0.4 SBU" 5 | echo "Required disk space: 36 MB" 6 | 7 | # 5.32. Tar package contains an archiving program 8 | tar -xf /sources/tar-*.tar.xz -C /tmp/ \ 9 | && mv /tmp/tar-* /tmp/tar \ 10 | && pushd /tmp/tar \ 11 | && FORCE_UNSAFE_CONFIGURE=1 ./configure --prefix=/tools \ 12 | && FORCE_UNSAFE_CONFIGURE=1 make \ 13 | && if [ $LFS_TEST -eq 1 ]; then make check; fi \ 14 | && make install \ 15 | && popd \ 16 | && rm -rf /tmp/tar || true 17 | -------------------------------------------------------------------------------- /book/chapter-5/5.32-make-texinfo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building texinfo.." 4 | echo "Approximate build time: 0.2 SBU" 5 | echo "Required disk space: 100 MB" 6 | 7 | # 5.33. Texinfo package contains programs for reading, writing, and converting info pages 8 | tar -xf /sources/texinfo-*.tar.xz -C /tmp/ \ 9 | && mv /tmp/texinfo-* /tmp/texinfo \ 10 | && pushd /tmp/texinfo \ 11 | && ./configure --prefix=/tools \ 12 | && make \ 13 | && if [ $LFS_TEST -eq 1 ]; then make check; fi \ 14 | && make install \ 15 | && popd \ 16 | && rm -rf /tmp/texinfo 17 | -------------------------------------------------------------------------------- /book/chapter-5/5.33-make-util-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building Util-linux.." 4 | echo "Approximate build time: 1.0 SBU" 5 | echo "Required disk space: 140 MB" 6 | 7 | # 5.34. Util-linux package contains miscellaneous utility programs 8 | tar -xf /sources/util-linux-*.tar.xz -C /tmp/ \ 9 | && mv /tmp/util-linux-* /tmp/util-linux \ 10 | && pushd /tmp/util-linux \ 11 | && ./configure --prefix=/tools \ 12 | --without-python \ 13 | --disable-makeinstall-chown \ 14 | --without-systemdsystemunitdir \ 15 | --without-ncurses \ 16 | PKG_CONFIG="" \ 17 | && make \ 18 | && make install \ 19 | && popd \ 20 | && rm -rf /tmp/util-linux 21 | -------------------------------------------------------------------------------- /book/chapter-5/5.34-make-xz.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building Xz.." 4 | echo "Approximate build time: 0.2 SBU" 5 | echo "Required disk space: 18 MB" 6 | 7 | # 5.35. Xz package contains programs for compressing and decompressing files. 8 | # It provides capabilities for the lzma and the newer xz compression formats. 9 | # Compressing text files with xz yields a better compression percentage than 10 | # with the traditional gzip or bzip2 commands 11 | tar -xf /sources/xz-*.tar.xz -C /tmp/ \ 12 | && mv /tmp/xz-* /tmp/xz \ 13 | && pushd /tmp/xz \ 14 | && ./configure --prefix=/tools \ 15 | && make \ 16 | && if [ $LFS_TEST -eq 1 ]; then make check; fi \ 17 | && make install \ 18 | && popd \ 19 | && rm -rf /tmp/xz 20 | -------------------------------------------------------------------------------- /book/chapter-5/5.35-strip.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Stripping.." 4 | 5 | # The steps in this section are optional, but if the LFS partition is rather 6 | # small, it is beneficial to learn that unnecessary items can be removed. 7 | # The executables and libraries built so far contain about 70 MB of unneeded 8 | # debugging symbols. Remove those symbols with: 9 | strip --strip-debug /tools/lib/* || true 10 | /usr/bin/strip --strip-unneeded /tools/{,s}bin/* || true 11 | 12 | # To save more, remove the documentation: 13 | rm -rf /tools/{,share}/{info,man,doc} 14 | 15 | # Remove unneeded files: 16 | find /tools/{lib,libexec} -name \*.la -delete 17 | -------------------------------------------------------------------------------- /book/chapter-5/5.4-make-binutils.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building binutils.." 4 | echo "Approximate build time: 1 SBU" 5 | echo "Required disk space: 547 MB" 6 | 7 | # 5.4 Binutils package contains a linker, an assembler, and other 8 | # tools for handling object files 9 | tar -xf /sources/binutils-*.tar.xz -C /tmp/ \ 10 | && mv /tmp/binutils-* /tmp/binutils \ 11 | && pushd /tmp/binutils \ 12 | && mkdir -v build \ 13 | && cd build \ 14 | && ../configure \ 15 | --prefix=/tools \ 16 | --with-sysroot=$LFS \ 17 | --with-lib-path=/tools/lib \ 18 | --target=$LFS_TGT \ 19 | --disable-nls \ 20 | --disable-werror \ 21 | && make \ 22 | && mkdir -pv /tools/lib \ 23 | && ln -sv lib /tools/lib64 \ 24 | && make install \ 25 | && popd \ 26 | && rm -rf /tmp/binutils 27 | -------------------------------------------------------------------------------- /book/chapter-5/5.5-make-gcc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building gcc.." 4 | echo "Approximate build time: 14.3 SBU" 5 | echo "Required disk space: 2.2 GB" 6 | 7 | # 5.5. Pass 1 GCC package contains the GNU compiler collection, 8 | # which includes the C and C++ compilers 9 | tar -xf /sources/gcc-*.tar.xz -C /tmp/ \ 10 | && mv /tmp/gcc-* /tmp/gcc \ 11 | && pushd /tmp/gcc \ 12 | && tar -xf $LFS/sources/mpfr-*.tar.xz \ 13 | && mv -v mpfr-* mpfr \ 14 | && tar -xf $LFS/sources/gmp-*.tar.xz \ 15 | && mv -v gmp-* gmp \ 16 | && tar -xf $LFS/sources/mpc-*.tar.gz \ 17 | && mv -v mpc-* mpc 18 | 19 | for file in gcc/config/{linux,i386/linux{,64}}.h 20 | do 21 | cp -uv $file{,.orig} 22 | sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \ 23 | -e 's@/usr@/tools@g' $file.orig > $file 24 | echo ' 25 | #undef STANDARD_STARTFILE_PREFIX_1 26 | #undef STANDARD_STARTFILE_PREFIX_2 27 | #define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/" 28 | #define STANDARD_STARTFILE_PREFIX_2 ""' >> $file 29 | touch $file.orig 30 | done 31 | 32 | case $(uname -m) in 33 | x86_64) 34 | sed -e '/m64=/s/lib64/lib/' \ 35 | -i.orig gcc/config/i386/t-linux64 36 | ;; 37 | esac 38 | 39 | mkdir -v build 40 | cd build 41 | 42 | ../configure \ 43 | --target=$LFS_TGT \ 44 | --prefix=/tools \ 45 | --with-glibc-version=2.11 \ 46 | --with-sysroot=$LFS \ 47 | --with-newlib \ 48 | --without-headers \ 49 | --with-local-prefix=/tools \ 50 | --with-native-system-header-dir=/tools/include \ 51 | --disable-nls \ 52 | --disable-shared \ 53 | --disable-multilib \ 54 | --disable-decimal-float \ 55 | --disable-threads \ 56 | --disable-libatomic \ 57 | --disable-libgomp \ 58 | --disable-libmpx \ 59 | --disable-libquadmath \ 60 | --disable-libssp \ 61 | --disable-libvtv \ 62 | --disable-libstdcxx \ 63 | --enable-languages=c,c++ 64 | 65 | make 66 | make install 67 | 68 | popd \ 69 | && rm -rf /tmp/gcc 70 | -------------------------------------------------------------------------------- /book/chapter-5/5.6-make-linux-api-headers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building Linux API Headers.." 4 | echo "Approximate build time: 0.1 SBU" 5 | echo "Required disk space: 910 MB" 6 | 7 | # 5.6. Linux API Headers expose the kernel's API for use by Glibc 8 | tar -xf /sources/linux-*.tar.xz -C /tmp/ \ 9 | && mv /tmp/linux-* /tmp/linux \ 10 | && pushd /tmp/linux \ 11 | && make mrproper \ 12 | && make INSTALL_HDR_PATH=dest headers_install \ 13 | && cp -rv dest/include/* /tools/include \ 14 | && popd \ 15 | && rm -rf /tmp/linux 16 | -------------------------------------------------------------------------------- /book/chapter-5/5.7-make-glibc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building glibc.." 4 | echo "Approximate build time: 4.3 SBU" 5 | echo "Required disk space: 823 MB" 6 | 7 | # 5.7. Glibc package contains the main C library. This library provides 8 | # the basic routines for allocating memory, searching directories, opening 9 | # and closing files, reading and writing files, string handling, pattern 10 | # matching, arithmetic, and so on 11 | tar -xf /sources/glibc-*.tar.xz -C /tmp/ \ 12 | && mv /tmp/glibc-* /tmp/glibc \ 13 | && pushd /tmp/glibc 14 | 15 | mkdir -v build 16 | cd build 17 | 18 | ../configure \ 19 | --prefix=/tools \ 20 | --host=$LFS_TGT \ 21 | --build=$(../scripts/config.guess) \ 22 | --enable-kernel=3.2 \ 23 | --with-headers=/tools/include \ 24 | libc_cv_forced_unwind=yes \ 25 | libc_cv_c_cleanup=yes 26 | 27 | # Compile the package: 28 | make 29 | 30 | # Install the package: 31 | make install 32 | 33 | popd \ 34 | && rm -rf /tmp/glibc 35 | 36 | # perform a sanity check that basic functions (compiling and linking) 37 | # are working as expected 38 | if [ $LFS_TEST -eq 1 ]; then 39 | # perform a sanity check 40 | echo 'int main(){}' > dummy.c \ 41 | && $LFS_TGT-gcc dummy.c \ 42 | && readelf -l a.out | grep ': /tools' \ 43 | && rm -v dummy.c a.out 44 | fi 45 | -------------------------------------------------------------------------------- /book/chapter-5/5.8-make-libstdc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building libstdc.." 4 | echo "Approximate build time: 0.5 SBU" 5 | echo "Required disk space: 803 MB" 6 | 7 | # 5.8. Libstdc++ is the standard C++ library. It is needed for 8 | # the correct operation of the g++ compile 9 | tar -xf /sources/gcc-*.tar.xz -C /tmp/ \ 10 | && mv /tmp/gcc-* /tmp/gcc \ 11 | && pushd /tmp/gcc \ 12 | && mkdir -v build \ 13 | && cd build \ 14 | && ../libstdc++-v3/configure \ 15 | --host=$LFS_TGT \ 16 | --prefix=/tools \ 17 | --disable-multilib \ 18 | --disable-nls \ 19 | --disable-libstdcxx-threads \ 20 | --disable-libstdcxx-pch \ 21 | --with-gxx-include-dir=/tools/$LFS_TGT/include/c++/8.2.0 \ 22 | && make \ 23 | && make install \ 24 | && popd \ 25 | && rm -rf /tmp/gcc 26 | -------------------------------------------------------------------------------- /book/chapter-5/5.9-make-binutils.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building binutils.." 4 | echo "Approximate build time: 1.1 SBU" 5 | echo "Required disk space: 593 MB" 6 | 7 | # 5.9. Pass 2 Binutils package contains a linker, an assembler, 8 | # and other tools for handling object files 9 | tar -xf /sources/binutils-*.tar.xz -C /tmp/ \ 10 | && mv /tmp/binutils-* /tmp/binutils \ 11 | && pushd /tmp/binutils \ 12 | && mkdir -v build \ 13 | && cd build \ 14 | && CC=$LFS_TGT-gcc \ 15 | AR=$LFS_TGT-ar \ 16 | RANLIB=$LFS_TGT-ranlib \ 17 | ../configure \ 18 | --prefix=/tools \ 19 | --disable-nls \ 20 | --disable-werror \ 21 | --with-lib-path=/tools/lib \ 22 | --with-sysroot \ 23 | && make \ 24 | && make install \ 25 | && make -C ld clean \ 26 | && make -C ld LIB_PATH=/usr/lib:/lib \ 27 | && cp -v ld/ld-new /tools/bin \ 28 | && popd \ 29 | && rm -rf /tmp/binutils 30 | -------------------------------------------------------------------------------- /book/chapter-6-chroot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "> Continue with chroot environment..." 4 | 5 | sh /book/chapter-6/6.5-create-directories.sh 6 | sh /book/chapter-6/6.6-create-essentials.sh 7 | sh /book/chapter-6/6.7-make-linux-api-headers.sh 8 | sh /book/chapter-6/6.8-make-man-pages.sh 9 | sh /book/chapter-6/6.9-make-glibc.sh 10 | sh /book/chapter-6/6.10-adjust-toolchain.sh 11 | sh /book/chapter-6/6.11-make-zlib.sh 12 | sh /book/chapter-6/6.12-make-file.sh 13 | sh /book/chapter-6/6.13-make-readline.sh 14 | sh /book/chapter-6/6.14-make-m4.sh 15 | sh /book/chapter-6/6.15-make-bc.sh 16 | sh /book/chapter-6/6.16-make-binutils.sh 17 | sh /book/chapter-6/6.17-make-gmp.sh 18 | sh /book/chapter-6/6.18-make-mpfr.sh 19 | sh /book/chapter-6/6.19-make-mpc.sh 20 | sh /book/chapter-6/6.20-make-shadow.sh 21 | sh /book/chapter-6/6.21-make-gcc.sh 22 | sh /book/chapter-6/6.22-make-bzip2.sh 23 | sh /book/chapter-6/6.23-make-pkg-config.sh 24 | sh /book/chapter-6/6.24-make-ncurses.sh 25 | sh /book/chapter-6/6.25-make-attr.sh 26 | sh /book/chapter-6/6.26-make-acl.sh 27 | sh /book/chapter-6/6.27-make-libcap.sh 28 | sh /book/chapter-6/6.28-make-sed.sh 29 | sh /book/chapter-6/6.29-make-psmisc.sh 30 | sh /book/chapter-6/6.30-make-iana-etc.sh 31 | sh /book/chapter-6/6.31-make-bison.sh 32 | sh /book/chapter-6/6.32-make-flex.sh 33 | sh /book/chapter-6/6.33-make-grep.sh 34 | sh /book/chapter-6/6.34-make-bash.sh 35 | sh /book/chapter-6/6.35-make-libtool.sh 36 | sh /book/chapter-6/6.36-make-gdbm.sh 37 | sh /book/chapter-6/6.37-make-gperf.sh 38 | sh /book/chapter-6/6.38-make-expat.sh 39 | sh /book/chapter-6/6.39-make-inetutils.sh 40 | sh /book/chapter-6/6.40-make-perl.sh 41 | sh /book/chapter-6/6.41-make-xml-parser.sh 42 | sh /book/chapter-6/6.42-make-intltool.sh 43 | sh /book/chapter-6/6.43-make-autoconf.sh 44 | sh /book/chapter-6/6.44-make-automake.sh 45 | sh /book/chapter-6/6.45-make-xz.sh 46 | sh /book/chapter-6/6.46-make-kmod.sh 47 | sh /book/chapter-6/6.47-make-gettext.sh 48 | sh /book/chapter-6/6.48-make-libelf.sh 49 | sh /book/chapter-6/6.49-make-libffi.sh 50 | sh /book/chapter-6/6.50-make-openssl.sh 51 | sh /book/chapter-6/6.51-make-python.sh 52 | sh /book/chapter-6/6.52-make-ninja.sh 53 | sh /book/chapter-6/6.53-make-meson.sh 54 | sh /book/chapter-6/6.54-make-procps-ng.sh 55 | sh /book/chapter-6/6.55-make-e2fsprogs.sh 56 | sh /book/chapter-6/6.56-make-coreutils.sh 57 | sh /book/chapter-6/6.57-make-check.sh 58 | sh /book/chapter-6/6.58-make-diffutils.sh 59 | sh /book/chapter-6/6.59-make-gawk.sh 60 | sh /book/chapter-6/6.60-make-findutils.sh 61 | sh /book/chapter-6/6.61-make-groff.sh 62 | sh /book/chapter-6/6.62-make-grub.sh 63 | sh /book/chapter-6/6.63-make-less.sh 64 | sh /book/chapter-6/6.64-make-gzip.sh 65 | sh /book/chapter-6/6.65-make-iproute2.sh 66 | sh /book/chapter-6/6.66-make-kbd.sh 67 | sh /book/chapter-6/6.67-make-libpipeline.sh 68 | sh /book/chapter-6/6.68-make-make.sh 69 | sh /book/chapter-6/6.69-make-patch.sh 70 | sh /book/chapter-6/6.70-make-sysklogd.sh 71 | sh /book/chapter-6/6.71-make-sysvinit.sh 72 | sh /book/chapter-6/6.72-make-eudev.sh 73 | sh /book/chapter-6/6.73-make-util-linux.sh 74 | sh /book/chapter-6/6.74-make-man-db.sh 75 | sh /book/chapter-6/6.75-make-tar.sh 76 | sh /book/chapter-6/6.76-make-texinfo.sh 77 | sh /book/chapter-6/6.77-make-vim.sh 78 | sh /book/chapter-6/6.79-strip.sh 79 | sh /book/chapter-6/6.80-clean.sh 80 | 81 | exit 82 | -------------------------------------------------------------------------------- /book/chapter-6.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | echo ">>> Chapter 6" 4 | 5 | # prepartion 6 | sh /book/chapter-6/6.2-prepare-vkfs.sh 7 | 8 | # enter and continue in chroot environment with tools 9 | chroot "$LFS" /tools/bin/env -i \ 10 | HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \ 11 | PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \ 12 | LFS="$LFS" LC_ALL="$LC_ALL" \ 13 | LFS_TGT="$LFS_TGT" MAKEFLAGS="$MAKEFLAGS" \ 14 | LFS_TEST="$LFS_TEST" LFS_DOCS="$LFS_DOCS" \ 15 | JOB_COUNT="$JOB_COUNT" \ 16 | /tools/bin/bash --login +h \ 17 | -c "sh /book/chapter-6-chroot.sh" 18 | -------------------------------------------------------------------------------- /book/chapter-6/6.10-adjust-toolchain.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Adjusting toolchain.." 4 | 5 | # 6.10. Adjusting the Toolchain 6 | # fix linker 7 | mv -v /tools/bin/{ld,ld-old} 8 | mv -v /tools/$(uname -m)-pc-linux-gnu/bin/{ld,ld-old} 9 | mv -v /tools/bin/{ld-new,ld} 10 | ln -sv /tools/bin/ld /tools/$(uname -m)-pc-linux-gnu/bin/ld 11 | # amend the GCC specs file so that it points to the new dynamic linker 12 | gcc -dumpspecs | sed -e 's@/tools@@g' \ 13 | -e '/\*startfile_prefix_spec:/{n;s@.*@/usr/lib/ @}' \ 14 | -e '/\*cpp:/{n;s@$@ -isystem /usr/include@}' > \ 15 | `dirname $(gcc --print-libgcc-file-name)`/specs 16 | # perform check 17 | echo 'int main(){}' > dummy.c 18 | cc dummy.c -v -Wl,--verbose &> dummy.log 19 | readelf -l a.out | grep ': /lib' 20 | # additional checks (observe output manually) 21 | grep -o '/usr/lib.*/crt[1in].*succeeded' dummy.log 22 | grep -B1 '^ /usr/include' dummy.log 23 | grep 'SEARCH.*/usr/lib' dummy.log |sed 's|; |\n|g' 24 | grep "/lib.*/libc.so.6 " dummy.log 25 | grep found dummy.log 26 | # cleanup 27 | rm -v dummy.c a.out dummy.log 28 | -------------------------------------------------------------------------------- /book/chapter-6/6.11-make-zlib.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building zlib.." 4 | echo "Approximate build time: less than 0.1 SBU" 5 | echo "Required disk space: 4.4 MB" 6 | 7 | # 6.11. Zlib package contains compression and decompression 8 | # routines used by some programs 9 | tar -xf /sources/zlib-*.tar.xz -C /tmp/ \ 10 | && mv /tmp/zlib-* /tmp/zlib \ 11 | && pushd /tmp/zlib 12 | 13 | ./configure --prefix=/usr 14 | make 15 | if [ $LFS_TEST -eq 1 ]; then make check; fi 16 | make install 17 | mv -v /usr/lib/libz.so.* /lib 18 | ln -sfv ../../lib/$(readlink /usr/lib/libz.so) /usr/lib/libz.so 19 | 20 | popd \ 21 | && rm -rf /tmp/zlib 22 | -------------------------------------------------------------------------------- /book/chapter-6/6.12-make-file.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building file.." 4 | echo "Approximate build time: 0.1 SBU" 5 | echo "Required disk space: 18 MB" 6 | 7 | # 6.12. The File package contains a utility for determining the 8 | # type of a given file or files. 9 | tar -xf /sources/file-*.tar.gz -C /tmp/ \ 10 | && mv /tmp/file-* /tmp/file \ 11 | && pushd /tmp/file 12 | 13 | ./configure --prefix=/usr 14 | make 15 | if [ $LFS_TEST -eq 1 ]; then make check; fi 16 | make install 17 | 18 | popd \ 19 | && rm -rf /tmp/file 20 | -------------------------------------------------------------------------------- /book/chapter-6/6.13-make-readline.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building readline.." 4 | echo "Approximate build time: 0.1 SBU" 5 | echo "Required disk space: 18 MB" 6 | 7 | # 6.13. Readline package is a set of libraries that offers command-line 8 | # editing and history capabilities 9 | tar -xf /sources/readline-*.tar.gz -C /tmp/ \ 10 | && mv /tmp/readline-* /tmp/readline \ 11 | && pushd /tmp/readline 12 | 13 | sed -i '/MV.*old/d' Makefile.in 14 | sed -i '/{OLDSUFF}/c:' support/shlib-install 15 | ./configure --prefix=/usr \ 16 | --disable-static \ 17 | --docdir=/usr/share/doc/readline-7.0 18 | make SHLIB_LIBS="-L/tools/lib -lncursesw" 19 | make SHLIB_LIBS="-L/tools/lib -lncurses" install 20 | # move the dynamic libraries to a more appropriate location 21 | # and fix up some symbolic links 22 | mv -v /usr/lib/lib{readline,history}.so.* /lib 23 | chmod -v u+w /lib/lib{readline,history}.so.* 24 | ln -sfv ../../lib/$(readlink /usr/lib/libreadline.so) /usr/lib/libreadline.so 25 | ln -sfv ../../lib/$(readlink /usr/lib/libhistory.so ) /usr/lib/libhistory.so 26 | 27 | # If desired, install the documentation 28 | if [ $LFS_DOCS -eq 1 ]; then 29 | install -v -m644 doc/*.{ps,pdf,html,dvi} /usr/share/doc/readline-7.0 30 | fi 31 | 32 | popd \ 33 | && rm -rf /tmp/readline 34 | -------------------------------------------------------------------------------- /book/chapter-6/6.14-make-m4.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building M4.." 4 | echo "Approximate build time: 0.4 SBU" 5 | echo "Required disk space: 33 MB" 6 | 7 | # 6.14. The M4 package contains a macro processor. 8 | tar -xf /sources/m4-*.tar.xz -C /tmp/ \ 9 | && mv /tmp/m4-* /tmp/m4 \ 10 | && pushd /tmp/m4 11 | 12 | # First, make some fixes required by glibc-2.28: 13 | sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' lib/*.c 14 | echo "#define _IO_IN_BACKUP 0x100" >> lib/stdio-impl.h 15 | 16 | # Prepare M4 for compilation: 17 | ./configure --prefix=/usr 18 | 19 | # Compile the package: 20 | make 21 | 22 | # To test the results, issue: 23 | if [ $LFS_TEST -eq 1 ]; then make check; fi 24 | 25 | # Install the package: 26 | make install 27 | 28 | popd \ 29 | && rm -rf /tmp/m4 30 | -------------------------------------------------------------------------------- /book/chapter-6/6.15-make-bc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building Bc.." 4 | echo "Approximate build time: 0.1 SBU" 5 | echo "Required disk space: 4.1 MB" 6 | 7 | # 6.15. The Bc package contains an arbitrary precision numeric 8 | # processing language. 9 | tar -xf /sources/bc-*.tar.gz -C /tmp/ \ 10 | && mv /tmp/bc-* /tmp/bc \ 11 | && pushd /tmp/bc 12 | 13 | # First, change an internal script to use sed instead of ed: 14 | cat > bc/fix-libmath_h << "EOF" 15 | #! /bin/bash 16 | sed -e '1 s/^/{"/' \ 17 | -e 's/$/",/' \ 18 | -e '2,$ s/^/"/' \ 19 | -e '$ d' \ 20 | -i libmath.h 21 | 22 | sed -e '$ s/$/0}/' \ 23 | -i libmath.h 24 | EOF 25 | 26 | # create temporary symbolic links so the package can find the readline library 27 | ln -sv /tools/lib/libncursesw.so.6 /usr/lib/libncursesw.so.6 28 | ln -sfv libncurses.so.6 /usr/lib/libncurses.so 29 | 30 | # fix an issue in configure due to missing files in the early stages of LFS 31 | sed -i -e '/flex/s/as_fn_error/: ;; # &/' configure 32 | 33 | # build 34 | ./configure --prefix=/usr \ 35 | --with-readline \ 36 | --mandir=/usr/share/man \ 37 | --infodir=/usr/share/info 38 | make 39 | if [ $LFS_TEST -eq 1 ]; then echo "quit" | ./bc/bc -l Test/checklib.b || true; fi 40 | make install 41 | 42 | popd \ 43 | && rm -rf /tmp/bc 44 | -------------------------------------------------------------------------------- /book/chapter-6/6.16-make-binutils.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building binutils.." 4 | echo "Approximate build time: 6.6 SBU" 5 | echo "Required disk space: 4.9 Gb" 6 | 7 | # 6.16. Binutils package contains a linker, an assembler, and other tools 8 | # for handling object files 9 | tar -xf /sources/binutils-*.tar.xz -C /tmp/ \ 10 | && mv /tmp/binutils-* /tmp/binutils \ 11 | && pushd /tmp/binutils 12 | # verify that the PTYs are working properly inside the chroot environment 13 | expect -c "spawn ls" 14 | mkdir -v build 15 | cd build 16 | ../configure --prefix=/usr \ 17 | --enable-gold \ 18 | --enable-ld=default \ 19 | --enable-plugins \ 20 | --enable-shared \ 21 | --disable-werror \ 22 | --enable-64-bit-bfd \ 23 | --with-system-zlib 24 | make tooldir=/usr 25 | if [ $LFS_TEST -eq 1 ]; then make -k check || true; fi 26 | make tooldir=/usr install 27 | 28 | popd \ 29 | && rm -rf /tmp/binutils 30 | -------------------------------------------------------------------------------- /book/chapter-6/6.17-make-gmp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building GMP.." 4 | echo "Approximate build time: 1.2 SBU" 5 | echo "Required disk space: 61 MB" 6 | 7 | # 6.17. GMP package contains math libraries 8 | tar -xf /sources/gmp-*.tar.xz -C /tmp/ \ 9 | && mv /tmp/gmp-* /tmp/gmp \ 10 | && pushd /tmp/gmp 11 | 12 | # For solve bug: 13 | # libtool: error: '/usr/lib/../lib/libstdc++.la' is not a valid libtool archive 14 | rm -v /usr/lib/libstdc++.la 15 | 16 | ./configure --prefix=/usr \ 17 | --enable-cxx \ 18 | --disable-static \ 19 | --docdir=/usr/share/doc/gmp-6.1.2 20 | make 21 | make html 22 | if [ $LFS_TEST -eq 1 ]; then 23 | make check 2>&1 | tee gmp-check-log 24 | awk '/# PASS:/{total+=$3} ; END{print total}' gmp-check-log 25 | fi 26 | # continue with installation 27 | make install 28 | if [ $LFS_DOCS -eq 1 ]; then make install-html; fi 29 | 30 | popd \ 31 | && rm -rf /tmp/gmp 32 | -------------------------------------------------------------------------------- /book/chapter-6/6.18-make-mpfr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building MPFR.." 4 | echo "Approximate build time: 1.1 SBU" 5 | echo "Required disk space: 36 MB" 6 | 7 | # 6.18. MPFR package contains functions for multiple precision math 8 | tar -xf /sources/mpfr-*.tar.xz -C /tmp/ \ 9 | && mv /tmp/mpfr-* /tmp/mpfr \ 10 | && pushd /tmp/mpfr 11 | 12 | ./configure --prefix=/usr \ 13 | --disable-static \ 14 | --enable-thread-safe \ 15 | --docdir=/usr/share/doc/mpfr-4.0.1 16 | make 17 | make html 18 | if [ $LFS_TEST -eq 1 ]; then make check; fi 19 | make install 20 | if [ $LFS_DOCS -eq 1 ]; then make install-html; fi 21 | 22 | popd \ 23 | && rm -rf /tmp/mpfr 24 | -------------------------------------------------------------------------------- /book/chapter-6/6.19-make-mpc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building MPC.." 4 | echo "Approximate build time: 0.3 SBU" 5 | echo "Required disk space: 22 MB" 6 | 7 | # 6.19. The MPC package contains a library for the arithmetic of 8 | # complex numbers with arbitrarily high precision and correct 9 | # rounding of the result. 10 | tar -xf /sources/mpc-*.tar.gz -C /tmp/ \ 11 | && mv /tmp/mpc-* /tmp/mpc \ 12 | && pushd /tmp/mpc 13 | 14 | # Prepare MPC for compilation: 15 | ./configure --prefix=/usr \ 16 | --disable-static \ 17 | --docdir=/usr/share/doc/mpc-1.1.0 18 | 19 | # Compile the package and generate the HTML documentation: 20 | make 21 | make html 22 | 23 | # To test the results, issue: 24 | if [ $LFS_TEST -eq 1 ]; then make check; fi 25 | 26 | # Install the package and its documentation: 27 | make install 28 | if [ $LFS_DOCS -eq 1 ]; then make install-html; fi 29 | 30 | popd \ 31 | && rm -rf /tmp/mpc 32 | -------------------------------------------------------------------------------- /book/chapter-6/6.2-prepare-vkfs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Preparing Virtual Kernel File Systems.." 3 | 4 | # create directories onto which the file systems will be mounted 5 | mkdir -pv $LFS/{dev,proc,sys,run} 6 | 7 | # create Initial Device Nodes 8 | mknod -m 600 $LFS/dev/console c 5 1 9 | mknod -m 666 $LFS/dev/null c 1 3 10 | 11 | # mount and populate /dev 12 | mount -v --bind /dev $LFS/dev 13 | 14 | # mount Virtual Kernel File Systems 15 | mount -vt devpts devpts $LFS/dev/pts -o gid=5,mode=620 16 | mount -vt proc proc $LFS/proc 17 | mount -vt sysfs sysfs $LFS/sys 18 | mount -vt tmpfs tmpfs $LFS/run 19 | 20 | if [ -h $LFS/dev/shm ]; then 21 | mkdir -pv $LFS/$(readlink $LFS/dev/shm) 22 | fi 23 | -------------------------------------------------------------------------------- /book/chapter-6/6.20-make-shadow.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building Shadow.." 4 | echo "Approximate build time: 0.2 SBU" 5 | echo "Required disk space: 46 MB" 6 | 7 | # 6.28. The Shadow package contains programs for handling passwords 8 | # in a secure way. 9 | tar -xf /sources/shadow-*.tar.xz -C /tmp/ \ 10 | && mv /tmp/shadow-* /tmp/shadow \ 11 | && pushd /tmp/shadow 12 | 13 | touch /etc/passwd 14 | 15 | # Disable the installation of the groups program and its man pages, 16 | # as Coreutils provides a better version. Also Prevent the installation 17 | # of manual pages that were already installed by the man pages package: 18 | sed -i 's/groups$(EXEEXT) //' src/Makefile.in 19 | find man -name Makefile.in -exec sed -i 's/groups\.1 / /' {} \; 20 | find man -name Makefile.in -exec sed -i 's/getspnam\.3 / /' {} \; 21 | find man -name Makefile.in -exec sed -i 's/passwd\.5 / /' {} \; 22 | 23 | # Instead of using the default crypt method, use the more secure SHA-512 24 | # method of password encryption, which also allows passwords longer 25 | # than 8 characters. It is also necessary to change the obsolete 26 | # /var/spool/mail location for user mailboxes that Shadow uses by 27 | # default to the /var/mail location used currently: 28 | sed -i -e 's@#ENCRYPT_METHOD DES@ENCRYPT_METHOD SHA512@' \ 29 | -e 's@/var/spool/mail@/var/mail@' etc/login.defs 30 | 31 | # Make a minor change to make the first group number generated 32 | # by useradd 1000: 33 | sed -i 's/1000/999/' etc/useradd 34 | 35 | # Prepare Shadow for compilation: 36 | ./configure --sysconfdir=/etc --with-group-name-max-length=32 37 | 38 | # Compile the package: 39 | make 40 | 41 | # Install the package: 42 | make install 43 | 44 | # Move a misplaced program to its proper location: 45 | mv -v /usr/bin/passwd /bin 46 | 47 | # Segmentation failure on this stage 48 | ## To enable shadowed passwords, run the following command: 49 | #pwconv 50 | ## To enable shadowed group passwords, run: 51 | #grpconv 52 | 53 | # Cleanup 54 | popd \ 55 | && rm -rf /tmp/shadow 56 | -------------------------------------------------------------------------------- /book/chapter-6/6.21-make-gcc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building GCC.." 4 | echo "Approximate build time: 92 SBU (with tests)" 5 | echo "Required disk space: 4.0 GB" 6 | 7 | # 6.20. GCC package contains the GNU compiler collection, which 8 | # includes the C and C++ compilers 9 | tar -xf /sources/gcc-*.tar.xz -C /tmp/ \ 10 | && mv /tmp/gcc-* /tmp/gcc \ 11 | && pushd /tmp/gcc 12 | 13 | # If building on x86_64, change the default directory name for 14 | # 64-bit libraries to “lib”: 15 | case $(uname -m) in 16 | x86_64) 17 | sed -e '/m64=/s/lib64/lib/' \ 18 | -i.orig gcc/config/i386/t-linux64 19 | ;; 20 | esac 21 | 22 | # Remove the symlink created earlier as the final gcc includes will 23 | # be installed here 24 | rm -f /usr/lib/gcc 25 | 26 | # The GCC documentation recommends building GCC in a dedicated 27 | # build directory: 28 | mkdir -v build 29 | cd build 30 | 31 | # prepare for compilation 32 | SED=sed \ 33 | ../configure --prefix=/usr \ 34 | --enable-languages=c,c++ \ 35 | --disable-multilib \ 36 | --disable-bootstrap \ 37 | --disable-libmpx \ 38 | --with-system-zlib 39 | 40 | # Compile the package: 41 | make 42 | 43 | # Test the results, but do not stop at errors: 44 | if [ $LFS_TEST -eq 1 ]; then 45 | # One set of tests in the GCC test suite is known to exhaust the 46 | # stack, so increase the stack size prior to running the tests: 47 | ulimit -s 32768 48 | 49 | # Remove one test known to cause a problem: 50 | rm ../gcc/testsuite/g++.dg/pr83239.C 51 | 52 | # Test the results as a non-privileged user, but do not stop at errors: 53 | chown -Rv nobody . 54 | su nobody -s /bin/bash -c "PATH=$PATH make -k check" || true 55 | 56 | # To receive a summary of the test suite results, run: 57 | ../contrib/test_summary | grep -A7 Summ 58 | fi 59 | 60 | # Install the package: 61 | make install 62 | 63 | # Create a symlink required by the FHS for "historical" reasons. 64 | ln -sv ../usr/bin/cpp /lib 65 | 66 | # Many packages use the name cc to call the C compiler. 67 | # To satisfy those packages, create a symlink: 68 | ln -sv gcc /usr/bin/cc 69 | 70 | # Add a compatibility symlink to enable building programs with 71 | # Link Time Optimization (LTO): 72 | install -v -dm755 /usr/lib/bfd-plugins 73 | ln -sfv ../../libexec/gcc/$(gcc -dumpmachine)/8.2.0/liblto_plugin.so \ 74 | /usr/lib/bfd-plugins/ 75 | 76 | # Now that our final toolchain is in place, it is important to again 77 | # ensure that compiling and linking will work as expected. We do this 78 | # by performing the same sanity checks as we did earlier in the chapter: 79 | echo 'int main(){}' > dummy.c 80 | cc dummy.c -v -Wl,--verbose &> dummy.log 81 | readelf -l a.out | grep ': /lib' 82 | 83 | # Now make sure that we're setup to use the correct start files 84 | grep -o '/usr/lib.*/crt[1in].*succeeded' dummy.log 85 | 86 | # Verify that the compiler is searching for the correct header files: 87 | grep -B4 '^ /usr/include' dummy.log 88 | 89 | # Next, verify that the new linker is being used with the correct search paths: 90 | grep 'SEARCH.*/usr/lib' dummy.log |sed 's|; |\n|g' 91 | 92 | # Next make sure that we're using the correct libc: 93 | grep "/lib.*/libc.so.6 " dummy.log 94 | 95 | # Lastly, make sure GCC is using the correct dynamic linker: 96 | grep found dummy.log 97 | 98 | # Once everything is working correctly, clean up the test files: 99 | rm -v dummy.c a.out dummy.log 100 | 101 | # Finally, move a misplaced file: 102 | mkdir -pv /usr/share/gdb/auto-load/usr/lib 103 | mv -v /usr/lib/*gdb.py /usr/share/gdb/auto-load/usr/lib 104 | 105 | # Cleanup 106 | popd \ 107 | && rm -rf /tmp/gcc 108 | -------------------------------------------------------------------------------- /book/chapter-6/6.22-make-bzip2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building bzip2.." 4 | echo "Approximate build time: less than 0.1 SBU" 5 | echo "Required disk space: 2.3 MB" 6 | 7 | # 6.21. Bzip2 package contains programs for compressing and decompressing files. 8 | # Compressing text files with bzip2 yields a much better compression percentage 9 | # than with the traditional gzip 10 | tar -xf /sources/bzip2-*.tar.gz -C /tmp/ \ 11 | && mv /tmp/bzip2-* /tmp/bzip2 \ 12 | && pushd /tmp/bzip2 13 | 14 | # The following command ensures installation of symbolic links are relative 15 | patch -Np1 -i /sources/bzip2-1.0.6-install_docs-1.patch 16 | 17 | # Ensure the man pages are installed into the correct location 18 | sed -i 's@\(ln -s -f \)$(PREFIX)/bin/@\1@' Makefile 19 | 20 | # Prepare Bzip2 for compilation with: 21 | make -f Makefile-libbz2_so 22 | make clean 23 | 24 | # Compile and test the package: 25 | make 26 | 27 | # Install the programs: 28 | make PREFIX=/usr install 29 | 30 | # Install the shared bzip2 binary into the /bin directory, make some 31 | # necessary symbolic links, and clean up: 32 | cp -v bzip2-shared /bin/bzip2 33 | cp -av libbz2.so* /lib 34 | # Don't stop on error 35 | ln -sv ../../lib/libbz2.so.1.0 /usr/lib/libbz2.so || true 36 | rm -v /usr/bin/{bunzip2,bzcat,bzip2} 37 | ln -sv bzip2 /bin/bunzip2 38 | ln -sv bzip2 /bin/bzcat 39 | 40 | # Cleanup 41 | popd \ 42 | && rm -rf /tmp/bzip2 43 | -------------------------------------------------------------------------------- /book/chapter-6/6.23-make-pkg-config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building pkg config.." 4 | echo "Approximate build time: 0.4 SBU" 5 | echo "Required disk space: 30 MB" 6 | 7 | # 6.22. Pkg-config package contains a tool for passing the include path 8 | # and/or library paths to build tools during the configure and make file execution 9 | tar -xf /sources/pkg-config-*.tar.gz -C /tmp/ \ 10 | && mv /tmp/pkg-config-* /tmp/pkg-config \ 11 | && pushd /tmp/pkg-config 12 | 13 | ./configure --prefix=/usr \ 14 | --with-internal-glib \ 15 | --disable-host-tool \ 16 | --docdir=/usr/share/doc/pkg-config-0.29.2 17 | make 18 | if [ $LFS_TEST -eq 1 ]; then make check; fi 19 | make install 20 | 21 | popd \ 22 | && rm -rf /tmp/pkg-config 23 | -------------------------------------------------------------------------------- /book/chapter-6/6.24-make-ncurses.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building ncurses.." 4 | echo "Approximate build time: 0.4 SBU" 5 | echo "Required disk space: 42 MB" 6 | 7 | # 6.23. Ncurses package contains libraries for terminal-independent 8 | # handling of character screens 9 | tar -xf /sources/ncurses-*.tar.gz -C /tmp/ \ 10 | && mv /tmp/ncurses-* /tmp/ncurses \ 11 | && pushd /tmp/ncurses 12 | 13 | # Prepare Ncurses for compilation: 14 | ./configure --prefix=/usr \ 15 | --mandir=/usr/share/man \ 16 | --with-shared \ 17 | --without-debug \ 18 | --without-normal \ 19 | --enable-pc-files \ 20 | --enable-widec 21 | 22 | # Compile the package: 23 | make 24 | 25 | # Install the package: 26 | make install 27 | 28 | # Move the shared libraries to the /lib directory, 29 | # where they are expected to reside: 30 | mv -v /usr/lib/libncursesw.so.6* /lib 31 | 32 | # Because the libraries have been moved, one symlink points to a 33 | # non-existent file. Recreate it: 34 | ln -sfv ../../lib/$(readlink /usr/lib/libncursesw.so) /usr/lib/libncursesw.so 35 | 36 | # Many applications still expect the linker to be able to find 37 | # non-wide-character Ncurses libraries. Trick such applications 38 | # into linking with wide-character libraries by means of 39 | # symlinks and linker scripts: 40 | for lib in ncurses form panel menu ; do 41 | rm -vf /usr/lib/lib${lib}.so 42 | echo "INPUT(-l${lib}w)" > /usr/lib/lib${lib}.so 43 | ln -sfv ${lib}w.pc /usr/lib/pkgconfig/${lib}.pc 44 | done 45 | 46 | # Finally, make sure that old applications that look for -lcurses 47 | # at build time are still buildable: 48 | rm -vf /usr/lib/libcursesw.so 49 | echo "INPUT(-lncursesw)" > /usr/lib/libcursesw.so 50 | ln -sfv libncurses.so /usr/lib/libcurses.so 51 | 52 | # If desired, install the Ncurses documentation: 53 | if [ $LFS_DOCS -eq 1 ]; then 54 | mkdir -v /usr/share/doc/ncurses-6.1 55 | cp -v -R doc/* /usr/share/doc/ncurses-6.1 56 | fi 57 | 58 | # cleanup 59 | popd \ 60 | && rm -rf /tmp/ncurses 61 | -------------------------------------------------------------------------------- /book/chapter-6/6.25-make-attr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building Attr.." 4 | echo "Approximate build time: less than 0.1 SBU" 5 | echo "Required disk space: 4.2 MB" 6 | 7 | # 6.24. The Attr package contains utilities to administer the extended 8 | # attributes on filesystem objects 9 | tar -xf /sources/attr-*.tar.gz -C /tmp/ \ 10 | && mv /tmp/attr-* /tmp/attr \ 11 | && pushd /tmp/attr 12 | 13 | # Prepare Attr for compilation: 14 | ./configure --prefix=/usr \ 15 | --bindir=/bin \ 16 | --disable-static \ 17 | --sysconfdir=/etc \ 18 | --docdir=/usr/share/doc/attr-2.4.48 19 | 20 | # Compile the package: 21 | make 22 | 23 | # To test the results, issue: 24 | if [ $LFS_TEST -eq 1 ]; then make check; fi 25 | 26 | # Install the package: 27 | make install 28 | 29 | # The shared library needs to be moved to /lib, and as a result the 30 | # .so file in /usr/lib will need to be recreated: 31 | mv -v /usr/lib/libattr.so.* /lib 32 | ln -sfv ../../lib/$(readlink /usr/lib/libattr.so) /usr/lib/libattr.so 33 | 34 | # Cleanup 35 | popd \ 36 | && rm -rf /tmp/attr 37 | -------------------------------------------------------------------------------- /book/chapter-6/6.26-make-acl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building Acl.." 4 | echo "Approximate build time: less than 0.1 SBU" 5 | echo "Required disk space: 6.4 MB" 6 | 7 | # 6.25. The Acl package contains utilities to administer Access Control 8 | # Lists, which are used to define more fine-grained discretionary access 9 | # rights for files and directories 10 | tar -xf /sources/acl-*.tar.gz -C /tmp/ \ 11 | && mv /tmp/acl-* /tmp/acl \ 12 | && pushd /tmp/acl 13 | 14 | # Prepare Acl for compilation: 15 | ./configure --prefix=/usr \ 16 | --bindir=/bin \ 17 | --disable-static \ 18 | --libexecdir=/usr/lib \ 19 | --docdir=/usr/share/doc/acl-2.2.53 20 | 21 | # Compile the package: 22 | make 23 | 24 | # Install the package: 25 | make install 26 | 27 | # The shared library needs to be moved to /lib, and as a result the 28 | # .so file in /usr/lib will need to be recreated: 29 | mv -v /usr/lib/libacl.so.* /lib 30 | ln -sfv ../../lib/$(readlink /usr/lib/libacl.so) /usr/lib/libacl.so 31 | 32 | # Cleanup 33 | popd \ 34 | && rm -rf /tmp/acl 35 | -------------------------------------------------------------------------------- /book/chapter-6/6.27-make-libcap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building Libcap.." 4 | echo "Approximate build time: less than 0.1 SBU" 5 | echo "Required disk space: 1.4 MB" 6 | 7 | # 6.26. The Libcap package implements the user-space interfaces to the 8 | # POSIX 1003.1e capabilities available in Linux kernels. These 9 | # capabilities are a partitioning of the all powerful root privilege 10 | # into a set of distinct privileges 11 | tar -xf /sources/libcap-*.tar.xz -C /tmp/ \ 12 | && mv /tmp/libcap-* /tmp/libcap \ 13 | && pushd /tmp/libcap 14 | 15 | # Prevent a static library from being installed: 16 | sed -i '/install.*STALIBNAME/d' libcap/Makefile 17 | 18 | # Compile the package: 19 | make 20 | 21 | # Install the package: 22 | make RAISE_SETFCAP=no lib=lib prefix=/usr install 23 | chmod -v 755 /usr/lib/libcap.so 24 | 25 | # The shared library needs to be moved to /lib, and as a result the 26 | # .so file in /usr/lib will need to be recreated: 27 | mv -v /usr/lib/libcap.so.* /lib 28 | ln -sfv ../../lib/$(readlink /usr/lib/libcap.so) /usr/lib/libcap.so 29 | 30 | # Cleanup 31 | popd \ 32 | && rm -rf /tmp/libcap 33 | -------------------------------------------------------------------------------- /book/chapter-6/6.28-make-sed.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building Sed.." 4 | echo "Approximate build time: 0.5 SBU" 5 | echo "Required disk space: 30 MB" 6 | 7 | # 6.27. Sed package contains a stream editor 8 | tar -xf /sources/sed-*.tar.xz -C /tmp/ \ 9 | && mv /tmp/sed-* /tmp/sed \ 10 | && pushd /tmp/sed 11 | 12 | # First fix an issue in the LFS environment and remove a failing test: 13 | sed -i 's/usr/tools/' build-aux/help2man 14 | sed -i 's/testsuite.panic-tests.sh//' Makefile.in 15 | 16 | # Prepare Sed for compilation: 17 | ./configure --prefix=/usr --bindir=/bin 18 | 19 | # Compile the package and generate the HTML documentation: 20 | make 21 | make html 22 | 23 | # To test the results, issue: 24 | if [ $LFS_TEST -eq 1 ]; then make check; fi 25 | 26 | # Install the package and its documentation: 27 | make install 28 | if [ $LFS_DOCS -eq 1 ]; then 29 | install -d -m755 /usr/share/doc/sed-4.5 30 | install -m644 doc/sed.html /usr/share/doc/sed-4.5 31 | fi 32 | 33 | # Cleanup 34 | popd \ 35 | && rm -rf /tmp/sed 36 | -------------------------------------------------------------------------------- /book/chapter-6/6.29-make-psmisc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building Psmisc.." 4 | echo "Approximate build time: less than 0.1 SBU" 5 | echo "Required disk space: 4.3 MB" 6 | 7 | # 6.29. Psmisc package contains programs for displaying information 8 | # about running processes 9 | tar -xf /sources/psmisc-*.tar.xz -C /tmp/ \ 10 | && mv /tmp/psmisc-* /tmp/psmisc \ 11 | && pushd /tmp/psmisc 12 | 13 | ./configure --prefix=/usr 14 | make 15 | make install 16 | mv -v /usr/bin/fuser /bin 17 | mv -v /usr/bin/killall /bin 18 | # cleanup 19 | popd \ 20 | && rm -rf /tmp/psmisc 21 | -------------------------------------------------------------------------------- /book/chapter-6/6.30-make-iana-etc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building Iana-Etc.." 4 | echo "Approximate build time: less than 0.1 SBU" 5 | echo "Required disk space: 2.3 MB" 6 | 7 | # 6.30. Iana-Etc package provides data for network services and protocols 8 | tar -xf /sources/iana-etc-*.tar.bz2 -C /tmp/ \ 9 | && mv /tmp/iana-etc-* /tmp/iana-etc \ 10 | && pushd /tmp/iana-etc 11 | 12 | make 13 | make install 14 | # cleanup 15 | popd \ 16 | && rm -rf /tmp/iana-etc 17 | -------------------------------------------------------------------------------- /book/chapter-6/6.31-make-bison.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building Bison.." 4 | echo "Approximate build time: 0.3 SBU" 5 | echo "Required disk space: 35 MB" 6 | 7 | # 6.31. Bison package contains a parser generator 8 | tar -xf /sources/bison-*.tar.xz -C /tmp/ \ 9 | && mv /tmp/bison-* /tmp/bison \ 10 | && pushd /tmp/bison 11 | 12 | ./configure --prefix=/usr --docdir=/usr/share/doc/bison-3.0.5 13 | make 14 | make install 15 | # cleanup 16 | popd \ 17 | && rm -rf /tmp/bison 18 | -------------------------------------------------------------------------------- /book/chapter-6/6.32-make-flex.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building Flex.." 4 | echo "Approximate build time: 0.4 SBU" 5 | echo "Required disk space: 35 MB" 6 | 7 | # 6.32. Flex package contains a utility for generating programs 8 | # that recognize patterns in text 9 | tar -xf /sources/flex-*.tar.gz -C /tmp/ \ 10 | && mv /tmp/flex-* /tmp/flex \ 11 | && pushd /tmp/flex 12 | # fix a problem introduced with glibc-2.26 13 | sed -i "/math.h/a #include " src/flexdef.h 14 | # prepare for compilation 15 | HELP2MAN=/tools/bin/true \ 16 | ./configure --prefix=/usr --docdir=/usr/share/doc/flex-2.6.4 17 | # compile and install 18 | make 19 | if [ $LFS_TEST -eq 1 ]; then make check; fi 20 | make install 21 | # Don't stop on error 22 | ln -sv flex /usr/bin/lex || true 23 | # cleanup 24 | popd \ 25 | && rm -rf /tmp/flex 26 | -------------------------------------------------------------------------------- /book/chapter-6/6.33-make-grep.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building Grep.." 4 | echo "Approximate build time: 0.4 SBU" 5 | echo "Required disk space: 31 MB" 6 | 7 | # 6.33. Grep package contains programs for searching through files 8 | tar -xf /sources/grep-*.tar.xz -C /tmp/ \ 9 | && mv /tmp/grep-* /tmp/grep \ 10 | && pushd /tmp/grep 11 | 12 | ./configure --prefix=/usr --bindir=/bin 13 | make 14 | if [ $LFS_TEST -eq 1 ]; then make check; fi 15 | make install 16 | # cleanup 17 | popd \ 18 | && rm -rf /tmp/grep 19 | -------------------------------------------------------------------------------- /book/chapter-6/6.34-make-bash.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building bash" 4 | echo "Approximate build time: 2.1 SBU" 5 | echo "Required disk space: 58 MB" 6 | 7 | # 6.34. Bash package contains the Bourne-Again SHell 8 | tar -xf /sources/bash-*.tar.gz -C /tmp/ \ 9 | && mv /tmp/bash-* /tmp/bash \ 10 | && pushd /tmp/bash 11 | 12 | # prepare bash 13 | ./configure --prefix=/usr \ 14 | --docdir=/usr/share/doc/bash-4.4.18 \ 15 | --without-bash-malloc \ 16 | --with-installed-readline 17 | 18 | # Compile the package 19 | make 20 | 21 | # Run tests 22 | if [ $LFS_TEST -eq 1 ]; then 23 | # To prepare the tests, ensure that the nobody user can write to the sources tree 24 | chown -Rv nobody . 25 | # Now, run the tests as the nobody user: 26 | su nobody -s /bin/bash -c "PATH=$PATH make tests" 27 | fi 28 | 29 | # Install the package and move the main executable to /bin 30 | make install 31 | mv -vf /usr/bin/bash /bin 32 | 33 | # cleanup 34 | popd \ 35 | && rm -rf /tmp/bash 36 | -------------------------------------------------------------------------------- /book/chapter-6/6.35-make-libtool.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building libtool.." 4 | echo "Approximate build time: 1.9 SBU" 5 | echo "Required disk space: 43 MB" 6 | 7 | # 6.35. Libtool package contains the GNU generic library support script. It wraps 8 | # the complexity of using shared libraries in a consistent, portable interface 9 | tar -xf /sources/libtool-*.tar.xz -C /tmp/ \ 10 | && mv /tmp/libtool-* /tmp/libtool \ 11 | && pushd /tmp/libtool 12 | 13 | ./configure --prefix=/usr 14 | make 15 | # Five tests are known to fail in the LFS build environment due to a circular 16 | # dependency, but all tests pass if rechecked after automake is installed 17 | if [ $LFS_TEST -eq 1 ]; then make check || true; fi 18 | make install 19 | # cleanup 20 | popd \ 21 | && rm -rf /tmp/libtool 22 | -------------------------------------------------------------------------------- /book/chapter-6/6.36-make-gdbm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building GDBM.." 4 | echo "Approximate build time: 0.1 SBU" 5 | echo "Required disk space: 11 MB" 6 | 7 | # 6.36. GDBM package contains the GNU Database Manager. It is a library of 8 | # database functions that use extensible hashing and work similar to the 9 | # standard UNIX dbm. The library provides primitives for storing key/data pairs, 10 | # searching and retrieving the data by its key and deleting a key along with its data 11 | tar -xf /sources/gdbm-*.tar.gz -C /tmp/ \ 12 | && mv /tmp/gdbm-* /tmp/gdbm \ 13 | && pushd /tmp/gdbm 14 | 15 | ./configure --prefix=/usr \ 16 | --disable-static \ 17 | --enable-libgdbm-compat 18 | make 19 | if [ $LFS_TEST -eq 1 ]; then make check; fi 20 | make install 21 | # cleanup 22 | popd \ 23 | && rm -rf /tmp/gdbm 24 | -------------------------------------------------------------------------------- /book/chapter-6/6.37-make-gperf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building gperf.." 4 | echo "Approximate build time: less than 0.1 SBU" 5 | echo "Required disk space: 6.3 MB" 6 | 7 | # 6.37. Gperf generates a perfect hash function from a key set 8 | tar -xf /sources/gperf-*.tar.gz -C /tmp/ \ 9 | && mv /tmp/gperf-* /tmp/gperf \ 10 | && pushd /tmp/gperf 11 | # prepare 12 | ./configure --prefix=/usr --docdir=/usr/share/doc/gperf-3.1 13 | # compile and install 14 | make 15 | if [ $LFS_TEST -eq 1 ]; then make -j1 check; fi 16 | make install 17 | # cleanup 18 | popd \ 19 | && rm -rf /tmp/gperf 20 | -------------------------------------------------------------------------------- /book/chapter-6/6.38-make-expat.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building Expat.." 4 | echo "Approximate build time: 0.1 SBU" 5 | echo "Required disk space: 11 MB" 6 | 7 | # 6.38. The Expat package contains a stream oriented C library for 8 | # parsing XML. 9 | tar -xf /sources/expat-*.tar.bz2 -C /tmp/ \ 10 | && mv /tmp/expat-* /tmp/expat \ 11 | && pushd /tmp/expat 12 | 13 | # First fix a problem with the regession tests in the LFS environment 14 | sed -i 's|usr/bin/env |bin/|' run.sh.in 15 | 16 | # Prepare Expat for compilation: 17 | ./configure --prefix=/usr \ 18 | --disable-static \ 19 | --docdir=/usr/share/doc/expat-2.2.6 20 | 21 | # Compile the package: 22 | make 23 | 24 | # To test the results, issue: 25 | if [ $LFS_TEST -eq 1 ]; then make check; fi 26 | 27 | # Install the package: 28 | make install 29 | 30 | # If desired, install the documentation: 31 | if [ $LFS_DOCS -eq 1 ]; then 32 | install -v -m644 doc/*.{html,png,css} /usr/share/doc/expat-2.2.6 33 | fi 34 | 35 | # Cleanup 36 | popd \ 37 | && rm -rf /tmp/expat 38 | -------------------------------------------------------------------------------- /book/chapter-6/6.39-make-inetutils.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building Inetutils.." 4 | echo "Approximate build time: 0.4 SBU" 5 | echo "Required disk space: 29 MB" 6 | 7 | # 6.39. The Inetutils package contains programs for basic networking. 8 | tar -xf /sources/inetutils-*.tar.xz -C /tmp/ \ 9 | && mv /tmp/inetutils-* /tmp/inetutils \ 10 | && pushd /tmp/inetutils 11 | 12 | # prepare 13 | ./configure --prefix=/usr \ 14 | --localstatedir=/var \ 15 | --disable-logger \ 16 | --disable-whois \ 17 | --disable-rcp \ 18 | --disable-rexec \ 19 | --disable-rlogin \ 20 | --disable-rsh \ 21 | --disable-servers 22 | 23 | # Compile the package: 24 | make 25 | 26 | # One test, libls.sh, may fail in the initial chroot environment but will pass 27 | # if the test is rerun after the LFS system is complete 28 | if [ $LFS_TEST -eq 1 ]; then make check || true; fi 29 | 30 | # Install the package: 31 | make install 32 | 33 | # Move some programs so they are available if /usr is not accessible: 34 | mv -v /usr/bin/{hostname,ping,ping6,traceroute} /bin 35 | mv -v /usr/bin/ifconfig /sbin 36 | 37 | # cleanup 38 | popd \ 39 | && rm -rf /tmp/inetutils 40 | -------------------------------------------------------------------------------- /book/chapter-6/6.40-make-perl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building perl.." 4 | echo "Approximate build time: 9.1 SBU" 5 | echo "Required disk space: 274 MB" 6 | 7 | # 6.40. Perl package contains the Practical Extraction and Report Language 8 | tar -xf /sources/perl-*.tar.xz -C /tmp/ \ 9 | && mv /tmp/perl-* /tmp/perl \ 10 | && pushd /tmp/perl 11 | 12 | # First create a basic /etc/hosts file to be referenced in one of 13 | # Perl's configuration files as well as the optional test suite: 14 | echo "127.0.0.1 localhost $(hostname)" > /etc/hosts 15 | 16 | # use libs installed in system 17 | export BUILD_ZLIB=False 18 | export BUILD_BZIP2=0 19 | 20 | # configure 21 | sh Configure -des -Dprefix=/usr \ 22 | -Dvendorprefix=/usr \ 23 | -Dman1dir=/usr/share/man/man1 \ 24 | -Dman3dir=/usr/share/man/man3 \ 25 | -Dpager="/usr/bin/less -isR" \ 26 | -Duseshrplib \ 27 | -Dusethreads 28 | 29 | # Compile the package: 30 | make 31 | 32 | # Several tests related to zlib will fail due to using the system 33 | # version of zlib instead of the internal version 34 | if [ $LFS_TEST -eq 1 ]; then make -k test || true; fi 35 | 36 | # Install the package and clean up: 37 | make install 38 | unset BUILD_ZLIB BUILD_BZIP2 39 | 40 | # Cleanup 41 | popd \ 42 | && rm -rf /tmp/perl 43 | -------------------------------------------------------------------------------- /book/chapter-6/6.41-make-xml-parser.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building XML::Parser.." 4 | echo "Approximate build time: less than 0.1 SBU" 5 | echo "Required disk space: 2.1 MB" 6 | 7 | # 6.41. The XML::Parser module is a Perl interface to James Clark's 8 | # XML parser, Expat. 9 | tar -xf /sources/XML-Parser-*.tar.gz -C /tmp/ \ 10 | && mv /tmp/XML-Parser-* /tmp/XML-Parser \ 11 | && pushd /tmp/XML-Parser 12 | 13 | # Prepare XML::Parser for compilation: 14 | perl Makefile.PL 15 | 16 | # Compile the package: 17 | make 18 | 19 | # To test the results, issue: 20 | if [ $LFS_TEST -eq 1 ]; then make test; fi 21 | 22 | # Install the package: 23 | make install 24 | 25 | # Cleanup 26 | popd \ 27 | && rm -rf /tmp/XML-Parser 28 | -------------------------------------------------------------------------------- /book/chapter-6/6.42-make-intltool.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building Intltool.." 4 | echo "Approximate build time: less than 0.1 SBU" 5 | echo "Required disk space: 1.5 MB" 6 | 7 | # 6.42. Intltool is an internationalization tool used for extracting 8 | # translatable strings from source files 9 | tar -xf /sources/intltool-*.tar.gz -C /tmp/ \ 10 | && mv /tmp/intltool-* /tmp/intltool \ 11 | && pushd /tmp/intltool 12 | 13 | # First fix a warning that is caused by perl-5.22 and later: 14 | sed -i 's:\\\${:\\\$\\{:' intltool-update.in 15 | 16 | # Prepare Intltool for compilation: 17 | ./configure --prefix=/usr 18 | 19 | # Compile the package: 20 | make 21 | 22 | # To test the results, issue: 23 | if [ $LFS_TEST -eq 1 ]; then make check; fi 24 | 25 | # Install the package: 26 | make install 27 | install -v -Dm644 doc/I18N-HOWTO /usr/share/doc/intltool-0.51.0/I18N-HOWTO 28 | 29 | # Cleanup 30 | popd \ 31 | && rm -rf /tmp/intltool 32 | -------------------------------------------------------------------------------- /book/chapter-6/6.43-make-autoconf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building Autoconf.." 4 | echo "Approximate build time: less than 0.1 SBU (about 3.2 SBU with tests)" 5 | echo "Required disk space: 17.3 MB" 6 | 7 | # 6.43. Autoconf package contains programs for producing shell scripts 8 | # that can automatically configure source code 9 | tar -xf /sources/autoconf-*.tar.xz -C /tmp/ \ 10 | && mv /tmp/autoconf-* /tmp/autoconf \ 11 | && pushd /tmp/autoconf 12 | 13 | ./configure --prefix=/usr 14 | make 15 | if [ $LFS_TEST -eq 1 ]; then make check || true; fi 16 | make install 17 | # cleanup 18 | popd \ 19 | && rm -rf /tmp/autoconf 20 | -------------------------------------------------------------------------------- /book/chapter-6/6.44-make-automake.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building Automake.." 4 | echo "Approximate build time: less than 0.1 SBU (about 8.4 SBU with tests)" 5 | echo "Required disk space: 109 MB" 6 | 7 | # 6.44. Automake package contains programs for generating Makefiles 8 | # for use with Autoconf 9 | tar -xf /sources/automake-*.tar.xz -C /tmp/ \ 10 | && mv /tmp/automake-* /tmp/automake \ 11 | && pushd /tmp/automake 12 | 13 | ./configure --prefix=/usr --docdir=/usr/share/doc/automake-1.16.1 14 | make 15 | if [ $LFS_TEST -eq 1 ]; then make -j4 check || true; fi 16 | make install 17 | # cleanup 18 | popd \ 19 | && rm -rf /tmp/automake 20 | -------------------------------------------------------------------------------- /book/chapter-6/6.45-make-xz.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building Xz.." 4 | echo "Approximate build time: 0.2 SBU" 5 | echo "Required disk space: 16 MB" 6 | 7 | # 6.45. Xz package contains programs for compressing and decompressing files. 8 | # It provides capabilities for the lzma and the newer xz compression formats 9 | tar -xf /sources/xz-*.tar.xz -C /tmp/ \ 10 | && mv /tmp/xz-* /tmp/xz \ 11 | && pushd /tmp/xz 12 | 13 | ./configure --prefix=/usr \ 14 | --disable-static \ 15 | --docdir=/usr/share/doc/xz-5.2.4 16 | make 17 | if [ $LFS_TEST -eq 1 ]; then make check; fi 18 | make install 19 | mv -v /usr/bin/{lzma,unlzma,lzcat,xz,unxz,xzcat} /bin 20 | mv -v /usr/lib/liblzma.so.* /lib 21 | ln -svf ../../lib/$(readlink /usr/lib/liblzma.so) /usr/lib/liblzma.so 22 | # cleanup 23 | popd \ 24 | && rm -rf /tmp/xz 25 | -------------------------------------------------------------------------------- /book/chapter-6/6.46-make-kmod.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building kmod.." 4 | echo "Approximate build time: 0.1 SBU" 5 | echo "Required disk space: 13 MB" 6 | 7 | # 6.46. Kmod package contains libraries and utilities for loading kernel modules 8 | tar -xf /sources/kmod-*.tar.xz -C /tmp/ \ 9 | && mv /tmp/kmod-* /tmp/kmod \ 10 | && pushd /tmp/kmod 11 | 12 | ./configure --prefix=/usr \ 13 | --bindir=/bin \ 14 | --sysconfdir=/etc \ 15 | --with-rootlibdir=/lib \ 16 | --with-xz \ 17 | --with-zlib 18 | make 19 | make install 20 | # create symlinks for compatibility with Module-Init-Tools (the package that 21 | # previously handled Linux kernel modules) 22 | for target in depmod insmod lsmod modinfo modprobe rmmod; do 23 | ln -sfv ../bin/kmod /sbin/$target 24 | done 25 | ln -sfv kmod /bin/lsmod 26 | # cleanup 27 | popd \ 28 | && rm -rf /tmp/kmod 29 | -------------------------------------------------------------------------------- /book/chapter-6/6.47-make-gettext.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building gettext.." 4 | echo "Approximate build time: 2.6 SBU" 5 | echo "Required disk space: 210 MB" 6 | 7 | # 6.47. Gettext package contains utilities for internationalization and 8 | # localization. These allow programs to be compiled with NLS 9 | # (Native Language Support), enabling them to output messages in the 10 | # user's native language 11 | tar -xf /sources/gettext-*.tar.xz -C /tmp/ \ 12 | && mv /tmp/gettext-* /tmp/gettext \ 13 | && pushd /tmp/gettext 14 | 15 | # First, suppress two invocations of test-lock which on some machines can loop forever: 16 | sed -i '/^TESTS =/d' gettext-runtime/tests/Makefile.in && 17 | sed -i 's/test-lock..EXEEXT.//' gettext-tools/gnulib-tests/Makefile.in 18 | 19 | # Now fix a configuration file: 20 | sed -e '/AppData/{N;N;p;s/\.appdata\./.metainfo./}' \ 21 | -i gettext-tools/its/appdata.loc 22 | 23 | # prepare for compilation 24 | ./configure --prefix=/usr \ 25 | --disable-static \ 26 | --docdir=/usr/share/doc/gettext-0.19.8.1 27 | 28 | # compile, test, install 29 | make 30 | if [ $LFS_TEST -eq 1 ]; then make check; fi 31 | make install 32 | chmod -v 0755 /usr/lib/preloadable_libintl.so 33 | # cleanup 34 | popd \ 35 | && rm -rf /tmp/gettext 36 | -------------------------------------------------------------------------------- /book/chapter-6/6.48-make-libelf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building Libelf.." 4 | echo "Approximate build time: 1.0 SBU" 5 | echo "Required disk space: 91 MB" 6 | 7 | # 6.48. Libelf is a library for handling ELF (Executable and Linkable 8 | # Format) files. 9 | tar -xf /sources/elfutils-*.tar.bz2 -C /tmp/ \ 10 | && mv /tmp/elfutils-* /tmp/elfutils \ 11 | && pushd /tmp/elfutils 12 | # prepare for compilation 13 | ./configure --prefix=/usr 14 | # compile, test and install 15 | make 16 | # run tests 17 | if [ $LFS_TEST -eq 1 ]; then make check || true; fi 18 | make -C libelf install 19 | install -vm644 config/libelf.pc /usr/lib/pkgconfig 20 | # cleanup 21 | popd \ 22 | && rm -rf /tmp/elfutils 23 | -------------------------------------------------------------------------------- /book/chapter-6/6.49-make-libffi.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building Libffi.." 4 | echo "Approximate build time: 0.4 SBU" 5 | echo "Required disk space: 7.6 MB" 6 | 7 | # 6.49. The Libffi library provides a portable, high level programming 8 | # interface to various calling conventions. This allows a programmer 9 | # to call any function specified by a call interface description at 10 | # run time. 11 | tar -xf /sources/libffi-*.tar.gz -C /tmp/ \ 12 | && mv /tmp/libffi-* /tmp/libffi \ 13 | && pushd /tmp/libffi 14 | 15 | # Modify the Makefile to install headers into the standard /usr/include directory instead of /usr/lib/libffi-3.2.1/include. 16 | sed -e '/^includesdir/ s/$(libdir).*$/$(includedir)/' \ 17 | -i include/Makefile.in 18 | sed -e '/^includedir/ s/=.*$/=@includedir@/' \ 19 | -e 's/^Cflags: -I${includedir}/Cflags:/' \ 20 | -i libffi.pc.in 21 | 22 | # prepare for compilation 23 | ./configure --prefix=/usr --disable-static --with-gcc-arch=native 24 | # compile, test and install 25 | make 26 | # run tests 27 | if [ $LFS_TEST -eq 1 ]; then make check || true; fi 28 | make install 29 | # cleanup 30 | popd \ 31 | && rm -rf /tmp/libffi 32 | -------------------------------------------------------------------------------- /book/chapter-6/6.5-create-directories.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # create directories 5 | mkdir -pv /{bin,boot,etc/{opt,sysconfig},home,lib/firmware,mnt,opt} 6 | mkdir -pv /{media/{floppy,cdrom},sbin,srv,var} 7 | install -dv -m 0750 /root 8 | install -dv -m 1777 /tmp /var/tmp 9 | mkdir -pv /usr/{,local/}{bin,include,lib,sbin,src} 10 | mkdir -pv /usr/{,local/}share/{color,dict,doc,info,locale,man} 11 | mkdir -v /usr/{,local/}share/{misc,terminfo,zoneinfo} 12 | mkdir -v /usr/libexec 13 | mkdir -pv /usr/{,local/}share/man/man{1..8} 14 | 15 | case $(uname -m) in 16 | x86_64) mkdir -v /lib64 ;; 17 | esac 18 | 19 | mkdir -v /var/{log,mail,spool} 20 | ln -sv /run /var/run 21 | ln -sv /run/lock /var/lock 22 | mkdir -pv /var/{opt,cache,lib/{color,misc,locate},local} 23 | -------------------------------------------------------------------------------- /book/chapter-6/6.50-make-openssl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building OpenSSL.." 4 | echo "Approximate build time: 1.7 SBU" 5 | echo "Required disk space: 75 MB" 6 | 7 | # 6.50. The OpenSSL package contains management tools and libraries relating to cryptography. 8 | # These are useful for providing cryptographic functions to other packages, such as OpenSSH, 9 | # email applications and web browsers (for accessing HTTPS sites). 10 | tar -xf /sources/openssl-*.tar.gz -C /tmp/ \ 11 | && mv /tmp/openssl-* /tmp/openssl \ 12 | && pushd /tmp/openssl 13 | 14 | # prepare for compilation 15 | ./config --prefix=/usr \ 16 | --openssldir=/etc/ssl \ 17 | --libdir=lib \ 18 | shared \ 19 | zlib-dynamic 20 | 21 | # compile, test and install 22 | make 23 | 24 | # Run tests 25 | if [ $LFS_TEST -eq 1 ]; then make test || true; fi 26 | sed -i '/INSTALL_LIBS/s/libcrypto.a libssl.a//' Makefile 27 | make MANSUFFIX=ssl install 28 | 29 | if [ $LFS_DOCS -eq 1 ]; then 30 | mv -v /usr/share/doc/openssl /usr/share/doc/openssl-1.1.0i 31 | cp -vfr doc/* /usr/share/doc/openssl-1.1.0i 32 | fi 33 | 34 | # cleanup 35 | popd \ 36 | && rm -rf /tmp/openssl 37 | -------------------------------------------------------------------------------- /book/chapter-6/6.51-make-python.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building Python.." 4 | echo "Approximate build time: 1.3 SBU" 5 | echo "Required disk space: 390 MB" 6 | 7 | # 6.51. The Python 3 package contains the Python development environment. It is useful 8 | # for object-oriented programming, writing scripts, prototyping large programs or 9 | # developing entire applications. 10 | tar -xf /sources/Python-*.tar.xz -C /tmp/ \ 11 | && mv /tmp/Python-* /tmp/python \ 12 | && pushd /tmp/python 13 | 14 | # Prepare Python for compilation: 15 | ./configure --prefix=/usr \ 16 | --enable-shared \ 17 | --with-system-expat \ 18 | --with-system-ffi \ 19 | --with-ensurepip=yes 20 | 21 | # compile, test and install 22 | make 23 | # install tool 24 | make install 25 | chmod -v 755 /usr/lib/libpython3.7m.so 26 | chmod -v 755 /usr/lib/libpython3.so 27 | 28 | # install the documentation 29 | if [ $LFS_DOCS -eq 1 ]; then 30 | # Install documentation 31 | install -v -dm755 /usr/share/doc/python-3.7.0/html 32 | tar --strip-components=1 \ 33 | --no-same-owner \ 34 | --no-same-permissions \ 35 | -C /usr/share/doc/python-3.7.0/html \ 36 | -xvf /sources/python-3.7.0-docs-html.tar.bz2 37 | fi 38 | 39 | # cleanup 40 | popd \ 41 | && rm -rf /tmp/python 42 | -------------------------------------------------------------------------------- /book/chapter-6/6.52-make-ninja.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building Ninja.." 4 | echo "Approximate build time: 0.2 SBU" 5 | echo "Required disk space: 83 MB" 6 | 7 | # 6.51. Ninja is a small build system with a focus on speed. 8 | tar -xf /sources/ninja-*.tar.gz -C /tmp/ \ 9 | && mv /tmp/ninja-* /tmp/ninja \ 10 | && pushd /tmp/ninja 11 | 12 | # Using the optional patch below allows a user to limit the number of parallel processes 13 | # via an environment variable, NINJAJOBS. For example setting: 14 | export NINJAJOBS=$JOB_COUNT 15 | 16 | # prepare for compilation 17 | patch -Np1 -i /sources/ninja-1.8.2-add_NINJAJOBS_var-1.patch 18 | 19 | # Build package 20 | python3 configure.py --bootstrap 21 | 22 | # Run tests 23 | if [ $LFS_TEST -eq 1 ]; then 24 | python3 configure.py 25 | ./ninja ninja_test 26 | ./ninja_test --gtest_filter=-SubprocessTest.SetWithLots || true 27 | fi 28 | 29 | # Install package 30 | install -vm755 ninja /usr/bin/ 31 | install -vDm644 misc/bash-completion /usr/share/bash-completion/completions/ninja 32 | install -vDm644 misc/zsh-completion /usr/share/zsh/site-functions/_ninja 33 | 34 | # cleanup 35 | popd \ 36 | && rm -rf /tmp/python 37 | -------------------------------------------------------------------------------- /book/chapter-6/6.53-make-meson.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building Meson.." 4 | echo "Approximate build time: 0.1 SBU" 5 | echo "Required disk space: 21 MB" 6 | 7 | # 6.51. Meson is an open source build system meant to be both extremely fast, 8 | # and, even more importantly, as user friendly as possible. 9 | tar -xf /sources/meson-*.tar.gz -C /tmp/ \ 10 | && mv /tmp/meson-* /tmp/meson \ 11 | && pushd /tmp/meson 12 | 13 | # Compile Meson with the following command: 14 | python3 setup.py build 15 | 16 | # Install the package: 17 | python3 setup.py install --root=dest 18 | cp -rv dest/* / 19 | 20 | # cleanup 21 | popd \ 22 | && rm -rf /tmp/meson 23 | -------------------------------------------------------------------------------- /book/chapter-6/6.54-make-procps-ng.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building procps-ng.." 4 | echo "Approximate build time: 0.1 SBU" 5 | echo "Required disk space: 17 MB" 6 | 7 | # 6.54. The Procps-ng package contains programs for monitoring processes. 8 | tar -xf /sources/procps-ng-*.tar.xz -C /tmp/ \ 9 | && mv /tmp/procps-ng-* /tmp/procps-ng \ 10 | && pushd /tmp/procps-ng 11 | 12 | # prepare for compilation 13 | ./configure --prefix=/usr \ 14 | --exec-prefix= \ 15 | --libdir=/usr/lib \ 16 | --docdir=/usr/share/doc/procps-ng-3.3.15 \ 17 | --disable-static \ 18 | --disable-kill 19 | 20 | # Compile the package: 21 | make 22 | 23 | # The test suite needs some custom modifications for LFS. Remove a test 24 | # that fails when scripting does not use a tty device and fix two others. 25 | # To run the test suite, run the following commands: 26 | sed -i -r 's|(pmap_initname)\\\$|\1|' testsuite/pmap.test/pmap.exp 27 | sed -i '/set tty/d' testsuite/pkill.test/pkill.exp 28 | rm testsuite/pgrep.test/pgrep.exp 29 | 30 | # Run tests 31 | if [ $LFS_TEST -eq 1 ]; then make check || true; fi 32 | 33 | # Install package 34 | make install 35 | mv -v /usr/lib/libprocps.so.* /lib 36 | ln -sfv ../../lib/$(readlink /usr/lib/libprocps.so) /usr/lib/libprocps.so 37 | 38 | # cleanup 39 | popd \ 40 | && rm -rf /tmp/procps-ng 41 | -------------------------------------------------------------------------------- /book/chapter-6/6.55-make-e2fsprogs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building e2fsprogs.." 4 | echo "Approximate build time: 1.6 SBU" 5 | echo "Required disk space: 96 MB" 6 | 7 | # 6.55. The E2fsprogs package contains the utilities for handling 8 | # the ext2 file system. It also supports the ext3 and ext4 journaling 9 | # file systems. 10 | tar -xf /sources/e2fsprogs-*.tar.gz -C /tmp/ \ 11 | && mv /tmp/e2fsprogs-* /tmp/e2fsprogs \ 12 | && pushd /tmp/e2fsprogs 13 | 14 | # The E2fsprogs documentation recommends that the package be built in 15 | # a subdirectory of the source tree: 16 | mkdir -v build 17 | cd build 18 | 19 | # Prepare E2fsprogs for compilation: 20 | # http://lists.linuxfromscratch.org/pipermail/lfs-support/2016-August/050256.html 21 | LIBS=-L/tools/lib \ 22 | CFLAGS=-I/tools/include \ 23 | PKG_CONFIG_PATH=/tools/lib/pkgconfig \ 24 | ../configure --prefix=/usr \ 25 | --bindir=/bin \ 26 | --with-root-prefix="" \ 27 | --enable-elf-shlibs \ 28 | --disable-libblkid \ 29 | --disable-libuuid \ 30 | --disable-uuidd \ 31 | --disable-fsck 32 | 33 | # Compile the package: 34 | make 35 | 36 | # To set up and run the test suite we need to first link some libraries 37 | # from /tools/lib to a location where the test programs look. To run 38 | # the tests, issue: 39 | if [ $LFS_TEST -eq 1 ]; then 40 | ln -sfv /tools/lib/lib{blk,uu}id.so.1 lib 41 | make LD_LIBRARY_PATH=/tools/lib check || true 42 | fi 43 | 44 | # Install the binaries, documentation, and shared libraries: 45 | make install 46 | 47 | # Install the static libraries and headers: 48 | make install-libs 49 | 50 | # Make the installed static libraries writable so debugging symbols can be removed later: 51 | chmod -v u+w /usr/lib/{libcom_err,libe2p,libext2fs,libss}.a 52 | 53 | # This package installs a gzipped .info file but doesn't update the system 54 | # -wide dir file. Unzip this file and then update the system dir file using 55 | # the following commands: 56 | gunzip -v /usr/share/info/libext2fs.info.gz 57 | install-info --dir-file=/usr/share/info/dir /usr/share/info/libext2fs.info 58 | 59 | # create and install some additional documentation 60 | if [ $LFS_DOCS -eq 1 ]; then 61 | makeinfo -o doc/com_err.info ../lib/et/com_err.texinfo 62 | install -v -m644 doc/com_err.info /usr/share/info 63 | install-info --dir-file=/usr/share/info/dir /usr/share/info/com_err.info 64 | fi 65 | 66 | # cleanup 67 | popd \ 68 | && rm -rf /tmp/e2fsprogs 69 | -------------------------------------------------------------------------------- /book/chapter-6/6.56-make-coreutils.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building coreutils.." 4 | echo "Approximate build time: 3.3 SBU" 5 | echo "Required disk space: 190 MB" 6 | 7 | # 6.56. The Coreutils package contains utilities for showing and 8 | # setting the basic system characteristics. 9 | tar -xf /sources/coreutils-*.tar.xz -C /tmp/ \ 10 | && mv /tmp/coreutils-* /tmp/coreutils \ 11 | && pushd /tmp/coreutils 12 | 13 | # The following patch fixes this non-compliance and other 14 | # internationalization-related bugs. 15 | patch -Np1 -i /sources/coreutils-8.30-i18n-1.patch 16 | 17 | # Suppress a test which on some machines can loop forever 18 | sed -i '/test.lock/s/^/#/' gnulib-tests/gnulib.mk 19 | 20 | # Now prepare Coreutils for compilation: 21 | autoreconf -fiv 22 | FORCE_UNSAFE_CONFIGURE=1 ./configure \ 23 | --prefix=/usr \ 24 | --enable-no-install-program=kill,uptime 25 | 26 | # Compile the package 27 | FORCE_UNSAFE_CONFIGURE=1 make 28 | 29 | echo " 30 | Coreutils tests skipped. 31 | 32 | Test programs test-getlogin and date-debug are known to fail 33 | in a partially built system environment like the chroot 34 | environment here. 35 | " 36 | 37 | ## Run tests 38 | #if [ $LFS_TEST -eq 1 ]; then 39 | # make NON_ROOT_USERNAME=nobody check-root 40 | # echo "dummy:x:1000:nobody" >> /etc/group 41 | # chown -Rv nobody . 42 | # # test programs test-getlogin and date-debug are known to fail in a partially 43 | # # built system environment like the chroot environment here 44 | # su nobody -s /bin/bash \ 45 | # -c "PATH=$PATH make RUN_EXPENSIVE_TESTS=yes check" || true 46 | # sed -i '/dummy/d' /etc/group 47 | #fi 48 | 49 | # install 50 | make install 51 | 52 | # move programs to the locations specified by the FHS 53 | mv -v /usr/bin/{cat,chgrp,chmod,chown,cp,date,dd,df,echo} /bin 54 | mv -v /usr/bin/{false,ln,ls,mkdir,mknod,mv,pwd,rm} /bin 55 | mv -v /usr/bin/{rmdir,stty,sync,true,uname} /bin 56 | mv -v /usr/bin/chroot /usr/sbin 57 | mv -v /usr/share/man/man1/chroot.1 /usr/share/man/man8/chroot.8 58 | sed -i s/\"1\"/\"8\"/1 /usr/share/man/man8/chroot.8 59 | 60 | mv -v /usr/bin/{head,sleep,nice} /bin 61 | 62 | # cleanup 63 | popd \ 64 | && rm -rf /tmp/coreutils 65 | -------------------------------------------------------------------------------- /book/chapter-6/6.57-make-check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building Check.." 4 | echo "Approximate build time: 0.1 SBU (about 3.8 SBU with tests)" 5 | echo "Required disk space: 12 MB" 6 | 7 | # 6.57. Check is a unit testing framework for C. 8 | tar -xf /sources/check-*.tar.gz -C /tmp/ \ 9 | && mv /tmp/check-* /tmp/check \ 10 | && pushd /tmp/check 11 | 12 | ./configure --prefix=/usr 13 | make 14 | if [ $LFS_TEST -eq 1 ]; then make check; fi 15 | make install 16 | sed -i '1 s/tools/usr/' /usr/bin/checkmk 17 | 18 | # cleanup 19 | popd \ 20 | && rm -rf /tmp/check 21 | -------------------------------------------------------------------------------- /book/chapter-6/6.58-make-diffutils.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building diffutils.." 4 | echo "Approximate build time: 0.4 SBU" 5 | echo "Required disk space: 33 MB" 6 | 7 | # 6.58. The Diffutils package contains programs that show the differences 8 | # between files or directories. 9 | tar -xf /sources/diffutils-*.tar.xz -C /tmp/ \ 10 | && mv /tmp/diffutils-* /tmp/diffutils \ 11 | && pushd /tmp/diffutils 12 | 13 | ./configure --prefix=/usr 14 | make 15 | if [ $LFS_TEST -eq 1 ]; then make check; fi 16 | make install 17 | 18 | # cleanup 19 | popd \ 20 | && rm -rf /tmp/diffutils 21 | -------------------------------------------------------------------------------- /book/chapter-6/6.59-make-gawk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building gawk.." 4 | echo "Approximate build time: 0.4 SBU" 5 | echo "Required disk space: 44 MB" 6 | 7 | # 6.59. Gawk package contains programs for manipulating text files 8 | tar -xf /sources/gawk-*.tar.xz -C /tmp/ \ 9 | && mv /tmp/gawk-* /tmp/gawk \ 10 | && pushd /tmp/gawk 11 | 12 | # First, ensure some unneeded files are not installed: 13 | sed -i 's/extras//' Makefile.in 14 | # Prepare Gawk for compilation: 15 | ./configure --prefix=/usr 16 | make 17 | if [ $LFS_TEST -eq 1 ]; then make check; fi 18 | make install 19 | 20 | # install docs 21 | if [ $LFS_DOCS -eq 1 ]; then 22 | mkdir -v /usr/share/doc/gawk-4.2.1 23 | cp -v doc/{awkforai.txt,*.{eps,pdf,jpg}} /usr/share/doc/gawk-4.2.1 24 | fi 25 | 26 | # cleanup 27 | popd \ 28 | && rm -rf /tmp/gawk 29 | -------------------------------------------------------------------------------- /book/chapter-6/6.6-create-essentials.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # create essential files and symlinks 5 | ln -sv /tools/bin/{bash,cat,dd,echo,ln,pwd,rm,stty} /bin 6 | ln -sv /tools/bin/{install,perl} /usr/bin 7 | ln -sv /tools/lib/libgcc_s.so{,.1} /usr/lib 8 | ln -sv /tools/lib/libstdc++.{a,so{,.6}} /usr/lib 9 | sed 's/tools/usr/' /tools/lib/libstdc++.la > /usr/lib/libstdc++.la 10 | 11 | # need for 6.7-make-linux-api-headers.sh 12 | ln -sv /tools/lib/crt*.o /tools/lib/gcc/x86_64-pc-linux-gnu/8.2.0/ 13 | 14 | for lib in blkid lzma mount uuid 15 | do 16 | ln -sv /tools/lib/lib$lib.{a,so*} /usr/lib || true 17 | sed 's/tools/usr/' /tools/lib/lib${lib}.la > /usr/lib/lib${lib}.la 18 | done 19 | ln -sv bash /bin/sh || true 20 | 21 | # create symlink for list of the mounted file systems 22 | ln -sv /proc/self/mounts /etc/mtab || true 23 | 24 | # configure root 25 | cat > /etc/passwd << "EOF" 26 | root::0:0:root:/root:/bin/bash 27 | bin:x:1:1:bin:/dev/null:/bin/false 28 | daemon:x:6:6:Daemon User:/dev/null:/bin/false 29 | messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false 30 | nobody:x:99:99:Unprivileged User:/dev/null:/bin/false 31 | EOF 32 | 33 | cat > /etc/group << "EOF" 34 | root:x:0: 35 | bin:x:1:daemon 36 | sys:x:2: 37 | kmem:x:3: 38 | tape:x:4: 39 | tty:x:5: 40 | daemon:x:6: 41 | floppy:x:7: 42 | disk:x:8: 43 | lp:x:9: 44 | dialout:x:10: 45 | audio:x:11: 46 | video:x:12: 47 | utmp:x:13: 48 | usb:x:14: 49 | cdrom:x:15: 50 | adm:x:16: 51 | messagebus:x:18: 52 | systemd-journal:x:23: 53 | input:x:24: 54 | mail:x:34: 55 | nogroup:x:99: 56 | users:x:999: 57 | EOF 58 | 59 | # initialize the log files and give them proper permissions 60 | touch /var/log/{btmp,lastlog,faillog,wtmp} 61 | chgrp -v utmp /var/log/lastlog 62 | chmod -v 664 /var/log/lastlog 63 | chmod -v 600 /var/log/btmp 64 | -------------------------------------------------------------------------------- /book/chapter-6/6.60-make-findutils.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building findutils.." 4 | echo "Approximate build time: 0.7 SBU" 5 | echo "Required disk space: 51 MB" 6 | 7 | # 6.53. Findutils package contains programs to find files 8 | tar -xf /sources/findutils-*.tar.gz -C /tmp/ \ 9 | && mv /tmp/findutils-* /tmp/findutils \ 10 | && pushd /tmp/findutils 11 | 12 | # First, suppress a test which on some machines can loop forever: 13 | sed -i 's/test-lock..EXEEXT.//' tests/Makefile.in 14 | 15 | # Next, make some fixes required by glibc-2.28: 16 | sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' gl/lib/*.c 17 | sed -i '/unistd/a #include ' gl/lib/mountlist.c 18 | echo "#define _IO_IN_BACKUP 0x100" >> gl/lib/stdio-impl.h 19 | 20 | # Prepare Findutils for compilation: 21 | ./configure --prefix=/usr --localstatedir=/var/lib/locate 22 | 23 | make 24 | if [ $LFS_TEST -eq 1 ]; then make check; fi 25 | make install 26 | 27 | mv -v /usr/bin/find /bin 28 | sed -i 's|find:=${BINDIR}|find:=/bin|' /usr/bin/updatedb 29 | 30 | # cleanup 31 | popd \ 32 | && rm -rf /tmp/findutils 33 | -------------------------------------------------------------------------------- /book/chapter-6/6.61-make-groff.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building groff.." 4 | echo "Approximate build time: 0.5 SBU" 5 | echo "Required disk space: 90 MB" 6 | 7 | # 6.61. Groff package contains programs for processing and formatting text 8 | tar -xf /sources/groff-*.tar.gz -C /tmp/ \ 9 | && mv /tmp/groff-* /tmp/groff \ 10 | && pushd /tmp/groff 11 | 12 | PAGE=A4 ./configure --prefix=/usr 13 | # This package does not support parallel build. Compile the package: 14 | make -j1 15 | make install 16 | 17 | # cleanup 18 | popd \ 19 | && rm -rf /tmp/groff 20 | -------------------------------------------------------------------------------- /book/chapter-6/6.62-make-grub.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building grub.." 4 | echo "Approximate build time: 0.8 SBU" 5 | echo "Required disk space: 147 MB" 6 | 7 | # 6.62. GRUB package contains the GRand Unified Bootloader 8 | tar -xf /sources/grub-*.tar.xz -C /tmp/ \ 9 | && mv /tmp/grub-* /tmp/grub \ 10 | && pushd /tmp/grub 11 | 12 | # Prepare GRUB for compilation: 13 | ./configure --prefix=/usr \ 14 | --sbindir=/sbin \ 15 | --sysconfdir=/etc \ 16 | --disable-efiemu \ 17 | --disable-werror 18 | 19 | # Compile the package: 20 | make 21 | 22 | # Install the package: 23 | make install 24 | 25 | # cleanup 26 | popd \ 27 | && rm -rf /tmp/grub 28 | -------------------------------------------------------------------------------- /book/chapter-6/6.63-make-less.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building less.." 4 | echo "Approximate build time: less than 0.1 SBU" 5 | echo "Required disk space: 3.9 MB" 6 | 7 | # 6.63. Less package contains a text file viewer 8 | tar -xf /sources/less-*.tar.gz -C /tmp/ \ 9 | && mv /tmp/less-* /tmp/less \ 10 | && pushd /tmp/less 11 | 12 | # Prepare Less for compilation: 13 | ./configure --prefix=/usr --sysconfdir=/etc 14 | 15 | # Compile the package: 16 | make 17 | 18 | # Install the package: 19 | make install 20 | 21 | # cleanup 22 | popd \ 23 | && rm -rf /tmp/less 24 | -------------------------------------------------------------------------------- /book/chapter-6/6.64-make-gzip.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building Gzip.." 4 | echo "Approximate build time: 0.1 SBU" 5 | echo "Required disk space: 19 MB" 6 | 7 | # 6.64. The Gzip package contains programs for compressing and 8 | # decompressing files. 9 | tar -xf /sources/gzip-*.tar.xz -C /tmp/ \ 10 | && mv /tmp/gzip-* /tmp/gzip \ 11 | && pushd /tmp/gzip 12 | 13 | # First, make some fixes required by glibc-2.28: 14 | sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' lib/*.c 15 | echo "#define _IO_IN_BACKUP 0x100" >> lib/stdio-impl.h 16 | 17 | # Prepare Gzip for compilation: 18 | ./configure --prefix=/usr 19 | 20 | # Compile the package: 21 | make 22 | 23 | # NOTE two tests are known to fail in the LFS environment: help-version and zmore 24 | if [ $LFS_TEST -eq 1 ]; then make check || true; fi 25 | 26 | # Install the package: 27 | make install 28 | 29 | # Move a program that needs to be on the root filesystem: 30 | mv -v /usr/bin/gzip /bin 31 | 32 | # cleanup 33 | popd \ 34 | && rm -rf /tmp/gzip 35 | -------------------------------------------------------------------------------- /book/chapter-6/6.65-make-iproute2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building IPRoute2.." 4 | echo "Approximate build time: 0.2 SBU" 5 | echo "Required disk space: 13 MB" 6 | 7 | # 6.65. IPRoute2 package contains programs for basic and advanced 8 | # IPV4-based networki 9 | tar -xf /sources/iproute2-*.tar.xz -C /tmp/ \ 10 | && mv /tmp/iproute2-* /tmp/iproute2 \ 11 | && pushd /tmp/iproute2 12 | 13 | sed -i /ARPD/d Makefile 14 | rm -fv man/man8/arpd.8 15 | sed -i 's/.m_ipt.o//' tc/Makefile 16 | make 17 | make DOCDIR=/usr/share/doc/iproute2-4.18.0 install 18 | # cleanup 19 | popd \ 20 | && rm -rf /tmp/iproute2 21 | -------------------------------------------------------------------------------- /book/chapter-6/6.66-make-kbd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building kbd.." 4 | echo "Approximate build time: 0.1 SBU" 5 | echo "Required disk space: 30 MB" 6 | 7 | # 6.66. Kbd package contains key-table files, console fonts, and 8 | # keyboard utilities 9 | tar -xf /sources/kbd-*.tar.xz -C /tmp/ \ 10 | && mv /tmp/kbd-* /tmp/kbd \ 11 | && pushd /tmp/kbd 12 | 13 | # fixes an issue for i386 keymaps 14 | patch -Np1 -i /sources/kbd-2.0.4-backspace-1.patch 15 | 16 | # remove the redundant resizecons program 17 | sed -i 's/\(RESIZECONS_PROGS=\)yes/\1no/g' configure 18 | sed -i 's/resizecons.8 //' docs/man/man8/Makefile.in 19 | 20 | # prepare 21 | PKG_CONFIG_PATH=/tools/lib/pkgconfig ./configure --prefix=/usr --disable-vlock 22 | 23 | # compile, test and install 24 | make 25 | 26 | if [ $LFS_TEST -eq 1 ]; then make check; fi 27 | 28 | # Install the package: 29 | make install 30 | 31 | # install docs 32 | if [ $LFS_DOCS -eq 1 ]; then 33 | mkdir -v /usr/share/doc/kbd-2.0.4 34 | cp -R -v docs/doc/* /usr/share/doc/kbd-2.0.4 35 | fi 36 | 37 | # cleanup 38 | popd \ 39 | && rm -rf /tmp/kbd 40 | -------------------------------------------------------------------------------- /book/chapter-6/6.67-make-libpipeline.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building libpipeline.." 4 | echo "Approximate build time: 0.1 SBU" 5 | echo "Required disk space: 8.2 MB" 6 | 7 | # 6.67. Libpipeline package contains a library for manipulating 8 | # pipelines of subprocesses in a flexible and convenient way 9 | tar -xf /sources/libpipeline-*.tar.gz -C /tmp/ \ 10 | && mv /tmp/libpipeline-* /tmp/libpipeline \ 11 | && pushd /tmp/libpipeline 12 | 13 | # prepare 14 | ./configure --prefix=/usr 15 | 16 | # compile, test and install 17 | make 18 | if [ $LFS_TEST -eq 1 ]; then make check; fi 19 | make install 20 | 21 | # cleanup 22 | popd \ 23 | && rm -rf /tmp/libpipeline 24 | -------------------------------------------------------------------------------- /book/chapter-6/6.68-make-make.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building make.." 4 | echo "Approximate build time: 0.6 SBU" 5 | echo "Required disk space: 13 MB" 6 | 7 | # 6.68. Make package contains a program for compiling packages 8 | tar -xf /sources/make-*.tar.bz2 -C /tmp/ \ 9 | && mv /tmp/make-* /tmp/make \ 10 | && pushd /tmp/make 11 | 12 | # Again, work around an error caused by glibc-2.27 13 | sed -i '211,217 d; 219,229 d; 232 d' glob/glob.c 14 | 15 | # Configure 16 | ./configure --prefix=/usr 17 | 18 | # Build 19 | make 20 | 21 | # Run tests 22 | if [ $LFS_TEST -eq 1 ]; then make PERL5LIB=$PWD/tests/ check; fi 23 | 24 | # Install 25 | make install 26 | 27 | # cleanup 28 | popd \ 29 | && rm -rf /tmp/make 30 | -------------------------------------------------------------------------------- /book/chapter-6/6.69-make-patch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building patch.." 4 | echo "Approximate build time: 0.2 SBU" 5 | echo "Required disk space: 13 MB" 6 | 7 | # 6.69. Patch package contains a program for modifying or creating files 8 | # by applying a “patch” file typically created by the diff program 9 | tar -xf /sources/patch-*.tar.xz -C /tmp/ \ 10 | && mv /tmp/patch-* /tmp/patch \ 11 | && pushd /tmp/patch 12 | 13 | ./configure --prefix=/usr 14 | make 15 | if [ $LFS_TEST -eq 1 ]; then make check; fi 16 | make install 17 | 18 | # cleanup 19 | popd \ 20 | && rm -rf /tmp/patch 21 | -------------------------------------------------------------------------------- /book/chapter-6/6.7-make-linux-api-headers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building Linux API headers.." 4 | echo "Approximate build time: less than 0.1 SBU" 5 | echo "Required disk space: 924 MB" 6 | 7 | # 6.7. Linux API Headers package exposes the kernel API for use by Glib 8 | tar -xf /sources/linux-*.tar.xz -C /tmp/ \ 9 | && mv /tmp/linux-* /tmp/linux \ 10 | && pushd /tmp/linux \ 11 | && make mrproper \ 12 | && make INSTALL_HDR_PATH=dest headers_install \ 13 | && find dest/include \( -name .install -o -name ..install.cmd \) -delete \ 14 | && cp -rv dest/include/* /usr/include \ 15 | && popd \ 16 | && rm -rf /tmp/linux 17 | -------------------------------------------------------------------------------- /book/chapter-6/6.70-make-sysklogd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building sysklogd.." 4 | echo "Approximate build time: less than 0.1 SBU" 5 | echo "Required disk space: 0.6 MB" 6 | 7 | # 6.70. The Sysklogd package contains programs for logging system 8 | # messages, such as those given by the kernel when unusual things 9 | # happen. 10 | tar -xf /sources/sysklogd-*.tar.gz -C /tmp/ \ 11 | && mv /tmp/sysklogd-* /tmp/sysklogd \ 12 | && pushd /tmp/sysklogd 13 | 14 | # fix bugs 15 | sed -i '/Error loading kernel symbols/{n;n;d}' ksym_mod.c 16 | sed -i 's/union wait/int/' syslogd.c 17 | 18 | # compile 19 | make 20 | 21 | # install 22 | make BINDIR=/sbin install 23 | 24 | # 6.70.2. Configuring Sysklogd 25 | cat > /etc/syslog.conf << "EOF" 26 | # Begin /etc/syslog.conf 27 | 28 | auth,authpriv.* -/var/log/auth.log 29 | *.*;auth,authpriv.none -/var/log/sys.log 30 | daemon.* -/var/log/daemon.log 31 | kern.* -/var/log/kern.log 32 | mail.* -/var/log/mail.log 33 | user.* -/var/log/user.log 34 | *.emerg * 35 | 36 | # End /etc/syslog.conf 37 | EOF 38 | 39 | # cleanup 40 | popd \ 41 | && rm -rf /tmp/sysklogd 42 | -------------------------------------------------------------------------------- /book/chapter-6/6.71-make-sysvinit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building sysvinit.." 4 | echo "Approximate build time: less than 0.1 SBU" 5 | echo "Required disk space: 1.1 MB" 6 | 7 | # 6.71. Sysvinit package contains programs for controlling the startup, 8 | # running, and shutdown of the system 9 | tar -xf /sources/sysvinit-*.tar.xz -C /tmp/ \ 10 | && mv /tmp/sysvinit-* /tmp/sysvinit \ 11 | && pushd /tmp/sysvinit 12 | 13 | # apply a patch that removes several programs installed by other packages, 14 | # clarifies a message, and fixes a compiler warning 15 | patch -Np1 -i /sources/sysvinit-2.90-consolidated-1.patch 16 | 17 | # compile and install 18 | make -C src 19 | make -C src install 20 | 21 | # cleanup 22 | popd \ 23 | && rm -rf /tmp/sysvinit 24 | -------------------------------------------------------------------------------- /book/chapter-6/6.72-make-eudev.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building Eudev.." 4 | echo "Approximate build time: 0.2 SBU" 5 | echo "Required disk space: 81 MB" 6 | 7 | # 6.72. The Eudev package contains programs for dynamic creation of device nodes. 8 | tar -xf /sources/eudev-*.tar.gz -C /tmp/ \ 9 | && mv /tmp/eudev-* /tmp/eudev \ 10 | && pushd /tmp/eudev 11 | 12 | # Next, add a workaround to prevent the /tools directory from 13 | # being hard coded into Eudev binary files library locations: 14 | cat > config.cache << "EOF" 15 | HAVE_BLKID=1 16 | BLKID_LIBS="-lblkid" 17 | BLKID_CFLAGS="-I/tools/include" 18 | EOF 19 | 20 | ./configure --prefix=/usr \ 21 | --bindir=/sbin \ 22 | --sbindir=/sbin \ 23 | --libdir=/usr/lib \ 24 | --sysconfdir=/etc \ 25 | --libexecdir=/lib \ 26 | --with-rootprefix= \ 27 | --with-rootlibdir=/lib \ 28 | --enable-manpages \ 29 | --disable-static \ 30 | --config-cache 31 | 32 | # Compile the package: 33 | LIBRARY_PATH=/tools/lib make 34 | 35 | # Create some directories now that are needed for tests, 36 | # but will also be used as a part of installation: 37 | mkdir -pv /lib/udev/rules.d 38 | mkdir -pv /etc/udev/rules.d 39 | 40 | # test 41 | # NOTE FAIL: udev-test.pl 42 | if [ $LFS_TEST -eq 1 ]; then make LD_LIBRARY_PATH=/tools/lib check || true; fi 43 | 44 | # install 45 | make LD_LIBRARY_PATH=/tools/lib install 46 | tar -xvf /sources/udev-lfs-20171102.tar.bz2 47 | make -f udev-lfs-20171102/Makefile.lfs install 48 | 49 | # create initial database 50 | LD_LIBRARY_PATH=/tools/lib udevadm hwdb --update 51 | 52 | # cleanup 53 | popd \ 54 | && rm -rf /tmp/eudev 55 | -------------------------------------------------------------------------------- /book/chapter-6/6.73-make-util-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building Util-linux.." 4 | echo "Approximate build time: 1.1 SBU" 5 | echo "Required disk space: 200 MB" 6 | 7 | # 6.73. The Util-linux package contains miscellaneous utility programs. Among 8 | # them are utilities for handling file systems, consoles, partitions, and messages 9 | tar -xf /sources/util-linux-*.tar.xz -C /tmp/ \ 10 | && mv /tmp/util-linux-* /tmp/util-linux \ 11 | && pushd /tmp/util-linux 12 | 13 | # Remove the earlier created symlinks: 14 | rm -vf /usr/include/{blkid,libmount,uuid} 15 | 16 | # Prepare Util-linux for compilation: 17 | ./configure ADJTIME_PATH=/var/lib/hwclock/adjtime \ 18 | --docdir=/usr/share/doc/util-linux-2.32.1 \ 19 | --disable-chfn-chsh \ 20 | --disable-login \ 21 | --disable-nologin \ 22 | --disable-su \ 23 | --disable-setpriv \ 24 | --disable-runuser \ 25 | --disable-pylibmount \ 26 | --disable-static \ 27 | --without-python \ 28 | --without-systemd \ 29 | --without-systemdsystemunitdir 30 | 31 | # Compile the package: 32 | make 33 | 34 | echo "Util-linux test skipped due to warning." 35 | #if [ $LFS_TEST -eq 1 ]; then 36 | # chown -Rv nobody . 37 | # su nobody -s /bin/bash -c "PATH=$PATH make -k check" 38 | #fi 39 | 40 | # install 41 | make install 42 | 43 | # cleanup 44 | popd \ 45 | && rm -rf /tmp/util-linux 46 | -------------------------------------------------------------------------------- /book/chapter-6/6.74-make-man-db.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building man-db.." 4 | echo "Approximate build time: 0.4 SBU" 5 | echo "Required disk space: 30 MB" 6 | 7 | # 6.74. Man-DB package contains programs for finding and viewing man pages 8 | tar -xf /sources/man-db-*.tar.xz -C /tmp/ \ 9 | && mv /tmp/man-db-* /tmp/man-db \ 10 | && pushd /tmp/man-db 11 | 12 | ./configure --prefix=/usr \ 13 | --docdir=/usr/share/doc/man-db-2.8.4 \ 14 | --sysconfdir=/etc \ 15 | --disable-setuid \ 16 | --enable-cache-owner=bin \ 17 | --with-browser=/usr/bin/lynx \ 18 | --with-vgrind=/usr/bin/vgrind \ 19 | --with-grap=/usr/bin/grap \ 20 | --with-systemdtmpfilesdir= 21 | 22 | # Compile the package: 23 | make 24 | 25 | # To test the results, issue: 26 | if [ $LFS_TEST -eq 1 ]; then make check; fi 27 | 28 | # Install the package: 29 | make install 30 | 31 | # cleanup 32 | popd \ 33 | && rm -rf /tmp/man-db || true 34 | -------------------------------------------------------------------------------- /book/chapter-6/6.75-make-tar.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building tar.." 4 | echo "Approximate build time: 2.8 SBU" 5 | echo "Required disk space: 44 MB" 6 | 7 | # 6.75. Tar package contains an archiving program 8 | tar -xf /sources/tar-*.tar.xz -C /tmp/ \ 9 | && mv /tmp/tar-* /tmp/tar \ 10 | && pushd /tmp/tar 11 | 12 | FORCE_UNSAFE_CONFIGURE=1 \ 13 | ./configure --prefix=/usr \ 14 | --bindir=/bin 15 | 16 | # Compile the package: 17 | make 18 | 19 | # To test the results (about 3 SBU), issue: 20 | if [ $LFS_TEST -eq 1 ]; then make check; fi 21 | 22 | # Install the package: 23 | make install 24 | make -C doc install-html docdir=/usr/share/doc/tar-1.30 25 | 26 | # cleanup 27 | popd \ 28 | && rm -rf /tmp/tar || true 29 | -------------------------------------------------------------------------------- /book/chapter-6/6.76-make-texinfo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building texinfo.." 4 | echo "Approximate build time: 1.1 SBU" 5 | echo "Required disk space: 129 MB" 6 | 7 | # 6.76. Texinfo package contains programs for reading, writing, 8 | # and converting info pages 9 | tar -xf /sources/texinfo-*.tar.xz -C /tmp/ \ 10 | && mv /tmp/texinfo-* /tmp/texinfo \ 11 | && pushd /tmp/texinfo 12 | 13 | # Fix a file that creates a lot of failures in the regression checks: 14 | sed -i '5481,5485 s/({/(\\{/' tp/Texinfo/Parser.pm 15 | 16 | # Prepare Texinfo for compilation: 17 | ./configure --prefix=/usr --disable-static 18 | 19 | # Compile the package: 20 | make 21 | 22 | # To test the results, issue: 23 | if [ $LFS_TEST -eq 1 ]; then make check; fi 24 | 25 | # Install the package: 26 | make install 27 | 28 | # Optionally, install the components belonging in a TeX installation: 29 | make TEXMF=/usr/share/texmf install-tex 30 | 31 | # fix package out of sync with the info pages installed on the system 32 | pushd /usr/share/info 33 | rm -v dir 34 | for f in * 35 | do install-info $f dir 2>/dev/null 36 | done 37 | popd 38 | 39 | # cleanup 40 | popd \ 41 | && rm -rf /tmp/texinfo 42 | -------------------------------------------------------------------------------- /book/chapter-6/6.77-make-vim.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building vim.." 4 | echo "Approximate build time: 1.6 SBU" 5 | echo "Required disk space: 169 MB" 6 | 7 | # 6.77. Vim package contains a powerful text editor 8 | tar -xf /sources/vim-*.tar.bz2 -C /tmp/ \ 9 | && mv /tmp/vim* /tmp/vim \ 10 | && pushd /tmp/vim 11 | 12 | # change default location of the vimrc configuration file to /etc 13 | echo '#define SYS_VIMRC_FILE "/etc/vimrc"' >> src/feature.h 14 | 15 | # disable a test that fails 16 | sed -i '/call/{s/split/xsplit/;s/303/492/}' src/testdir/test_recover.vim 17 | 18 | # prepare Vim for compilation: 19 | ./configure --prefix=/usr 20 | 21 | # Compile the package: 22 | make 23 | 24 | # To test the results, issue: 25 | if [ $LFS_TEST -eq 1 ]; then LANG=en_US.UTF-8 make -j1 test &> vim-test.log; fi 26 | 27 | # Install the package: 28 | make install 29 | 30 | # create symlink for vi 31 | ln -sv vim /usr/bin/vi 32 | for L in /usr/share/man/{,*/}man1/vim.1; do 33 | ln -sv vim.1 $(dirname $L)/vi.1 34 | done 35 | ln -sv ../vim/vim81/doc /usr/share/doc/vim-8.1 36 | 37 | # 6.70.2. Configuring Vim 38 | cat > /etc/vimrc << "EOF" 39 | " Begin /etc/vimrc 40 | 41 | " Ensure defaults are set before customizing settings, not after 42 | source $VIMRUNTIME/defaults.vim 43 | let skip_defaults_vim=1 44 | 45 | set nocompatible 46 | set backspace=2 47 | set mouse= 48 | syntax on 49 | if (&term == "xterm") || (&term == "putty") 50 | set background=dark 51 | endif 52 | 53 | " End /etc/vimrc 54 | EOF 55 | 56 | # cleanup 57 | popd \ 58 | && rm -rf /tmp/vim 59 | -------------------------------------------------------------------------------- /book/chapter-6/6.79-strip.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Stripping again.." 4 | 5 | # 6.79. First place the debugging symbols for selected libraries in 6 | # separate files. This debugging information is needed if running 7 | # regression tests that use valgrind or gdb later in BLFS. 8 | save_lib="ld-2.28.so libc-2.28.so libpthread-2.28.so libthread_db-1.0.so" 9 | 10 | cd /lib 11 | 12 | for LIB in $save_lib; do 13 | objcopy --only-keep-debug $LIB $LIB.dbg 14 | strip --strip-unneeded $LIB 15 | objcopy --add-gnu-debuglink=$LIB.dbg $LIB 16 | done 17 | 18 | save_usrlib="libquadmath.so.0.0.0 libstdc++.so.6.0.25 19 | libitm.so.1.0.0 libatomic.so.1.2.0" 20 | 21 | cd /usr/lib 22 | 23 | for LIB in $save_usrlib; do 24 | objcopy --only-keep-debug $LIB $LIB.dbg 25 | strip --strip-unneeded $LIB 26 | objcopy --add-gnu-debuglink=$LIB.dbg $LIB 27 | done 28 | 29 | unset LIB save_lib save_usrlib 30 | 31 | # strip 32 | /tools/bin/find /usr/lib -type f -name \*.a \ 33 | -exec /tools/bin/strip --strip-debug {} ';' 34 | 35 | /tools/bin/find /lib /usr/lib -type f \( -name \*.so* -a ! -name \*dbg \) \ 36 | -exec /tools/bin/strip --strip-unneeded {} ';' 37 | 38 | /tools/bin/find /{bin,sbin} /usr/{bin,sbin,libexec} -type f \ 39 | -exec /tools/bin/strip --strip-all {} ';' 40 | -------------------------------------------------------------------------------- /book/chapter-6/6.8-make-man-pages.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building man pages.." 4 | echo "Approximate build time: less than 0.1 SBU" 5 | echo "Required disk space: 28 MB" 6 | 7 | # 6.8. Man-pages package describes C programming language functions, 8 | # important device files, and significant configuration files 9 | tar -xf /sources/man-pages-*.tar.xz -C /tmp/ \ 10 | && mv /tmp/man-pages-* /tmp/man-pages \ 11 | && pushd /tmp/man-pages \ 12 | && make install \ 13 | && popd \ 14 | && rm -rf /tmp/man-pages 15 | -------------------------------------------------------------------------------- /book/chapter-6/6.80-clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Cleaning up.." 4 | 5 | # 6.80. Cleaning Up 6 | 7 | # workaround for https://github.com/moby/moby/issues/13451 8 | pushd /tmp/ 9 | for i in $(ls -d */); do 10 | while [[ -e ${i%%/}/confdir3/confdir3 ]]; do 11 | mv confdir3/confdir3 confdir3a; rmdir confdir3; mv confdir3a confdir3; 12 | done; 13 | done; 14 | popd 15 | 16 | # Finally, clean up some extra files left around from running tests: 17 | rm -rf /tmp/* 18 | 19 | # cleanup leftovers 20 | rm -f /usr/lib/lib{bfd,opcodes}.a 21 | rm -f /usr/lib/libbz2.a 22 | rm -f /usr/lib/lib{com_err,e2p,ext2fs,ss}.a 23 | rm -f /usr/lib/libltdl.a 24 | rm -f /usr/lib/libfl.a 25 | rm -f /usr/lib/libz.a 26 | 27 | find /usr/lib /usr/libexec -name \*.la -delete 28 | -------------------------------------------------------------------------------- /book/chapter-6/6.9-make-glibc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building glibc.." 4 | echo "Approximate build time: 24 SBU" 5 | echo "Required disk space: 2.8 Gb" 6 | 7 | # 6.9. Glibc package contains the main C library 8 | tar -xf /sources/glibc-*.tar.xz -C /tmp/ \ 9 | && mv /tmp/glibc-* /tmp/glibc \ 10 | && pushd /tmp/glibc 11 | 12 | # 6.9.1. Installation of Glibc 13 | patch -Np1 -i /sources/glibc-2.28-fhs-1.patch 14 | ln -sfv /tools/lib/gcc /usr/lib 15 | 16 | # Determine the GCC include directory and create a symlink for LSB 17 | # compliance. Additionally, for x86_64, create a compatibility 18 | # symlink required for the dynamic loader to function correctly: 19 | case $(uname -m) in 20 | i?86) GCC_INCDIR=/usr/lib/gcc/$(uname -m)-pc-linux-gnu/8.2.0/include 21 | ln -sfv ld-linux.so.2 /lib/ld-lsb.so.3 22 | ;; 23 | x86_64) GCC_INCDIR=/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include 24 | ln -sfv ../lib/ld-linux-x86-64.so.2 /lib64 25 | ln -sfv ../lib/ld-linux-x86-64.so.2 /lib64/ld-lsb-x86-64.so.3 26 | ;; 27 | esac 28 | 29 | # Remove a file that may be left over from a previous build attempt 30 | rm -f /usr/include/limits.h 31 | # The Glibc documentation recommends building Glibc in a dedicated 32 | # build directory: 33 | mkdir -v build 34 | cd build 35 | # prepare Glibc for compilation: 36 | CC="gcc -isystem $GCC_INCDIR -isystem /usr/include" \ 37 | ../configure --prefix=/usr \ 38 | --disable-werror \ 39 | --enable-kernel=3.2 \ 40 | --enable-stack-protector=strong \ 41 | libc_cv_slibdir=/lib 42 | unset GCC_INCDIR 43 | make 44 | if [ $LFS_TEST -eq 1 ]; then make check || true; fi 45 | # prevent warning during install 46 | touch /etc/ld.so.conf 47 | # fix the generated Makefile to skip an uneeded sanity check that fails in the LFS partial environment 48 | sed '/test-installation/s@$(PERL)@echo not running@' -i ../Makefile 49 | # install the package 50 | make install 51 | # install the configuration file and runtime directory for nscd 52 | cp -v ../nscd/nscd.conf /etc/nscd.conf 53 | mkdir -pv /var/cache/nscd 54 | # install the locales that can make the system respond in a different language 55 | mkdir -pv /usr/lib/locale 56 | localedef -i cs_CZ -f UTF-8 cs_CZ.UTF-8 57 | localedef -i de_DE -f ISO-8859-1 de_DE 58 | localedef -i de_DE@euro -f ISO-8859-15 de_DE@euro 59 | localedef -i de_DE -f UTF-8 de_DE.UTF-8 60 | localedef -i en_GB -f UTF-8 en_GB.UTF-8 61 | localedef -i en_HK -f ISO-8859-1 en_HK 62 | localedef -i en_PH -f ISO-8859-1 en_PH 63 | localedef -i en_US -f ISO-8859-1 en_US 64 | localedef -i en_US -f UTF-8 en_US.UTF-8 65 | localedef -i es_MX -f ISO-8859-1 es_MX 66 | localedef -i fa_IR -f UTF-8 fa_IR 67 | localedef -i fr_FR -f ISO-8859-1 fr_FR 68 | localedef -i fr_FR@euro -f ISO-8859-15 fr_FR@euro 69 | localedef -i fr_FR -f UTF-8 fr_FR.UTF-8 70 | localedef -i it_IT -f ISO-8859-1 it_IT 71 | localedef -i it_IT -f UTF-8 it_IT.UTF-8 72 | localedef -i ja_JP -f EUC-JP ja_JP 73 | localedef -i ru_RU -f KOI8-R ru_RU.KOI8-R 74 | localedef -i ru_RU -f UTF-8 ru_RU.UTF-8 75 | localedef -i tr_TR -f UTF-8 tr_TR.UTF-8 76 | localedef -i zh_CN -f GB18030 zh_CN.GB18030 77 | # cleanup 78 | popd 79 | rm -rf /tmp/glibc 80 | 81 | # 6.9.2. Configuring Glibc 82 | # 6.9.2.1. Adding nsswitch.conf 83 | cat > /etc/nsswitch.conf <<"EOF" 84 | # Begin /etc/nsswitch.conf 85 | 86 | passwd: files 87 | group: files 88 | shadow: files 89 | 90 | hosts: files dns 91 | networks: files 92 | 93 | protocols: files 94 | services: files 95 | ethers: files 96 | rpc: files 97 | 98 | # End /etc/nsswitch.conf 99 | EOF 100 | 101 | # 6.9.2.2. Adding time zone data 102 | mkdir /tmp/tzdata \ 103 | && tar -xf /sources/tzdata2018e.tar.gz -C /tmp/tzdata \ 104 | && pushd /tmp/tzdata 105 | 106 | ZONEINFO=/usr/share/zoneinfo 107 | mkdir -pv $ZONEINFO/{posix,right} 108 | 109 | for tz in etcetera southamerica northamerica europe africa antarctica \ 110 | asia australasia backward pacificnew systemv; do 111 | zic -L /dev/null -d $ZONEINFO -y "sh yearistype.sh" ${tz} 112 | zic -L /dev/null -d $ZONEINFO/posix -y "sh yearistype.sh" ${tz} 113 | zic -L leapseconds -d $ZONEINFO/right -y "sh yearistype.sh" ${tz} 114 | done 115 | 116 | cp -v zone.tab zone1970.tab iso3166.tab $ZONEINFO 117 | zic -d $ZONEINFO -p America/New_York 118 | unset ZONEINFO 119 | 120 | popd && \ 121 | rm -rf /tmp/tzdata 122 | 123 | # set time zone info 124 | ln -sfv /usr/share/zoneinfo/UTC /etc/localtime 125 | 126 | # 6.9.2.3. Configuring the Dynamic Loader 127 | cat > /etc/ld.so.conf <<"EOF" 128 | # Begin /etc/ld.so.conf 129 | /usr/local/lib 130 | /opt/lib 131 | EOF 132 | cat >> /etc/ld.so.conf <<"EOF" 133 | # Add an include directory 134 | include /etc/ld.so.conf.d/*.conf 135 | EOF 136 | mkdir -pv /etc/ld.so.conf.d 137 | -------------------------------------------------------------------------------- /book/chapter-7-chroot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | echo "> Configure system..." 4 | 5 | sh /book/chapter-7/7.2-make-lfs-bootscripts.sh 6 | sh /book/chapter-7/7.4-manage-devices.sh 7 | sh /book/chapter-7/7.5-configure-network.sh 8 | sh /book/chapter-7/7.6-configure-systemv.sh 9 | sh /book/chapter-7/7.x-configure-bash.sh 10 | 11 | exit 12 | -------------------------------------------------------------------------------- /book/chapter-7.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | echo ">>> Chapter 7" 4 | 5 | # enter and continue in chroot environment with usr 6 | chroot "$LFS" /usr/bin/env -i \ 7 | HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \ 8 | PATH=/bin:/usr/bin:/sbin:/usr/sbin \ 9 | LFS="$LFS" LC_ALL="$LC_ALL" \ 10 | LFS_TGT="$LFS_TGT" MAKEFLAGS="$MAKEFLAGS" \ 11 | LFS_TEST="$LFS_TEST" LFS_DOCS="$LFS_DOCS" \ 12 | JOB_COUNT="$JOB_COUNT" \ 13 | /bin/bash --login \ 14 | -c "sh /book/chapter-7-chroot.sh" 15 | -------------------------------------------------------------------------------- /book/chapter-7/7.2-make-lfs-bootscripts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building LFS-Bootscripts.." 4 | echo "Approximate build time: less than 0.1 SBU" 5 | echo "Required disk space: 244 KB" 6 | 7 | # 7.2. LFS-Bootscripts package contains a set of scripts to start/stop 8 | # the LFS system at bootup/shutdown 9 | tar -xf /sources/lfs-bootscripts-*.tar.bz2 -C /tmp/ \ 10 | && mv /tmp/lfs-bootscripts-* /tmp/lfs-bootscripts \ 11 | && pushd /tmp/lfs-bootscripts 12 | 13 | make install 14 | 15 | # cleanup 16 | popd \ 17 | && rm -rf /tmp/lfs-bootscripts 18 | -------------------------------------------------------------------------------- /book/chapter-7/7.4-manage-devices.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Managing devices.." 4 | 5 | # patch script with docker vendor MAC prefix 6 | sed -i "/declare -A VENDORS$/aVENDORS['02:42:ac:']=\"docker\"" /lib/udev/init-net-rules.sh 7 | 8 | # generate udev rules for networking 9 | bash /lib/udev/init-net-rules.sh 10 | 11 | # inspect generated 12 | cat /etc/udev/rules.d/70-persistent-net.rules 13 | -------------------------------------------------------------------------------- /book/chapter-7/7.5-configure-network.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Setup general network configuration.." 4 | 5 | # 7.5.1 create a sample file for the wlp3s0 device with a static IP address 6 | # TODO make params configurable 7 | cd /etc/sysconfig/ 8 | cat > ifconfig.eth0 <<"EOF" 9 | ONBOOT=yes 10 | IFACE=eth0 11 | SERVICE=ipv4-static 12 | IP=10.0.2.15 13 | GATEWAY=10.0.2.2 14 | PREFIX=24 15 | BROADCAST=10.0.2.255 16 | EOF 17 | 18 | # 7.5.2 DNS configuration 19 | cat > /etc/resolv.conf <<"EOF" 20 | nameserver 8.8.8.8 21 | nameserver 8.8.4.4 22 | EOF 23 | 24 | # 7.5.3 configure system hostname 25 | echo "lfs" > /etc/hostname 26 | 27 | # 7.5.4 customize /etc/hosts file 28 | # TODO values need to be changed for specific uses or requirements 29 | cat > /etc/hosts << "EOF" 30 | # Begin /etc/hosts 31 | 32 | 127.0.0.1 localhost 33 | # 127.0.1.1 34 | # <192.168.1.1> [alias1] [alias2 ...] 35 | ::1 localhost ip6-localhost ip6-loopback 36 | ff02::1 ip6-allnodes 37 | ff02::2 ip6-allrouters 38 | 39 | # End /etc/hosts 40 | EOF 41 | -------------------------------------------------------------------------------- /book/chapter-7/7.6-configure-systemv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Setup system V bootscript configuration.." 4 | 5 | # 7.6.2 configure sysvinit 6 | cat > /etc/inittab << "EOF" 7 | # Begin /etc/inittab 8 | 9 | id:3:initdefault: 10 | 11 | si::sysinit:/etc/rc.d/init.d/rc S 12 | 13 | l0:0:wait:/etc/rc.d/init.d/rc 0 14 | l1:S1:wait:/etc/rc.d/init.d/rc 1 15 | l2:2:wait:/etc/rc.d/init.d/rc 2 16 | l3:3:wait:/etc/rc.d/init.d/rc 3 17 | l4:4:wait:/etc/rc.d/init.d/rc 4 18 | l5:5:wait:/etc/rc.d/init.d/rc 5 19 | l6:6:wait:/etc/rc.d/init.d/rc 6 20 | 21 | ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now 22 | 23 | su:S016:once:/sbin/sulogin 24 | 25 | 1:2345:respawn:/sbin/agetty --noclear tty1 9600 26 | 2:2345:respawn:/sbin/agetty tty2 9600 27 | 3:2345:respawn:/sbin/agetty tty3 9600 28 | 4:2345:respawn:/sbin/agetty tty4 9600 29 | 5:2345:respawn:/sbin/agetty tty5 9600 30 | 6:2345:respawn:/sbin/agetty tty6 9600 31 | 32 | # End /etc/inittab 33 | EOF 34 | 35 | # 7.6.4 configure system clock 36 | cat > /etc/sysconfig/clock << "EOF" 37 | # Begin /etc/sysconfig/clock 38 | 39 | UTC=1 40 | 41 | # Set this to any options you might need to give to hwclock, 42 | # such as machine hardware clock type for Alphas. 43 | CLOCKPARAMS= 44 | 45 | # End /etc/sysconfig/clock 46 | EOF 47 | 48 | # 7.6.5 configure linux console 49 | echo "Skip keyboard map configuration" 50 | 51 | # 7.6.8 configure rc.site 52 | cat > /etc/sysconfig/rc.site <<"EOF" 53 | # rc.site 54 | # Optional parameters for boot scripts. 55 | 56 | # Distro Information 57 | # These values, if specified here, override the defaults 58 | #DISTRO="Linux From Scratch" # The distro name 59 | #DISTRO_CONTACT="lfs-dev@linuxfromscratch.org" # Bug report address 60 | #DISTRO_MINI="LFS" # Short name used in filenames for distro config 61 | 62 | # Define custom colors used in messages printed to the screen 63 | 64 | # Please consult `man console_codes` for more information 65 | # under the "ECMA-48 Set Graphics Rendition" section 66 | # 67 | # Warning: when switching from a 8bit to a 9bit font, 68 | # the linux console will reinterpret the bold (1;) to 69 | # the top 256 glyphs of the 9bit font. This does 70 | # not affect framebuffer consoles 71 | 72 | # These values, if specified here, override the defaults 73 | #BRACKET="\\033[1;34m" # Blue 74 | #FAILURE="\\033[1;31m" # Red 75 | #INFO="\\033[1;36m" # Cyan 76 | #NORMAL="\\033[0;39m" # Grey 77 | #SUCCESS="\\033[1;32m" # Green 78 | #WARNING="\\033[1;33m" # Yellow 79 | 80 | # Use a colored prefix 81 | # These values, if specified here, override the defaults 82 | #BMPREFIX=" " 83 | #SUCCESS_PREFIX="${SUCCESS} * ${NORMAL}" 84 | #FAILURE_PREFIX="${FAILURE}*****${NORMAL}" 85 | #WARNING_PREFIX="${WARNING} *** ${NORMAL}" 86 | 87 | # Manually seet the right edge of message output (characters) 88 | # Useful when resetting console font during boot to override 89 | # automatic screen width detection 90 | #COLUMNS=120 91 | 92 | # Interactive startup 93 | #IPROMPT="yes" # Whether to display the interactive boot prompt 94 | #itime="3" # The amount of time (in seconds) to display the prompt 95 | 96 | # The total length of the distro welcome string, without escape codes 97 | #wlen=$(echo "Welcome to ${DISTRO}" | wc -c ) 98 | #welcome_message="Welcome to ${INFO}${DISTRO}${NORMAL}" 99 | 100 | # The total length of the interactive string, without escape codes 101 | #ilen=$(echo "Press 'I' to enter interactive startup" | wc -c ) 102 | #i_message="Press '${FAILURE}I${NORMAL}' to enter interactive startup" 103 | 104 | # Set scripts to skip the file system check on reboot 105 | #FASTBOOT=yes 106 | 107 | # Skip reading from the console 108 | #HEADLESS=yes 109 | 110 | # Write out fsck progress if yes 111 | #VERBOSE_FSCK=no 112 | 113 | # Speed up boot without waiting for settle in udev 114 | #OMIT_UDEV_SETTLE=y 115 | 116 | # Speed up boot without waiting for settle in udev_retry 117 | #OMIT_UDEV_RETRY_SETTLE=yes 118 | 119 | # Skip cleaning /tmp if yes 120 | #SKIPTMPCLEAN=no 121 | 122 | # For setclock 123 | #UTC=1 124 | #CLOCKPARAMS= 125 | 126 | # For consolelog (Note that the default, 7=debug, is noisy) 127 | #LOGLEVEL=7 128 | 129 | # For network 130 | #HOSTNAME=mylfs 131 | 132 | # Delay between TERM and KILL signals at shutdown 133 | #KILLDELAY=3 134 | 135 | # Optional sysklogd parameters 136 | #SYSKLOGD_PARMS="-m 0" 137 | 138 | # Console parameters 139 | #UNICODE=1 140 | #KEYMAP="de-latin1" 141 | #KEYMAP_CORRECTIONS="euro2" 142 | #FONT="lat0-16 -m 8859-15" 143 | #LEGACY_CHARSET= 144 | EOF 145 | -------------------------------------------------------------------------------- /book/chapter-7/7.x-configure-bash.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Setup bash shell.." 4 | 5 | # 7.8 create inputrc file 6 | cat > /etc/inputrc << "EOF" 7 | # Begin /etc/inputrc 8 | # Modified by Chris Lynn 9 | 10 | # Allow the command prompt to wrap to the next line 11 | set horizontal-scroll-mode Off 12 | 13 | # Enable 8bit input 14 | set meta-flag On 15 | set input-meta On 16 | 17 | # Turns off 8th bit stripping 18 | set convert-meta Off 19 | 20 | # Keep the 8th bit for display 21 | set output-meta On 22 | 23 | # none, visible or audible 24 | set bell-style none 25 | 26 | # All of the following map the escape sequence of the value 27 | # contained in the 1st argument to the readline specific functions 28 | "\eOd": backward-word 29 | "\eOc": forward-word 30 | 31 | # for linux console 32 | "\e[1~": beginning-of-line 33 | "\e[4~": end-of-line 34 | "\e[5~": beginning-of-history 35 | "\e[6~": end-of-history 36 | "\e[3~": delete-char 37 | "\e[2~": quoted-insert 38 | 39 | # for xterm 40 | "\eOH": beginning-of-line 41 | "\eOF": end-of-line 42 | 43 | # for Konsole 44 | "\e[H": beginning-of-line 45 | "\e[F": end-of-line 46 | 47 | # End /etc/inputrc 48 | EOF 49 | 50 | # create shells file 51 | cat > /etc/shells << "EOF" 52 | # Begin /etc/shells 53 | 54 | /bin/sh 55 | /bin/bash 56 | 57 | # End /etc/shells 58 | EOF 59 | -------------------------------------------------------------------------------- /book/chapter-8-chroot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | echo "> Make system bootable..." 4 | 5 | sh /book/chapter-8/8.2-create-fstab.sh 6 | sh /book/chapter-8/8.3-make-linux-kernel.sh 7 | sh /book/chapter-8/8.4-setup-grub.sh 8 | 9 | exit 10 | -------------------------------------------------------------------------------- /book/chapter-8.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | echo ">>> Chapter 8" 4 | 5 | # enter and continue in chroot environment with usr 6 | chroot "$LFS" /usr/bin/env -i \ 7 | HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \ 8 | PATH=/bin:/usr/bin:/sbin:/usr/sbin \ 9 | LFS="$LFS" LC_ALL="$LC_ALL" \ 10 | LFS_TGT="$LFS_TGT" MAKEFLAGS="$MAKEFLAGS" \ 11 | LFS_TEST="$LFS_TEST" LFS_DOCS="$LFS_DOCS" \ 12 | JOB_COUNT="$JOB_COUNT" \ 13 | /bin/bash --login \ 14 | -c "sh /book/chapter-8-chroot.sh" 15 | -------------------------------------------------------------------------------- /book/chapter-8/8.2-create-fstab.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Creating fstab.." 4 | 5 | # 8.2 Creating /etc/fstab 6 | cat > /etc/fstab << "EOF" 7 | # Begin /etc/fstab 8 | 9 | # file system mount-point type options dump fsck 10 | # order 11 | 12 | /dev/ / defaults 1 1 13 | /dev/ swap swap pri=1 0 0 14 | proc /proc proc nosuid,noexec,nodev 0 0 15 | sysfs /sys sysfs nosuid,noexec,nodev 0 0 16 | devpts /dev/pts devpts gid=5,mode=620 0 0 17 | tmpfs /run tmpfs defaults 0 0 18 | devtmpfs /dev devtmpfs mode=0755,nosuid 0 0 19 | 20 | # End /etc/fstab 21 | EOF 22 | -------------------------------------------------------------------------------- /book/chapter-8/8.3-make-linux-kernel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Building linux kernel.." 4 | echo "Approximate build time: 4.4 - 66.0 SBU (typically about 6 SBU)" 5 | echo "Required disk space: 960 - 4250 MB (typically about 1100 MB)" 6 | 7 | # 8.3. Linux package contains the Linux kernel 8 | tar -xf /sources/linux-*.tar.xz -C /tmp/ \ 9 | && mv /tmp/linux-* /tmp/linux \ 10 | && pushd /tmp/linux 11 | 12 | # ensure proper ownership of the files 13 | chown -R 0:0 . 14 | 15 | # 8.3.1 install kernel 16 | 17 | # clean source tree 18 | make mrproper 19 | 20 | # copy premade config 21 | # NOTE manual way is by launching: 22 | # make menuconfig 23 | cp /book/kernel.config .config 24 | 25 | # compile 26 | make 27 | 28 | # installation 29 | make modules_install 30 | 31 | # copy kernel image 32 | cp -iv arch/x86/boot/bzImage /boot/vmlinuz-4.18.5-lfs-8.3 33 | 34 | # copy symbols 35 | cp -iv System.map /boot/System.map-4.18.5 36 | 37 | # copy original configuration 38 | cp -iv .config /boot/config-4.18.5 39 | 40 | # install documentation 41 | install -d /usr/share/doc/linux-4.18.5 42 | cp -r Documentation/* /usr/share/doc/linux-4.18.5 43 | 44 | # 8.3.2. configure linux module load order 45 | install -v -m755 -d /etc/modprobe.d 46 | cat > /etc/modprobe.d/usb.conf << "EOF" 47 | # Begin /etc/modprobe.d/usb.conf 48 | 49 | install ohci_hcd /sbin/modprobe ehci_hcd ; /sbin/modprobe -i ohci_hcd ; true 50 | install uhci_hcd /sbin/modprobe ehci_hcd ; /sbin/modprobe -i uhci_hcd ; true 51 | 52 | # End /etc/modprobe.d/usb.conf 53 | EOF 54 | 55 | # cleanup 56 | popd \ 57 | && rm -rf /tmp/linux 58 | -------------------------------------------------------------------------------- /book/chapter-8/8.4-setup-grub.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Using GRUB to setup the boot process.." 4 | 5 | echo "NOTE: skipped. Check 8.4 chapter of LFS book for details" 6 | 7 | #cd /tmp 8 | #grub-mkrescue --output=grub-img.iso 9 | #xorriso -as cdrecord -v dev=/dev/cdrw blank=as_needed grub-img.iso 10 | 11 | # install GRUB 12 | #grub-install /dev/sda 13 | 14 | # create grub config 15 | #cat > /boot/grub/grub.cfg << "EOF" 16 | ## Begin /boot/grub/grub.cfg 17 | #set default=0 18 | #set timeout=5 19 | # 20 | #insmod ext2 21 | #set root=(hd0,2) 22 | # 23 | #menuentry "GNU/Linux, Linux 4.18.5-lfs-8.3" { 24 | # linux /boot/vmlinuz-4.18.5-lfs-8.3 root=/dev/sda2 ro 25 | #} 26 | #EOF 27 | -------------------------------------------------------------------------------- /book/chapter-9-chroot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | echo "> The End" 4 | 5 | sh /book/chapter-9/9.1-the-end.sh 6 | 7 | exit 8 | -------------------------------------------------------------------------------- /book/chapter-9.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | echo ">>> Chapter 9" 4 | 5 | # enter and continue in chroot environment with usr 6 | chroot "$LFS" /usr/bin/env -i \ 7 | HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \ 8 | PATH=/bin:/usr/bin:/sbin:/usr/sbin \ 9 | LFS="$LFS" LC_ALL="$LC_ALL" \ 10 | LFS_TGT="$LFS_TGT" MAKEFLAGS="$MAKEFLAGS" \ 11 | LFS_TEST="$LFS_TEST" LFS_DOCS="$LFS_DOCS" \ 12 | JOB_COUNT="$JOB_COUNT" \ 13 | /bin/bash --login \ 14 | -c "sh /book/chapter-9-chroot.sh" 15 | 16 | # cleanup 17 | sh /book/chapter-9/9.x-cleanup.sh 18 | -------------------------------------------------------------------------------- /book/chapter-9/9.1-the-end.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Finalize LFS configuration.." 4 | 5 | # LFS version file 6 | echo 8.3 > /etc/lfs-release 7 | 8 | # Remove shell by tools ans set bash as default 9 | rm -v /bin/sh 10 | ln -s /bin/bash /bin/sh 11 | 12 | # LSB version file 13 | cat > /etc/lsb-release << "EOF" 14 | DISTRIB_ID="Linux From Scratch" 15 | DISTRIB_RELEASE="8.3" 16 | DISTRIB_CODENAME="EvilFreelancer" 17 | DISTRIB_DESCRIPTION="Linux From Scratch" 18 | EOF 19 | 20 | # add login logo 21 | cat > /etc/issue << "EOF" 22 | Linux From Scratch \n \l 23 | EOF 24 | -------------------------------------------------------------------------------- /book/chapter-9/9.x-cleanup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo "Cleanup.." 4 | 5 | # Then unmount the virtual file systems: 6 | umount -v $LFS/dev/pts 7 | umount -v $LFS/dev 8 | umount -v $LFS/run 9 | umount -v $LFS/proc 10 | umount -v $LFS/sys 11 | 12 | # Unmount the LFS file system itself: 13 | umount -v $LFS 14 | -------------------------------------------------------------------------------- /book/library-check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | for lib in lib{gmp,mpfr,mpc}.la; do 4 | echo $lib: $(if find /usr/lib* -name $lib | grep -q $lib;then :;else echo not;fi) found 5 | done 6 | unset 7 | -------------------------------------------------------------------------------- /book/version-check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Simple script to list version numbers of critical development tools 4 | export LC_ALL=C 5 | bash --version | head -n1 | cut -d" " -f2-4 6 | MYSH=$(readlink -f /bin/sh) 7 | echo "/bin/sh -> $MYSH" 8 | echo $MYSH | grep -q bash || echo "ERROR: /bin/sh does not point to bash" 9 | unset MYSH 10 | 11 | echo -n "Binutils: "; ld --version | head -n1 | cut -d" " -f3- 12 | bison --version | head -n1 13 | 14 | if [ -h /usr/bin/yacc ]; then 15 | echo "/usr/bin/yacc -> `readlink -f /usr/bin/yacc`"; 16 | elif [ -x /usr/bin/yacc ]; then 17 | echo yacc is `/usr/bin/yacc --version | head -n1` 18 | else 19 | echo "yacc not found" 20 | fi 21 | 22 | bzip2 --version 2>&1 < /dev/null | head -n1 | cut -d" " -f1,6- 23 | echo -n "Coreutils: "; chown --version | head -n1 | cut -d")" -f2 24 | diff --version | head -n1 25 | find --version | head -n1 26 | gawk --version | head -n1 27 | 28 | if [ -h /usr/bin/awk ]; then 29 | echo "/usr/bin/awk -> `readlink -f /usr/bin/awk`"; 30 | elif [ -x /usr/bin/awk ]; then 31 | echo awk is `/usr/bin/awk --version | head -n1` 32 | else 33 | echo "awk not found" 34 | fi 35 | 36 | gcc --version | head -n1 37 | g++ --version | head -n1 38 | ldd --version | head -n1 | cut -d" " -f2- # glibc version 39 | grep --version | head -n1 40 | gzip --version | head -n1 41 | cat /proc/version 42 | m4 --version | head -n1 43 | make --version | head -n1 44 | patch --version | head -n1 45 | echo Perl `perl -V:version` 46 | sed --version | head -n1 47 | tar --version | head -n1 48 | makeinfo --version | head -n1 49 | xz --version | head -n1 50 | 51 | echo 'int main(){}' > dummy.c && g++ -o dummy dummy.c 52 | if [ -x dummy ] 53 | then echo "g++ compilation OK"; 54 | else echo "g++ compilation failed"; fi 55 | rm -f dummy.c dummy 56 | -------------------------------------------------------------------------------- /docker-compose.yml.dist: -------------------------------------------------------------------------------- 1 | version: '2' 2 | 3 | services: 4 | lfs: 5 | restart: unless-stopped 6 | privileged: true 7 | image: evilfreelancer/docker-lfs-build 8 | volumes: 9 | - ./book:/lfs/book 10 | - ./image:/lfs/image 11 | - ./sources:/lfs/sources 12 | - ./tools:/lfs/tools 13 | - ./lfs:/lfs 14 | - ./dist:/dist 15 | entrypoint: ["sleep", "inf"] 16 | -------------------------------------------------------------------------------- /image/1.configure-syslinux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | echo "> Configuring syslinux.." 4 | 5 | mkdir -p /image/isolinux 6 | 7 | # extract syslinux 8 | tar -xf /sources/syslinux-*.tar.xz -C /tmp/ 9 | mv /tmp/syslinux-* /tmp/syslinux 10 | 11 | # copy needed syslinux binaries 12 | cp -v /tmp/syslinux/bios/core/isolinux.bin /image/isolinux/isolinux.bin 13 | cp -v /tmp/syslinux/bios/com32/elflink/ldlinux/ldlinux.c32 /image/isolinux/ldlinux.c32 14 | 15 | # copy kernel to isolinux folder 16 | cp $LFS/boot/vmlinuz-* /image/isolinux/vmlinuz 17 | 18 | # cleanup 19 | rm -rf /tmp/syslinux 20 | 21 | cat > /image/isolinux/isolinux.cfg << "EOF" 22 | PROMT 0 23 | 24 | DEFAULT bz2 25 | 26 | LABEL bz2 27 | MENU LABEL Bz2 Image of RAM disk 28 | KERNEL vmlinuz 29 | APPEND initrd=lfs.bz2 root=/dev/ram0 rw 3 30 | EOF 31 | -------------------------------------------------------------------------------- /image/2.create-ramdisk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | # Change folder to root of image 4 | cd /image 5 | 6 | echo "> Creating ramdisk..." 7 | 8 | # Create yet another loop device if not exist 9 | [ -e $LOOP ] || mknod $LOOP b 7 0 10 | 11 | # create ramdisk file of IMAGE_SIZE 12 | dd if=/dev/zero of=$IMAGE_RAM bs=1k count=$IMAGE_SIZE 13 | 14 | # plug off any virtual fs from loop device 15 | losetup -d $LOOP 16 | 17 | # associate it with ${LOOP} 18 | losetup $LOOP $IMAGE_RAM 19 | 20 | # make an ext2 filesystem 21 | mkfs.ext4 -q -m 0 $LOOP $IMAGE_SIZE 22 | 23 | # ensure loop2 directory 24 | [ -d $LOOP_DIR ] || mkdir -pv $LOOP_DIR 25 | 26 | # mount it 27 | mount $LOOP $LOOP_DIR 28 | rm -rf $LOOP_DIR/lost+found 29 | 30 | # copy LFS system without build artifacts 31 | pushd $INITRD_TREE 32 | cp -dpR $(ls -A | grep -Ev "sources|tools|book|image|dist") $LOOP_DIR 33 | popd 34 | 35 | # show statistics 36 | df $LOOP_DIR 37 | 38 | echo "Compressing system ramdisk image.." 39 | bzip2 -c $IMAGE_RAM > $IMAGE_BZ2 40 | 41 | # Cleanup 42 | umount $LOOP_DIR 43 | losetup -d $LOOP 44 | rm -rf $LOOP_DIR 45 | -------------------------------------------------------------------------------- /image/3.build-iso.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | # Change folder to root of image 4 | cd /image 5 | 6 | rm -v $IMAGE_ISO 7 | 8 | echo "> Building bootable iso.." 9 | 10 | cp -v $IMAGE_BZ2 isolinux/ 11 | 12 | # build iso 13 | genisoimage -o $IMAGE_ISO \ 14 | -b isolinux/isolinux.bin \ 15 | -c isolinux/boot.cat \ 16 | -no-emul-boot \ 17 | -boot-load-size 4 \ 18 | -boot-info-table $LFS/image/ 19 | 20 | echo "Image is created: $IMAGE_ISO" 21 | -------------------------------------------------------------------------------- /image/image.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | echo ">>> Start building bootable image.." 4 | 5 | # Change folder to root of image 6 | cd /image 7 | 8 | sh /image/1.configure-syslinux.sh 9 | sh /image/2.create-ramdisk.sh 10 | sh /image/3.build-iso.sh 11 | 12 | rm -rf /image/isolinux 13 | -------------------------------------------------------------------------------- /sources/.gitsave: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EvilFreelancer/docker-lfs-build/445cdb2e187762d5988d3c578786072dff19cfc6/sources/.gitsave --------------------------------------------------------------------------------