第 21.1 节 获取 FreeBSD 内核源码

FreeBSD 项目在 2021 年从 SVN 全面迁移到了 Git,即 https://git.freebsd.orgopen in new window

所以获取源代码的方式也产生了变化,不再使用 svn 了。

从 Git 获取源代码

  • Git
# pkg install -y git
# git clone --depth 1 https://git.FreeBSD.org/src.git /usr/src  # 或 https://github.com/freebsd/freebsd-src

故障排除:

  • Git
    • fatal: unable to update url base from redirection

使用 FreeBSD 源却没加 .git

  • Gitup
# pkg install -y gitup
# gitup release # 具体版本需要参考当前 gitup 配置 https://github.com/johnmehr/gitup/blob/main/gitup.conf
# gitup current # 获取 current 源代码

故障排除:

  • fatal: unable to access 'https://git.FreeBSD.org/src.git/': SSL certificate problem: certificate is not yet valid

可能是时间不对造成的,同步时间:

# ntpdate -u pool.ntp.org # 当时间相差较大时必须使用该命令,其他命令不会生效

从压缩包获取源代码(推荐)

该方法比较简单快捷。

以 FreeBSD 13.2 为例:

# fetch https://download.freebsd.org/ftp/releases/amd64/13.2-RELEASE/src.txz
# tar xvzf src.txz  -C /

如果速度慢可以切换到 13.2-RELEASE/src.txzopen in new window