LFS 11.2(Linux From Scratch)构建过程全记录(三):下载所需的软件包
写在前面
本文将记录构建LFS的过程中,下载软件包的全过程
准备下载的路径
注意请确保$LFS已经设置完毕
我们需要创建一个文件夹,地址为$LFS/sources,用于保存对应的源码
输入的指令如下:
sudo mkdir -v $LFS/sources
如果创建成功,将会有以下的显示:
我们需要修改文件夹的读写权限,修改的指令如下:
sudo chmod -v a+wt $LFS/sources
如果修改成功,将有以下的显示:
文件下载
构建成功这些文件后,我们就可以开始下载所需的文件了
在LFS-BOOK中,给出了两种下载的方法
方法一:在LFS-BOOK 11.2的3.2章,给出了所有需要下载的文件(含源码和插件)的链接,可以一个一个地手动下载
方法二:使用linux中的wget命令进行下载
由于方法二比较方便,笔者将采用方法二进行下载
下载的命令如下:
wget --input-file=wget-list --continue --directory-prefix=$LFS/sources
在执行下载的命令前,我们需要在当前终端的目录下,新建一个wget-list文件
wget-list文件中,保存有所有需要下载的文件的链接
下方给出一个wget-list文件的下载地址:
https://www.linuxfromscratch.org/lfs/downloads/stable/wget-list
警告:注意一定要最新版的wget-list(我要返工了)
下方内容为wget-list中给出的下载链接集,可以直接复制保存为wget-list文件
https://download.savannah.gnu.org/releases/acl/acl-2.3.1.tar.xz https://download.savannah.gnu.org/releases/attr/attr-2.5.1.tar.gz https://ftp.gnu.org/gnu/autoconf/autoconf-2.71.tar.xz https://ftp.gnu.org/gnu/automake/automake-1.16.5.tar.xz https://ftp.gnu.org/gnu/bash/bash-5.1.16.tar.gz https://github.com/gavinhoward/bc/releases/download/6.0.1/bc-6.0.1.tar.xz https://ftp.gnu.org/gnu/binutils/binutils-2.39.tar.xz https://ftp.gnu.org/gnu/bison/bison-3.8.2.tar.xz https://www.sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz https://github.com/libcheck/check/releases/download/0.15.2/check-0.15.2.tar.gz https://ftp.gnu.org/gnu/coreutils/coreutils-9.1.tar.xz https://dbus.freedesktop.org/releases/dbus/dbus-1.14.0.tar.xz https://ftp.gnu.org/gnu/dejagnu/dejagnu-1.6.3.tar.gz https://ftp.gnu.org/gnu/diffutils/diffutils-3.8.tar.xz https://downloads.sourceforge.net/project/e2fsprogs/e2fsprogs/v1.46.5/e2fsprogs-1.46.5.tar.gz https://sourceware.org/ftp/elfutils/0.187/elfutils-0.187.tar.bz2 https://github.com/eudev-project/eudev/releases/download/v3.2.11/eudev-3.2.11.tar.gz https://prdownloads.sourceforge.net/expat/expat-2.4.8.tar.xz https://prdownloads.sourceforge.net/expect/expect5.45.4.tar.gz https://astron.com/pub/file/file-5.42.tar.gz https://ftp.gnu.org/gnu/findutils/findutils-4.9.0.tar.xz https://github.com/westes/flex/releases/download/v2.6.4/flex-2.6.4.tar.gz https://ftp.gnu.org/gnu/gawk/gawk-5.1.1.tar.xz https://ftp.gnu.org/gnu/gcc/gcc-12.2.0/gcc-12.2.0.tar.xz https://ftp.gnu.org/gnu/gdbm/gdbm-1.23.tar.gz https://ftp.gnu.org/gnu/gettext/gettext-0.21.tar.xz https://ftp.gnu.org/gnu/glibc/glibc-2.36.tar.xz https://ftp.gnu.org/gnu/gmp/gmp-6.2.1.tar.xz https://ftp.gnu.org/gnu/gperf/gperf-3.1.tar.gz https://ftp.gnu.org/gnu/grep/grep-3.7.tar.xz https://ftp.gnu.org/gnu/groff/groff-1.22.4.tar.gz https://ftp.gnu.org/gnu/grub/grub-2.06.tar.xz https://ftp.gnu.org/gnu/gzip/gzip-1.12.tar.xz https://github.com/Mic92/iana-etc/releases/download/20220812/iana-etc-20220812.tar.gz https://ftp.gnu.org/gnu/inetutils/inetutils-2.3.tar.xz https://launchpad.net/intltool/trunk/0.51.0/+download/intltool-0.51.0.tar.gz https://www.kernel.org/pub/linux/utils/net/iproute2/iproute2-5.19.0.tar.xz https://files.pythonhosted.org/packages/source/J/Jinja2/Jinja2-3.1.2.tar.gz https://www.kernel.org/pub/linux/utils/kbd/kbd-2.5.1.tar.xz https://www.kernel.org/pub/linux/utils/kernel/kmod/kmod-30.tar.xz https://www.greenwoodsoftware.com/less/less-590.tar.gz https://www.linuxfromscratch.org/lfs/downloads/11.2/lfs-bootscripts-20220723.tar.xz https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.65.tar.xz https://github.com/libffi/libffi/releases/download/v3.4.2/libffi-3.4.2.tar.gz https://download.savannah.gnu.org/releases/libpipeline/libpipeline-1.5.6.tar.gz https://ftp.gnu.org/gnu/libtool/libtool-2.4.7.tar.xz https://www.kernel.org/pub/linux/kernel/v5.x/linux-5.19.2.tar.xz https://ftp.gnu.org/gnu/m4/m4-1.4.19.tar.xz https://ftp.gnu.org/gnu/make/make-4.3.tar.gz https://download.savannah.gnu.org/releases/man-db/man-db-2.10.2.tar.xz https://www.kernel.org/pub/linux/docs/man-pages/man-pages-5.13.tar.xz https://files.pythonhosted.org/packages/source/M/MarkupSafe/MarkupSafe-2.1.1.tar.gz https://github.com/mesonbuild/meson/releases/download/0.63.1/meson-0.63.1.tar.gz https://ftp.gnu.org/gnu/mpc/mpc-1.2.1.tar.gz https://ftp.gnu.org/gnu/mpfr/mpfr-4.1.0.tar.xz https://invisible-mirror.net/archives/ncurses/ncurses-6.3.tar.gz https://github.com/ninja-build/ninja/archive/v1.11.0/ninja-1.11.0.tar.gz https://www.openssl.org/source/openssl-3.0.5.tar.gz https://ftp.gnu.org/gnu/patch/patch-2.7.6.tar.xz https://www.cpan.org/src/5.0/perl-5.36.0.tar.xz https://pkg-config.freedesktop.org/releases/pkg-config-0.29.2.tar.gz https://sourceforge.net/projects/procps-ng/files/Production/procps-ng-4.0.0.tar.xz https://sourceforge.net/projects/psmisc/files/psmisc/psmisc-23.5.tar.xz https://www.python.org/ftp/python/3.10.6/Python-3.10.6.tar.xz https://www.python.org/ftp/python/doc/3.10.6/python-3.10.6-docs-html.tar.bz2 https://ftp.gnu.org/gnu/readline/readline-8.1.2.tar.gz https://ftp.gnu.org/gnu/sed/sed-4.8.tar.xz https://github.com/shadow-maint/shadow/releases/download/4.12.2/shadow-4.12.2.tar.xz https://www.infodrom.org/projects/sysklogd/download/sysklogd-1.5.1.tar.gz https://github.com/systemd/systemd/archive/v251/systemd-251.tar.gz https://anduin.linuxfromscratch.org/LFS/systemd-man-pages-251.tar.xz https://download.savannah.gnu.org/releases/sysvinit/sysvinit-3.04.tar.xz https://ftp.gnu.org/gnu/tar/tar-1.34.tar.xz https://downloads.sourceforge.net/tcl/tcl8.6.12-src.tar.gz https://downloads.sourceforge.net/tcl/tcl8.6.12-html.tar.gz https://ftp.gnu.org/gnu/texinfo/texinfo-6.8.tar.xz https://www.iana.org/time-zones/repository/releases/tzdata2022c.tar.gz https://anduin.linuxfromscratch.org/LFS/udev-lfs-20171102.tar.xz https://www.kernel.org/pub/linux/utils/util-linux/v2.38/util-linux-2.38.1.tar.xz https://anduin.linuxfromscratch.org/LFS/vim-9.0.0228.tar.gz https://anduin.linuxfromscratch.org/LFS/wheel-0.37.1.tar.gz https://cpan.metacpan.org/authors/id/T/TO/TODDR/XML-Parser-2.46.tar.gz https://tukaani.org/xz/xz-5.2.6.tar.xz https://zlib.net/zlib-1.2.12.tar.xz https://github.com/facebook/zstd/releases/download/v1.5.2/zstd-1.5.2.tar.gz https://www.linuxfromscratch.org/patches/lfs/11.2/bzip2-1.0.8-install_docs-1.patch https://www.linuxfromscratch.org/patches/lfs/11.2/coreutils-9.1-i18n-1.patch https://www.linuxfromscratch.org/patches/lfs/11.2/glibc-2.36-fhs-1.patch https://www.linuxfromscratch.org/patches/lfs/11.2/kbd-2.5.1-backspace-1.patch https://www.linuxfromscratch.org/patches/lfs/11.2/sysvinit-3.04-consolidated-1.patch https://www.linuxfromscratch.org/patches/lfs/11.2/systemd-251-glibc_2.36_fix-1.patch https://www.linuxfromscratch.org/patches/lfs/11.2/zstd-1.5.2-upstream_fixes-1.patch
wget-list
运行下载指令后,输出如下则表示开始下载
接下来,你需要静静地等待所有文件下载完成
关于下载方面的一些Tips
部分链接下载比较慢,可以考虑用镜像来实现(比如将https://ftp.gnu.org/gnu/替换为http://mirrors.ustc.edu.cn/gnu/)
wget支持断点下载,可以放心地多次进行下载,不需要删除以前留下的文件
部分文件在内网环境下无法下载,可以考虑挂梯子
在下载的过程中,有三个文件无法正常下载,分别是
https://github.com/shadow-maint/shadow/releases/download/4.12.2/shadow-4.12.2.tar.xz https://github.com/systemd/systemd/archive/v251/systemd-251.tar.gz https://github.com/facebook/zstd/releases/download/v1.5.2/zstd-1.5.2.tar.gz
最后,我通过手动在浏览器中输入对应的链接,才成功进行下载
检验
文件下载后,我们需要检验文件是否已经完整,正确地完成了下载
我们可以使用系统自带的md5检验工具进行检验,检验的命令如下
pushd $LFS/sources md5sum -c md5sums popd
在执行该组命令前,我们需要准备md5sums文件,该文件下载链接为
https://www.linuxfromscratch.org/lfs/downloads/stable/md5sums
我们要将该文件放在$LFS/sources下方
检索后的输出结果如下所示
alphainf@ubuntu:/mnt/lfs/sources$ md5sum -c md5sums acl-2.3.1.tar.xz: OK attr-2.5.1.tar.gz: OK autoconf-2.71.tar.xz: OK automake-1.16.5.tar.xz: OK bash-5.1.16.tar.gz: OK bc-6.0.1.tar.xz: OK binutils-2.39.tar.xz: OK bison-3.8.2.tar.xz: OK bzip2-1.0.8.tar.gz: OK check-0.15.2.tar.gz: OK coreutils-9.1.tar.xz: OK dejagnu-1.6.3.tar.gz: OK diffutils-3.8.tar.xz: OK e2fsprogs-1.46.5.tar.gz: OK elfutils-0.187.tar.bz2: OK eudev-3.2.11.tar.gz: OK expat-2.4.8.tar.xz: OK expect5.45.4.tar.gz: OK file-5.42.tar.gz: OK findutils-4.9.0.tar.xz: OK flex-2.6.4.tar.gz: OK gawk-5.1.1.tar.xz: OK gcc-12.2.0.tar.xz: OK gdbm-1.23.tar.gz: OK gettext-0.21.tar.xz: OK glibc-2.36.tar.xz: OK gmp-6.2.1.tar.xz: OK gperf-3.1.tar.gz: OK grep-3.7.tar.xz: OK groff-1.22.4.tar.gz: OK grub-2.06.tar.xz: OK gzip-1.12.tar.xz: OK iana-etc-20220812.tar.gz: OK inetutils-2.3.tar.xz: OK intltool-0.51.0.tar.gz: OK iproute2-5.19.0.tar.xz: OK kbd-2.5.1.tar.xz: OK kmod-30.tar.xz: OK less-590.tar.gz: OK lfs-bootscripts-20220723.tar.xz: OK libcap-2.65.tar.xz: OK libffi-3.4.2.tar.gz: OK libpipeline-1.5.6.tar.gz: OK libtool-2.4.7.tar.xz: OK linux-5.19.2.tar.xz: OK m4-1.4.19.tar.xz: OK make-4.3.tar.gz: OK man-db-2.10.2.tar.xz: OK man-pages-5.13.tar.xz: OK meson-0.63.1.tar.gz: OK mpc-1.2.1.tar.gz: OK mpfr-4.1.0.tar.xz: OK ncurses-6.3.tar.gz: OK ninja-1.11.0.tar.gz: OK openssl-3.0.5.tar.gz: OK patch-2.7.6.tar.xz: OK perl-5.36.0.tar.xz: OK pkg-config-0.29.2.tar.gz: OK procps-ng-4.0.0.tar.xz: OK psmisc-23.5.tar.xz: OK Python-3.10.6.tar.xz: OK python-3.10.6-docs-html.tar.bz2: OK readline-8.1.2.tar.gz: OK sed-4.8.tar.xz: OK shadow-4.12.2.tar.xz: OK sysklogd-1.5.1.tar.gz: OK sysvinit-3.04.tar.xz: OK tar-1.34.tar.xz: OK tcl8.6.12-src.tar.gz: OK tcl8.6.12-html.tar.gz: OK texinfo-6.8.tar.xz: OK tzdata2022c.tar.gz: OK udev-lfs-20171102.tar.xz: OK util-linux-2.38.1.tar.xz: OK vim-9.0.0228.tar.gz: FAILED wheel-0.37.1.tar.gz: OK XML-Parser-2.46.tar.gz: FAILED xz-5.2.6.tar.xz: OK zlib-1.2.12.tar.xz: OK zstd-1.5.2.tar.gz: OK bzip2-1.0.8-install_docs-1.patch: OK coreutils-9.1-i18n-1.patch: OK glibc-2.36-fhs-1.patch: OK kbd-2.5.1-backspace-1.patch: OK sysvinit-3.04-consolidated-1.patch: OK zstd-1.5.2-upstream_fixes-1.patch: OK md5sum: WARNING: 2 computed checksums did NOT match
我们发现,有两个包出现了报错,我们需要重新进行手动下载
经过手动重新下载,我们修复了这个问题
最后,我们拍摄快照
请忽视STEP 3.0版本,这是一个使用了错误的wget-list而引发的悲剧