2 # generic emulator specific functions
4 ################################################################
6 # Copyright (c) 1995-2014 SUSE Linux Products GmbH
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License version 2 or 3 as
10 # published by the Free Software Foundation.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program (see the file COPYING); if not, write to the
19 # Free Software Foundation, Inc.,
20 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 ################################################################
24 vm_verify_options_emulator() {
25 if test -f "$BUILD_DIR/emulator/verify-options.sh"; then
26 . "$BUILD_DIR/emulator/verify-options.sh"
32 vm_startup_emulator() {
33 pushd "$BUILD_DIR/emulator"
34 if test -z "$EMULATOR_SCRIPT" ; then
35 EMULATOR_SCRIPT=./emulator.sh
36 elif test "${EMULATOR_SCRIPT:0:1}" != / ; then
37 EMULATOR_SCRIPT="./$EMULATOR_SCRIPT"
39 set -- "$EMULATOR_SCRIPT" "$VM_IMAGE" "$VM_SWAP"
43 echo "ERROR: The emulator returned with a failure"
48 test -n "$VM_SWAP" && return
50 # Emulators may not offer to use a second swap space.
51 # So we just mount the filesystem.
52 # WARNING: This is not safe against attacks.
53 mkdir -p $BUILD_ROOT/.build.packages
54 cd $BUILD_ROOT/.build.packages || cleanup_and_exit 1
56 mount $VM_IMAGE -o loop .mount
57 if test -e .mount/.build.packages ; then
58 cp -a .mount/.build.packages/* .
60 exitcode=`cat .mount/.build/_exitcode`
63 cleanup_and_exit "$exitcode"
67 if ! fuser -k -TERM "$VM_IMAGE" ; then
68 echo "could not kill build in $VM_IMAGE"
74 # emulator may not be able to hand over kernel parameters
75 ln -sf /.build/build $BUILD_ROOT/sbin/init
78 vm_attach_root_emulator() {
81 vm_attach_swap_emulator() {
84 vm_detach_root_emulator() {
87 vm_detach_swap_emulator() {
90 vm_cleanup_emulator() {