RHEL 10 的 dnf 仍是 4.20:dnf5 迁移前先确认什么
This content is not available in your language yet.
很多“RHEL 10 用 dnf5”的说法并不准确:RHEL 10.2 默认仍是 dnf 4.20,dnf5 连包都没有。迁移脚本前,先把版本和现有命令核对清楚,别按 dnf5 的语法改。
在 PVE 390 rhel10-lab(RHEL 10.2)执行:
dnf --versionrpm -q dnfrpm -q dnf5 || truecommand -v dnf5 || echo no-dnf5E3 记录:plans/content-expansion/evidence/rhel/rhel-dnf5/run.json(4 步,含版本、repoquery、history、assumeno)。
先给结论:10.2 没有 dnf5
Section titled “先给结论:10.2 没有 dnf5”$ dnf --version4.20.0$ rpm -q dnfdnf-4.20.0-22.el10_2.noarch$ rpm -q dnf5package dnf5 is not installed$ command -v dnf5(空)所以:
- 现有脚本继续按 dnf4 写;
- 不要假设
dnf5子命令/参数存在; - 真要做 dnf5 兼容,等 RHEL 版本实际提供 dnf5 后再按差异测试。
repoquery
Section titled “repoquery”$ dnf -q repoquery --latest-limit 1 bashbash-0:5.2.26-6.el10.x86_64repoquery 在 dnf4 里是插件;--latest-limit、--qf 等参数可用。
history
Section titled “history”$ dnf -q history --reverse | head -4ID | Command line | Date and time | Action(s) | Altered 1 | -q -y install zsh | 2026-11-04 02:28 | Install | 1 2 | -q -y history undo last | 2026-11-04 02:28 | Removed | 1 3 | -q -y install zsh | 2026-11-04 02:28 | Install | 1history undo 依赖 dnf4 的事务 ID;迁移到 dnf5 前要确认新工具是否保留同样的 history/undo 语义。
--assumeno
Section titled “--assumeno”$ sudo dnf -y --assumeno install nano...Operation aborted.--assumeno 用来“只算事务不执行”,在 dnf4 仍有效;自动化里比 --downloadonly 更安全。
迁移检查清单
Section titled “迁移检查清单”-
dnf --version确认 4.x/5.x; -
command -v dnf5是否存在; - 脚本是否用了
dnf5专属参数; -
repoquery/history/--assumeno是否仍可用; - 插件(versionlock/config-manager)是否随 dnf 版本变化;
- 在目标 RHEL 小版本上重跑,而不是只在文档里看。
未实测与边界
Section titled “未实测与边界”- 未安装 dnf5,未测试 dnf5 命令差异;
- 未测试 dnf5 插件/模块流;
- 未测试 dnf4→dnf5 的 history 兼容;
- 未测试
microdnf/容器内 dnf。
- RHEL 10 包回滚与版本锁定 — dnf history/versionlock
- RHEL 10 AppStream — 模块流
- 官方:Managing software with the DNF tool