Hi, On Sat, 14 Sep 2019 18:18:12 +0200 Johannes Schauer <[email protected]> wrote: > Quoting Giovanni Mascellani (2019-09-14 08:27:19) > > Il 13/09/19 23:20, Johannes Schauer ha scritto: > > > you write that support for the foreign executable is available in the > > > container > > > as well. If so, then why does arch-test determine that armhf cannot be > > > executed? > > Maybe "support for foreign executable" was not the right choice of words: it > > still goes through qemu-user, so it is excluded by arch-test called with -n > > (as mmdebstrap does). So execution of foreign executables is available, > > meaning that the kernel is configured through binfmt_misc to reroute them to > > qemu-user, but binfmt_misc is not visible inside the container. arch-test > > detects them in the same way it does outside of the container: with -n it > > only sees native archs, but without it perfectly sees the qemu-user (and > > wine) ones. > ah okay, great! Then I think there is an even better solution. I guess > mmdebstrap should first run "arch-test" (without the -n) to check if support > exists without qemu-user emulation. Only if that does *not* work, should > mmdebstrap run "arch-test -n" and then check /proc for possible problem > reasons.
unfortunately I have no experience with docker. Would you be willing to test a patch (attached) that should fix the problem you reported? Alternatively, since mmdebstrap is a single file script, you could also copy the git HEAD version from https://gitlab.mister-muffin.de/josch/mmdebstrap Thanks! cheers, josch
>From d5033dd0d1bbaed6be699fd4d2bf32fc6b8481ed Mon Sep 17 00:00:00 2001 From: Johannes 'josch' Schauer <[email protected]> Date: Thu, 26 Sep 2019 10:14:45 +0200 Subject: [PATCH] also check for situations in which a non-native arch can be executed without emulation --- mmdebstrap | 77 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 59 insertions(+), 18 deletions(-) diff --git a/mmdebstrap b/mmdebstrap index fa952f2..d4c86b1 100755 --- a/mmdebstrap +++ b/mmdebstrap @@ -1951,26 +1951,56 @@ sub main() { }; chomp (my $hostarch = `dpkg --print-architecture`); if ($hostarch ne $nativearch) { - my $pid = open my $fh, '-|' // error "failed to fork(): $!"; - if ($pid == 0) { - { - no warnings; # don't print a warning if the following fails - exec 'arch-test', '-n', $nativearch; + my $withemu = 0; + my $noemu = 0; + { + my $pid = open my $fh, '-|' // error "failed to fork(): $!"; + if ($pid == 0) { + { + no warnings; # don't print a warning if the following fails + exec 'arch-test', $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 and $content eq "$nativearch: ok") { + $withemu = 1; } - # 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") { - info "$nativearch cannot be executed, falling back to qemu-user"; - if (!exists $deb2qemu->{$nativearch}) { - error "no mapping from $nativearch to qemu-user binary"; + { + my $pid = open my $fh, '-|' // error "failed to fork(): $!"; + if ($pid == 0) { + { + no warnings; # don't print a warning if the following fails + 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; } - $options->{qemu} = $deb2qemu->{$nativearch}; + chomp (my $content = do { local $/; <$fh> }); + close $fh; + if ($? == 0 and $content eq "$nativearch: ok") { + $noemu = 1; + } + } + # four different outcomes, depending on whether arch-test + # succeeded with or without emulation + # + # withemu | noemu | + # --------+-------+----------------- + # 0 | 0 | test why emu doesn't work and quit + # 0 | 1 | should never happen + # 1 | 0 | use qemu emulation + # 1 | 1 | don't use qemu emulation + if ($withemu == 0 and $noemu == 0) { { open my $fh, '<', '/proc/filesystems' or error "failed to open /proc/filesystems: $!"; unless (grep /^nodev\tbinfmt_misc$/, (<$fh>)) { @@ -1993,8 +2023,19 @@ sub main() { error "qemu-$options->{qemu} is not a supported binfmt name"; } } + error "qemu emulation of $nativearch failed for an unknown reason"; + } elsif ($withemu == 0 and $noemu == 1) { + error "arch-test succeeded without emu but not with emu"; + } elsif ($withemu == 1 and $noemu == 0) { + info "$nativearch cannot be executed, falling back to qemu-user"; + if (!exists $deb2qemu->{$nativearch}) { + error "no mapping from $nativearch to qemu-user binary"; + } + $options->{qemu} = $deb2qemu->{$nativearch}; + } elsif ($withemu == 1 and $noemu == 1) { + info "$nativearch is different from $hostarch but can be executed natively"; } else { - info "$nativearch can be executed on this $hostarch machine"; + error "logic error"; } } else { info "chroot architecture $nativearch is equal to the host's architecture"; -- 2.20.1
signature.asc
Description: signature

