Apt

Dpkg 無法載入 ‘/usr/lib/arm-linux-gnueabihf/perl/5.28/auto/Fcntl/Fcntl.so’

  • October 11, 2019

當我嘗試sudo apt upgrade執行 Raspbian Buster 的 Raspberry Pi 系統dpkg時,在配置以下內容時出錯openssh-server

$ sudo apt upgrade -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following package was automatically installed and is no longer required:
 rpi.gpio-common
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
debconf: Perl may be unconfigured (Can't load '/usr/lib/arm-linux-gnueabihf/perl/5.28/auto/Fcntl/Fcntl.so' for module Fcntl: /usr/lib/arm-linux-gnueabihf/perl/5.28/auto/Fcntl/Fcntl.so: invalid ELF header at /usr/share/perl/5.28/XSLoader.pm line 93.
 at /usr/lib/arm-linux-gnueabihf/perl/5.28/Fcntl.pm line 11.
Compilation failed in require at /usr/lib/arm-linux-gnueabihf/perl/5.28/IO/Seekable.pm line 11.
BEGIN failed--compilation aborted at /usr/lib/arm-linux-gnueabihf/perl/5.28/IO/Seekable.pm line 11.
Compilation failed in require at /usr/lib/arm-linux-gnueabihf/perl/5.28/IO/File.pm line 10.
BEGIN failed--compilation aborted at /usr/lib/arm-linux-gnueabihf/perl/5.28/IO/File.pm line 10.
Compilation failed in require at /usr/share/perl/5.28/FileHandle.pm line 9.
Compilation failed in require at (eval 1) line 3.
BEGIN failed--compilation aborted at (eval 1) line 3.
) -- aborting
Setting up openssh-server (1:7.9p1-10+deb10u1) ...
Can't load '/usr/lib/arm-linux-gnueabihf/perl/5.28/auto/Fcntl/Fcntl.so' for module Fcntl: /usr/lib/arm-linux-gnueabihf/perl/5.28/auto/Fcntl/Fcntl.so: invalid ELF header at /usr/share/perl/5.28/XSLoader.pm line 93.
 at /usr/lib/arm-linux-gnueabihf/perl/5.28/Fcntl.pm line 11.
Compilation failed in require at /usr/lib/arm-linux-gnueabihf/perl/5.28/POSIX.pm line 11.
BEGIN failed--compilation aborted at /usr/lib/arm-linux-gnueabihf/perl/5.28/POSIX.pm line 17.
Compilation failed in require at /usr/share/perl5/Debconf/Template.pm line 7.
BEGIN failed--compilation aborted at /usr/share/perl5/Debconf/Template.pm line 7.
Compilation failed in require at /usr/share/perl5/Debconf/Question.pm line 8.
BEGIN failed--compilation aborted at /usr/share/perl5/Debconf/Question.pm line 8.
Compilation failed in require at /usr/share/perl5/Debconf/Config.pm line 7.
BEGIN failed--compilation aborted at /usr/share/perl5/Debconf/Config.pm line 7.
Compilation failed in require at /usr/share/perl5/Debconf/Log.pm line 10.
Compilation failed in require at /usr/share/perl5/Debconf/Db.pm line 7.
BEGIN failed--compilation aborted at /usr/share/perl5/Debconf/Db.pm line 7.
Compilation failed in require at /usr/share/debconf/frontend line 6.
BEGIN failed--compilation aborted at /usr/share/debconf/frontend line 6.
dpkg: error processing package openssh-server (--configure):
installed openssh-server package post-installation script subprocess returned error exit status 255
dpkg: dependency problems prevent configuration of ssh:
ssh depends on openssh-server (>= 1:7.9p1-10+deb10u1); however:
 Package openssh-server is not configured yet.

dpkg: error processing package ssh (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
openssh-server
ssh
E: Sub-process /usr/bin/dpkg returned an error code (1)

在看到提示配置問題的錯誤行時,我嘗試sudo dpkg --configure -a了,只是再次獲得相同的輸出:

$ sudo dpkg --configure -a
Setting up openssh-server (1:7.9p1-10+deb10u1) ...
Can't load '/usr/lib/arm-linux-gnueabihf/perl/5.28/auto/Fcntl/Fcntl.so' for module Fcntl: /usr/lib/arm-linux-gnueabihf/perl/5.28/auto/Fcntl/Fcntl.so: invalid ELF header at /usr/share/perl/5.28/XSLoader.pm line 93.
 at /usr/lib/arm-linux-gnueabihf/perl/5.28/Fcntl.pm line 11.
Compilation failed in require at /usr/lib/arm-linux-gnueabihf/perl/5.28/POSIX.pm line 11.
BEGIN failed--compilation aborted at /usr/lib/arm-linux-gnueabihf/perl/5.28/POSIX.pm line 17.
Compilation failed in require at /usr/share/perl5/Debconf/Template.pm line 7.
BEGIN failed--compilation aborted at /usr/share/perl5/Debconf/Template.pm line 7.
Compilation failed in require at /usr/share/perl5/Debconf/Question.pm line 8.
BEGIN failed--compilation aborted at /usr/share/perl5/Debconf/Question.pm line 8.
Compilation failed in require at /usr/share/perl5/Debconf/Config.pm line 7.
BEGIN failed--compilation aborted at /usr/share/perl5/Debconf/Config.pm line 7.
Compilation failed in require at /usr/share/perl5/Debconf/Log.pm line 10.
Compilation failed in require at /usr/share/perl5/Debconf/Db.pm line 7.
BEGIN failed--compilation aborted at /usr/share/perl5/Debconf/Db.pm line 7.
Compilation failed in require at /usr/share/debconf/frontend line 6.
BEGIN failed--compilation aborted at /usr/share/debconf/frontend line 6.
dpkg: error processing package openssh-server (--configure):
installed openssh-server package post-installation script subprocess returned error exit status 255
dpkg: dependency problems prevent configuration of ssh:
ssh depends on openssh-server (>= 1:7.9p1-10+deb10u1); however:
 Package openssh-server is not configured yet.

dpkg: error processing package ssh (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
openssh-server
ssh

當談到 Linux 包配置和包的模糊性時openssh-server,我是一個完全的菜鳥。我無法在網上找到任何描述類似問題和可行解決方案的文獻或論壇文章。我該如何解決這個明顯的圖書館衝突?

編輯:

$ sudo apt --reinstall install perl-base
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
 rpi.gpio-common
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
Need to get 1,352 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://mirror.os6.org/raspbian/raspbian buster/main armhf perl-base armhf 5.28.1-6 [1,352 kB]
Fetched 1,352 kB in 1s (1,069 kB/s)
debconf: Perl may be unconfigured (Can't load '/usr/lib/arm-linux-gnueabihf/perl/5.28/auto/Fcntl/Fcntl.so' for module Fcntl: /usr/lib/arm-linux-gnueabihf/perl/5.28/auto/Fcntl/Fcntl.so: invalid ELF header at /usr/share/perl/5.28/XSLoader.pm line 93.
 at /usr/lib/arm-linux-gnueabihf/perl/5.28/Fcntl.pm line 11.
Compilation failed in require at /usr/lib/arm-linux-gnueabihf/perl/5.28/IO/Seekable.pm line 11.
BEGIN failed--compilation aborted at /usr/lib/arm-linux-gnueabihf/perl/5.28/IO/Seekable.pm line 11.
Compilation failed in require at /usr/lib/arm-linux-gnueabihf/perl/5.28/IO/File.pm line 10.
BEGIN failed--compilation aborted at /usr/lib/arm-linux-gnueabihf/perl/5.28/IO/File.pm line 10.
Compilation failed in require at /usr/share/perl/5.28/FileHandle.pm line 9.
Compilation failed in require at (eval 1) line 3.
BEGIN failed--compilation aborted at (eval 1) line 3.
) -- aborting
(Reading database ... 43627 files and directories currently installed.)
Preparing to unpack .../perl-base_5.28.1-6_armhf.deb ...
Unpacking perl-base (5.28.1-6) over (5.28.1-6) ...
Setting up perl-base (5.28.1-6) ...
Setting up openssh-server (1:7.9p1-10+deb10u1) ...
Can't load '/usr/lib/arm-linux-gnueabihf/perl/5.28/auto/Fcntl/Fcntl.so' for module Fcntl: /usr/lib/arm-linux-gnueabihf/perl/5.28/auto/Fcntl/Fcntl.so: invalid ELF header at /usr/share/perl/5.28/XSLoader.pm line 93........................]
 at /usr/lib/arm-linux-gnueabihf/perl/5.28/Fcntl.pm line 11........................................................]
Compilation failed in require at /usr/lib/arm-linux-gnueabihf/perl/5.28/POSIX.pm line 11............................]
BEGIN failed--compilation aborted at /usr/lib/arm-linux-gnueabihf/perl/5.28/POSIX.pm line 17........................]
Compilation failed in require at /usr/share/perl5/Debconf/Template.pm line 7........................................]
BEGIN failed--compilation aborted at /usr/share/perl5/Debconf/Template.pm line 7.
Compilation failed in require at /usr/share/perl5/Debconf/Question.pm line 8.
BEGIN failed--compilation aborted at /usr/share/perl5/Debconf/Question.pm line 8.
Compilation failed in require at /usr/share/perl5/Debconf/Config.pm line 7.
BEGIN failed--compilation aborted at /usr/share/perl5/Debconf/Config.pm line 7.
Compilation failed in require at /usr/share/perl5/Debconf/Log.pm line 10.
Compilation failed in require at /usr/share/perl5/Debconf/Db.pm line 7.
BEGIN failed--compilation aborted at /usr/share/perl5/Debconf/Db.pm line 7.
Compilation failed in require at /usr/share/debconf/frontend line 6.
BEGIN failed--compilation aborted at /usr/share/debconf/frontend line 6.
dpkg: error processing package openssh-server (--configure):
installed openssh-server package post-installation script subprocess returned error exit status 255
dpkg: dependency problems prevent configuration of ssh:
ssh depends on openssh-server (>= 1:7.9p1-10+deb10u1); however:
 Package openssh-server is not configured yet.

dpkg: error processing package ssh (--configure):
dependency problems - leaving unconfigured
Processing triggers for man-db (2.8.5-2) ...
Illegal instruction
Errors were encountered while processing:
openssh-server
ssh
E: Sub-process /usr/bin/dpkg returned an error code (1)
$ ls /usr/bin/ -lah | grep perl
-rwxr-xr-x  2 root root    2.8M Mar 31  2019 perl
-rwxr-xr-x  2 root root    2.8M Mar 31  2019 perl5.28.1
-rwxr-xr-x  1 root root    5.5K Mar 31  2019 perl5.28-arm-linux-gnueabihf
-rwxr-xr-x  2 root root     46K Mar 31  2019 perlbug
-rwxr-xr-x  1 root root     125 Mar 31  2019 perldoc
-rwxr-xr-x  1 root root     11K Mar 31  2019 perlivp
-rwxr-xr-x  2 root root     46K Mar 31  2019 perlthanks

看起來問題是由 perl 和debconf之間的先有雞還是先有蛋的問題引起的。Debconf是一項可選功能,它允許軟體包在開始時而不是在安裝過程中獲取配置問題:它不是至關重要的,所以這是要離開的。

在 Debian 9 或 10 系統上,其呼叫配置為/etc/apt/apt.conf.d/70debconf

// Pre-configure all packages with debconf before they are installed.
// If you don't like it, comment it out.
DPkg::Pre-Install-Pkgs {"/usr/sbin/dpkg-preconfigure --apt || true";};

所以只需註釋掉DPkg::Pre-Install-Pkgs上面的行。

從錯誤消息中,我認為該包libperl5.28的內容可能已損壞。perl-baseapt一起重新安裝它:

apt-get --fix-broken --reinstall install perl-base libperl5.28

或者(如果apt還需要 Perl 並且還阻塞)直接使用**dpkg嘗試,因為它已下載:

dpkg -i /var/cache/apt/archives/libperl5.28_5.28.1-6_armhf.deb

如果您遇到更多錯誤,這可能意味著系統之前發生了其他事情,但問題中沒有解釋。了解系統之前發生的錯誤可以幫助修復它。

一旦 perl 恢復工作,您可以取消對上一行的註釋以啟用debconf

引用自:https://unix.stackexchange.com/questions/546351