Last active
April 19, 2023 17:27
-
-
Save sfan5/9d0051e97aaef113d833bffe5b3c897d to your computer and use it in GitHub Desktop.
Builds qemu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
prefix=/opt/qemu | |
qemuver=7.2.1 | |
targets=('x86_64' 'i386') | |
# install dependencies | |
which apt-get &>/dev/null && apt-get install -y --no-install-recommends \ | |
gcc make python3 pkg-config bison flex ninja-build \ | |
lib{jpeg,png,aio,jemalloc,cap-ng,glib2.0,pixman-1}-dev | |
which pacman &>/dev/null && pacman -S --needed \ | |
gcc make python pkg-config bison flex ninja \ | |
lib{jpeg-turbo,png,aio,cap-ng} jemalloc glib2 pixman | |
cd /var/tmp | |
# download | |
wget https://download.qemu.org/qemu-${qemuver}.tar.xz -O qemu.tar.xz | |
tar -xJf qemu.tar.xz | |
rm qemu.tar.xz | |
# build it! | |
pushd "qemu-${qemuver}" | |
target_list="" | |
for t in ${targets[@]}; do | |
target_list="$target_list${t}-softmmu,${t}-linux-user," | |
done | |
./configure --prefix=$prefix \ | |
--audio-drv-list= --enable-pie --extra-ldflags=-s \ | |
--enable-{vnc-jpeg,linux-aio,jemalloc,cap-ng} \ | |
--target-list=$target_list | |
nice make -j$(nproc) | |
# install it | |
make install | |
chmod u+s $prefix/libexec/qemu-bridge-helper | |
mkdir -p $prefix/etc/qemu | |
echo "allow all" >$prefix/etc/qemu/bridge.conf | |
# cleanup | |
popd | |
rm -rf "qemu-${qemuver}" | |
echo "Done, qemu has been installed to $prefix" | |
echo | |
echo "Example command line:" | |
echo "qemu-system-x86_64 -enable-kvm -drive file=disk.img,if=virtio -netdev bridge,id=net0 -device virtio-net,netdev=net0" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment