Anticipate arch-test not being installed and only check if chroot architecture is unequal host's architecture

pull/1/head
parent c96a1526b2
commit 0166f95545
Signed by: josch
GPG Key ID: F2CBA5C78FBD83E1

@ -954,6 +954,7 @@ sub main() {
$options->{nativearch} = $nativearch;
$options->{foreignarchs} = \@foreignarchs;
{
my $deb2qemu = {
alpha => 'alpha',
amd64 => 'x86_64',
@ -977,14 +978,31 @@ sub main() {
sparc => 'sparc',
sparc64 => 'sparc64',
};
open my $fh, '-|', 'arch-test', '-n', $nativearch // die "failed to fork(): $!";
chomp (my $hostarch = `dpkg --print-architecture`);
if ($hostarch ne $nativearch) {
my $pid = open my $fh, '-|' // die "failed to fork(): $!";
if ($pid == 0) {
{ exec 'arch-test', '-n', $nativearch; }
# if exec didn't work (for example because the arch-test program is
# missing) prepare for the worst and assume that the architecture
# cannot be executed
print "$nativearch: not supported on this machine/kernel\n";
exit 1;
}
chomp (my $content = do { local $/; <$fh> });
close $fh;
if ($? != 0 or $content ne "$nativearch: ok") {
print STDERR "I: $nativearch cannot be executed, falling back to qemu-user\n";
if (!exists $deb2qemu->{$nativearch}) {
die "no mapping from $nativearch to qemu-user binary";
}
$options->{qemu} = $deb2qemu->{$nativearch};
} else {
print STDERR "I: $nativearch can be executed on this $hostarch machine\n";
}
} else {
print STDERR "I: chroot architecture $nativearch is equal to the host's architecture\n";
}
}
if (scalar @ARGV > 0) {

Loading…
Cancel
Save