Skip to content
Search RHEL

This page uses Chinese content. Search opens the Chinese documentation.

    Browse this documentation

    RHEL 10 的 DNF 行为变化

    This content is not available in your language yet.

    RHEL 10 的包管理器没有换成 DNF5——至少在 10.2 仍是 DNF 4.20。真正会咬人的是三处行为变化:模块弃用、filelists 元数据默认不下载、debug 插件被移除。本页用 UBI 10.2 容器实测,并给出升级前的脚本检查清单。

    在 registry.access.redhat.com/ubi10/ubi(aarch64,digest sha256:b0a29d36…,Red Hat Enterprise Linux 10.2 (Coughlan))容器内实际执行:

    Terminal window
    cat /etc/redhat-release
    dnf --version | head -2
    rpm -q dnf dnf-plugins-core
    dnf module list
    dnf config-manager --dump | grep -iE 'optional_metadata|filelists'
    dnf clean all && dnf makecache
    find /var/cache/dnf -name '*filelists*' | wc -l
    dnf --setopt=optional_metadata_types=filelists makecache
    find /var/cache/dnf -name '*filelists*' | wc -l
    dnf debug-dump
    dnf debug-restore

    原始输出:plans/content-expansion/evidence/rhel/rhel-dnf-behavior/commands.log(sha256 90021bff3c0b4e73…)。

    另在 PVE 390 rhel10-lab(RHEL 10.2 x86_64,内核 6.12.0-211.7.3.el10_2)复核 dnf --version、dnf module list、dnf debug-dump:版本同为 4.20.0,模块弃用警告与 debug 插件缺失一致;日志 evidence/rhel/rhel-dnf-behavior/rhel-vm.log,控制台截图 shots/02-dnf-version.png、shots/03-module-warning.png。

    Red Hat Enterprise Linux release 10.2 (Coughlan)
    4.20.0
    dnf-4.20.0-22.el10_2.noarch

    dnf5 命令不存在,UBI 仓库也检索不到 dnf5 包。网上“EL10 已换 DNF5”的说法,把 Fedora 41 的事件套到了 RHEL 上;RHEL 10 的 4.x 语法、插件与 python3-dnf API 继续有效。

    dnf module list 仍能执行,但会先打印弃用警告:

    WARNING: modularity is deprecated, and functionality will be removed in a future release of DNF5.

    官方 adoption 文档 22.1 的口径是:RHEL 10 不再计划提供以模块形式发布的 Application Stream。对存量系统的实际影响:

    • 依赖 dnf module enable/install 的自动化脚本,短期内还能跑,但不应再作为新部署的前提;
    • 升级评估时,把“模块流版本”从依赖清单里改成普通 RPM 包版本;
    • 不要按 Fedora 的模块退场时间表规划 RHEL,二者不同步。

    变化二:filelists 元数据默认不下载

    Section titled “变化二:filelists 元数据默认不下载”

    RHEL 10 默认不再下载仓库的 filelists 元数据(它体积大、多数操作不需要)。实测:

    optional_metadata_types = # 默认空
    filelists after default makecache: 0
    filelists after setopt: 3

    后果是:当某个包依赖的是文件路径而不是包名时,DNF 可能报依赖解析错误,并提示:

    (try to add '--skip-broken' to skip uninstallable packages or
    '--setopt=optional_metadata_types=filelists' to load additional filelists metadata)

    两种处置:

    1. 单次命令加 --setopt=optional_metadata_types=filelists;
    2. 长期需要就在 /etc/dnf/dnf.conf 的 [main] 里加 optional_metadata_types=filelists(会增大元数据下载量)。

    dnf-plugins-core 里不再包含 debug 插件:

    No such command: debug-dump. Please use /usr/bin/dnf --help
    No such command: debug-restore. Please use /usr/bin/dnf --help

    官方给出的替代:

    原用法RHEL 10 替代
    dnf debug-dump 列出已装包dnf repoquery --installed 或 dnf list --installed
    dnf debug-dump 列仓库dnf repolist -v
    复制源机包列表到目标机dnf repoquery --installed >/tmp/list,再 dnf install $(</tmp/list)
    • 脚本里是否出现 dnf module?有就改成普通包名/版本锁定,别等它失效;
    • 是否用文件路径做依赖(dnf install /usr/bin/...)?在 RHEL 10 上显式加 --setopt=optional_metadata_types=filelists;
    • 是否调用 dnf debug-dump/debug-restore?换成 repoquery --installed 与 repolist -v;
    • 是否按 DNF5 语法写了 dnf5 命令?RHEL 10 没有 dnf5,改回 dnf;
    • 是否假设 dnf history/versionlock 行为变化?RHEL 10 仍是 DNF4 语义,按原行为测试即可。
    • x86_64 的 RHEL 10.2 虚拟机已复核 dnf 版本、模块警告与 debug 插件缺失;filelists 计数因未注册、无仓库未复测;
    • 未对比 RHEL 9.6 的同名命令输出;
    • 未验证“未来 RHEL 10.x 引入 DNF5”的时间表——官方只说模块功能会在未来的 DNF5 版本移除,没有给 RHEL 的日期;
    • 未测试第三方仓库(EPEL 等)在 filelists 缺省下的表现。

    以下截图来自 PVE 上的实测环境,仅保留关键步骤。

    控制台实测
    控制台实测
    dnf 4.20 版本
    dnf 4.20 版本
    模块流警告
    模块流警告