跳转到内容
搜索 Fedora 文档

    浏览当前文档目录

    COPR 第三方仓库:怎么启用、它会带来什么风险

    COPR(Cool Other Package Repo)是 Fedora 社区成员自己构建 RPM 的地方。它能让你装上官方仓库里没有的包,代价是这些包不受 Fedora 的质量与安全背书。

    本页给出实测的完整流程,以及那条容易被忽略的警告原文。

    dnf copr 由 dnf5-plugins 提供:

    Terminal window
    rpm -q dnf5-plugins
    dnf copr --help
    Commands:
    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

    四个动词的分工很清楚,后面会用表格再对比一次。

    Terminal window
    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 part
    of the main distribution, and quality may vary.
    The Fedora Project does not exercise any power over the contents of
    this 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 Fedora
    Bugzilla. 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
    Terminal window
    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 garrus
    baseurl=https://download.copr.fedorainfracloud.org/results/garrus/clang-opt/fedora-45-x86_64/
    type=rpm-md
    skip_if_unavailable=True
    gpgcheck=1
    gpgkey=https://download.copr.fedorainfracloud.org/results/garrus/clang-opt/pubkey.gpg
    repo_gpgcheck=0
    enabled=1
    enabled_metadata=1

    三点值得注意:

    • gpgcheck=1 但 repo_gpgcheck=0:包本身校验签名(用的是这个 COPR 自己的公钥),但元数据不做签名校验;
    • gpgkey 指向 COPR 侧的公钥,不是你系统里 Fedora 的那把;
    • baseurl 里带 fedora-45-x86_64,chroot 是写死的——升级到下一个版本后要重新启用。
    命令.repo 文件enabled=会卸载已装的包吗
    enable生成1否
    disable保留改成 0否
    remove删除—否
    dnf remove <包>不变不变是

    实测 disable:

    Terminal window
    sudo dnf copr disable garrus/clang-opt
    Copr repository 'copr.fedorainfracloud.org/garrus/clang-opt' in '/etc/yum.repos.d/_copr:copr.fedorainfracloud.org:garrus:clang-opt.repo' disabled.

    文件还在,enabled 变成 0。想彻底清掉用 remove:

    Terminal window
    sudo dnf copr remove garrus/clang-opt
    Repo file /etc/yum.repos.d/_copr:copr.fedorainfracloud.org:garrus:clang-opt.repo successfully removed

    注意 remove 不会卸载从这个仓库装的包。 卸载要单独 dnf remove,而且如果该包被别的包依赖,会牵出一串。

    最常见的报错:

    Terminal window
    sudo dnf copr enable garrus/clang-opt fedora-44-x86_64
    Chroot 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 列出来了,照抄即可。这比报”项目不存在”友好得多。

    场景建议
    桌面上的小工具、编辑器插件可以用,风险可接受
    生产服务器上的运行时、数据库不要,用官方仓库或自建仓库
    需要长期稳定的包不要,COPR 的构建可能随时消失
    只是想在测试机试一下可以,试完 copr remove

    判断标准不是”这个包好不好”,而是它出问题时你能不能自己兜住。COPR 的所有者是个人,项目可能停止维护、构建可能被删除。

    在没有 dnf5-plugins 的环境里,照上面的内容手写也行:

    Terminal window
    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 garrus
    baseurl=https://download.copr.fedorainfracloud.org/results/garrus/clang-opt/fedora-45-x86_64/
    type=rpm-md
    skip_if_unavailable=True
    gpgcheck=1
    gpgkey=https://download.copr.fedorainfracloud.org/results/garrus/clang-opt/pubkey.gpg
    repo_gpgcheck=0
    enabled=1
    EOF
    sudo dnf makecache
    Terminal window
    dnf copr list
    copr.fedorainfracloud.org/garrus/clang-opt

    排查”这个包从哪来的”:

    Terminal window
    dnf repoquery --installed --qf '%{name} %{from_repo}\n' | grep -i copr