RSYNCSRC=
RSYNCDEST=
RSYNCDONE=
+: ${EMULATOR_ARCHS:="armv4l armv5el armv7el sh4 ppc ppc64 mips mipsel"}
+
+export EMULATOR_ARCHS
# This is for insserv
export YAST_IS_RUNNING=instsys
umount $BUILD_ROOT || cleanup_and_exit 1
fi
+ if check_use_emulator; then
+ vm_init_script="/.build/initscript_qemu_vm"
+ else
+ vm_init_script="/.build/build"
+ fi
+
if [ "$VM_TYPE" = 'xen' ]; then
XMROOT=file:$VM_IMAGE
XMROOT=${XMROOT/#file:\/dev/phy:/dev}
XENID="${VM_IMAGE%/root}"
XENID="${XENID%/tmpfs}"
XENID="${XENID##*/}"
- CROSS_INIT_SCRIPT="/.build/build"
- # to run the qemu initialization in the XEN chroot, we need to register it with a statically build shell
- if [ x"$BUILD_ARCH" == xarmv4l -o x"$BUILD_ARCH" == xarmv5el -o x"$BUILD_ARCH" == xarmv7el -o x"$BUILD_ARCH" == xsh4 -o x"$BUILD_ARCH" == xppc -o x"$BUILD_ARCH" == xppc64 -o x"$BUILD_ARCH" == xmips -o x"$BUILD_ARCH" == xmipsel ]; then
- if [ -n "$(uname -m | grep '[x3-6]86')" ]; then
- if [ -e /bin/bash-static -a -e /bin/mount-static ]; then
- CROSS_INIT_SCRIPT="/.build/initscript_qemu_vm"
- fi
- fi
- fi
echo "booting XEN kernel ..."
if xm list "build:$XENID" >/dev/null 2>&1 ; then
echo "Please report to your server admin, there might be multiple services running for same domain"
cleanup_and_exit 3
fi
- set -- xm create -c $BUILD_DIR/xen.conf name="build:$XENID" ${MEMSIZE:+memory=$MEMSIZE} $XMROOT $XMSWAP extra="quiet init="$CROSS_INIT_SCRIPT" panic=1 console=ttyS0"
+ set -- xm create -c $BUILD_DIR/xen.conf name="build:$XENID" ${MEMSIZE:+memory=$MEMSIZE} $XMROOT $XMSWAP extra="quiet init="$vm_init_script" panic=1 console=ttyS0"
if test "$PERSONALITY" != 0 ; then
# have to switch back to PER_LINUX to make xm work
set -- linux64 "$@"
"$@" || cleanup_and_exit 3
elif [ "$VM_TYPE" = 'uml' ]; then
echo "booting UML kernel ..."
- set -- $uml_kernel initrd=$uml_initrd root=/ubda init=/.build/build panic=1 quiet ubd0=$VM_IMAGE ${MEMSIZE:+mem=$MEMSIZE}
+ set -- $uml_kernel initrd=$uml_initrd root=/ubda init="$vm_init_script" panic=1 quiet ubd0=$VM_IMAGE ${MEMSIZE:+mem=$MEMSIZE}
echo "$@"
"$@"
elif [ "$VM_TYPE" = 'qemu' -o "$VM_TYPE" = 'kvm' ]; then
qemu_disks[${#qemu_disks[@]}]="$VM_SWAP"
fi
fi
- CROSS_INIT_SCRIPT="/.build/build"
- # to run the qemu initialization in the XEN chroot, we need to register it with a statically build shell
- if [ x"$BUILD_ARCH" == xarmv4l -o x"$BUILD_ARCH" == xarmv5el -o x"$BUILD_ARCH" == xarmv6el -o x"$BUILD_ARCH" == xarmv7el -o x"$BUILD_ARCH" == xarmv8el -o x"$BUILD_ARCH" == xsh4 -o x"$BUILD_ARCH" == xppc -o x"$BUILD_ARCH" == xppc64 -o x"$BUILD_ARCH" == xmips -o x"$BUILD_ARCH" == xmipsel ]; then
- echo "Building for arch: $BUILD_ARCH"
- if [ -n "$(uname -m | grep '[x3-6]86')" ]; then
- echo " on arch: $(uname -m | grep '[x3-6]86')"
- if [ -e /bin/bash-static -a -e /bin/mount-static ]; then
- echo " using cross-init"
- CROSS_INIT_SCRIPT="/.build/initscript_qemu_vm"
- fi
- fi
- fi
set -- $qemu_bin -no-reboot -nographic -net none -serial stdio \
-kernel $qemu_kernel \
-initrd $qemu_initrd \
- -append "root=$qemu_rootdev panic=1 quiet noapic rw console=ttyS0 init=$CROSS_INIT_SCRIPT" \
+ -append "root=$qemu_rootdev panic=1 quiet noapic rw console=ttyS0 init=$vm_init_script" \
${MEMSIZE:+-m $MEMSIZE} \
"${qemu_disks[@]}"
LXCID=${BUILD_ROOT##*/}
lxc-destroy -n "$LXCID" >/dev/null 2>&1 || true
lxc-create -n "$LXCID" -f "$LXCCONF" || cleanup_and_exit 1
- CROSS_INIT_SCRIPT="/.build/build"
- # to run the qemu initialization in the XEN chroot, we need to register it with a statically build shell
- if [ x"$BUILD_ARCH" == xarmv4l -o x"$BUILD_ARCH" == xarmv5el -o x"$BUILD_ARCH" == xarmv7el -o x"$BUILD_ARCH" == xsh4 -o x"$BUILD_ARCH" == xppc -o x"$BUILD_ARCH" == xppc64 -o x"$BUILD_ARCH" == xmips -o x"$BUILD_ARCH" == xmipsel ]; then
- if [ -n "$(uname -m | grep '[x3-6]86')" ]; then
- if [ -e /bin/bash-static -a -e /bin/mount-static ]; then
- CROSS_INIT_SCRIPT="/.build/initscript_qemu_vm"
- fi
- fi
- fi
- lxc-start -n "$LXCID" "$CROSS_INIT_SCRIPT"
+ lxc-start -n "$LXCID" "$vm_init_script"
BUILDSTATUS="$?"
test "$BUILDSTATUS" != 255 || BUILDSTATUS=3
cleanup_and_exit "$BUILDSTATUS"
fi
}
-function register_qemu_user {
#
# 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
#
-if [ x"$BUILD_ARCH" == xarmv4l -o x"$BUILD_ARCH" == xarmv5el -o x"$BUILD_ARCH" == xarmv7el -o x"$BUILD_ARCH" == xsh4 -o x"$BUILD_ARCH" == xppc -o x"$BUILD_ARCH" == xppc64 -o x"$BUILD_ARCH" == xmips -o x"$BUILD_ARCH" == xmipsel ]; then
- if [ -n "$(uname -m | grep '[x3-6]86')" ]; then
- if [ -e /usr/sbin/qemu-binfmt-conf.sh ]; then
- (mkdir -p $BUILD_ROOT/usr/bin $BUILD_ROOT/usr/sbin && set -x && cp /usr/bin/qemu-* $BUILD_ROOT/usr/bin && cp /usr/sbin/qemu-binfmt-conf.sh $BUILD_ROOT/usr/sbin)
- fi
- # To initially run the init script, there needs to be also a static bash to register qemu in this chroot and though to start up /.build/build
- if [ -e /bin/bash-static -a -e /bin/mount-static ]; then
- (mkdir -p $BUILD_ROOT/bin && set -x && cp /bin/bash-static $BUILD_ROOT/bin && cp /bin/mount-static $BUILD_ROOT/bin && chmod a+x $BUILD_ROOT/bin/*-static )
- fi
- if [ -e /proc/sys/fs/binfmt_misc/arm -o -e /proc/sys/fs/binfmt_misc/armeb -o -e /proc/sys/fs/binfmt_misc/sh4 -o -e /proc/sys/fs/binfmt_misc/mips -o -e /proc/sys/fs/binfmt_misc/ppc -o -e /proc/sys/fs/binfmt_misc/ppc64 ]; then
- echo "qemu-* already registered"
- else
- if [ -e /usr/sbin/qemu-binfmt-conf.sh ]; then
- echo "qemu-* will be registered"
- (set -x && /usr/sbin/qemu-binfmt-conf.sh)
- fi
- fi
+copy_qemu()
+{
+ check_use_emulator || return
+
+ 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/bin
+ install -m755 /bin/bash-static $BUILD_ROOT/bin
+ install -m755 /bin/mount-static $BUILD_ROOT/bin
+ # XXX: not needed if vm is used
+ if ! check_binfmt_registered; then
+ echo "registering binfmt handlers"
+ /usr/sbin/qemu-binfmt-conf.sh
fi
-fi
+}
+
+check_binfmt_registered()
+{
+ local arch
+ for arch in arm $EMULATOR_ARCHS; do
+ if test -e /proc/sys/fs/binfmt_misc/$arch; then
+ return 0
+ fi
+ done
+ return 1
}
fail_exit()
# register the QEMU emulator
# reset mmap_min_addr for QEMU
#
-register_qemu_user
+copy_qemu
#
# store that we start to build system