有人建议我sudo dpkg --add-architecture armhf
跑去添加交叉编译到我的运行 Ubuntu 18.04 LTS 的 x86_64 盒子,但它似乎不起作用:
$ sudo dpkg --add-architecture armhf
[sudo] password for leeand00:
Odd number of elements in hash assignment at /usr/share/pkg-config-dpkghook line 30.
有问题的 dpkghook(perl 文件)如下所示:
#! /usr/bin/perl
#
# Sets up /usr/bin/*-pkg-config symlinks to point to the cross wrapper.
#
# It is called from dpkg --post-invoke and from postinst with the "update"
# argument to instate the necessary symlinks.
#
# It is called from prerm with the "remove" argument to remove all symlinks.
#
use strict;
use warnings;
use Dpkg::Arch qw(debarch_to_gnutriplet);
use Dpkg::ErrorHandling qw(error);
my $crosswrapper = "/usr/share/pkg-config-crosswrapper";
my $action = $ARGV[0];
error("parameter must be 'remove' or 'update'")
unless defined $action && ($action eq "remove" || $action eq "update");
my $arch = `dpkg --print-architecture`;
error('dpkg --print-architecture failed') if $? >> 8;
my @architectures = `dpkg --print-foreign-architectures`;
error('dpkg --print-foreign-architectures failed') if $? >> 8;
push @architectures, $arch;
chomp @architectures;
my %gnutriplets = map { debarch_to_gnutriplet($_) => 1 } @architectures;
my %symlinks = map { $_ => 1 } </usr/bin/*-pkg-config>;
foreach my $symlink (keys %symlinks) {
$symlink =~ m,^/usr/bin/([^-]+-[^-]+-[^-]+)-pkg-config, or next;
next if exists $gnutriplets{$1} && $action eq "update";
next unless -l $symlink;
next unless readlink $symlink eq $crosswrapper;
unlink $symlink or
error("failed to remove symlink $symlink: $!");
}
if ($action eq 'update') {
foreach (keys %gnutriplets) {
my $linktarget = "/usr/bin/${_}-pkg-config";
next if exists $symlinks{$linktarget};
next if -e $linktarget;
symlink $crosswrapper, $linktarget or
error("failed to create symlink $linktarget to $crosswrapper: $!");
}
}
第 30 行如下所示:
my %gnutriplets = map { debarch_to_gnutriplet($_) => 1 } @architectures;
除了用于安装/状态/卸载包等基本功能之外,我不太了解 Ubuntu 中的包管理器dpkg
,那么为什么我会看到这个错误以及如何修复它?
答案1
我遇到了同样的问题。我能够调试钩子脚本。在调试过程中,我发现我试图添加不受支持的架构,在我的情况下是 aarch64。
尝试运行:
dpkg --print-foreign-architectures
如果您看到不受支持的架构,请尝试将其删除:
sudo dpkg --remove-architecture aarch64
至少这对我有用。