FreeBSD 有四類源,pkg、ports、portsnap、update。http://freebsd.cn 暫不可用。
對于失去安全支援的版本,如 FreeBSD 9.0 是沒有 pkg 源可用的,隻能使用當時的 ports 編譯安裝軟體。
本文對于一個源列出了多個鏡像站,無需全部配置,隻需選擇其一即可。
目前境内沒有官方鏡像站,以下均為非官方鏡像站。
pkg 源:pkg 源提供二進制安裝包.
pkg 的下載下傳路徑是
/var/cache/pkg/
FreeBSD 中 pkg 源分為系統級和使用者級兩個源.不建議直接修改 /etc/pkg/FreeBSD.conf
,因為該檔案會随着基本系統的更新而發生改變.
建立使用者級源目錄:
# mkdir -p /usr/local/etc/pkg/repos
北京交通大學自由與開源軟體鏡像站
建立使用者級源檔案:
# ee /usr/local/etc/pkg/repos/bjtu.conf
寫入以下内容: bjtu: {
url: "pkg+http://mirror.bjtu.edu.cn/reverse/freebsd-pkg/${ABI}/quarterly",
mirror_type: "srv",
signature_type: "none",
fingerprints: "/usr/share/keys/pkg",
enabled: yes
}
FreeBSD: { enabled: no }
故障排除
若要擷取滾動更新的包,請将
quarterly
修改為
latest
.請注意,
CURRENT
版本隻有
latest
.
若要使用https,請先安裝security/ca_root_nss,并将
http
https
,最後使用指令
# pkg update -f
重新整理緩存即可,下同。
網易開源鏡像站
# ee /usr/local/etc/pkg/repos/163.conf
163: {
url: "pkg+http://mirrors.163.com/freebsd-pkg/${ABI}/quarterly",
mirror_type: "srv",
signature_type: "none",
fingerprints: "/usr/share/keys/pkg",
enabled: yes
}
FreeBSD: { enabled: no }
中國科學技術大學開源軟體鏡像站
# ee /usr/local/etc/pkg/repos/ustc.conf
ustc: {
url: "pkg+http://mirrors.ustc.edu.cn/freebsd-pkg/${ABI}/quarterly",
mirror_type: "srv",
signature_type: "none",
fingerprints: "/usr/share/keys/pkg",
enabled: yes
}
FreeBSD: { enabled: no }
南京大學開源鏡像站
# ee /usr/local/etc/pkg/repos/nju.conf
nju: {
url: "pkg+http://mirrors.nju.edu.cn/freebsd-pkg/${ABI}/quarterly",
mirror_type: "srv",
signature_type: "none",
fingerprints: "/usr/share/keys/pkg",
enabled: yes
}
FreeBSD: { enabled: no }
http://FreeBSD.cn
# ee /usr/local/etc/pkg/repos/freebsdcn.conf
freebsdcn: {
url: "pkg+http://pkg.freebsd.cn/${ABI}/quarterly",
mirror_type: "srv",
signature_type: "none",
fingerprints: "/usr/share/keys/pkg",
enabled: yes
}
FreeBSD: { enabled: no }
ports 源:提供源碼方式安裝軟體的包管理器
ports 下載下傳路徑是
/usr/ports/distfiles
建立或修改檔案
# ee /etc/make.conf
:
MASTER_SITE_OVERRIDE?=http://mirror.bjtu.edu.cn/reverse/freebsd-pkg/ports-distfiles/
# ee /etc/make.conf
MASTER_SITE_OVERRIDE?=http://mirrors.163.com/freebsd-ports/distfiles/
# ee /etc/make.conf
MASTER_SITE_OVERRIDE?=http://mirrors.ustc.edu.cn/freebsd-ports/distfiles/
# ee /etc/make.conf
MASTER_SITE_OVERRIDE?=http://ports.freebsd.cn/ports-distfiles/
portsnap 源:打包的 ports檔案
編輯portsnap配置檔案
# ee /etc/portsnap.conf
:
将
SERVERNAME=portsnap.FreeBSD.org
修改為
SERVERNAME=freebsd-portsnap.mirror.bjtulug.org
擷取portsnap更新
# portsnap fetch extract
Snapshot appears to have been created more than one day into the future!
(Is the system clock correct?)
Cowardly refusing to proceed any further.
需要同步時間。
ntpdate ntp.api.bz
http://FreeBSD.cn (暫不可用)
# ee /etc/portsnap.conf
SERVERNAME=portsnap.FreeBSD.org
SERVERNAME=portsnap.FreeBSD.cn
freebsd-update 源:提供基本系統更新
注意:隻有一級架構的 release 版本才提供該源。也就是說 current 和 stable 是沒有的。關于架構的支援等級說明請看:
https://www.freebsd.org/platforms/www.freebsd.org/platforms/
編輯
# ee /etc/freebsd-update.conf
檔案:
ServerName update.FreeBSD.org
ServerName freebsd-update.mirror.bjtulug.org
例:從 FreeBSD 12 更新到 13.0
# freebsd-update -r 13.0-RELEASE upgrade
# ee /etc/freebsd-update.conf
ServerName update.FreeBSD.org
ServerName update.FreeBSD.cn