Milestone 4 (Chapters 8, 9 and 10)
Chapter 8 Installing Basic System Software
8.3. Man-pages-5.13
Install Man-pages by running:
8.4. Iana-Etc-20220812
For this package, we only need to copy the files into place:
8.5. Glibc-2.36
Some of the Glibc programs use the non-FHS compliant /var/db
directory to store their runtime data. Apply the following patch to make such programs store their runtime data in the FHS-compliant locations:
The Glibc documentation recommends building Glibc in a dedicated build directory:
Ensure that the ldconfig and sln utilities will be installed into /usr/sbin
:
Prepare Glibc for compilation:
Compile the package:
Generally a few tests do not pass. The test failures listed below are usually safe to ignore.
Though it is a harmless message, the install stage of Glibc will complain about the absence of /etc/ld.so.conf
. Prevent this warning with:
Fix the Makefile to skip an unneeded sanity check that fails in the LFS partial environment:
Install the package:
Fix hardcoded path to the executable loader in ldd script:
Install the configuration file and runtime directory for nscd:
Individual locales can be installed using the localedef program. E.g., the second localedef command below combines the /usr/share/i18n/locales/cs_CZ
charset-independent locale definition with the /usr/share/i18n/charmaps/UTF-8.gz
charmap definition and appends the result to the /usr/lib/locale/locale-archive
file. The following instructions will install the minimum set of locales necessary for the optimal coverage of tests:
Alternatively, install all locales listed in the glibc-2.36/localedata/SUPPORTED
file (it includes every locale listed above and many more) at once with the following time-consuming command:
Then use the localedef command to create and install locales not listed in the glibc-2.36/localedata/SUPPORTED
file when you need them. For instance, the following two locales are needed for some tests later in this chapter:
8.5.2. Configuring Glibc
Create a new file /etc/nsswitch.conf
by running the following:
Install and set up the time zone data with the following:
Had an error here and had to make /dev/null not a file
Then create the /etc/localtime
file by running:
Create a new file /etc/ld.so.conf
by running the following:
If desired, the dynamic loader can also search a directory and include the contents of files found there. Generally the files in this include directory are one line specifying the desired library path. To add this capability run the following commands:
8.6. Zlib-1.2.12
Prepare Zlib for compilation:
Compile the package:
To test the results, issue:
Install the package:
Remove a useless static library:
8.7. Bzip2-1.0.8
Apply a patch that will install the documentation for this package:
The following command ensures installation of symbolic links are relative:
Ensure the man pages are installed into the correct location:
Prepare Bzip2 for compilation with:
8.8. Xz-5.2.6
Prepare Xz for compilation with:
Compile the package:
To test the results, issue:
Install the package:
8.9. Zstd-1.5.2
Apply a patch to fix some issues identified by upstream:
Compile the package:
To test the results, issue:
Install the package:
Remove the static library:
8.10. File-5.42
Prepare File for compilation:
Compile the package:
To test the results, issue:
Install the package:
8.11. Readline-8.1.2
Reinstalling Readline will cause the old libraries to be moved to <libraryname>.old. While this is normally not a problem, in some cases it can trigger a linking bug in ldconfig. This can be avoided by issuing the following two seds:
Prepare Readline for compilation:
Compile the package:
Install the package:
If desired, install the documentation:
8.12. M4-1.4.19
Prepare M4 for compilation:
Compile the package:
To test the results, issue:
Install the package:
8.13. Bc-6.0.1
Prepare Bc for compilation:
Compile the package:
To test bc, run:
Install the package:
8.14. Flex-2.6.4
Prepare Flex for compilation:
Compile the package:
To test the results (about 0.5 SBU), issue:
Install the package:
A few programs do not know about flex yet and try to run its predecessor, lex. To support those programs, create a symbolic link named lex
that runs flex
in lex emulation mode:
8.15. Tcl-8.6.12
First, unpack the documentation by issuing the following command:
Prepare Tcl for compilation:
Build the package:
To test the results, issue:
Install the package:
Make the installed library writable so debugging symbols can be removed later:
Install Tcl's headers. The next package, Expect, requires them.
Now make a necessary symbolic link:
Rename a man page that conflicts with a Perl man page:
If you downloaded the optional documentation, install it by issuing the following commands:
8.16. Expect-5.45.4
Prepare Expect for compilation:
Build the package:
To test the results, issue:
Install the package:
8.17. DejaGNU-1.6.3
The upstream recommends building DejaGNU in a dedicated build directory:
Prepare DejaGNU for compilation:
Build and install the package:
To test the results, issue:
8.18. Binutils-2.39
Verify that the PTYs are working properly inside the chroot environment by performing a simple test:
This command should output the following:
I got the output of.
To fix this I did
The Binutils documentation recommends building Binutils in a dedicated build directory:
Prepare Binutils for compilation:
Compile the package:
Test the results:
Install the package:
Remove useless static libraries:
8.19. GMP-6.2.1
Prepare GMP for compilation:
Compile the package and generate the HTML documentation:
Test the results:
Ensure that all 197 tests in the test suite passed. Check the results by issuing the following command:
Install the package and its documentation:
8.20. MPFR-4.1.0
Prepare MPFR for compilation:
Compile the package and generate the HTML documentation:
Test the results and ensure that all tests passed:
Install the package and its documentation:
8.21. MPC-1.2.1
Prepare MPC for compilation:
Compile the package and generate the HTML documentation:
To test the results, issue:
Install the package and its documentation:
8.22. Attr-2.5.1
Prepare Attr for compilation:
Compile the package:
The tests need to be run on a filesystem that supports extended attributes such as the ext2, ext3, or ext4 filesystems. To test the results, issue:
Install the package:
8.24. Libcap-2.65
Prevent static libraries from being installed:
Compile the package:
To test the results, issue:
Install the package:
8.25. Shadow-4.12.2
Disable the installation of the groups program and its man pages, as Coreutils provides a better version. Also, prevent the installation of manual pages that were already installed in Section 8.3, “Man-pages-5.13”:
Compile the package:
Install the package:
To enable shadowed passwords, run the following command:
To enable shadowed group passwords, run:
Choose a password for user root and set it by running:
I had an error here the solution was leaving chroot and re-entering
8.26. GCC-12.2.0
If building on x86_64, change the default directory name for 64-bit libraries to “lib”:
The GCC documentation recommends building GCC in a dedicated build directory:
Prepare GCC for compilation:
Compile the package:
One set of tests in the GCC test suite is known to exhaust the default stack, so increase the stack size prior to running the tests:
Test the results as a non-privileged user, but do not stop at errors:
To receive a summary of the test suite results, run:
Install the package:
The GCC build directory is owned by tester
now and the ownership of the installed header directory (and its content) will be incorrect. Change the ownership to root
user and group:
Create a symlink required by the FHS for "historical" reasons.
Add a compatibility symlink to enable building programs with Link Time Optimization (LTO):
Now that our final toolchain is in place, it is important to again ensure that compiling and linking will work as expected. We do this by performing some sanity checks:
There should be no errors, and the output of the last command will be (allowing for platform-specific differences in the dynamic linker name):
Now make sure that we're setup to use the correct start files:
The output of the last command should be:
Verify that the compiler is searching for the correct header files:
This command should return the following output:
Next, verify that the new linker is being used with the correct search paths:
References to paths that have components with '-linux-gnu' should be ignored, but otherwise the output of the last command should be:
Next make sure that we're using the correct libc:
The output of the last command should be:
Make sure GCC is using the correct dynamic linker:
The output of the last command should be (allowing for platform-specific differences in dynamic linker name):
Once everything is working correctly, clean up the test files:
Finally, move a misplaced file:
8.27. Pkg-config-0.29.2
Prepare Pkg-config for compilation:
Compile the package:
To test the results, issue:
Install the package:
8.28. Ncurses-6.3
Prepare Ncurses for compilation:
Compile the package:
The installation of this package will overwrite libncursesw.so.6.3
in-place. It may crash the shell process which is using code and data from the library file. Install the package with DESTDIR
, and replace the library file correctly using install command. A useless static archive which is not handled by configure is also removed:
Many applications still expect the linker to be able to find non-wide-character Ncurses libraries. Trick such applications into linking with wide-character libraries by means of symlinks and linker scripts:
Finally, make sure that old applications that look for -lcurses
at build time are still buildable:
If desired, install the Ncurses documentation:
8.29. Sed-4.8
Prepare Sed for compilation:
Compile the package and generate the HTML documentation:
To test the results, issue:
Install the package and its documentation:
8.30. Psmisc-23.5
Prepare Psmisc for compilation:
Compile the package:
Install the package:
8.31. Gettext-0.21
Prepare Gettext for compilation:
Compile the package:
To test the results (this takes a long time, around 3 SBUs), issue:
Install the package:
8.32. Bison-3.8.2
Prepare Bison for compilation:
Compile the package:
To test the results (about 5.5 SBU), issue:
Install the package:
8.33. Grep-3.7
Prepare Grep for compilation:
Compile the package:
To test the results, issue:
Install the package:
8.34. Bash-5.1.16
Prepare Bash for compilation:
Compile the package:
To prepare the tests, ensure that the tester
user can write to the sources tree:
The testsuite of the package is designed to be run as a non-root
user that owns the terminal connected to standard input. To satisfy the requirement, spawn a new pseudo terminal using Expect and run the tests as the tester
user:
Install the package:
Run the newly compiled bash program (replacing the one that is currently being executed):
8.35. Libtool-2.4.7
Prepare Libtool for compilation:
Compile the package:
To test the results, issue:
Install the package:
Remove a useless static library:
8.36. GDBM-1.23
Prepare GDBM for compilation:
Compile the package:
To test the results, issue:
Install the package:
8.37. Gperf-3.1
Prepare Gperf for compilation:
Compile the package:
The tests are known to fail if running multiple simultaneous tests (-j option greater than 1). To test the results, issue:
Install the package:
8.38. Expat-2.4.8
Prepare Expat for compilation:
Compile the package:
To test the results, issue:
Install the package:
If desired, install the documentation:
8.39. Inetutils-2.3
Prepare Inetutils for compilation:
Compile the package:
To test the results, issue:
Install the package:
Move a program to the proper location:
8.40. Less-590
Prepare Less for compilation:
Compile the package:
Install the package:
8.41. Perl-5.36.0
This version of Perl now builds the Compress::Raw::Zlib and Compress::Raw::BZip2 modules. By default Perl will use an internal copy of the sources for the build. Issue the following command so that Perl will use the libraries installed on the system:
To have full control over the way Perl is set up, you can remove the “-des” options from the following command and hand-pick the way this package is built. Alternatively, use the command exactly as below to use the defaults that Perl auto-detects:
Compile the package:
To test the results (approximately 11 SBU), issue:
Install the package and clean up:
8.42. XML::Parser-2.46
Prepare XML::Parser for compilation:
Compile the package:
To test the results, issue:
Install the package:
8.43. Intltool-0.51.0
First fix a warning that is caused by perl-5.22 and later:
Prepare Intltool for compilation:
Compile the package:
To test the results, issue:
Install the package:
8.44. Autoconf-2.71
Prepare Autoconf for compilation:
Compile the package:
To test the results, issue:
Install the package:
8.45. Automake-1.16.5
Prepare Automake for compilation:
Compile the package:
Using the -j4 make option speeds up the tests, even on systems with only one processor, due to internal delays in individual tests. To test the results, issue:
The test t/subobj.sh is known to fail.
Install the package:
8.46. OpenSSL-3.0.5
Prepare OpenSSL for compilation:
Compile the package:
To test the results, issue:
Install the package:
Add the version to the documentation directory name, to be consistent with other packages:
If desired, install some additional documentation:
8.47. Kmod-30
Prepare Kmod for compilation:
Compile the package:
Install the package and create symlinks for compatibility with Module-Init-Tools (the package that previously handled Linux kernel modules):
8.48. Libelf from Elfutils-0.187
Libelf is part of elfutils-0.187 package. Use the elfutils-0.187.tar.bz2 as the source tarball.
Prepare Libelf for compilation:
Compile the package:
To test the results, issue:
Install only Libelf:
8.49. Libffi-3.4.2
Prepare libffi for compilation:
Compile the package:
To test the results, issue:
Install the package:
8.50. Python-3.10.8
Prepare Python for compilation:
Compile the package:
Install the package:
If desired, install the preformatted documentation:
8.51. Wheel-0.37.1
Install wheel with the following command:
8.52. Ninja-1.11.0
Using the optional procedure below allows a user to limit the number of parallel processes via an environment variable, NINJAJOBS. For example, setting:
If desired, add the capability to use the environment variable NINJAJOBS by running:
Build Ninja with:
To test the results, issue:
Install the package:
8.53. Meson-0.63.1
Compile Meson with the following command:
Install the package:
8.54. Coreutils-9.1
POSIX requires that programs from Coreutils recognize character boundaries correctly even in multibyte locales. The following patch fixes this non-compliance and other internationalization-related bugs.
Now prepare Coreutils for compilation:
Compile the package:
Now the test suite is ready to be run. First, run the tests that are meant to be run as user root
:
We're going to run the remainder of the tests as the tester
user. Certain tests require that the user be a member of more than one group. So that these tests are not skipped, add a temporary group and make the user tester
a part of it:
Fix some of the permissions so that the non-root
user can compile and run the tests:
Now run the tests:
Remove the temporary group:
Install the package:
Move programs to the locations specified by the FHS:
8.55. Check-0.15.2
Prepare Check for compilation:
Build the package:
Compilation is now complete. To run the Check test suite, issue the following command:
Install the package:
8.56. Diffutils-3.8
Prepare Diffutils for compilation:
Compile the package:
To test the results, issue:
Install the package:
8.57. Gawk-5.1.1
First, ensure some unneeded files are not installed:
Prepare Gawk for compilation:
Compile the package:
To test the results, issue:
Install the package:
If desired, install the documentation:
8.58. Findutils-4.9.0
Prepare Findutils for compilation:
Compile the package:
To test the results, issue:
Install the package:
8.59. Groff-1.22.4
Prepare Groff for compilation:
This package does not support parallel build. Compile the package:
Install the package:
8.60. GRUB-2.06
Prepare GRUB for compilation:
Compile the package:
Install the package:
8.61. Gzip-1.12
Prepare Gzip for compilation:
Compile the package:
To test the results, issue:
Install the package:
8.62. IPRoute2-5.19.0
8.63. Kbd-2.5.1
The behaviour of the backspace and delete keys is not consistent across the keymaps in the Kbd package. The following patch fixes this issue for i386 keymaps:
Remove the redundant resizecons program (it requires the defunct svgalib to provide the video mode files - for normal use setfont sizes the console appropriately) together with its manpage.
Prepare Kbd for compilation:
Compile the package:
To test the results, issue:
Install the package:
If desired, install the documentation:
8.64. Libpipeline-1.5.6
Prepare Libpipeline for compilation:
Compile the package:
To test the results, issue:
Install the package:
8.65. Make-4.3
Prepare Make for compilation:
Compile the package:
To test the results, issue:
Install the package:
8.66. Patch-2.7.6
Prepare Patch for compilation:
Compile the package:
To test the results, issue:
Install the package:
8.67. Tar-1.34
Prepare Tar for compilation:
Compile the package:
To test the results, issue:
Install the package:
8.68. Texinfo-6.8
Prepare Texinfo for compilation:
Compile the package:
To test the results, issue:
Install the package:
Optionally, install the components belonging in a TeX installation:
The Info documentation system uses a plain text file to hold its list of menu entries. The file is located at /usr/share/info/dir
. Unfortunately, due to occasional problems in the Makefiles of various packages, it can sometimes get out of sync with the info pages installed on the system. If the /usr/share/info/dir
file ever needs to be recreated, the following optional commands will accomplish the task:
8.69. Vim-9.0.0228
8.70. Eudev-3.2.11
Prepare Eudev for compilation:
Compile the package:
Create some directories now that are needed for tests, but will also be used as a part of installation:
To test the results, issue:
Install the package:
Install some custom rules and support files useful in an LFS environment:
Configuring Eudev
8.70 MarkupSafe
8.71 Jinja2
8.72. Systemd-251
First, fix an issue introduced by glibc-2.36.
Remove two unneeded groups, render
and sgx
, from the default udev rules:
Prepare systemd for compilation:
Compile the package:
Install the package:
Install the man pages:
Create the /etc/machine-id
file needed by systemd-journald:
Setup the basic target structure:
Disable a service for upgrading binary distros. It's useless for a basic Linux system built from source, and it will report an error if it's enabled but not configured:
8.73. D-Bus-1.14.0
Prepare D-Bus for compilation:
Compile the package:
Install the package:
Create a symlink so that D-Bus and systemd can use the same machine-id
file:
8.74. Man-DB-2.10.2
Prepare Man-DB for compilation:
Compile the package:
To test the results, issue:
Install the package:
8.75. Procps-ng-4.0.0
Prepare procps-ng for compilation:
Compile the package:
To run the test suite, run:
Install the package:
8.76. Util-linux-2.38.1
Prepare Util-linux for compilation:
Compile the package:
Install the package:
8.77. E2fsprogs-1.46.5
The e2fsprogs documentation recommends that the package be built in a subdirectory of the source tree:
Prepare e2fsprogs for compilation:
Compile the package:
To run the tests, issue:
Install the package:
Skipped over stripping
8.80. Cleaning Up
Finally, clean up some extra files left around from running tests:
The compiler built in Chapter 6 and Chapter 7 is still partially installed and not needed anymore. Remove it with:
Finally, remove the temporary 'tester' user account created at the beginning of the previous chapter.
Chapter 9 System Configuration
9.2 Networking Configuration
9.2.1.3. DHCP Configuration
The command below creates a basic configuration file for an IPv4 DHCP setup:
9.2.3 Hostname
9.2.4 /etc/hosts
9.5 System Clock
9.7 Locale
9.8 inputrc
9.9 shells
9.10 Systemd configuration
Chapter 10 Making LFS Bootable
10.2 /etc/fstab
10.3.1 Linux Kernel
10.3.2 Module load order
10.4 Grub
Powered off snapshot
Chapter 11 The End
Last updated