summaryrefslogtreecommitdiffstats
path: root/run_qemu.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 14:14:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 14:14:39 +0000
commitee17e45964b786b48b455959dfe68715971893fb (patch)
tree118f40aa65dc838499053413b05adfd00f839c62 /run_qemu.sh
parentInitial commit. (diff)
downloadmmdebstrap-ee17e45964b786b48b455959dfe68715971893fb.tar.xz
mmdebstrap-ee17e45964b786b48b455959dfe68715971893fb.zip
Adding upstream version 1.4.3.upstream/1.4.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'run_qemu.sh')
-rwxr-xr-xrun_qemu.sh49
1 files changed, 49 insertions, 0 deletions
diff --git a/run_qemu.sh b/run_qemu.sh
new file mode 100755
index 0000000..fc00ed9
--- /dev/null
+++ b/run_qemu.sh
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+set -eu
+
+: "${DEFAULT_DIST:=unstable}"
+: "${cachedir:=./shared/cache}"
+tmpdir="$(mktemp -d)"
+
+cleanup() {
+ rv=$?
+ rm -f "$tmpdir/log"
+ [ -e "$tmpdir" ] && rmdir "$tmpdir"
+ if [ -e shared/output.txt ]; then
+ res="$(cat shared/exitstatus.txt)"
+ if [ "$res" != "0" ]; then
+ # this might possibly overwrite another non-zero rv
+ rv=1
+ fi
+ fi
+ exit $rv
+}
+
+trap cleanup INT TERM EXIT
+
+echo 1 > shared/exitstatus.txt
+if [ -e shared/output.txt ]; then
+ rm shared/output.txt
+fi
+touch shared/output.txt
+setpriv --pdeathsig TERM tail -f shared/output.txt &
+
+# to connect to serial use:
+# minicom -D 'unix#/tmp/ttyS0'
+#
+# or this (quit with ctrl+q):
+# socat stdin,raw,echo=0,escape=0x11 unix-connect:/tmp/ttyS0
+ret=0
+timeout --foreground 40m debvm-run --image="$(realpath "$cachedir")/debian-$DEFAULT_DIST.ext4" -- \
+ -nic none \
+ -m 4G -snapshot \
+ -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 \
+ >"$tmpdir/log" 2>&1 || ret=$?
+if [ "$ret" -ne 0 ]; then
+ cat "$tmpdir/log"
+ exit $ret
+fi