forge
Explore
Log in

Don't you dare go Hollow

Windows Prepare shows the VM's live setup status (download/install) while waiting for ssh, waits up to 3h for a fresh install

Browse files at this commit

9edf87cacf5a7720268d91b536a8f5967797a858Ahmet Kaan GümüşParent: ccf421a
  • feat
    • Windows Prepare shows the VM's live setup status (download/install) while waiting for ssh, waits up to 3h for a fresh install
    • Linux packages guarded by a ready marker so a half-failed apt retries
Show full message
✨ feat: Windows Prepare shows the VM's live setup status (download/install) while waiting for ssh, waits up to 3h for a fresh install; Linux packages guarded by a ready marker so a half-failed apt retries
crates/client/src/release.rsmodified+28 -3
@@ -71,6 +71,7 @@ const LINUX_PACKAGES: &str = "ca-certificates curl git build-essential pkg-confi
71 const ARCHIVE: &str = "dist/source.tgz";71 const ARCHIVE: &str = "dist/source.tgz";
72 const VM: &str = "yumush-win";72 const VM: &str = "yumush-win";
73 const VM_DIR: &str = "vm/yumush-win";73 const VM_DIR: &str = "vm/yumush-win";
74+const SSH_WAIT: Duration = Duration::from_secs(3 * 60 * 60);
74 const VM_IMAGE: &str = "docker.io/dockurr/windows";75 const VM_IMAGE: &str = "docker.io/dockurr/windows";
75 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";76 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";
76 const INSTALL: &str = include_str!("release/install.bat");77 const INSTALL: &str = include_str!("release/install.bat");
@@ -347,7 +348,7 @@ fn start_linux(job: Job, source: &Path, cx: &Cx) -> Result<(), String> {
347 )?;348 )?;
348 let rust = host_rust()?;349 let rust = host_rust()?;
349 let script = format!(350 let script = format!(
350- "command -v clang >/dev/null || {{ apt-get update; apt-get install -y --no-install-recommends {LINUX_PACKAGES}; }}351+ "[ -f /etc/yumush-ready ] || {{ apt-get update; apt-get install -y --no-install-recommends {LINUX_PACKAGES}; touch /etc/yumush-ready; }}
351 [ -x /root/.cargo/bin/rustup ] || curl -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --default-toolchain none352 [ -x /root/.cargo/bin/rustup ] || curl -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --default-toolchain none
352 rustup toolchain install {rust} --profile minimal353 rustup toolchain install {rust} --profile minimal
353 rustup default {rust}354 rustup default {rust}
@@ -541,7 +542,7 @@ exit $LASTEXITCODE
541 }542 }
542 543
543 fn wait_ssh(job: Job, key: &Path, cx: &Cx) -> Result<(), String> {544 fn wait_ssh(job: Job, key: &Path, cx: &Cx) -> Result<(), String> {
544- let deadline = Instant::now() + Duration::from_secs(600);545+ let deadline = Instant::now() + SSH_WAIT;
545 while !ssh_ok(key) {546 while !ssh_ok(key) {
546 if cx.cancelled() {547 if cx.cancelled() {
547 return Err("cancelled".into());548 return Err("cancelled".into());
@@ -549,12 +550,36 @@ fn wait_ssh(job: Job, key: &Path, cx: &Cx) -> Result<(), String> {
549 if Instant::now() >= deadline {550 if Instant::now() >= deadline {
550 return Err("ssh timeout".into());551 return Err("ssh timeout".into());
551 }552 }
552- cx.send(Event::Line(job, "waiting for ssh".into()));553+ cx.send(Event::Line(job, vm_status()));
553 thread::sleep(Duration::from_secs(5));554 thread::sleep(Duration::from_secs(5));
554 }555 }
555 Ok(())556 Ok(())
556 }557 }
557 558
559+fn vm_status() -> String {
560+ let Ok(out) = podman().args(["logs", "--tail", "5", VM]).output() else {
561+ return "waiting for ssh".into();
562+ };
563+ let text = String::from_utf8_lossy(&out.stdout) + String::from_utf8_lossy(&out.stderr);
564+ text.lines()
565+ .map(plain)
566+ .rfind(|line| !line.is_empty())
567+ .unwrap_or_else(|| "waiting for ssh".into())
568+}
569+
570+fn plain(line: &str) -> String {
571+ let mut out = String::new();
572+ let mut chars = line.chars();
573+ while let Some(c) = chars.next() {
574+ if c == '\u{1b}' {
575+ chars.by_ref().find(|c| c.is_ascii_alphabetic());
576+ } else if c != '❯' {
577+ out.push(c);
578+ }
579+ }
580+ out.trim().trim_end_matches("...").to_string()
581+}
582+
558 fn opts(key: &Path, port_flag: &str) -> Vec<String> {583 fn opts(key: &Path, port_flag: &str) -> Vec<String> {
559 let mut args = vec!["-i".to_string(), key.display().to_string()];584 let mut args = vec!["-i".to_string(), key.display().to_string()];
560 for option in [585 for option in [