XFix gbs full build error: binary not found
[tools/build.git] / build-vm-emulator
1 #
2 # generic emulator specific functions
3 #
4 ################################################################
5 #
6 # Copyright (c) 1995-2014 SUSE Linux Products GmbH
7 #
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.
11 #
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.
16 #
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
21 #
22 ################################################################
23
24 vm_verify_options_emulator() {
25     if test -f "$BUILD_DIR/emulator/verify-options.sh"; then
26       . "$BUILD_DIR/emulator/verify-options.sh"
27     else
28       VM_SWAP=
29     fi
30 }
31
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"
38     fi
39     set -- "$EMULATOR_SCRIPT" "$VM_IMAGE" "$VM_SWAP"
40     echo "$@"
41     if ! "$@"; then
42          popd
43          echo "ERROR: The emulator returned with a failure"
44          cleanup_and_exit 3
45     fi
46     popd
47
48     test -n "$VM_SWAP" && return
49
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
55     mkdir -p .mount
56     mount $VM_IMAGE -o loop .mount
57     if test -e .mount/.build.packages ; then
58         cp -a .mount/.build.packages/* .
59     fi
60     exitcode=`cat .mount/.build/_exitcode`
61     umount .mount
62     rmdir .mount
63     cleanup_and_exit "$exitcode"
64 }
65
66 vm_kill_emulator() {
67     if ! fuser -k -TERM "$VM_IMAGE" ; then
68         echo "could not kill build in $VM_IMAGE"
69         cleanup_and_exit 1
70     fi
71 }
72
73 vm_fixup_emulator() {
74     # emulator may not be able to hand over kernel parameters
75     ln -sf /.build/build $BUILD_ROOT/sbin/init
76 }
77
78 vm_attach_root_emulator() {
79     :
80 }
81 vm_attach_swap_emulator() {
82     :
83
84 vm_detach_root_emulator() {
85     :
86 }
87 vm_detach_swap_emulator() {
88     :
89 }
90 vm_cleanup_emulator() {
91     :
92 }
93