COPR 第三方仓库:怎么启用、它会带来什么风险
COPR(Cool Other Package Repo)是 Fedora 社区成员自己构建 RPM 的地方。它能让你装上官方仓库里没有的包,代价是这些包不受 Fedora 的质量与安全背书。
本页给出实测的完整流程,以及那条容易被忽略的警告原文。
先确认插件在
Section titled “先确认插件在”dnf copr 由 dnf5-plugins 提供:
rpm -q dnf5-pluginsdnf copr --helpCommands: list list Copr repositories enable download the repository info from a Copr server and install it as a /etc/yum.repos.d/*.repo file disable disable specified Copr repository (if exists), keep /etc/yum.repos.d/*.repo file - just mark enabled=0 remove remove specified Copr repository from the system (removes the /etc/yum.repos.d/*.repo file) debug print useful info about the system, useful for debugging四个动词的分工很清楚,后面会用表格再对比一次。
启用一个 COPR
Section titled “启用一个 COPR”sudo dnf copr enable garrus/clang-opt fedora-45-x86_64第二个参数是 chroot,格式 NAME-RELEASE-ARCH。不写时会自动探测。
启用过程中会打印一段警告(原文):
Enabling a Copr repository. Please note that this repository is not partof the main distribution, and quality may vary.
The Fedora Project does not exercise any power over the contents ofthis repository beyond the rules outlined in the Copr FAQ at<https://docs.copr.fedorainfracloud.org/user_documentation.html#what-i-can-build-in-copr>,and packages are not held to any quality or security level.
Please do not file bug reports about these packages in FedoraBugzilla. In case of problems, contact the owner of this repository.这段话值得逐句读:
| 原话 | 含义 |
|---|---|
not part of the main distribution | 不在主发行版内 |
quality may vary | 质量不保证 |
not held to any quality or security level | 不做任何质量或安全背书 |
do not file bug reports ... in Fedora Bugzilla | 出问题找仓库所有者,不是 Fedora |
它生成了什么
Section titled “它生成了什么”ls /etc/yum.repos.d/_copr:copr.fedorainfracloud.org:garrus:clang-opt.repo文件名把仓库身份编码进去了。内容:
[copr:copr.fedorainfracloud.org:garrus:clang-opt]name=Copr repo for clang-opt owned by garrusbaseurl=https://download.copr.fedorainfracloud.org/results/garrus/clang-opt/fedora-45-x86_64/type=rpm-mdskip_if_unavailable=Truegpgcheck=1gpgkey=https://download.copr.fedorainfracloud.org/results/garrus/clang-opt/pubkey.gpgrepo_gpgcheck=0enabled=1enabled_metadata=1三点值得注意:
gpgcheck=1但repo_gpgcheck=0:包本身校验签名(用的是这个 COPR 自己的公钥),但元数据不做签名校验;gpgkey指向 COPR 侧的公钥,不是你系统里 Fedora 的那把;baseurl里带fedora-45-x86_64,chroot 是写死的——升级到下一个版本后要重新启用。
四个动作的区别
Section titled “四个动作的区别”| 命令 | .repo 文件 | enabled= | 会卸载已装的包吗 |
|---|---|---|---|
enable | 生成 | 1 | 否 |
disable | 保留 | 改成 0 | 否 |
remove | 删除 | — | 否 |
dnf remove <包> | 不变 | 不变 | 是 |
实测 disable:
sudo dnf copr disable garrus/clang-optCopr repository 'copr.fedorainfracloud.org/garrus/clang-opt' in '/etc/yum.repos.d/_copr:copr.fedorainfracloud.org:garrus:clang-opt.repo' disabled.文件还在,enabled 变成 0。想彻底清掉用 remove:
sudo dnf copr remove garrus/clang-optRepo file /etc/yum.repos.d/_copr:copr.fedorainfracloud.org:garrus:clang-opt.repo successfully removed注意 remove 不会卸载从这个仓库装的包。 卸载要单独 dnf remove,而且如果该包被别的包依赖,会牵出一串。
找不到 chroot 怎么办
Section titled “找不到 chroot 怎么办”最常见的报错:
sudo dnf copr enable garrus/clang-opt fedora-44-x86_64Chroot not found in the given Copr project (fedora-44-x86_64).You can choose one of the available chroots explicitly: fedora-45-i386 fedora-45-x86_64好消息是它直接把可用的 chroot 列出来了,照抄即可。这比报”项目不存在”友好得多。
该不该用:一条判断线
Section titled “该不该用:一条判断线”| 场景 | 建议 |
|---|---|
| 桌面上的小工具、编辑器插件 | 可以用,风险可接受 |
| 生产服务器上的运行时、数据库 | 不要,用官方仓库或自建仓库 |
| 需要长期稳定的包 | 不要,COPR 的构建可能随时消失 |
| 只是想在测试机试一下 | 可以,试完 copr remove |
判断标准不是”这个包好不好”,而是它出问题时你能不能自己兜住。COPR 的所有者是个人,项目可能停止维护、构建可能被删除。
手工写 .repo(命令不可用时)
Section titled “手工写 .repo(命令不可用时)”在没有 dnf5-plugins 的环境里,照上面的内容手写也行:
sudo tee /etc/yum.repos.d/copr-clang-opt.repo >/dev/null <<'EOF'[copr:copr.fedorainfracloud.org:garrus:clang-opt]name=Copr repo for clang-opt owned by garrusbaseurl=https://download.copr.fedorainfracloud.org/results/garrus/clang-opt/fedora-45-x86_64/type=rpm-mdskip_if_unavailable=Truegpgcheck=1gpgkey=https://download.copr.fedorainfracloud.org/results/garrus/clang-opt/pubkey.gpgrepo_gpgcheck=0enabled=1EOFsudo dnf makecachednf copr listcopr.fedorainfracloud.org/garrus/clang-opt排查”这个包从哪来的”:
dnf repoquery --installed --qf '%{name} %{from_repo}\n' | grep -i copr- Fedora 仓库与 dnf5 — 仓库配置与第三方源的整体取舍
- 仓库配置迁到 /usr — F45 的路径变化
- 强制签名校验 — COPR 的
gpgcheck与 Fedora 自己的公钥不是同一把 - 模块流(已废弃) — 另一种”装非官方版本”的历史方式
- 报错速查 —
No match for argument、仓库类报错 - 官方:COPR 文档