Stop copying qemu-$arch-static binary into the chroot
- since qemu-user binfmt has support for pre-opening the interpreter since stretch, there is no reason to copy it into the chroot anymore
This commit is contained in:
parent
bf41b91e6f
commit
21366f76b7
1 changed files with 42 additions and 83 deletions
67
mmdebstrap
67
mmdebstrap
|
@ -2772,11 +2772,10 @@ sub run_prepare {
|
|||
error "unknown mode: $options->{mode}";
|
||||
}
|
||||
|
||||
# copy qemu-user-static binary into chroot
|
||||
if (defined $options->{qemu}) {
|
||||
if ($options->{mode} eq 'fakechroot') {
|
||||
# Make sure that the fakeroot and fakechroot shared
|
||||
# libraries exist for the right architecture
|
||||
# foreign architecture setup for fakechroot mode
|
||||
if (defined $options->{qemu} && $options->{mode} eq 'fakechroot') {
|
||||
# Make sure that the fakeroot and fakechroot shared libraries exist for
|
||||
# the right architecture
|
||||
open my $fh, '-|', 'dpkg-architecture', '-a',
|
||||
$options->{nativearch},
|
||||
'-qDEB_HOST_MULTIARCH' // error "failed to fork(): $!";
|
||||
|
@ -2799,64 +2798,24 @@ sub run_prepare {
|
|||
. " Install libfakeroot:$options->{nativearch}"
|
||||
. " outside the chroot";
|
||||
}
|
||||
# The rest of this block sets environment variables, so we
|
||||
# have to add the "no critic" statement to stop perlcritic
|
||||
# from complaining about setting global variables
|
||||
|
||||
# The rest of this block sets environment variables, so we have to add
|
||||
# the "no critic" statement to stop perlcritic from complaining about
|
||||
# setting global variables
|
||||
## no critic (Variables::RequireLocalizedPunctuationVars)
|
||||
# fakechroot only fills LD_LIBRARY_PATH with the
|
||||
# directories of the host's architecture. We append the
|
||||
# directories of the chroot architecture.
|
||||
# fakechroot only fills LD_LIBRARY_PATH with the directories of the
|
||||
# host's architecture. We append the directories of the chroot
|
||||
# architecture.
|
||||
$ENV{LD_LIBRARY_PATH}
|
||||
= "$ENV{LD_LIBRARY_PATH}:$fakechrootdir:$fakerootdir";
|
||||
# The binfmt support on the outside is used, so qemu needs
|
||||
# to know where it has to look for shared libraries
|
||||
# The binfmt support on the outside is used, so qemu needs to know
|
||||
# where it has to look for shared libraries
|
||||
if (defined $ENV{QEMU_LD_PREFIX}
|
||||
&& $ENV{QEMU_LD_PREFIX} ne "") {
|
||||
$ENV{QEMU_LD_PREFIX} = "$ENV{QEMU_LD_PREFIX}:$options->{root}";
|
||||
} else {
|
||||
$ENV{QEMU_LD_PREFIX} = $options->{root};
|
||||
}
|
||||
} elsif (any { $_ eq $options->{mode} } ('root', 'unshare')) {
|
||||
my $require_qemu_static = 1;
|
||||
# make $@ local, so we don't print an eventual error
|
||||
# in other parts where we evaluate $@
|
||||
local $@ = '';
|
||||
eval {
|
||||
# Check for the F flag which makes the kernel open the binfmt
|
||||
# binary at configuration time instead of lazily at startup
|
||||
# time. If the flag is set, then the qemu-static binary is not
|
||||
# required inside the chroot.
|
||||
if (-e "/proc/sys/fs/binfmt_misc/qemu-$options->{qemu}") {
|
||||
open my $fh, '<',
|
||||
"/proc/sys/fs/binfmt_misc/qemu-$options->{qemu}";
|
||||
while (my $line = <$fh>) {
|
||||
chomp($line);
|
||||
if ($line =~ /^flags: [A-Z]*F[A-Z]*$/) {
|
||||
$require_qemu_static = 0;
|
||||
last;
|
||||
}
|
||||
}
|
||||
close $fh;
|
||||
}
|
||||
};
|
||||
if ($require_qemu_static) {
|
||||
# other modes require a static qemu-user binary
|
||||
my $qemubin = "/usr/bin/qemu-$options->{qemu}-static";
|
||||
if (!-e $qemubin) {
|
||||
error "cannot find $qemubin";
|
||||
}
|
||||
copy $qemubin, "$options->{root}/$qemubin"
|
||||
or error "cannot copy $qemubin: $!";
|
||||
# File::Copy does not retain permissions but on some
|
||||
# platforms (like Travis CI) the binfmt interpreter must
|
||||
# have the executable bit set or otherwise execve will
|
||||
# fail with EACCES
|
||||
chmod 0755, "$options->{root}/$qemubin"
|
||||
or error "cannot chmod $qemubin: $!";
|
||||
}
|
||||
} else {
|
||||
error "unknown mode: $options->{mode}";
|
||||
}
|
||||
}
|
||||
|
||||
# some versions of coreutils use the renameat2 system call in mv.
|
||||
|
|
Loading…
Reference in a new issue