FreeBSD 中文镜像

2025-02-03 (Updated 2025-02-05)

之前用 BSD 的时候一直不知道有中国非官方镜像,导致长时间只能使用被墙的低速镜像。

以下是我现使用 USTC 镜像的配置:

make.conf

USTC 还有 port 的 git 镜像,但是这个没被墙,勉强还能用,所以在此略过。

Distfile 镜像

USTC 提供编译 Port 软件所需的 Distfile, 通过更改 make.conf 来使用:

/etc/make.conf 增加以下内容:

# Use USTC mirror
MASTER_SITE_OVERRIDE?=http://mirrors.ustc.edu.cn/freebsd-ports/distfiles/${DIST_SUBDIR}/

Shell Environment

Go

Poudriere 会屏蔽掉自定义的环境变量,因此只能 fetch 二进制包,或者自己手动编译。

export GO111MODULE=on
export GOPROXY?=https://goproxy.cn

Poudriere

Jail 所需的操作系统 stage 3

在创建 jail 时使用 -m url=https://cmcc.mirrors.ustc.edu.cn/freebsd/releases/amd64/14.2-RELEASE/

poudriere jail -c -j 142quarterly -v 14.2-RELEASE -m 'url=https://cmcc.mirrors.ustc.edu.cn/freebsd/releases/amd64/14.2-RELEASE/'

Jail 所需二进制包

/usr/local/etc/poudriere.conf:374:

# Set to always attempt to fetch packages or dependencies before building.
# XXX: This is subject to change
# Default: off; requires -b <branch> for bulk or testport.
PACKAGE_FETCH_BRANCH=latest
# The branch will be appended to the URL:
PACKAGE_FETCH_URL=https://mirrors.ustc.edu.cn/freebsd-pkg/\${ABI}

Poudriere会报错:No SRV record found for the repo,此报错无害,但有时会同时无法更新 pkg 源,此时重启 dns 服务器即可。