From 86b430190f854b64bf5afa084734875211e0fa3d Mon Sep 17 00:00:00 2001 From: Johannes 'josch' Schauer Date: Sun, 6 Oct 2019 18:37:30 +0200 Subject: [PATCH] set qemu binfmt identifier before using it to avoid uninitialized value error --- mmdebstrap | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/mmdebstrap b/mmdebstrap index b52df72..60dc229 100755 --- a/mmdebstrap +++ b/mmdebstrap @@ -2031,11 +2031,16 @@ sub main() { close $fh; } { - open my $fh, '-|', '/usr/sbin/update-binfmts', '--display', "qemu-$options->{qemu}" // error "failed to fork(): $!"; - chomp (my $binfmts = do { local $/; <$fh> }); - close $fh; - if ($binfmts eq '') { - warning "qemu-$options->{qemu} is not a supported binfmt name"; + if (!exists $deb2qemu->{$nativearch}) { + warning "no mapping from $nativearch to qemu-user binary"; + } else { + my $binfmt_identifier = 'qemu-' . $deb2qemu->{$nativearch}; + open my $fh, '-|', '/usr/sbin/update-binfmts', '--display', $binfmt_identifier // error "failed to fork(): $!"; + chomp (my $binfmts = do { local $/; <$fh> }); + close $fh; + if ($binfmts eq '') { + warning "$binfmt_identifier is not a supported binfmt name"; + } } } error "qemu user emulation of $nativearch using binfmt_misc failed";