-
Notifications
You must be signed in to change notification settings - Fork 2
/
build-qemu.sh
executable file
·55 lines (46 loc) · 1.37 KB
/
build-qemu.sh
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
#!/bin/bash
# Written to be called from migration-test.sh
PROGNAME=build-qemu.sh
QEMUDIR=qemu
function error_exit
{
# ----------------------------------------------------------------
# Function for exit due to fatal program error
# Accepts 1 argument:
# string containing descriptive error message
# ----------------------------------------------------------------
echo "${PROGNAME}: ${1:-"Unknown Error"}" 1>&2
exit 2
}
declare -a tools=("git" "gcc")
for tool in "${tools[@]}"
do
if ! tool_loc="$(type -p "$tool")" || [ -z "$tool_loc" ]; then
error_exit "$tool is required, please install, aborting"
fi
done
if [[ -e qemu-system-aarch64 ]]; then
error_exit "qemu binary already exists."
fi
if [[ -d $QEMUDIR ]]; then
echo "QEMU source directory already exists. Skipping clone."
else
git clone git://git.qemu.org/qemu.git $QEMUDIR
fi
pushd $QEMUDIR
VERSION=`git tag | grep '^v[0-9]\+\.[0-9]\+\.[0-9]\+$' | sort -V | tail -n 1`
echo "Building QEMU $VERSION..."
git checkout $VERSION
git submodule update --init dtc
mkdir -p build
pushd build
../configure --target-list=aarch64-softmmu
make -j `nproc`
popd
popd
cp $QEMUDIR/build/aarch64-softmmu/qemu-system-aarch64 .
echo "I have bulid you a brand new QEMU $VERSION for you."
read -p "Would you like me to clean up after myself and remove the source dir? [y/N]" -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
rm -rf $QEMUDIR
fi