fi
}
+check_copy_qemu()
+{
+ local arch
+
+ for arch in $EMULATOR_DEVS; do
+ if test -e $BUILD_DIR/qemu-$arch; then
+ return 0
+ fi
+ done
+ return 1
+}
+
+copy_qemu()
+{
+ local path dest
+
+ echo "copying qemu"
+
+ mkdir -p $BUILD_ROOT/usr/bin
+
+ if check_copy_qemu; then
+
+ for path in $BUILD_DIR/qemu-*; do
+ if file $path | grep -q static; then
+ dest="$BUILD_ROOT/usr/bin/${path##*/}"
+ if [ -f "$path" -a ! -x "$dest" ]; then
+ echo -n " $path" # report copy
+ #echo install -m755 "$path" "$dest"
+ install -m755 "$path" "$dest"
+ fi
+ fi
+ done
+
+ else
+
+ for path in /usr/bin/qemu-*; do
+ if file $path | grep -q static; then
+ dest="$BUILD_ROOT/usr/bin/${path##*/}"
+ if [ -f "$path" -a ! -x "$dest" ]; then
+ echo -n " $path" # report copy
+ #echo install -m755 "$path" "$dest"
+ install -m755 "$path" "$dest"
+ fi
+ fi
+ done
+
+ 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
+
+ fi
+ echo ""
+
+ # Below for backward compatibility when /.build/initvm is not present
+
+ if [ -n "$PREPARE_VM" ]; then
+ 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
+}
+
+check_binfmt_registered()
+{
+ local arch
+ for arch in $EMULATOR_DEVS; do
+ if test -e /proc/sys/fs/binfmt_misc/$arch; then
+ return 0
+ fi
+ done
+ return 1
+}
+
fail_exit()
{
cleanup_and_exit 1
# register the QEMU emulator
#
if check_use_emulator; then
+ [ -n "$USE_SYSTEM_QEMU" ] && copy_qemu
echo "registering binfmt handlers for VM"
if [ -x "$BUILD_DIR/initvm.`uname -m`" -a -e "$BUILD_DIR/qemu-reg" ]; then