pacman 升级软件包提示 “failed to commit transaction (invalid or corrupted package)“

很久没打开 WSL 2 里面的 Arch Linux, 想着更新一下软件包, 执行 pacman -Syu, 遇到 “signature is marginal trust” “failed to commit transaction (invalid or corrupted package)” 等错误.

执行 pacman -Syu 报错 "Failed to commit transaction (invalid or corrupted package)"
观察输出的信息, 似乎提到了 “签名” “信任” 的问题 (signature … is marginal trust).

可能当时自己搜索时关键字没提供完整或是什么问题, 总之没能解决问题, 于是可怜兮兮去问友人, 然后被告知 ArchWiki 上就有, 还被责怪为什么不先去看 Wiki.

友人回复挺快, 而且 ArchWiki 的 Pacman 页面 上边 Troubleshooting 章节下的第二点就是, 估计也是常见的问题. ArchWiki 上边的其他记录也挺全面详实的.

果然遇事还是应该先看 Wiki, 写这篇博文也是为了记录这个教训.

总之, 在 ArchWiki 的对应部分, 也就是 “Failed to commit transaction (invalid or corrupted package)” error, 可以看到这样一段话:

That same error may also appear if archlinux-keyring is out-of-date, preventing pacman from verifying signatures. See Pacman/Package signing#Upgrade system regularly for the fix and how to avoid it in the future.

大概意思是说:

同样的错误也可能是 archlinux-keyring 这个软件包过时所导致的, 使得 pacman 无法进行签名验证. 参考 Pacman/关于软件包签名#定期更新系统 以获得问题的解决方案以及如何避免在未来遇到同样问题.

点进文字中链接的这个页面可以看到:

Upgrading the system regularly via pacman#Upgrading packages prevents most signing errors. If delay is unavoidable and system upgrade gets delayed for an extended period, manually sync the package database and upgrade the archlinux-keyring package before system upgrade:

# pacman -Sy archlinux-keyring && pacman -Su

This command is not considered a partial upgrade since it syncs the package database and upgrades the keyring package first. Both must be processed just before starting system upgrade to ensure signatures of all upgraded packages can be properly verified.

大概意思是说:

根据 pacman#升级软件包 中的内容定期升级系统可以避免大部分的签名错误. 如果遇到了不可避免的延迟, 导致系统升级 (system upgrade) 比平时延迟了更长一段时间, 则需要使用如下命令, 在系统升级前手动同步软件包数据库并升级 archlinux-keyring 软件包:

pacman -Sy archlinux-keyring && pacman -Su

这个命令并不会被视作一次 “部分升级”, 因为它在同步了软件包数据库后只是首先安装了 keyring 软件包. 在进行系统升级前, 两项工作都必须进行, 以确保所有被升级的软件包的签名都能被正确验证.

如上, 签名无法验证导致软件包提示损坏的问题应该就能够解决了.

  • 4
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值