DIY Linux Reference Build

Greg Schafer

Note: A version of this document entirely on one web page is available here.

Permission is granted to copy, distribute, and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is available at http://www.gnu.org/licenses/fdl.html.

This document may be copied and distributed in any medium, either commercially or noncommercially, provided that the GNU Free Documentation License (FDL), the copyright notices, and the license notice saying the GNU FDL applies to the document are reproduced in all copies, and that you add no other conditions whatsoever to those of the GNU FDL.

Jakub "Jimmac" Steiner created the admonition graphics (caution, important, note, tip, and warning) and the navigation graphics (home, next, prev, and up).

Linux is a registered trademark of Linus Torvalds.

All other trademarks and copyrights referred to are the property of their respective owners.

Revision History
Revision CVS 24th April 2009
Please refer to the CVS ChangeLog for full revision history. Note: Due to the dynamic nature of the subject matter this document is forever evolving. As such, there will never be an official "release" with a version number.

Abstract

This is an attempt to document a robust method of natively bootstrapping a modern GNU/Linux system from source, with a strong focus on technical correctness, testing, automation and package management.


Table of Contents

1. Introduction
1.1. Preamble
1.2. Goals
1.3. Build Methods
1.4. Architectures
1.5. Automation
1.6. Build Notes
1.7. Prerequisites
1.8. Security
1.9. Kernel
1.10. Package Management
2. Getting Started
2.1. Environment
2.2. Tarballs
2.3. Patches
3. Temptools Phase - Next Generation Build Method
3.1. Bash-3.2 Pass 1
3.2. Make-3.81 Pass 1
3.3. Sed-4.1.5 Pass 1
3.4. Binutils Pass 1 a.k.a. Cross Binutils (2.16.1 through 2.18)
3.5. GCC Pass 1 a.k.a. Cross GCC (3.4.6 through 4.3.3)
3.6. Linux-Kernel-Headers-2.6.27
3.7. Linux-Libc-Headers-2.6.12.0 (Older toolchains only)
3.8. Glibc 32-bit - *ONLY* for Bi-arch x86_64 (2.3.6 through 2.8)
3.9. Glibc (2.3.6 through 2.8)
3.10. Adjust Toolchain
3.11. Binutils Pass 2 (2.16.1 through 2.18)
3.12. GCC Pass 2 (3.4.6 through 4.3.3)
3.13. Gawk-3.1.6
3.14. Coreutils-6.12
3.15. Bzip2-1.0.5
3.16. Gzip-1.3.12
3.17. Diffutils-2.8.1
3.18. Findutils-4.4.0
3.19. Make-3.81 Pass 2
3.20. Grep-2.5.4
3.21. Sed-4.1.5 Pass 2
3.22. Gettext-0.17
3.23. Ncurses-5.7
3.24. Patch-2.5.4
3.25. Tar-1.22
3.26. Texinfo-4.13a
3.27. Bash-3.2 Pass 2
3.28. M4-1.4.13
3.29. Bison-2.4.1
3.30. Flex-2.5.35
3.31. E2fsprogs-1.41.4
3.32. Util-Linux-ng-2.14.2
3.33. Perl-5.10.0
3.34. Tcl-8.4.19
3.35. Expect-5.43.0
3.36. DejaGnu-1.4.4
3.37. Fakeroot-1.11 (Optional)
3.38. Zlib-1.2.3 (Optional)
3.39. Libtar-1.2.11 (Optional)
3.40. Pacman-2.9.8 (Optional)
3.41. Ogdlutils-20041124 (Optional)
3.42. Cpio-2.9 (Optional)
3.43. BPM-1.7 (Optional)
3.44. Remove Cruft
4. Chroot Phase - Next Generation Build Method
4.1. About $PM_DEST
4.2. Enter Chroot Environment
4.3. Create Directories
4.4. Perform Mounts
4.5. Create Symlinks
4.6. Create Misc. Files
4.7. Create Users
4.8. Makedev-1.7
4.9. Man-Pages-3.20
4.10. Man-Pages-Posix-2003-a
4.11. Linux-Kernel-Headers-2.6.27
4.12. Linux-Libc-Headers-2.6.12.0 (Older toolchains only)
4.13. Glibc 32-bit - *ONLY* for Bi-arch x86_64 (2.3.6 through 2.8)
4.14. Glibc (2.3.6 through 2.8)
4.15. Readjust Toolchain
4.16. Zlib-1.2.3
4.17. Binutils (2.16.1 through 2.18)
4.18. GCC (3.4.6 through 4.3.3)
4.19. Sed-4.1.5
4.20. E2fsprogs-1.41.4
4.21. Coreutils-6.12
4.22. Iana-Etc-2.30
4.23. Gawk-3.1.6
4.24. Findutils-4.4.0
4.25. Ncurses-5.7
4.26. Readline-5.2
4.27. Vim-7.2
4.28. M4-1.4.13
4.29. Bison-2.4.1
4.30. Less-429
4.31. Groff-1.19.2
4.32. Flex-2.5.35
4.33. Gettext-0.17
4.34. Net-Tools-1.60
4.35. Inetutils-1.6
4.36. Procps-3.2.7
4.37. Perl-5.10.0
4.38. Gzip-1.3.12
4.39. Texinfo-4.13a
4.40. Grep-2.5.4
4.41. File-5.00
4.42. Libtool-2.2.6a
4.43. Autoconf-2.63
4.44. Automake-1.10.1
4.45. Bash-3.2
4.46. Bzip2-1.0.5
4.47. Diffutils-2.8.1
4.48. Ed-1.2
4.49. Kbd-1.14.1
4.50. Man-1.6f
4.51. Make-3.81
4.52. Module-Init-Tools-3.4.1
4.53. Patch-2.5.4
4.54. Psmisc-22.6
4.55. Shadow-4.1.2.2
4.56. Sysklogd-1.5
4.57. Sysvinit-2.86
4.58. Tar-1.22
4.59. Util-Linux-ng-2.14.2
4.60. Grub-0.97 (x86 and Bi-arch x86_64 Only)
4.61. Yaboot-1.3.14 (PPC Only)
4.62. Mac-Fdisk-0.1 (PPC Only)
4.63. Hfsutils-3.2.6 (PPC Only)
4.64. Fakeroot-1.11 (Optional)
4.65. Libtar-1.2.11 (Optional)
4.66. Pacman-2.9.8 (Optional)
4.67. Ogdlutils-20041124 (Optional)
4.68. Cpio-2.9 (Optional)
4.69. BPM-1.7 (Optional)
5. Finishing Up
5.1. Making it Functional
5.2. Conclusion
5.3. Acknowledgments
6. Temptools Phase - Original Build Method (Deprecated)
6.1. Bash-3.2 Pass 1
6.2. Make-3.81 Pass 1
6.3. Sed-4.1.5 Pass 1
6.4. Binutils Pass 1 (2.16.1 through 2.18)
6.5. GCC Pass 1 (3.4.6 through 4.2.4)
6.6. Linux-Kernel-Headers-2.6.27
6.7. Linux-Libc-Headers-2.6.12.0 (Older toolchains only)
6.8. Glibc (2.3.6 through 2.7)
6.9. Adjust Toolchain
6.10. GCC Pass 2 (3.4.6 through 4.2.4)
6.11. Binutils Pass 2 (2.16.1 through 2.18)
6.12. Gawk-3.1.6
6.13. Coreutils-6.12
6.14. Bzip2-1.0.5
6.15. Gzip-1.3.12
6.16. Diffutils-2.8.1
6.17. Findutils-4.4.0
6.18. Make-3.81 Pass 2
6.19. Grep-2.5.4
6.20. Sed-4.1.5 Pass 2
6.21. Gettext-0.17
6.22. Ncurses-5.7
6.23. Patch-2.5.4
6.24. Tar-1.22
6.25. Texinfo-4.13a
6.26. Bash-3.2 Pass 2
6.27. M4-1.4.13
6.28. Bison-2.4.1
6.29. Flex-2.5.35
6.30. E2fsprogs-1.41.4
6.31. Util-Linux-ng-2.14.2
6.32. Perl-5.10.0
6.33. Tcl-8.4.19
6.34. Expect-5.43.0
6.35. DejaGnu-1.4.4
6.36. Fakeroot-1.11 (Optional)
6.37. Zlib-1.2.3 (Optional)
6.38. Libtar-1.2.11 (Optional)
6.39. Pacman-2.9.8 (Optional)
6.40. Ogdlutils-20041124 (Optional)
6.41. Cpio-2.9 (Optional)
6.42. BPM-1.7 (Optional)
6.43. Remove Cruft
7. Chroot Phase - Original Build Method (Deprecated)
7.1. About $PM_DEST
7.2. Enter Chroot Environment
7.3. Create Directories
7.4. Perform Mounts
7.5. Create Symlinks
7.6. Create Misc. Files
7.7. Create Users
7.8. Makedev-1.7
7.9. Man-Pages-3.20
7.10. Man-Pages-Posix-2003-a
7.11. Linux-Kernel-Headers-2.6.27
7.12. Linux-Libc-Headers-2.6.12.0 (Older toolchains only)
7.13. Glibc (2.3.6 through 2.7)
7.14. Readjust Toolchain
7.15. GCC (3.4.6 through 4.2.4)
7.16. Binutils (2.16.1 through 2.18)
7.17. Sed-4.1.5
7.18. E2fsprogs-1.41.4
7.19. Coreutils-6.12
7.20. Zlib-1.2.3
7.21. Iana-Etc-2.30
7.22. Gawk-3.1.6
7.23. Findutils-4.4.0
7.24. Ncurses-5.7
7.25. Readline-5.2
7.26. Vim-7.2
7.27. M4-1.4.13
7.28. Bison-2.4.1
7.29. Less-429
7.30. Groff-1.19.2
7.31. Flex-2.5.35
7.32. Gettext-0.17
7.33. Net-Tools-1.60
7.34. Inetutils-1.6
7.35. Procps-3.2.7
7.36. Perl-5.10.0
7.37. Gzip-1.3.12
7.38. Texinfo-4.13a
7.39. Grep-2.5.4
7.40. File-5.00
7.41. Libtool-2.2.6a
7.42. Autoconf-2.63
7.43. Automake-1.10.1
7.44. Bash-3.2
7.45. Bzip2-1.0.5
7.46. Diffutils-2.8.1
7.47. Ed-1.2
7.48. Kbd-1.14.1
7.49. Man-1.6f
7.50. Make-3.81
7.51. Module-Init-Tools-3.4.1
7.52. Patch-2.5.4
7.53. Psmisc-22.6
7.54. Shadow-4.1.2.2
7.55. Sysklogd-1.5
7.56. Sysvinit-2.86
7.57. Tar-1.22
7.58. Util-Linux-ng-2.14.2
7.59. Grub-0.97 (X86 Only)
7.60. Yaboot-1.3.14 (PPC Only)
7.61. Mac-Fdisk-0.1 (PPC Only)
7.62. Hfsutils-3.2.6 (PPC Only)
7.63. Fakeroot-1.11 (Optional)
7.64. Libtar-1.2.11 (Optional)
7.65. Pacman-2.9.8 (Optional)
7.66. Ogdlutils-20041124 (Optional)
7.67. Cpio-2.9 (Optional)
7.68. BPM-1.7 (Optional)
A. Bootstrap Status
B. Toolchain Special Section