summaryrefslogtreecommitdiff
path: root/build-vm-emulator
blob: 045d2447adfc6f861b78ecd5b57da20cc1fffed5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#
# generic emulator specific functions
#
################################################################
#
# Copyright (c) 1995-2014 SUSE Linux Products GmbH
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program (see the file COPYING); if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#
################################################################

vm_verify_options_emulator() {
    if test -f "$BUILD_DIR/emulator/verify-options.sh"; then
      . "$BUILD_DIR/emulator/verify-options.sh"
    else
      VM_SWAP=
    fi
}

vm_startup_emulator() {
    pushd "$BUILD_DIR/emulator"
    if test -z "$EMULATOR_SCRIPT" ; then
       EMULATOR_SCRIPT=./emulator.sh
    elif test "${EMULATOR_SCRIPT:0:1}" != / ; then
       EMULATOR_SCRIPT="./$EMULATOR_SCRIPT"
    fi
    set -- "$EMULATOR_SCRIPT" "$VM_IMAGE" "$VM_SWAP"
    echo "$@"
    if ! "$@"; then
	 popd
	 echo "ERROR: The emulator returned with a failure"
	 cleanup_and_exit 3
    fi
    popd

    test -n "$VM_SWAP" && return

    # Emulators may not offer to use a second swap space.
    # So we just mount the filesystem.
    # WARNING: This is not safe against attacks.
    mkdir -p $BUILD_ROOT/.build.packages
    cd $BUILD_ROOT/.build.packages || cleanup_and_exit 1
    mkdir -p .mount
    mount $VM_IMAGE -o loop .mount
    if test -e .mount/.build.packages ; then
        cp -a .mount/.build.packages/* .
    fi
    exitcode=`cat .mount/.build/_exitcode`
    umount .mount
    rmdir .mount
    cleanup_and_exit "$exitcode"
}

vm_kill_emulator() {
    if ! fuser -k -TERM "$VM_IMAGE" ; then
        echo "could not kill build in $VM_IMAGE"
        cleanup_and_exit 1
    fi
}

vm_fixup_emulator() {
    # emulator may not be able to hand over kernel parameters
    ln -sf /.build/build $BUILD_ROOT/sbin/init
}

vm_attach_root_emulator() {
    :
}
vm_attach_swap_emulator() {
    :
} 
vm_detach_root_emulator() {
    :
}
vm_detach_swap_emulator() {
    :
}
vm_cleanup_emulator() {
    :
}