forked from josch/mmdebstrap
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
20
mmdebstrap
20
mmdebstrap
|
@ -954,6 +954,7 @@ sub main() {
|
||||||
$options->{nativearch} = $nativearch;
|
$options->{nativearch} = $nativearch;
|
||||||
$options->{foreignarchs} = \@foreignarchs;
|
$options->{foreignarchs} = \@foreignarchs;
|
||||||
|
|
||||||
|
{
|
||||||
my $deb2qemu = {
|
my $deb2qemu = {
|
||||||
alpha => 'alpha',
|
alpha => 'alpha',
|
||||||
amd64 => 'x86_64',
|
amd64 => 'x86_64',
|
||||||
|
@ -977,14 +978,31 @@ sub main() {
|
||||||
sparc => 'sparc',
|
sparc => 'sparc',
|
||||||
sparc64 => 'sparc64',
|
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> });
|
chomp (my $content = do { local $/; <$fh> });
|
||||||
close $fh;
|
close $fh;
|
||||||
if ($? != 0 or $content ne "$nativearch: ok") {
|
if ($? != 0 or $content ne "$nativearch: ok") {
|
||||||
|
print STDERR "I: $nativearch cannot be executed, falling back to qemu-user\n";
|
||||||
if (!exists $deb2qemu->{$nativearch}) {
|
if (!exists $deb2qemu->{$nativearch}) {
|
||||||
die "no mapping from $nativearch to qemu-user binary";
|
die "no mapping from $nativearch to qemu-user binary";
|
||||||
}
|
}
|
||||||
$options->{qemu} = $deb2qemu->{$nativearch};
|
$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) {
|
if (scalar @ARGV > 0) {
|
||||||
|
|
Loading…
Reference in a new issue