Table of Contents
序章 .................................................................................................................................................... vii
i. 前言 ........................................................................................................................................... vii
ii. 致读者 ...................................................................................................................................... vii
iii. LFS 的目标架构 ........................................................................................................................ viii
iv. LFS 和标准 .............................................................................................................................. viii
v. 本书中的软件包逻辑 ................................................................................................................... ix
vi. 前提条件 .................................................................................................................................. xiii
vii. 排版约定 ................................................................................................................................. xiii
viii. 本书结构 ................................................................................................................................ xiv
ix. 勘误表 ..................................................................................................................................... xiv
I. 介绍 .................................................................................................................................................. 1
1. 介绍 .......................................................................................................................................... 2
1.1. 如何构建 LFS 系统 ............................................................................................................ 2
1.2. 自上一版手册发布后的变更 ................................................................................................ 2
1.3. 更新日志 ........................................................................................................................... 3
1.4. 资源 ................................................................................................................................. 6
1.5. 帮助 ................................................................................................................................. 6
II. 准备构建 .......................................................................................................................................... 8
2. 准备宿主系统 ............................................................................................................................. 9
2.1. 简介 ................................................................................................................................. 9
2.2. 宿主系统要求 .................................................................................................................... 9
2.3. 分阶段构建 LFS ............................................................................................................... 12
2.4. 创建新分区 ..................................................................................................................... 12
2.5. 在分区上创建文件系统 ..................................................................................................... 13
2.6. 设置 $LFS 变量 ............................................................................................................... 14
2.7. 挂载新分区 ..................................................................................................................... 14
3. 软件包和补丁 ........................................................................................................................... 16
3.1. 简介 ............................................................................................................................... 16
3.2. 所有软件包 ..................................................................................................................... 16
3.3. 需要的补丁 ..................................................................................................................... 22
4. 最后的准备工作 ........................................................................................................................ 24
4.1. 简介 ............................................................................................................................... 24
4.2. 创建目录 $LFS/tools ....................................................................................................... 24
4.3. 添加 LFS 用户 ................................................................................................................. 24
4.4. 设置环境 ......................................................................................................................... 25
4.5. 关于 SBUs ...................................................................................................................... 25
4.6. 关于测试套件 .................................................................................................................. 26
5. 构建临时系统 ........................................................................................................................... 27
5.1. 简介 ............................................................................................................................... 27
5.2. 工具链技术说明 ............................................................................................................... 27
5.3. 通用编译指南 .................................................................................................................. 28
5.4. Binutils-2.32 - 第 1 遍 .................................................................................................... 30
5.5. GCC-9.2.0 - 第 1 遍 ........................................................................................................ 32
5.6. Linux-5.2.8 API 头文件 .................................................................................................... 34
5.7. Glibc-2.30 ....................................................................................................................... 35
5.8. GCC-9.2.0 中的 Libstdc++ ............................................................................................... 37
5.9. Binutils-2.32 - 第 2 遍 .................................................................................................... 38
5.10. GCC-9.2.0 - 第 2 遍 ...................................................................................................... 39
5.11. Tcl-8.6.9 ....................................................................................................................... 41
5.12. Expect-5.45.4 ................................................................................................................ 42
5.13. DejaGNU-1.6.2 .............................................................................................................. 43
5.14. M4-1.4.18 .................................................................................................................... 44
5.15. Ncurses-6.1 .................................................................................................................. 45
5.16. Bash-5.0 ....................................................................................................................... 46
5.17. Bison-3.4.1 ................................................................................................................... 47
5.18. Bzip2-1.0.8 ................................................................................................................... 48
5.19. Coreutils-8.31 ............................................................................................................... 49
5.20. Diffutils-3.7 ................................................................................................................... 5Linux From Scratch (简体中文版) - 版本 9.0
5.21. File-5.37 ....................................................................................................................... 51
5.22. Findutils-4.6.0 ............................................................................................................... 52
5.23. Gawk-5.0.1 ................................................................................................................... 53
5.24. Gettext-0.20.1 ............................................................................................................... 54
5.25. Grep-3.3 ....................................................................................................................... 55
5.26. Gzip-1.10 ...................................................................................................................... 56
5.27. Make-4.2.1 ................................................................................................................... 57
5.28. Patch-2.7.6 ................................................................................................................... 58
5.29. Perl-5.30.0 .................................................................................................................... 59
5.30. Python-3.7.4 ................................................................................................................. 60
5.31. Sed-4.7 ........................................................................................................................ 61
5.32. Tar-1.32 ........................................................................................................................ 62
5.33. Texinfo-6.6 .................................................................................................................... 63
5.34. Xz-5.2.4 ........................................................................................................................ 64
5.35. 清理无用内容 ................................................................................................................ 65
5.36. 改变属主 ....................................................................................................................... 65
III. 构建 LFS 系统 ............................................................................................................................... 66
6. 安装基本的系统软件 ................................................................................................................. 67
6.1. 简介 ............................................................................................................................... 67
6.2. 准备虚拟内核文件系统 ..................................................................................................... 67
6.3. 软件包管理 ..................................................................................................................... 68
6.4. 进入 Chroot 环境 ............................................................................................................. 70
6.5. 创建目录 ......................................................................................................................... 71
6.6. 创建必要的文件和符号链接 .............................................................................................. 71
6.7. Linux-5.2.8 API 头文件 .................................................................................................... 74
6.8. Man-pages-5.02 .............................................................................................................. 75
6.9. Glibc-2.30 ....................................................................................................................... 76
6.10. 调整工具链 ................................................................................................................... 82
6.11. Zlib-1.2.11 .................................................................................................................... 84
6.12. File-5.37 ....................................................................................................................... 85
6.13. Readline-8.0 .................................................................................................................. 86
6.14. M4-1.4.18 .................................................................................................................... 87
6.15. Bc-2.1.3 ....................................................................................................................... 88
6.16. Binutils-2.32 ................................................................................................................. 89
6.17. GMP-6.1.2 .................................................................................................................... 91
6.18. MPFR-4.0.2 ................................................................................................................... 93
6.19. MPC-1.1.0 ..................................................................................................................... 94
6.20. Shadow-4.7 ................................................................................................................... 95
6.21. GCC-9.2.0 ..................................................................................................................... 98
6.22. Bzip2-1.0.8 ................................................................................................................. 102
6.23. Pkg-config-0.29.2 ........................................................................................................ 104
6.24. Ncurses-6.1 ................................................................................................................ 105
6.25. Attr-2.4.48 .................................................................................................................. 107
6.26. Acl-2.2.53 ................................................................................................................... 108
6.27. Libcap-2.27 ................................................................................................................. 109
6.28. Sed-4.7 ....................................................................................................................... 110
6.29. Psmisc-23.2 ................................................................................................................ 111
6.30. Iana-Etc-2.30 .............................................................................................................. 112
6.31. Bison-3.4.1 ................................................................................................................. 113
6.32. Flex-2.6.4 .................................................................................................................... 114
6.33. Grep-3.3 ..................................................................................................................... 115
6.34. Bash-5.0 ..................................................................................................................... 116
6.35. Libtool-2.4.6 ............................................................................................................... 117
6.36. GDBM-1.18.1 .............................................................................................................. 118
6.37. Gperf-3.1 .................................................................................................................... 119
6.38. Expat-2.2.7 ................................................................................................................. 120
6.39. Inetutils-1.9.4 ............................................................................................................. 121
6.40. Perl-5.30.0 .................................................................................................................. 123
6.41. XML::Parser-2.44 ......................................................................................................... 125
6.42. Intltool-0.51.0 ............................................................................................................. 126
6.43. Autoconf-2.69 ............................................................................................................. 127
iv
Linux From Scratch (简体中文版) - 版本 9.0
6.44. Automake-1.16.1 .........................................................................................................
128
6.45. Xz-5.2.4 ......................................................................................................................
129
6.46. Kmod-26 .....................................................................................................................
131
6.47. Gettext-0.20.1 .............................................................................................................
132
6.48. Libelf 源自 Elfutils-0.177 .............................................................................................
134
6.49. Libffi-3.2.1 ..................................................................................................................
135
6.50. OpenSSL-1.1.1c ..........................................................................................................
136
6.51. Python-3.7.4 ...............................................................................................................
137
6.52. Ninja-1.9.0 ..................................................................................................................
139
6.53. Meson-0.51.1 .............................................................................................................
140
6.54. Coreutils-8.31 .............................................................................................................
141
6.55. Check-0.12.0 ..............................................................................................................
145
6.56. Diffutils-3.7 .................................................................................................................
146
6.57. Gawk-5.0.1 .................................................................................................................
147
6.58. Findutils-4.6.0 .............................................................................................................
148
6.59. Groff-1.22.4 ................................................................................................................
149
6.60. GRUB-2.04 ..................................................................................................................
151
6.61. Less-551 ....................................................................................................................
153
6.62. Gzip-1.10 ....................................................................................................................
154
6.63. IPRoute2-5.2.0 ............................................................................................................
155
6.64. Kbd-2.2.0 ....................................................................................................................
157
6.65. Libpipeline-1.5.1 ..........................................................................................................
159
6.66. Make-4.2.1 .................................................................................................................
160
6.67. Patch-2.7.6 .................................................................................................................
161
6.68. Man-DB-2.8.6.1 ...........................................................................................................
162
6.69. Tar-1.32 ......................................................................................................................
164
6.70. Texinfo-6.6 ..................................................................................................................
165
6.71. Vim-8.1.1846 ..............................................................................................................
167
6.72. Procps-ng-3.3.15 .........................................................................................................
170
6.73. Util-linux-2.34 ..............................................................................................................
172
6.74. E2fsprogs-1.45.3 .........................................................................................................
176
6.75. Sysklogd-1.5.1 ............................................................................................................
178
6.76. Sysvinit-2.95 ...............................................................................................................
179
6.77. Eudev-3.2.8 ................................................................................................................
180
6.78. 关于调试符号 ..............................................................................................................
181
6.79. 再次清理无用内容 ........................................................................................................
181
6.80. 清理 ...........................................................................................................................
182
7. 基本系统配置 .........................................................................................................................
183
7.1. 简介 .............................................................................................................................
183
7.2. LFS-Bootscripts-20190524 ............................................................................................
184
7.3. 设备与模块管理概述 ......................................................................................................
185
7.4. 设备管理 .......................................................................................................................
187
7.5. 通用网络配置 ................................................................................................................
189
7.6. System V 启动脚本的运用与配置 ....................................................................................
191
7.7. Bash Shell 启动文件 ......................................................................................................
197
7.8. 创建 /etc/inputrc 文件 ...................................................................................................
198
7.9. 创建 /etc/shells 文件 ....................................................................................................
199
8. 让 LFS 系统可引导 .................................................................................................................
200
8.1. 简介 .............................................................................................................................
200
8.2. 创建 /etc/fstab 文件 .....................................................................................................
200
8.3. Linux-5.2.8 ....................................................................................................................
201
8.4. 使用 GRUB 设置启动过程 ..............................................................................................
204
9. 尾声 ......................................................................................................................................
206
9.1. 最后的最后 ...................................................................................................................
206
9.2. 为 LFS 用户数添砖加瓦 ..................................................................................................
206
9.3. 重启系统 .......................................................................................................................
206
9.4. 接下来做什么呢? ..........................................................................................................
207
IV. 附录 ............................................................................................................................................
208
A. 缩写和术语 .............................................................................................................................
209
B. 致谢 ......................................................................................................................................
211
C. 依赖关系 ................................................................................................................................
213
v
Linux From Scratch (简体中文版) - 版本 9.0
D. 启动及系统配置脚本版本-20190524 ....................................................................................... 223
D.1. /etc/rc.d/init.d/rc .......................................................................................................... 223
D.2. /lib/lsb/init-functions ..................................................................................................... 226
D.3. /etc/rc.d/init.d/mountvirtfs ............................................................................................ 237
D.4. /etc/rc.d/init.d/modules ................................................................................................ 238
D.5. /etc/rc.d/init.d/udev ..................................................................................................... 239
D.6. /etc/rc.d/init.d/swap ..................................................................................................... 240
D.7. /etc/rc.d/init.d/setclock ................................................................................................ 241
D.8. /etc/rc.d/init.d/checkfs ................................................................................................. 242
D.9. /etc/rc.d/init.d/mountfs ................................................................................................ 244
D.10. /etc/rc.d/init.d/udev_retry ........................................................................................... 245
D.11. /etc/rc.d/init.d/cleanfs ................................................................................................ 247
D.12. /etc/rc.d/init.d/console ............................................................................................... 248
D.13. /etc/rc.d/init.d/localnet ............................................................................................... 250
D.14. /etc/rc.d/init.d/sysctl .................................................................................................. 251
D.15. /etc/rc.d/init.d/sysklogd .............................................................................................. 252
D.16. /etc/rc.d/init.d/network ............................................................................................... 253
D.17. /etc/rc.d/init.d/sendsignals ......................................................................................... 254
D.18. /etc/rc.d/init.d/reboot ................................................................................................. 255
D.19. /etc/rc.d/init.d/halt ..................................................................................................... 256
D.20. /etc/rc.d/init.d/template ............................................................................................. 256
D.21. /etc/sysconfig/modules ............................................................................................... 257
D.22. /etc/sysconfig/createfiles ............................................................................................ 257
D.23. /etc/sysconfig/udev-retry ............................................................................................. 258
D.24. /sbin/ifup ................................................................................................................... 258
D.25. /sbin/ifdown ............................................................................................................... 260
D.26. /lib/services/ipv4-static ............................................................................................... 262
D.27. /lib/services/ipv4-static-route ...................................................................................... 263
E. udev 配置规则 ........................................................................................................................ 265
E.1. 55-lfs.rules .................................................................................................................... 265
F. LFS Licenses .......................................................................................................................... 266
F.1. Creative Commons License ............................................................................................ 266
F.2. The MIT License ............................................................................................................ 269
Index ................................................................................................................................................ 270
离线