centos 用dnf 命令安装包的时候出现包签名错误
报错信息
[root@localhost]# dnf install git
CentOS-8 - AppStream 388 kB/s | 4.4 kB 00:00
CentOS-8 - Base 3.7 kB/s | 3.9 kB 00:01
CentOS-8 - Extras 376 kB/s | 2.9 kB 00:00
Dependencies resolved.
Package Architecture Version Repository Size
Installing:
git x86_64 2.39.3-1.el8 AppStream 104 k
Installing dependencies:
git-core x86_64 2.39.3-1.el8 AppStream 11 M
git-core-doc noarch 2.39.3-1.el8 AppStream 3.3 M
perl-Error noarch 1:0.17025-2.el8 AppStream 46 k
perl-Git noarch 2.39.3-1.el8 AppStream 79 k
perl-TermReadKey x86_64 2.37-7.el8 AppStream 40 k
Transaction Summary
Install 6 Packages
Total download size: 14 M
Installed size: 44 M
Is this ok [y/N]: y
Downloading Packages:
(1/6): git-2.39.3-1.el8.x86_64.rpm 1.9 MB/s | 104 kB 00:00
(2/6): perl-Error-0.17025-2.el8.noarch.rpm 1.6 MB/s | 46 kB 00:00
(3/6): perl-Git-2.39.3-1.el8.noarch.rpm 1.3 MB/s | 79 kB 00:00
(4/6): perl-TermReadKey-2.37-7.el8.x86_64.rpm 954 kB/s | 40 kB 00:00
(5/6): git-core-doc-2.39.3-1.el8.noarch.rpm 700 kB/s | 3.3 MB 00:04
(6/6): git-core-2.39.3-1.el8.x86_64.rpm 1.4 MB/s | 11 MB 00:07
Total 1.8 MB/s | 14 MB 00:07
error: /var/cache/dnf/AppStream-91699f31f6595bcf/packages/git-core-2.39.3-1.el8.x86_64.rpm: signature hdr data: BAD, no. of bytes(59520) out of range
error: /var/cache/dnf/AppStream-91699f31f6595bcf/packages/git-core-doc-2.39.3-1.el8.noarch.rpm: signature hdr data: BAD, no. of bytes(294284) out of range
Problem opening package git-core-2.39.3-1.el8.x86_64.rpm
Problem opening package git-core-doc-2.39.3-1.el8.noarch.rpm
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing ‘dnf clean packages’.
Error: GPG check FAILED
尝试了几种方法都不行
1.dnf clean packages/all
2.使用–nogpgcheck 参数 dnf install git --nogpgcheck
3.修改CentOS-Base.repo中的gpgcheck参数为0 ,然后重新import gpgkey
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
再把gpgchekc改成1,最后重新安装dnf install git
正确的解决方式:
dnf update rpm
dnf update
参考原因
This is coming from the fact that when you create a new CentOS Droplet and then try to update it with the dnf or yum update command you are updating the rpm package as well causing differences in the rpm version trying to unpackage rpm files thus coming with an error like :
Problem opening package linux-firmware-20230217-113.git83f1d778.el8.noarch.rpm
I’ve reported this however for the time being what you can do is to update rpm alone and then do the dnf update on all packages;