2018-11-04 19:34:40 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2018-11-23 16:40:17 +00:00
|
|
|
set -eu
|
|
|
|
|
2018-12-28 06:44:54 +00:00
|
|
|
: "${cachedir:=./shared/cache}"
|
2018-11-23 16:44:59 +00:00
|
|
|
tmpdir="$(mktemp -d)"
|
2018-11-04 19:34:40 +00:00
|
|
|
|
2018-12-27 13:14:01 +00:00
|
|
|
cleanup() {
|
|
|
|
rv=$?
|
|
|
|
rm -f "$tmpdir/debian-unstable-overlay.qcow"
|
|
|
|
[ -e "$tmpdir" ] && rmdir "$tmpdir"
|
|
|
|
if [ -e shared/result.txt ]; then
|
|
|
|
head --lines=-1 shared/result.txt
|
|
|
|
res="$(tail --lines=1 shared/result.txt)"
|
|
|
|
rm shared/result.txt
|
2018-12-30 16:13:46 +00:00
|
|
|
if [ "$res" != "0" ]; then
|
2018-12-27 13:14:01 +00:00
|
|
|
# this might possibly overwrite another non-zero rv
|
|
|
|
rv=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
exit $rv
|
|
|
|
}
|
|
|
|
|
|
|
|
trap cleanup INT TERM EXIT
|
|
|
|
|
2018-11-23 16:41:29 +00:00
|
|
|
# the path to debian-unstable.qcow must be absolute or otherwise qemu will
|
|
|
|
# look for the path relative to debian-unstable-overlay.qcow
|
2018-11-23 16:44:59 +00:00
|
|
|
qemu-img create -f qcow2 -b "$(realpath $cachedir)/debian-unstable.qcow" "$tmpdir/debian-unstable-overlay.qcow"
|
2018-12-04 08:05:00 +00:00
|
|
|
KVM=
|
|
|
|
if [ -e /dev/kvm ]; then
|
|
|
|
KVM="-enable-kvm"
|
|
|
|
fi
|
2018-12-30 16:14:15 +00:00
|
|
|
# to connect to serial use:
|
|
|
|
# minicom -D 'unix#/tmp/ttyS0'
|
2018-12-04 08:05:00 +00:00
|
|
|
qemu-system-x86_64 $KVM -m 512M -nographic \
|
2018-11-04 19:34:40 +00:00
|
|
|
-monitor unix:/tmp/monitor,server,nowait \
|
|
|
|
-serial unix:/tmp/ttyS0,server,nowait \
|
|
|
|
-serial unix:/tmp/ttyS1,server,nowait \
|
|
|
|
-virtfs local,id=mmdebstrap,path="$(pwd)/shared",security_model=none,mount_tag=mmdebstrap \
|
2018-11-23 16:44:59 +00:00
|
|
|
-drive file="$tmpdir/debian-unstable-overlay.qcow",cache=unsafe,index=0
|