From 9edf87cacf5a7720268d91b536a8f5967797a858 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Tue, 1 Dec 2026 05:16:26 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20Windows=20Prepare=20shows?= =?UTF-8?q?=20the=20VM's=20live=20setup=20status=20(download/install)=20wh?= =?UTF-8?q?ile=20waiting=20for=20ssh,=20waits=20up=20to=203h=20for=20a=20f?= =?UTF-8?q?resh=20install;=20Linux=20packages=20guarded=20by=20a=20ready?= =?UTF-8?q?=20marker=20so=20a=20half-failed=20apt=20retries?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/client/src/release.rs | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/crates/client/src/release.rs b/crates/client/src/release.rs index 91149bd..0373e79 100644 --- a/crates/client/src/release.rs +++ b/crates/client/src/release.rs @@ -71,6 +71,7 @@ const LINUX_PACKAGES: &str = "ca-certificates curl git build-essential pkg-confi const ARCHIVE: &str = "dist/source.tgz"; const VM: &str = "yumush-win"; const VM_DIR: &str = "vm/yumush-win"; +const SSH_WAIT: Duration = Duration::from_secs(3 * 60 * 60); const VM_IMAGE: &str = "docker.io/dockurr/windows"; const VM_AUDIO: &str = "ARGUMENTS=-audiodev none,id=snd0 -device ich9-intel-hda,id=hda1 -device hda-duplex,bus=hda1.0,audiodev=snd0 -device ich9-intel-hda,id=hda2 -device hda-duplex,bus=hda2.0,audiodev=snd0"; const INSTALL: &str = include_str!("release/install.bat"); @@ -347,7 +348,7 @@ fn start_linux(job: Job, source: &Path, cx: &Cx) -> Result<(), String> { )?; let rust = host_rust()?; let script = format!( - "command -v clang >/dev/null || {{ apt-get update; apt-get install -y --no-install-recommends {LINUX_PACKAGES}; }} + "[ -f /etc/yumush-ready ] || {{ apt-get update; apt-get install -y --no-install-recommends {LINUX_PACKAGES}; touch /etc/yumush-ready; }} [ -x /root/.cargo/bin/rustup ] || curl -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --default-toolchain none rustup toolchain install {rust} --profile minimal rustup default {rust} @@ -541,7 +542,7 @@ exit $LASTEXITCODE } fn wait_ssh(job: Job, key: &Path, cx: &Cx) -> Result<(), String> { - let deadline = Instant::now() + Duration::from_secs(600); + let deadline = Instant::now() + SSH_WAIT; while !ssh_ok(key) { if cx.cancelled() { return Err("cancelled".into()); @@ -549,12 +550,36 @@ fn wait_ssh(job: Job, key: &Path, cx: &Cx) -> Result<(), String> { if Instant::now() >= deadline { return Err("ssh timeout".into()); } - cx.send(Event::Line(job, "waiting for ssh".into())); + cx.send(Event::Line(job, vm_status())); thread::sleep(Duration::from_secs(5)); } Ok(()) } +fn vm_status() -> String { + let Ok(out) = podman().args(["logs", "--tail", "5", VM]).output() else { + return "waiting for ssh".into(); + }; + let text = String::from_utf8_lossy(&out.stdout) + String::from_utf8_lossy(&out.stderr); + text.lines() + .map(plain) + .rfind(|line| !line.is_empty()) + .unwrap_or_else(|| "waiting for ssh".into()) +} + +fn plain(line: &str) -> String { + let mut out = String::new(); + let mut chars = line.chars(); + while let Some(c) = chars.next() { + if c == '\u{1b}' { + chars.by_ref().find(|c| c.is_ascii_alphabetic()); + } else if c != '❯' { + out.push(c); + } + } + out.trim().trim_end_matches("...").to_string() +} + fn opts(key: &Path, port_flag: &str) -> Vec { let mut args = vec!["-i".to_string(), key.display().to_string()]; for option in [