OSDN Git Service

03e888ca8613a6dd8ea33b3aa4c2f0fc10979829
[resuse/doc.git] / LFS手册持续更新.txt
1 SUReLinux项目构建手册(内部文件,不要外传,参数说明见LFS官方文档)\r
2 第一章 准备系统\r
3 1.1准备工作\r
4 本文假定中途不会关机,推荐使用虚拟机挂起功能。\r
5 作者在VMWare Workstation 15.5下测试。(请不要使用virtualbox,virtualbox的CPU利用率较低,在支持超线程的CPU上面甚至低于hyper-v。qemu存在桥接网卡的问题,方案自行检索。hyper-v, xen未测试)\r
6 内存推荐4G,最少2G, swap最少4G。硬盘80G(完整版内核需要15G以上空间编译,所以必须要这么大硬盘,使用虚拟机的话,直接创建80G以及以上硬盘即可),处理器能好点用好点的,只要是64位处理器就行。\r
7 LFS系统宿主机要求(按照LFS要求筛选之后):OpenSUSE(leap, tumbleweeded均可,推荐)\r
8 mageia(推荐)\r
9 ubuntu/debian/kali(debian与kali请用su - root代替su,并请运行sudo dpkg-reconfigure bash,将默认shell从dash切为bash)\r
10 archlinux/manjaro(archlinux vmware剪贴板异常,manjaro安装gtkmm gtkmm3后没问题)\r
11 gentoo/funtoo(vmware剪贴板异常),debian/kali(普通用户的su请改为su - root)\r
12 已知存在问题的不符合要求的:fedora/centos/rhel(yacc这边不一致,fedora可用opensuse的bison安装包代替),alpine(使用的是musl,不是glibc),solus(多项不符合要求),WSL(没有lsblk,无法chroot)。\r
13 另外请自行准备ocserv服务器/代理服务器,aria2c或者wget\r
14 使用如下代码检测是否安装全必要的软件\r
15 cat > version-check.sh << "EOF"\r
16 #!/bin/bash\r
17 # Simple script to list version numbers of critical development tools\r
18 export LC_ALL=C\r
19 bash --version | head -n1 | cut -d" " -f2-4\r
20 MYSH=$(readlink -f /bin/sh)\r
21 echo "/bin/sh -> $MYSH"\r
22 echo $MYSH | grep -q bash || echo "ERROR: /bin/sh does not point to bash"\r
23 unset MYSH\r
24 \r
25 echo -n "Binutils: "; ld --version | head -n1 | cut -d" " -f3-\r
26 bison --version | head -n1\r
27 \r
28 if [ -h /usr/bin/yacc ]; then\r
29   echo "/usr/bin/yacc -> `readlink -f /usr/bin/yacc`";\r
30 elif [ -x /usr/bin/yacc ]; then\r
31   echo yacc is `/usr/bin/yacc --version | head -n1`\r
32 else\r
33   echo "yacc not found"\r
34 fi\r
35 \r
36 bzip2 --version 2>&1 < /dev/null | head -n1 | cut -d" " -f1,6-\r
37 echo -n "Coreutils: "; chown --version | head -n1 | cut -d")" -f2\r
38 diff --version | head -n1\r
39 find --version | head -n1\r
40 gawk --version | head -n1\r
41 echo -n "pkg-config "; pkg-config --version\r
42 if [ -h /usr/bin/awk ]; then\r
43   echo "/usr/bin/awk -> `readlink -f /usr/bin/awk`";\r
44 elif [ -x /usr/bin/awk ]; then\r
45   echo awk is `/usr/bin/awk --version | head -n1`\r
46 else\r
47   echo "awk not found"\r
48 fi\r
49 \r
50 gcc --version | head -n1\r
51 g++ --version | head -n1\r
52 ldd --version | head -n1 | cut -d" " -f2-  # glibc version\r
53 grep --version | head -n1\r
54 gzip --version | head -n1\r
55 cat /proc/version\r
56 m4 --version | head -n1\r
57 make --version | head -n1\r
58 patch --version | head -n1\r
59 echo Perl `perl -V:version`\r
60 python3 --version\r
61 sed --version | head -n1\r
62 tar --version | head -n1\r
63 makeinfo --version | head -n1  # texinfo version\r
64 xz --version | head -n1\r
65 \r
66 echo 'int main(){}' > dummy.c && g++ -o dummy dummy.c\r
67 if [ -x dummy ]\r
68   then echo "g++ compilation OK";\r
69   else echo "g++ compilation failed"; fi\r
70 rm -f dummy.c dummy\r
71 EOF\r
72 bash version-check.sh\r
73 \r
74 额外,装qemu方便测试,lzip用于ed源代码解包。\r
75 1.2创建变量\r
76 export LFS=/mnt/lfs\r
77 使用如下命令确认变量(一定要在root账户下再确认一遍)\r
78 echo $LFS\r
79 1.3准备硬盘\r
80 这里选用和LFS略有区别的方案,采用的是loop法,这里不做详细介绍。主要是为了方便测试。\r
81 dd bs=1G count=60 if=/dev/zero of=60.img #划分60G的img空盘作为虚拟硬盘\r
82 sudo cfdisk ~/60.img #dos分区,一个就行\r
83 sudo kpartx -av ~/60.img #让img变成系统分区\r
84 mkfs.ext4 /dev/mapper/loop0p1 #格式化,linux内核默认兼容ext4,这里请切换为su,后续将维持在su下,ubuntu可能为loop3,自行用lsblk确认下\r
85 1.4挂载分区\r
86 mkdir -pv $LFS\r
87 mount -v -t ext4 /dev/mapper/loop0p1 $LFS\r
88 请使用lsblk确认挂载成功\r
89 1.5下包\r
90 几点说明:①GNU,CPAN镜像用的是上海交通大学镜像,kernel.org为中科大镜像,openssh为清华大学镜像\r
91 ②内核为opensuse提供的定制的4.19LTS内核\r
92 ③从LFS中被删除的包:iana-etc, gdbm, gperf, expat, XML::Parser, intltool, libffi, python3(glibc编译需要py3, 但chroot后不安装), ninja, meson, check, kbd, libpipeline, vim, sysklogd, pkg-config, sysvinit, 加入的包:ed, nano, dhcpcd, openssh, wget, pkgconf, openrc\r
93 ④OpenRC已加入,脚本还需重写\r
94 ⑤源代码ed是用lzip压缩的,请自行安装lzip,在chroot之前把ed解包,lzip暂不编译\r
95 ⑥file如果不好下载可以改为https://github.com/file/file/archive/FILE5_37.tar.gz, dhcpcd不好下可以改为https://github.com/rsmarples/dhcpcd/archive/dhcpcd-8.0.6.tar.gz\r
96 mkdir -pv $LFS/sources\r
97 chmod -v a+wt $LFS/sources #可选,方便非root用户复制源代码包到文件夹\r
98 cat > wgetlist << "EOF"\r
99 https://mirrors.sjtug.sjtu.edu.cn/gnu/binutils/binutils-2.32.tar.xz\r
100 https://mirrors.sjtug.sjtu.edu.cn/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.xz\r
101 https://mirrors.sjtug.sjtu.edu.cn/gnu/gmp/gmp-6.1.2.tar.xz\r
102 https://mirrors.sjtug.sjtu.edu.cn/gnu/mpfr/mpfr-4.0.2.tar.xz\r
103 https://mirrors.sjtug.sjtu.edu.cn/gnu/mpc/mpc-1.1.0.tar.gz\r
104 https://mirrors.sjtug.sjtu.edu.cn/gnu/m4/m4-1.4.18.tar.xz\r
105 https://mirrors.sjtug.sjtu.edu.cn/gnu/glibc/glibc-2.30.tar.xz\r
106 https://mirrors.sjtug.sjtu.edu.cn/gnu/dejagnu/dejagnu-1.6.2.tar.gz\r
107 https://mirrors.sjtug.sjtu.edu.cn/gnu/ncurses/ncurses-6.1.tar.gz\r
108 https://mirrors.sjtug.sjtu.edu.cn/gnu/bash/bash-5.0.tar.gz\r
109 https://mirrors.sjtug.sjtu.edu.cn/gnu/bison/bison-3.4.1.tar.xz\r
110 https://mirrors.sjtug.sjtu.edu.cn/gnu/coreutils/coreutils-8.31.tar.xz\r
111 https://mirrors.sjtug.sjtu.edu.cn/gnu/diffutils/diffutils-3.7.tar.xz\r
112 https://mirrors.sjtug.sjtu.edu.cn/gnu/findutils/findutils-4.7.0.tar.xz\r
113 https://mirrors.sjtug.sjtu.edu.cn/gnu/gawk/gawk-5.0.1.tar.xz\r
114 https://mirrors.sjtug.sjtu.edu.cn/gnu/gettext/gettext-0.20.1.tar.xz\r
115 https://mirrors.sjtug.sjtu.edu.cn/gnu/grep/grep-3.3.tar.xz\r
116 https://mirrors.sjtug.sjtu.edu.cn/gnu/gzip/gzip-1.10.tar.xz\r
117 https://mirrors.sjtug.sjtu.edu.cn/gnu/make/make-4.2.1.tar.gz\r
118 https://mirrors.sjtug.sjtu.edu.cn/gnu/patch/patch-2.7.6.tar.xz\r
119 https://mirrors.sjtug.sjtu.edu.cn/gnu/sed/sed-4.7.tar.xz\r
120 https://mirrors.sjtug.sjtu.edu.cn/gnu/tar/tar-1.32.tar.xz\r
121 https://mirrors.sjtug.sjtu.edu.cn/gnu/bc/bc-1.07.1.tar.gz\r
122 https://mirrors.sjtug.sjtu.edu.cn/gnu/texinfo/texinfo-6.6.tar.xz\r
123 https://mirrors.sjtug.sjtu.edu.cn/gnu/readline/readline-8.0.tar.gz\r
124 https://mirrors.sjtug.sjtu.edu.cn/gnu/libtool/libtool-2.4.6.tar.xz\r
125 https://mirrors.sjtug.sjtu.edu.cn/gnu/inetutils/inetutils-1.9.4.tar.xz\r
126 https://mirrors.sjtug.sjtu.edu.cn/gnu/autoconf/autoconf-2.69.tar.xz\r
127 https://mirrors.sjtug.sjtu.edu.cn/gnu/automake/automake-1.16.1.tar.xz\r
128 https://mirrors.sjtug.sjtu.edu.cn/gnu/groff/groff-1.22.4.tar.gz\r
129 https://mirrors.sjtug.sjtu.edu.cn/gnu/grub/grub-2.04.tar.xz\r
130 https://mirrors.sjtug.sjtu.edu.cn/gnu/nano/nano-4.4.tar.xz\r
131 https://mirrors.sjtug.sjtu.edu.cn/gnu/wget/wget-1.20.3.tar.gz\r
132 https://mirrors.sjtug.sjtu.edu.cn/gnu/ed/ed-1.15.tar.lz\r
133 https://mirrors.sjtug.sjtu.edu.cn/cpan/src/5.0/perl-5.30.0.tar.gz\r
134 https://mirrors.tuna.tsinghua.edu.cn/OpenBSD/OpenSSH/portable/openssh-8.0p1.tar.gz\r
135 https://mirrors.ustc.edu.cn/kernel.org/linux/utils/util-linux/v2.34/util-linux-2.34.tar.xz\r
136 https://mirrors.ustc.edu.cn/kernel.org/linux/libs/security/linux-privs/libcap2/libcap-2.27.tar.xz\r
137 https://mirrors.ustc.edu.cn/kernel.org/linux/utils/net/iproute2/iproute2-5.2.0.tar.xz\r
138 https://download.savannah.nongnu.org/releases/acl/acl-2.2.53.tar.gz\r
139 https://download.savannah.nongnu.org/releases/attr/attr-2.4.48.tar.gz\r
140 https://prdownloads.sourceforge.net/psmisc/psmisc/psmisc-23.2.tar.xz\r
141 https://prdownloads.sourceforge.net/tcl/Tcl/8.6.9/tcl8.6.9-src.tar.gz\r
142 https://prdownloads.sourceforge.net/expect/Expect/5.45.4/expect5.45.4.tar.gz\r
143 https://prdownloads.sourceforge.net/libpng/zlib-1.2.11.tar.xz\r
144 https://prdownloads.sourceforge.net/procps-ng/Production/procps-ng-3.3.15.tar.xz\r
145 https://prdownloads.sourceforge.net/e2fsprogs/e2fsprogs/v1.45.3/e2fsprogs-1.45.3.tar.gz\r
146 https://sourceware.org/elfutils/ftp/elfutils-latest.tar.bz2\r
147 https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz\r
148 https://github.com/openSUSE/kernel/archive/v4.19.75.tar.gz\r
149 https://github.com/shadow-maint/shadow/releases/download/4.7/shadow-4.7.tar.xz\r
150 https://github.com/westes/flex/releases/download/v2.6.4/flex-2.6.4.tar.gz\r
151 https://github.com/OpenRC/openrc/archive/0.42.1.tar.gz\r
152 https://distfiles.dereferenced.org/pkgconf/pkgconf-1.1.0.tar.xz\r
153 https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tar.xz\r
154 https://data.iana.org/time-zones/releases/tzdata2019c.tar.gz\r
155 https://tukaani.org/xz/xz-5.2.4.tar.xz\r
156 http://www.greenwoodsoftware.com/less/less-551.tar.gz\r
157 https://roy.marples.name/downloads/dhcpcd/dhcpcd-8.0.6.tar.xz\r
158 https://www.openssl.org/source/openssl-1.1.1c.tar.gz\r
159 https://dev.gentoo.org/~blueness/eudev/eudev-3.2.8.tar.gz\r
160 ftp://ftp.astron.com/pub/file/file-5.37.tar.gz\r
161 EOF\r
162 wget --input-file=wgetlist --continue --directory-prefix=$LFS/sources\r
163 mv $LFS/sources/v4.19.75.tar.gz $LFS/sources/kernel-4.19.75.tar.gz #wget下载的文件名和浏览器不统一,修正下\r
164 mv $LFS/sources/0.42.1.tar.gz $LFS/sources/openrc-0.42.1.tar.gz\r
165 或者\r
166 aria2c -c -i wgetlist -d $LFS/sources #可以添加-j16和-x16提高速度\r
167 1.6创建目录 $LFS/tools\r
168 mkdir -v $LFS/tools\r
169 ln -sv $LFS/tools /  #创建 /tools 的符号链接。将其指向 SURE 分区中新建的目录。\r
170 1.7添加 LFS 用户\r
171 groupadd lfs\r
172 useradd -s /bin/bash -g lfs -m -k /dev/null lfs\r
173 passwd lfs\r
174 chown -v lfs $LFS/tools\r
175 chown -v lfs $LFS/sources\r
176 su - lfs\r
177 1.8设置环境\r
178 cat > ~/.bash_profile << "EOF"\r
179 exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash\r
180 EOF\r
181 cat > ~/.bashrc << "EOF"\r
182 set +h\r
183 umask 022\r
184 LFS=/mnt/lfs\r
185 LC_ALL=POSIX\r
186 LFS_TGT=$(uname -m)-lfs-linux-gnu\r
187 PATH=/tools/bin:/bin:/usr/bin\r
188 export LFS LC_ALL LFS_TGT PATH\r
189 EOF\r
190 source ~/.bash_profile\r
191 1.9解包说明与编译说明\r
192 在sources里面tar xvf(v可以省略)文件夹,cd进去。编译完成,删除解包的文件夹\r
193 自行在make后面-jx x为电脑线程数,可以额外+1,gcc,内核等SBU非常大的可以考虑x-1\r
194 第二章 构建临时系统(参数请查阅LFS手册)\r
195 2.1 Binutils pass1(链接器与汇编器等)\r
196 mkdir -v build\r
197 cd       build\r
198 ../configure --prefix=/tools            \\r
199              --with-sysroot=$LFS        \\r
200              --with-lib-path=/tools/lib \\r
201              --target=$LFS_TGT          \\r
202              --disable-nls              \\r
203              --disable-werror\r
204 make -j$(nproc --all)\r
205 case $(uname -m) in\r
206   x86_64) mkdir -v /tools/lib && ln -sv lib /tools/lib64 ;;\r
207 esac\r
208 make install\r
209 cd ../..\r
210 2.2 gcc pass1\r
211 tar xf ../mpfr-*.tar.xz\r
212 mv -v mpfr-* mpfr\r
213 tar xf ../gmp-*.tar.xz\r
214 mv -v gmp-* gmp\r
215 tar xf ../mpc-*.tar.gz\r
216 mv -v mpc-* mpc\r
217 for file in gcc/config/{linux,i386/linux{,64}}.h\r
218 do\r
219   cp -uv $file{,.orig}\r
220   sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \\r
221       -e 's@/usr@/tools@g' $file.orig > $file\r
222   echo '\r
223 #undef STANDARD_STARTFILE_PREFIX_1\r
224 #undef STANDARD_STARTFILE_PREFIX_2\r
225 #define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"\r
226 #define STANDARD_STARTFILE_PREFIX_2 ""' >> $file\r
227   touch $file.orig\r
228 done\r
229 case $(uname -m) in\r
230   x86_64)\r
231     sed -e '/m64=/s/lib64/lib/' \\r
232         -i.orig gcc/config/i386/t-linux64\r
233  ;;\r
234 esac\r
235 mkdir -v build\r
236 cd       build\r
237 ../configure                                       \\r
238     --target=$LFS_TGT                              \\r
239     --prefix=/tools                                \\r
240     --with-glibc-version=2.11                      \\r
241     --with-sysroot=$LFS                            \\r
242     --with-newlib                                  \\r
243     --without-headers                              \\r
244     --with-local-prefix=/tools                     \\r
245     --with-native-system-header-dir=/tools/include \\r
246     --disable-nls                                  \\r
247     --disable-shared                               \\r
248     --disable-multilib                             \\r
249     --disable-decimal-float                        \\r
250     --disable-threads                              \\r
251     --disable-libatomic                            \\r
252     --disable-libgomp                              \\r
253     --disable-libquadmath                          \\r
254     --disable-libssp                               \\r
255     --disable-libvtv                               \\r
256     --disable-libstdcxx                            \\r
257     --enable-languages=c,c++\r
258 make -j$(nproc --all)\r
259 make install\r
260 cd ../..\r
261 2.3 kernel header\r
262 make mrproper\r
263 make INSTALL_HDR_PATH=dest headers_install\r
264 cp -r dest/include/* /tools/include\r
265 cd ..\r
266 2.4 glibc(C函数库)\r
267 mkdir -v build\r
268 cd build\r
269 ../configure                             \\r
270       --prefix=/tools                    \\r
271       --host=$LFS_TGT                    \\r
272       --build=$(../scripts/config.guess) \\r
273       --enable-kernel=3.2                \\r
274       --with-headers=/tools/include\r
275 make -j$(nproc --all)\r
276 make install\r
277 请注意在此处进行一次测试\r
278 echo 'int main(){}' > dummy.c\r
279 $LFS_TGT-gcc dummy.c\r
280 readelf -l a.out | grep ': /tools'\r
281 如果输出[Requesting program interpreter: /tools/lib64/ld-linux-x86-64.so.2]则成功,成功后执行\r
282 rm -v dummy.c a.out\r
283 cd ../..\r
284 2.5 libstdc++(标准C++库,包含在gcc里面,解包gcc)\r
285 mkdir -v build\r
286 cd build\r
287 GCCVER=9.2.0\r
288 ../libstdc++-v3/configure           \\r
289     --host=$LFS_TGT                 \\r
290     --prefix=/tools                 \\r
291     --disable-multilib              \\r
292     --disable-nls                   \\r
293     --disable-libstdcxx-threads     \\r
294     --disable-libstdcxx-pch         \\r
295     --with-gxx-include-dir=/tools/$LFS_TGT/include/c++/${GCCVER}\r
296 make -j$(nproc --all)\r
297 make install\r
298 2.6 Binutils pass2\r
299 mkdir -v build\r
300 cd build\r
301 CC=$LFS_TGT-gcc                \\r
302 AR=$LFS_TGT-ar                 \\r
303 RANLIB=$LFS_TGT-ranlib         \\r
304 ../configure                   \\r
305     --prefix=/tools            \\r
306     --disable-nls              \\r
307     --disable-werror           \\r
308     --with-lib-path=/tools/lib \\r
309     --with-sysroot\r
310 make -j$(nproc --all)\r
311 make install\r
312 make -C ld clean\r
313 make -C ld LIB_PATH=/usr/lib:/lib\r
314 cp -v ld/ld-new /tools/bin\r
315 2.7 gcc pass2\r
316 cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \\r
317   `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/include-fixed/limits.h\r
318 for file in gcc/config/{linux,i386/linux{,64}}.h\r
319 do\r
320   cp -uv $file{,.orig}\r
321   sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \\r
322       -e 's@/usr@/tools@g' $file.orig > $file\r
323   echo '\r
324 #undef STANDARD_STARTFILE_PREFIX_1\r
325 #undef STANDARD_STARTFILE_PREFIX_2\r
326 #define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"\r
327 #define STANDARD_STARTFILE_PREFIX_2 ""' >> $file\r
328   touch $file.orig\r
329 done\r
330 case $(uname -m) in\r
331   x86_64)\r
332     sed -e '/m64=/s/lib64/lib/' \\r
333         -i.orig gcc/config/i386/t-linux64\r
334   ;;\r
335 esac\r
336 tar xvf ../mpfr-*.tar.xz\r
337 mv -v mpfr-* mpfr\r
338 tar xvf ../gmp-*.tar.xz\r
339 mv -v gmp-* gmp\r
340 tar xvf ../mpc-*.tar.gz\r
341 mv -v mpc-* mpc\r
342 mkdir -v build\r
343 cd build\r
344 CC=$LFS_TGT-gcc                                    \\r
345 CXX=$LFS_TGT-g++                                   \\r
346 AR=$LFS_TGT-ar                                     \\r
347 RANLIB=$LFS_TGT-ranlib                             \\r
348 ../configure                                       \\r
349     --prefix=/tools                                \\r
350     --with-local-prefix=/tools                     \\r
351     --with-native-system-header-dir=/tools/include \\r
352     --enable-languages=c,c++                       \\r
353     --disable-libstdcxx-pch                        \\r
354     --disable-multilib                             \\r
355     --disable-bootstrap                            \\r
356     --disable-libgomp\r
357 make -j$(nproc --all)\r
358 make install\r
359 ln -sv gcc /tools/bin/cc\r
360 请注意在此处进行一次测试\r
361 echo 'int main(){}' > dummy.c\r
362 cc dummy.c\r
363 readelf -l a.out | grep ': /tools'\r
364 如果输出[Requesting program interpreter: /tools/lib64/ld-linux-x86-64.so.2]则成功,成功后执行\r
365 rm -v dummy.c a.out\r
366 cd ../..\r
367 2.8 tcl(测试套件1)\r
368 cd unix\r
369 ./configure --prefix=/tools\r
370 make -j$(nproc --all)\r
371 make install\r
372 chmod u+w /tools/lib64/libtcl8.6.so\r
373 make install-private-headers\r
374 ln -sv tclsh8.6 /tools/bin/tclsh\r
375 cd ../..\r
376 2.9 expect(测试套件2)\r
377 cp -v configure{,.orig}\r
378 sed 's:/usr/local/bin:/bin:' configure.orig > configure\r
379 ./configure --prefix=/tools       \\r
380             --with-tcl=/tools/lib \\r
381             --with-tclinclude=/tools/include\r
382 make -j$(nproc --all)\r
383 make SCRIPTS="" install\r
384 cd ..\r
385 2.10 dejagnu(测试套件3)\r
386 ./configure --prefix=/tools\r
387 make install\r
388 cd ..\r
389 2.11 m4\r
390 sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' lib/*.c\r
391 echo "#define _IO_IN_BACKUP 0x100" >> lib/stdio-impl.h\r
392 ./configure --prefix=/tools\r
393 make -j$(nproc --all)\r
394 make install\r
395 cd ..\r
396 2.12 ncurses\r
397 sed -i s/mawk// configure\r
398 ./configure --prefix=/tools \\r
399             --with-shared   \\r
400             --without-debug \\r
401             --without-ada   \\r
402             --enable-widec  \\r
403             --enable-overwrite\r
404 make -j$(nproc --all)\r
405 make install\r
406 ln -s libncursesw.so /tools/lib/libncurses.so\r
407 cd ..\r
408 2.13 bash\r
409 ./configure --prefix=/tools --without-bash-malloc\r
410 make -j$(nproc --all)\r
411 make install\r
412 ln -sv bash /tools/bin/sh\r
413 cd ..\r
414 2.14 bison\r
415 ./configure --prefix=/tools\r
416 make -j$(nproc --all)\r
417 make install\r
418 cd ..\r
419 2.15 coreutils (系统基本工具)\r
420 ./configure --prefix=/tools --enable-install-program=hostname\r
421 make -j$(nproc --all)\r
422 make install\r
423 cd ..\r
424 2.16-2.19 diffutils file findutils gawk\r
425 for package in diffutils-3.7 file-5.37 findutils-4.7.0 gawk-5.0.1; do\r
426     tar xf "${package}".tar.*\r
427     cd "${package}" || continue\r
428     ./configure --prefix=/tools\r
429     make -j$(nproc --all)\r
430     make install\r
431     cd $LFS/sources/ || break\r
432     rm -rvf "${package}"\r
433 done\r
434 2.20 gettext\r
435 ./configure --prefix=/tools --disable-shared\r
436 make -j$(nproc --all)\r
437 cp -v gettext-tools/src/{msgfmt,msgmerge,xgettext} /tools/bin\r
438 cd ..\r
439 2.21-2.22 grep gzip\r
440 for package in grep-3.3 gzip-1.10; do\r
441     tar xvf "${package}".tar.*\r
442     cd "${package}" || continue\r
443     ./configure --prefix=/tools\r
444     make -j$(nproc --all)\r
445     make install\r
446     cd $LFS/sources/ || break\r
447     rm -rvf "${package}"\r
448 done\r
449 2.23 make\r
450 sed -i '211,217 d; 219,229 d; 232 d' glob/glob.c\r
451 ./configure --prefix=/tools --without-guile\r
452 make -j$(nproc --all)\r
453 make install\r
454 cd ..\r
455 2.24 patch\r
456 ./configure --prefix=/tools\r
457 make -j$(nproc --all)\r
458 make install\r
459 cd ..\r
460 2.25 perl\r
461 PERLVER=5.30.0\r
462 sh Configure -des -Dprefix=/tools -Dlibs=-lm -Uloclibpth -Ulocincpth\r
463 make -j$(nproc --all)\r
464 cp -v perl cpan/podlators/scripts/pod2man /tools/bin\r
465 mkdir -pv /tools/lib/perl5/${PERLVER}\r
466 cp -Rv lib/* /tools/lib/perl5/${PERLVER}\r
467 cd ..\r
468 2.26-2.29 sed xz tar texinfo\r
469 for package in sed-4.7 tar-1.32 texinfo-6.6 xz-5.2.4; do\r
470     tar xvf "${package}".tar.*\r
471     cd "${package}" || continue\r
472     ./configure --prefix=/tools\r
473     make -j$(nproc --all)\r
474     make install\r
475     cd $LFS/sources/ || break\r
476     rm -rvf "${package}"\r
477 done\r
478 2.19 python3\r
479 sed -i '/def add_multiarch_paths/a \        return' setup.py\r
480 ./configure --prefix=/tools --without-ensurepip\r
481 make -j$(nproc --all)\r
482 make install\r
483 2.19 Stripping(清理无用内容)\r
484 strip --strip-debug /tools/lib/*\r
485 /usr/bin/strip --strip-unneeded /tools/{,s}bin/*\r
486 rm -rvf /tools/{,share}/{info,man,doc}\r
487 find /tools/{lib,libexec} -name \*.la -delete\r
488 2.20 改变属主\r
489 exit #请确认是切换到root\r
490 chown -R root:root $LFS/tools\r
491 第三章 构建编译内核依赖以及ssh, dhcp和nano\r
492 3.1 准备虚拟内核文件系统\r
493 mkdir -pv $LFS/{dev,proc,sys,run}\r
494 mknod -m 600 $LFS/dev/console c 5 1\r
495 mknod -m 666 $LFS/dev/null c 1 3\r
496 mount -v --bind /dev $LFS/dev\r
497 mount -vt devpts devpts $LFS/dev/pts -o gid=5,mode=620\r
498 mount -vt proc proc $LFS/proc\r
499 mount -vt sysfs sysfs $LFS/sys\r
500 mount -vt tmpfs tmpfs $LFS/run\r
501 3.2 chroot\r
502 chroot "$LFS" /tools/bin/env -i \\r
503     HOME=/root                  \\r
504     TERM="$TERM"                \\r
505     PS1='(sure chroot) \u:\w\$ ' \\r
506     PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \\r
507     /tools/bin/bash --login +h\r
508 3.3 创建目录(几个lib文件夹请确认下,是否要改lib64或者添加lib64)\r
509 mkdir -p /{bin,boot,etc/{opt,sysconfig},home,lib64/firmware,mnt,opt}\r
510 mkdir -p /{media/{floppy,cdrom},sbin,srv,var}\r
511 install -d -m 0750 /root\r
512 install -d -m 1777 /tmp /var/tmp\r
513 mkdir -p /usr/{,local/}{bin,include,lib64,sbin,src}\r
514 mkdir -p /usr/{,local/}share/{color,dict,doc,info,locale,man}\r
515 mkdir -p /usr/{,local/}share/{misc,terminfo,zoneinfo}\r
516 mkdir -p /usr/libexec\r
517 mkdir -p /usr/{,local/}share/man/man{1..8}\r
518 case $(uname -m) in\r
519 x86_64) mkdir -p /lib64 ;;\r
520 i?86)   mkdir -p /lib32 ;;\r
521 esac\r
522 mkdir -p /var/{log,mail,spool}\r
523 ln -sf /run /var/run\r
524 ln -sf /run/lock /var/lock\r
525 mkdir -p /var/{opt,cache,lib64/{color,misc,locate},local}\r
526 3.4 创建必要的文件和符号链接(几个lib文件夹请确认下,是否要改lib64或者添加lib64)\r
527 ln -sv /tools/bin/{bash,cat,chmod,dd,echo,ln,mkdir,pwd,rm,stty,touch} /bin\r
528 ln -sv /tools/bin/{env,install,perl,printf}         /usr/bin\r
529 ln -sv /tools/lib/libgcc_s.so{,.1}                  /usr/lib64\r
530 ln -sv /tools/lib/libstdc++.{a,so{,.6}}             /usr/lib64\r
531 \r
532 ln -sv bash /bin/sh\r
533 ln -sv /proc/self/mounts /etc/mtab\r
534 cat > /etc/passwd << "EOF"\r
535 root:x:0:0:root:/root:/bin/bash\r
536 bin:x:1:1:bin:/dev/null:/bin/false\r
537 daemon:x:6:6:Daemon User:/dev/null:/bin/false\r
538 messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false\r
539 nobody:x:99:99:Unprivileged User:/dev/null:/bin/false\r
540 EOF\r
541 \r
542 cat > /etc/group << "EOF"\r
543 root:x:0:\r
544 bin:x:1:daemon\r
545 sys:x:2:\r
546 kmem:x:3:\r
547 tape:x:4:\r
548 tty:x:5:\r
549 daemon:x:6:\r
550 floppy:x:7:\r
551 disk:x:8:\r
552 lp:x:9:\r
553 dialout:x:10:\r
554 audio:x:11:\r
555 video:x:12:\r
556 utmp:x:13:\r
557 usb:x:14:\r
558 cdrom:x:15:\r
559 adm:x:16:\r
560 messagebus:x:18:\r
561 input:x:24:\r
562 mail:x:34:\r
563 kvm:x:61:\r
564 wheel:x:97:\r
565 nogroup:x:99:\r
566 users:x:999:\r
567 EOF\r
568 \r
569 exec /tools/bin/bash --login +h\r
570 touch /var/log/{btmp,lastlog,faillog,wtmp}\r
571 chgrp -v utmp /var/log/lastlog\r
572 chmod -v 664  /var/log/lastlog\r
573 chmod -v 600  /var/log/btmp\r
574 3.5 kernel header\r
575 make mrproper\r
576 make INSTALL_HDR_PATH=dest headers_install #lfs开发版有误,headers_install可用\r
577 find dest/include \( -name .install -o -name ..install.cmd \) -delete\r
578 cp -rv dest/include/* /usr/include\r
579 3.6 glibc(二次编译需加入libidn2)\r
580 GCCVER=9.2.0\r
581 #patch -Np1 -i ../glibc-2.28-fhs-1.patch #请确认是否需要打这个补丁,是否需要打其他补丁\r
582 case $(uname -m) in\r
583 i?86)\r
584 GCC_INCDIR=/usr/lib32/gcc/$(uname -m)-pc-linux-gnu/${GCCVER}/include\r
585 ln -sf ld-linux.so.2 /lib32/ld-lsb.so.3\r
586 ;;\r
587 x86_64)\r
588 GCC_INCDIR=/usr/lib64/gcc/x86_64-pc-linux-gnu/${GCCVER}/include\r
589 ln -sf ../lib64/ld-linux-x86-64.so.2 /lib64\r
590 ln -sf ../lib64/ld-linux-x86-64.so.2 /lib64/ld-lsb-x86-64.so.3\r
591 ;;\r
592 esac\r
593 mkdir -v build\r
594 cd build\r
595 ##CC="gcc -ffile-prefix-map=/tools=/usr" \\r
596 #../configure --prefix=/usr                          \\r
597 #             --disable-werror                       \\r
598 #             --enable-kernel=3.2                    \\r
599 #             --enable-stack-protector=strong        \\r
600 #             --with-headers=/usr/include            \\r
601 #             libc_cv_slibdir=/lib ###原本为LFS提供\r
602 CC="gcc" CXX="g++" CFLAGS="-O2 -mtune=generic -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-function -Wno-maybe-uninitialized" ../configure \\r
603     --host=x86_64-sure-linux-gnu --build=x86_64-sure-linux-gnu \\r
604     --prefix=/usr \\r
605     --libexecdir=/usr/libexec \\r
606     --infodir=/usr/share/info \\r
607     --enable-add-ons=libidn --without-cvs \\r
608     --without-selinux \\r
609     --enable-kernel=3.2 \\r
610     --with-headers=/usr/include \\r
611     --enable-obsolete-rpc \\r
612     --enable-obsolete-nsl \\r
613     --disable-crypts ##由mageia提供\r
614 make -j1\r
615 case $(uname -m) in\r
616   i?86)   ln -sfnv $PWD/elf/ld-linux.so.2        /lib ;;\r
617   x86_64) ln -sfnv $PWD/elf/ld-linux-x86-64.so.2 /lib64 ;;\r
618 esac\r
619 make check -j$(nproc --all) #mageia的configure fail3,多出来了cond-mutex10\r
620 #这里任何的fail都应该报告,xpass/xfail/unsupport不需要\r
621 \r
622 \r
623 \r
624 以下未测试,请不要急着用\r
625 \r
626 \r
627 touch /etc/ld.so.conf\r
628 sed '/test-installation/s@$(PERL)@echo not running@' -i ../Makefile\r
629 make install\r
630 cp -v ../nscd/nscd.conf /etc/nscd.conf\r
631 mkdir -pv /var/cache/nscd\r
632 make localedata/install-locales -j$(nproc --all)\r
633 cat > /etc/nsswitch.conf << "EOF"\r
634 # Begin /etc/nsswitch.conf\r
635 passwd: files\r
636 group: files\r
637 shadow: files\r
638 hosts: files dns\r
639 networks: files\r
640 protocols: files\r
641 services: files\r
642 ethers: files\r
643 rpc: files\r
644 # End /etc/nsswitch.conf\r
645 EOF\r
646 tar -xvf ../../tzdata*.tar.gz\r
647 ZONEINFO=/usr/share/zoneinfo\r
648 mkdir -pv $ZONEINFO/{posix,right}\r
649 for tz in etcetera southamerica northamerica europe africa antarctica asia australasia backward pacificnew systemv; do\r
650 zic -L /dev/null -d $ZONEINFO -y "sh yearistype.sh" ${tz}\r
651 zic -L /dev/null -d $ZONEINFO/posix -y "sh yearistype.sh" ${tz}\r
652 zic -L leapseconds -d $ZONEINFO/right -y "sh yearistype.sh" ${tz}\r
653 done\r
654 cp -v zone.tab zone1970.tab iso3166.tab $ZONEINFO\r
655 zic -d $ZONEINFO -p America/New_York\r
656 unset ZONEINFO\r
657 cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime\r
658 请检查下lib64\r
659 cat > /etc/ld.so.conf << "EOF"\r
660 # Begin /etc/ld.so.conf\r
661 /usr/local/lib\r
662 /opt/lib\r
663 EOF\r
664 cat >> /etc/ld.so.conf << "EOF"\r
665 # Add an include directory\r
666 include /etc/ld.so.conf.d/*.conf\r
667 EOF\r
668 mkdir -pv /etc/ld.so.conf.d\r
669 3.7 调整工具链\r
670 mv -v /tools/bin/{ld,ld-old}\r
671 mv -v /tools/$(uname -m)-pc-linux-gnu/bin/{ld,ld-old}\r
672 mv -v /tools/bin/{ld-new,ld}\r
673 ln -sv /tools/bin/ld /tools/$(uname -m)-pc-linux-gnu/bin/ld\r
674 gcc -dumpspecs | sed -e 's@/tools@@g' -e '/\*startfile_prefix_spec:/{n;s@.*@/usr/lib64/ @}' -e '/\*cpp:/{n;s@$@ -isystem /usr/include@}' > `dirname $(gcc --print-libgcc-file-name)`/specs\r
675 echo 'int main(){}' > dummy.c\r
676 cc dummy.c -v -Wl,--verbose &> dummy.log\r
677 readelf -l a.out | grep ': /lib64'\r
678 如果没有任何错误,应该输出[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]\r
679 grep -o '/usr/lib64.*/crt[1in].*succeeded' dummy.log #查下是不是lib64\r
680 应该输出/usr/lib64/../lib64/crt1.o succeeded\r
681 /usr/lib64/../lib64/crti.o succeeded\r
682 /usr/lib64/../lib64/crtn.o succeeded\r
683 grep -B1 '^ /usr/include' dummy.log\r
684 应该输出#include <...> search starts here:\r
685 /usr/include\r
686 grep 'SEARCH.*/usr/lib64' dummy.log |sed 's|; |\n|g' #查下是不是lib64\r
687 应该输出SEARCH_DIR("/usr/lib64")\r
688 SEARCH_DIR("/lib64")\r
689 grep "/lib.*/libc.so.6 " dummy.log\r
690 应该输出attempt to open /lib64/libc.so.6 succeeded\r
691 grep found dummy.log\r
692 应该输出found ld-linux-x86-64.so.2 at /lib64/ld-linux-x86-64.so.2\r
693 rm -v dummy.c a.out dummy.log\r
694 3.8 zlib\r
695 ./configure --prefix=/usr --libdir=/usr/lib64 --sharedlibdir=/usr/lib64\r
696 make -j$(nproc --all)\r
697 make check -j$(nproc --all)\r
698 make install\r
699 mv /usr/lib64/libz.so.* /lib64\r
700 ln -sf ../../lib64/$(readlink /usr/lib64/libz.so) /usr/lib64/libz.so\r
701 3.9 file\r
702 ./configure --prefix=/usr --libdir=/usr/lib64 --libexecdir=/usr/lib64\r
703 make -j$(nproc --all)\r
704 make check -j$(nproc --all)\r
705 make install\r
706 3.10 readline\r
707 READLINEVER=8.0\r
708 sed -i '/MV.*old/d' Makefile.in\r
709 sed -i '/{OLDSUFF}/c:' support/shlib-install\r
710 ./configure --prefix=/usr --libdir=/usr/lib64 --libexecdir=/usr/lib64 --disable-static --docdir=/usr/share/doc/readline-${READLINEVER}\r
711 make SHLIB_LIBS="-L/tools/lib64 -lncursesw" -j$(nproc --all)\r
712 make SHLIB_LIBS="-L/tools/lib64 -lncursesw" install\r
713 mv /usr/lib64/lib{readline,history}.so.* /lib64\r
714 chmod u+w /lib64/lib{readline,history}.so.*\r
715 ln -sf ../../lib64/$(readlink /usr/lib64/libreadline.so) /usr/lib64/libreadline.so\r
716 ln -sf ../../lib64/$(readlink /usr/lib64/libhistory.so ) /usr/lib64/libhistory.so\r
717 #install -m644 doc/*.{ps,pdf,html,dvi} /usr/share/doc/readline-${READLINEVER} #可以不安装文档\r
718 3.11 m4\r
719 sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' lib64/*.c\r
720 echo "#define _IO_IN_BACKUP 0x100" >> lib64/stdio-impl.h\r
721 ./configure --prefix=/usr --libdir=/usr/lib64 --libexecdir=/usr/lib64\r
722 make -j$(nproc --all)\r
723 make check -j$(nproc --all)\r
724 make install\r
725 3.12 bc (LFS开发版使用的是https://github.com/gavinhoward/bc,这里还是使用GNU bc)\r
726 cat > bc/fix-libmath_h << "EOF"\r
727 #! /bin/bash\r
728 sed -e '1   s/^/{"/' \\r
729     -e     's/$/",/' \\r
730     -e '2,$ s/^/"/'  \\r
731     -e   '$ d'       \\r
732     -i libmath.h\r
733 \r
734 sed -e '$ s/$/0}/' \\r
735     -i libmath.h\r
736 EOF\r
737 ln -s /tools/lib64/libncursesw.so.6 /usr/lib64/libncursesw.so.6\r
738 ln -sf libncursesw.so.6 /usr/lib64/libncurses.so\r
739 sed -i -e '/flex/s/as_fn_error/: ;; # &/' configure\r
740 ./configure --prefix=/usr --libdir=/usr/lib64 --libexecdir=/usr/lib64 --with-readline --mandir=/usr/share/man --infodir=/usr/share/info\r
741 make -j$(nproc --all)\r
742 echo "quit" | ./bc/bc -l Test/checklib.b\r
743 make install\r
744 3.13 binutils\r
745 expect -c "spawn ls"\r
746 如果输出spawn ls即可继续\r
747 sed -i '/@\tincremental_copy/d' gold/testsuite/Makefile.in\r
748 mkdir -v build\r
749 cd build\r
750 ../configure --prefix=/usr --libdir=/usr/lib64 --libexecdir=/usr/lib64 --enable-gold --enable-ld=default --enable-plugins --enable-shared --disable-werror --enable-64-bit-bfd --with-system-zlib\r
751 make tooldir=/usr -j$(nproc --all)\r
752 make -k check -j$(nproc --all) #任何fail请报告\r
753 make tooldir=/usr install\r
754 3.14 gmp\r
755 cp -v configfsf.guess config.guess\r
756 cp -v configfsf.sub   config.sub\r
757 GMPVER=6.1.2\r
758 ./configure --prefix=/usr --libdir=/usr/lib64 --libexecdir=/usr/lib64 --enable-cxx --disable-static --docdir=/usr/share/doc/gmp-${GMPVER}\r
759 make -j$(nproc --all)\r
760 #make html\r
761 make check 2>&1 -j$(nproc --all) | tee gmp-check-log\r
762 awk '/# PASS:/{total+=$3} ; END{print total}' gmp-check-log #不等于190请报告\r
763 make install\r
764 #make install-html\r
765 3.15 mpfr\r
766 MPFRVER=6.1.2\r
767 ./configure --prefix=/usr --libdir=/usr/lib64 --libexecdir=/usr/lib64 --enable-cxx --disable-static --docdir=/usr/share/doc/gmp-${MPFRVER}\r
768 make -j$(nproc --all)\r
769 #make html\r
770 make check -j$(nproc --all) #任何fail请报告\r
771 make install\r
772 #make install-html\r
773 3.16 mpc\r
774 MPCVER=1.1.0\r
775 ./configure --prefix=/usr --libdir=/usr/lib64 --libexecdir=/usr/lib64 --disable-static --docdir=/usr/share/doc/mpc-${MPCVER}\r
776 make -j$(nproc --all)\r
777 #make html\r
778 make check -j$(nproc --all) #任何fail请报告\r
779 make install\r
780 #make install-html\r
781 3.17 shadow\r
782 sed -i 's/groups$(EXEEXT) //' src/Makefile.in\r
783 find man -name Makefile.in -exec sed -i 's/groups\.1 / /'   {} \;\r
784 find man -name Makefile.in -exec sed -i 's/getspnam\.3 / /' {} \;\r
785 find man -name Makefile.in -exec sed -i 's/passwd\.5 / /'   {} \;\r
786 sed -i -e 's@#ENCRYPT_METHOD DES@ENCRYPT_METHOD SHA512@' \\r
787 -e 's@/var/spool/mail@/var/mail@' etc/login.defs\r
788 sed -i 's/1000/999/' etc/useradd\r
789 ./configure --prefix=/usr --libdir=/usr/lib64 --libexecdir=/usr/lib64 --sysconfdir=/etc --with-group-name-max-length=32\r
790 make -j$(nproc --all)\r
791 make install\r
792 mv -v /usr/bin/passwd /bin\r
793 pwconv\r
794 grpconv\r
795 passwd root #已设置为lfslinux\r
796 3.18 gcc\r
797 GCCVER=9.2.0\r
798 mkdir -v build\r
799 cd build\r
800 export LIBRARY_PATH=/usr/lib64:/lib64:/usr/lib:/lib\r
801 SED=sed ../configure --prefix=/usr --libdir=/usr/lib64 --libexecdir=/usr/lib64 --with-slibdir=/lib64 --enable-languages=c,c++ --disable-multilib --disable-bootstrap --disable-libmpx --with-system-zlib\r
802 make -j$(nproc --all)\r
803 ulimit -s 32768\r
804 chown -Rv nobody .\r
805 su nobody -s /bin/bash -c "PATH=$PATH make -k check -j$(nproc --all)"\r
806 ../contrib/test_summary\r
807 grep -A7 Summ #fail请报告\r
808 make install\r
809 rm -rf /usr/lib64/gcc/$(gcc -dumpmachine)/${GCCVER}/include-fixed/bits/\r
810 chown -v -R root:root /usr/lib64/gcc/*linux-gnu/${GCCVER}/include{,-fixed}\r
811 ln -sv ../usr/bin/cpp /lib64\r
812 ln -sv gcc /usr/bin/cc\r
813 install -v -dm755 /usr/lib64/bfd-plugins\r
814 ln -sfv ../../libexec/gcc/$(gcc -dumpmachine)/${GCCVER}/liblto_plugin.so /usr/lib64/bfd-plugins/\r
815 echo 'int main(){}' > dummy.c\r
816 cc dummy.c -v -Wl,--verbose &> dummy.log\r
817 readelf -l a.out | grep ': /lib64'\r
818 如果输出[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]即可继续\r
819 grep -o '/usr/lib.*/crt[1in].*succeeded' dummy.log\r
820 应该输出\r
821 /usr/lib64/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../lib64/crt1.o succeeded\r
822 /usr/lib64/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../lib64/crti.o succeeded\r
823 /usr/lib64/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../lib64/crtn.o succeeded\r
824 \r
825 grep -B4 '^ /usr/include' dummy.log\r
826 应该输出\r
827 #include <...> search starts here:\r
828  /usr/lib64/gcc/x86_64-pc-linux-gnu/9.2.0/include\r
829  /usr/local/include\r
830  /usr/lib64/gcc/x86_64-pc-linux-gnu/9.2.0/include-fixed\r
831  /usr/include\r
832 \r
833 grep 'SEARCH.*/usr/lib64' dummy.log |sed 's|; |\n|g'\r
834 应该输出\r
835 SEARCH_DIR("/usr/x86_64-pc-linux-gnu/lib64")\r
836 SEARCH_DIR("/usr/local/lib64")\r
837 SEARCH_DIR("/lib64")\r
838 SEARCH_DIR("/usr/lib64")\r
839 SEARCH_DIR("/usr/x86_64-pc-linux-gnu/lib")\r
840 SEARCH_DIR("/usr/local/lib")\r
841 SEARCH_DIR("/lib")\r
842 SEARCH_DIR("/usr/lib");\r
843 \r
844 grep "/lib64.*/libc.so.6 " dummy.log\r
845 应该输出attempt to open /lib64/libc.so.6 succeeded\r
846 grep found dummy.log\r
847 应该输出found ld-linux-x86-64.so.2 at /lib64/ld-linux-x86-64.so.2\r
848 rm -v dummy.c a.out dummy.log\r
849 mkdir -pv /usr/share/gdb/auto-load/usr/lib64\r
850 mv -v /usr/lib64/*gdb.py /usr/share/gdb/auto-load/usr/lib64\r
851 3.19 pkg-config\r
852 PKGCONFIGVER=0.29.2\r
853 ./configure --prefix=/usr --libdir=/usr/lib64 --libexecdir=/usr/lib64 --with-internal-glib --disable-host-tool --docdir=/usr/share/doc/pkg-config-${PKGCONFIGVER}\r
854 make -j$(nproc --all)\r
855 make check -j$(nproc --all)\r
856 make install\r
857 3.20 ncurses\r
858 sed -i '/LIBTOOL_INSTALL/d' c++/Makefile.in\r
859 ./configure --prefix=/usr --libdir=/usr/lib64 --libexecdir=/usr/lib64 --mandir=/usr/share/man --with-shared --without-debug --without-normal --enable-pc-files --enable-widec\r
860 make -j$(nproc --all)\r
861 make install\r
862 mv -v /usr/lib64/libncursesw.so.6* /lib64\r
863 ln -sfv ../../lib64/$(readlink /usr/lib64/libncursesw.so) /usr/lib64/libncursesw.so\r
864 for lib in ncurses form panel menu ; do\r
865     rm -vf                    /usr/lib64/lib${lib}.so\r
866     echo "INPUT(-l${lib}w)" > /usr/lib64/lib${lib}.so\r
867     ln -sfv ${lib}w.pc        /usr/lib64/pkgconfig/${lib}.pc\r
868 done\r
869 rm -vf                     /usr/lib64/libcursesw.so\r
870 echo "INPUT(-lncursesw)" > /usr/lib64/libcursesw.so\r
871 ln -sfv libncurses.so      /usr/lib64/libcurses.so\r
872 #mkdir -v       /usr/share/doc/ncurses-6.1\r
873 #cp -v -R doc/* /usr/share/doc/ncurses-6.1\r
874 3.21 attr\r
875 ATTRVER=2.4.48\r
876 ./configure --prefix=/usr --bindir=/bin --libdir=/usr/lib64 --libexecdir=/usr/lib64 --disable-static --sysconfdir=/etc --docdir=/usr/share/doc/attr-${ATTRVER}\r
877 make -j$(nproc --all)\r
878 make check -j$(nproc --all)\r
879 make install\r
880 mv -v /usr/lib64/libattr.so.* /lib64\r
881 ln -sfv ../../lib64/$(readlink /usr/lib64/libattr.so) /usr/lib64/libattr.so\r
882 第四章 基本系统配置(这章需要根据实际文件大幅修改)\r
883 \r
884 第五章 构建内核\r
885 \r
886 第六章 重新准备img,向rpm进发\r