Anticipate arch-test not being installed and only check if chroot architecture is unequal host's architecture
This commit is contained in:
parent
c96a1526b2
commit
0166f95545
1 changed files with 48 additions and 30 deletions
78
mmdebstrap
78
mmdebstrap
|
@ -954,37 +954,55 @@ sub main() {
|
||||||
$options->{nativearch} = $nativearch;
|
$options->{nativearch} = $nativearch;
|
||||||
$options->{foreignarchs} = \@foreignarchs;
|
$options->{foreignarchs} = \@foreignarchs;
|
||||||
|
|
||||||
my $deb2qemu = {
|
{
|
||||||
alpha => 'alpha',
|
my $deb2qemu = {
|
||||||
amd64 => 'x86_64',
|
alpha => 'alpha',
|
||||||
arm => 'arm',
|
amd64 => 'x86_64',
|
||||||
arm64 => 'aarch64',
|
arm => 'arm',
|
||||||
armel => 'arm',
|
arm64 => 'aarch64',
|
||||||
armhf => 'arm',
|
armel => 'arm',
|
||||||
hppa => 'hppa',
|
armhf => 'arm',
|
||||||
i386 => 'i386',
|
hppa => 'hppa',
|
||||||
m68k => 'm68k',
|
i386 => 'i386',
|
||||||
mips => 'mips',
|
m68k => 'm68k',
|
||||||
mips64 => 'mips64',
|
mips => 'mips',
|
||||||
mips64el => 'mips64el',
|
mips64 => 'mips64',
|
||||||
mipsel => 'mipsel',
|
mips64el => 'mips64el',
|
||||||
powerpc => 'ppc',
|
mipsel => 'mipsel',
|
||||||
ppc64 => 'ppc64',
|
powerpc => 'ppc',
|
||||||
ppc64el => 'ppc64le',
|
ppc64 => 'ppc64',
|
||||||
riscv64 => 'riscv64',
|
ppc64el => 'ppc64le',
|
||||||
s390x => 's390x',
|
riscv64 => 'riscv64',
|
||||||
sh4 => 'sh4',
|
s390x => 's390x',
|
||||||
sparc => 'sparc',
|
sh4 => 'sh4',
|
||||||
sparc64 => 'sparc64',
|
sparc => 'sparc',
|
||||||
};
|
sparc64 => 'sparc64',
|
||||||
open my $fh, '-|', 'arch-test', '-n', $nativearch // die "failed to fork(): $!";
|
};
|
||||||
chomp (my $content = do { local $/; <$fh> });
|
chomp (my $hostarch = `dpkg --print-architecture`);
|
||||||
close $fh;
|
if ($hostarch ne $nativearch) {
|
||||||
if ($? != 0 or $content ne "$nativearch: ok") {
|
my $pid = open my $fh, '-|' // die "failed to fork(): $!";
|
||||||
if (!exists $deb2qemu->{$nativearch}) {
|
if ($pid == 0) {
|
||||||
die "no mapping from $nativearch to qemu-user binary";
|
{ 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";
|
||||||
}
|
}
|
||||||
$options->{qemu} = $deb2qemu->{$nativearch};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scalar @ARGV > 0) {
|
if (scalar @ARGV > 0) {
|
||||||
|
|
Loading…
Reference in a new issue