BLFS Programming

Git

备注

GLib 编译安装时依赖git下载代码 libffi

  • 依赖: curl (当使用Git over http,https,ftp 或 ftps时需要)

  • 可选依赖:

    • OpenSSH 使用 Git over ssh 时需要,所以还是必须安装

Git
cd /sources

git_VERSION=2.46.0
tar xf git-${git_VERSION}.tar.xz
cd git-${git_VERSION}

./configure --prefix=/usr \
            --with-gitconfig=/etc/gitconfig \
            --with-python=python3 &&
make

make perllibdir=/usr/lib/perl5/5.40/site_perl install

SSL certificate problem: unable to get local issuer certificate

  • git 执行代码下载提示本地证书错误:

提示SSL证书错误
Cloning into 'libffi'...
fatal: unable to access 'https://gitlab.freedesktop.org/gstreamer/meson-ports/libffi.git/': SSL certificate problem: unable to get local issuer certificate

../meson.build:2218:13: ERROR: Git command failed: ['/usr/bin/git', '-c', 'advice.detachedHead=false', 'clone', '--depth', '1', '--branch', 'meson', 'https://gitlab.freedesktop.org/gstreamer/meson-ports/libffi.git', 'libffi']

这个报错是 HTTPS 协议,说明是 curl 访问HTTPS异常,所以检查 curl 编译安装是否存在问题: cRUL安装中有一个建议 Recommended at runtime 安装 make-ca 我当时跳过了。

参考 Unable to get local issuer certificate error with unusual certificate chain ,对于debian发行版,通常是通过重新安装 ca-certificates 软件包来修复证书链。

要绕过这个问题有一个办法(但是有安全隐患),临时禁止git校验SSL证书:

临时禁止SSL证书验证
git config --global http.sslVerify false

但是这个方法会导致中间人攻击,所以使用以后要马上恢复验证:

恢复SSL证书验证
git config --global http.sslVerify true

最终解决方案make-ca ,比较折腾的是需要为 openssl 设置代理才能解决

fatal: Unsupported SSL backend 'schannel'

接下来又遇到了新的报错:

提示SSL不支持 'schannel' 后端
Cloning into 'libffi'...
fatal: Unsupported SSL backend 'schannel'. Supported SSL backends:
	openssl

../meson.build:2218:13: ERROR: Git command failed: ['/usr/bin/git', '-c', 'advice.detachedHead=false', 'clone', '--depth', '1', '--branch', 'meson', 'https://gitlab.freedesktop.org/gstreamer/meson-ports/libffi.git', 'libffi']

这个问题同样参考 Unable to resolve "unable to get local issuer certificate" using git on Windows with self-signed certificate 调整 git SSL后端设置为 openssl :

设置git使用openssl作为SSL后端
git config --global http.sslbackend openssl

CMake

CMake是代替configure的配置生成工具,我在编译 LLaMa(Large Language Model Meta AI) 时需要

CMake
cd /sources

cmake_VERSION=3.30.2
tar xf cmake-${cmake_VERSION}.tar.gz
cd cmake-${cmake_VERSION}

sed -i '/"lib64"/s/64//' Modules/GNUInstallDirs.cmake &&

./bootstrap --prefix=/usr        \
            --system-libs        \
            --mandir=/share/man  \
            --no-system-jsoncpp  \
            --no-system-cppdap   \
            --no-system-librhash \
            --docdir=/share/doc/cmake-${cmake_VERSION} &&
make

make install