fi
if check_use_emulator; then
- vm_init_script="/.build/initscript_qemu_vm"
+ if [ -e $BUILD_DIR/initvm ]; then
+ vm_init_script="/.build/initvm"
+ elif [ -e $BUILD_DIR/initscript_qemu_vm ]; then
+ vm_init_script="/.build/initscript_qemu_vm"
+ else
+ echo "Warning: can't find initscript to register binfmts"
+ fi
else
vm_init_script="/.build/build"
fi
return 0
fi
- # to run the qemu initialization in the XEN chroot, we need to register it with a statically build shell
+ # to run the qemu initialization in the XEN chroot, we need to
+ # register it with a static program or shell script
case "$BUILD_HOST_ARCH" in
i?86|x86_64)
- if test -e /bin/bash-static \
+ if test -e /usr/lib/build/initvm && \
+ test -e /usr/lib/build/qemu-reg -o -e /.build/qemu-reg; then
+ return 0 # prefer initvm to handle registration
+ elif test -e /bin/bash-static \
-a -e /bin/mount-static \
-a -e /usr/sbin/qemu-binfmt-conf.sh; then
- return 0
+ return 0 # as backup use /usr/sbin/qemu-binfmt.conf.sh
else
# XXX: error?
echo "Warning: cross compile not possible due to missing static binaries"
}
#
-# Detect cross-build (fixed code) and copy qemus for cross-build emulation mode
-# And copy also a static host binary shell to run the init scripts in the target chroot
+# Copy qemu static binaries for cross-build emulation mode.
+# If initvm is available it will be in $BUILD_DIR; otherwise prepare to
+# fall back to initscript_qemu_vm shell script with corresponding static
+# bash and mount programs.
#
copy_qemu()
{
+ local dev path
+
echo "copying qemu"
- mkdir -p $BUILD_ROOT/usr/bin $BUILD_ROOT/usr/sbin
- install -m755 /usr/bin/qemu-* $BUILD_ROOT/usr/bin
- install -m755 /usr/sbin/qemu-binfmt-conf.sh $BUILD_ROOT/usr/sbin
- # To initially run the init script, there needs to be also a
- # static bash to register qemu in this chroot and to start up
- # /.build/build
+
+ mkdir -p $BUILD_ROOT/usr/bin
+ for dev in $EMULATOR_DEVS; do
+ for path in /usr/bin/qemu-${dev}*; do
+ if file $path | grep -q static; then
+ if [ -f "$path" -a ! -x "$BUILD_ROOT/$path" ]; then
+ echo -n " $path" # report copy
+ install -m755 "$path" "$BUILD_ROOT/$path"
+ fi
+ fi
+ done
+ done
+ echo ""
+
+ # Below for backward compatibility when /.build/initvm is not present
+ if [ -e /usr/sbin/qemu-binfmt-conf.sh \
+ -a ! -e $BUILD_ROOT/usr/sbin/qemu-binfmt-conf.sh ]; then
+ echo " /usr/sbin/qemu-binfmt-conf.sh" # report copy
+ mkdir -p $BUILD_ROOT/usr/sbin
+ install -m755 /usr/sbin/qemu-binfmt-conf.sh $BUILD_ROOT/usr/sbin
+ fi
+
if [ -n "$PREPARE_VM" ]; then
- mkdir -p $BUILD_ROOT/bin
- install -m755 /bin/bash-static $BUILD_ROOT/bin
- install -m755 /bin/mount-static $BUILD_ROOT/bin
+ if [ -x /bin/bash-static -a -x /bin/mount-static ]; then
+ echo " /bin/bash-static /bin/mount-static" # report copy
+ mkdir -p $BUILD_ROOT/bin
+ install -m755 /bin/bash-static $BUILD_ROOT/bin
+ install -m755 /bin/mount-static $BUILD_ROOT/bin
+ fi
fi
}
if [ -z "$PREPARE_VM" ]; then
if ! check_binfmt_registered; then
echo "registering binfmt handlers"
- /usr/sbin/qemu-binfmt-conf.sh
+ # prefer initvm over qemu-binfmt-conf.sh
+ success=false
+ for cmd in $BUILD_DIR/initvm /usr/sbin/qemu-binfmt-conf.sh
+ do
+ if [ -x $cmd ] && $cmd; then
+ success=true
+ break
+ fi
+ done
+ if [ success = false ]; then
+ echo "Warning: could not register binfmt handlers"
+ fi
fi
read mmap_min_addr < /proc/sys/vm/mmap_min_addr
if [ "$mmap_min_addr" != 0 ]; then