Compare commits

...

1 Commits

Author SHA1 Message Date
Astro e9447929b6 add debug output via tesseract 2022-10-14 03:48:16 +02:00
2 changed files with 24 additions and 4 deletions

View File

@ -36,6 +36,7 @@ rec {
# Wait for VM to be accessible
sleep 20
echo "Waiting for SSH..."
TEXT=""
while true; do
if test "$timeout" -eq 0; then
echo "SSH connection timed out"
@ -47,6 +48,13 @@ rec {
break
fi
${pkgs.vncdo}/bin/vncdo rcapture cap.png 0 0 1024 768
${pkgs.imagemagick}/bin/mogrify -density 70x70 -units PixelsPerInch cap.png
NEW_TEXT="$(${pkgs.tesseract}/bin/tesseract cap.png stdout)"
if [ "$TEXT" != "$NEW_TEXT" ]; then
echo "$NEW_TEXT"
TEXT="$NEW_TEXT"
fi
echo "Retrying in 1 second, timing out in $timeout seconds"
((timeout=$timeout-1))
@ -85,7 +93,7 @@ rec {
(map ({ listenAddr, targetAddr, port }:
",guestfwd=tcp:${listenAddr}:${toString port}-cmd:${pkgs.socat}/bin/socat\\ -\\ tcp:${targetAddr}:${toString port}"
) forwardedPorts);
qemuParams = mkQemuFlags (pkgs.lib.optional (!display) "-display none" ++ pkgs.lib.optional (!fakeRtc) "-rtc base=localtime" ++ [
qemuParams = mkQemuFlags (pkgs.lib.optional (!display) "-vnc 127.0.0.1:0" ++ pkgs.lib.optional (!fakeRtc) "-rtc base=localtime" ++ [
"-drive"
"file=${image},index=0,media=disk,cache=unsafe"
"-snapshot"

View File

@ -88,7 +88,7 @@ let
installScript = pkgs.writeScript "windows-install-script" (
let
qemuParams = utils.mkQemuFlags (lib.optional (!impureMode) "-display none" ++ [
qemuParams = utils.mkQemuFlags (lib.optional (!impureMode) "-vnc 127.0.0.1:0" ++ [
# "CD" drive with bootstrap pkgs
"-drive"
"id=virtio-win,file=${bootstrapPkgs},if=none,format=raw,readonly=on"
@ -108,7 +108,7 @@ let
in
''
#!${pkgs.runtimeShell}
set -euxo pipefail
set -euo pipefail
export PATH=${lib.makeBinPath [ p7zip utils.qemu guestfs-tools pkgs.wimlib ]}:$PATH
# Create a bootable "USB" image
@ -134,7 +134,19 @@ let
# Qemu requires files to be rw
qemu-img create -f qcow2 c.img ${diskImageSize}
qemu-system-x86_64 ${lib.concatStringsSep " " qemuParams}
qemu-system-x86_64 ${lib.concatStringsSep " " qemuParams} &
TEXT=""
while [ -n "$(jobs)" ]; do
${pkgs.vncdo}/bin/vncdo rcapture cap.png 0 0 1024 768
${pkgs.imagemagick}/bin/mogrify -density 70x70 -units PixelsPerInch cap.png
NEW_TEXT="$(${pkgs.tesseract5}/bin/tesseract cap.png stdout)"
if [ "$TEXT" != "$NEW_TEXT" ]; then
echo "$NEW_TEXT"
TEXT="$NEW_TEXT"
fi
sleep 1
done
''
);