This repository was archived by the owner on Feb 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 191
/
Copy pathinstall_qemu.sh
executable file
·81 lines (67 loc) · 2.21 KB
/
install_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
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
#!/bin/bash
#
# Copyright (c) 2018 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
set -e
cidir=$(dirname "$0")
source "${cidir}/lib.sh"
source /etc/os-release
CURRENT_QEMU_COMMIT=$(get_version "assets.hypervisor.qemu-lite.commit")
PACKAGED_QEMU="qemu-lite"
QEMU_ARCH=$(arch)
get_packaged_qemu_commit() {
if [ "$ID" == "ubuntu" ]; then
qemu_commit=$(sudo apt-cache madison $PACKAGED_QEMU \
| awk '{print $3}' | cut -d'-' -f1 | cut -d'.' -f4)
elif [ "$ID" == "fedora" ]; then
qemu_commit=$(sudo dnf --showduplicate list ${PACKAGED_QEMU}.${QEMU_ARCH} \
| awk '/'$PACKAGED_QEMU'/ {print $2}' | cut -d'-' -f1 | cut -d'.' -f4)
elif [ "$ID" == "centos" ]; then
qemu_commit=$(sudo yum --showduplicate list $PACKAGED_QEMU \
| awk '/'$PACKAGED_QEMU'/ {print $2}' | cut -d'-' -f1 | cut -d'.' -f4)
fi
if [ -z "$qemu_commit" ]; then
die "unknown qemu commit"
else
echo "${qemu_commit}"
fi
}
install_packaged_qemu() {
if [ "$ID" == "ubuntu" ]; then
sudo apt install -y "$PACKAGED_QEMU"
elif [ "$ID" == "fedora" ]; then
sudo dnf install -y "$PACKAGED_QEMU"
elif [ "$ID" == "centos" ]; then
sudo yum install -y "$PACKAGED_QEMU"
else
die "Unrecognized distro"
fi
}
build_and_install_qemu() {
QEMU_REPO=$(get_version "assets.hypervisor.qemu-lite.url")
# Remove 'https://' from the repo url to be able to clone the repo using 'go get'
QEMU_REPO=${QEMU_REPO/https:\/\//}
PACKAGING_REPO="github.com/kata-containers/packaging"
QEMU_CONFIG_SCRIPT="${GOPATH}/src/${PACKAGING_REPO}/scripts/configure-hypervisor.sh"
go get -d "${QEMU_REPO}" || true
go get -d "$PACKAGING_REPO" || true
pushd "${GOPATH}/src/${QEMU_REPO}"
git fetch
git checkout "$CURRENT_QEMU_COMMIT"
[ -d "capstone" ] || git clone https://github.com/qemu/capstone.git capstone
[ -d "ui/keycodemapdb" ] || git clone https://github.com/qemu/keycodemapdb.git ui/keycodemapdb
echo "Build Qemu"
"${QEMU_CONFIG_SCRIPT}" "qemu" | sed 's/--static//' | sed 's/--disable-tcg//' | xargs ./configure
make -j $(nproc)
echo "Install Qemu"
sudo -E make install
# Add link from /usr/local/bin to /usr/bin
sudo ln -sf $(command -v qemu-system-${QEMU_ARCH}) "/usr/bin/qemu-lite-system-${QEMU_ARCH}"
popd
}
main() {
build_and_install_qemu
}
main