diff --git a/controller/jobs.mjs b/controller/jobs.mjs index 884ad33..c5c7efa 100644 --- a/controller/jobs.mjs +++ b/controller/jobs.mjs @@ -7,7 +7,7 @@ import path from "node:path"; import { fileURLToPath } from "node:url"; import { JOBS_NODE, VALID_JOB } from "../core/boxery-core.mjs"; import { closeMaster } from "../core/profile.mjs"; -import { CliError, die, duration, needVm, note, num, quit, say, usage, vmSsh, vmSshCapture, WAIT_LOST, WAIT_TIMEOUT, warn } from "./lib.mjs"; +import { BOXERY, CliError, USAGE, die, duration, needVm, note, num, quit, say, usage, vmSsh, vmSshCapture, WAIT_LOST, WAIT_TIMEOUT, warn } from "./lib.mjs"; /** @import { Selected } from "./lib.mjs" */ @@ -34,7 +34,7 @@ const jobsVmCapture = (s, name, args, o) => vmSshCapture(s, helper(name, args), const exit = (rc) => { if (rc) throw new CliError("", rc); }; /** @param {string | undefined} id */ -const needJob = (id) => (VALID_JOB.test(id ?? "") ? /** @type {string} */ (id) : die(`invalid job id: ${id ?? ""} (see: boxery jobs NAME)`)); +const needJob = (id) => (VALID_JOB.test(id ?? "") ? /** @type {string} */ (id) : id ? die(`invalid job id: ${id} (see: ${BOXERY} jobs NAME)`) : die(`missing job id (see: ${BOXERY} jobs NAME)`, USAGE)); /** run --bg: start ARGV (each word's bytes) in the VM as a job, in CWD (bytes, or null: ~/project); its id. * @param {Selected} s @param {string} name @param {Buffer[]} argv @param {Buffer | null} cwd */ @@ -108,7 +108,7 @@ export async function waitJob(s, [vm, job, ...rest]) { // waiting doesn't affect the job (tmux in the VM): reconnect and keep waiting, within --timeout. if (!reached) die(`cannot reach ${name}`); if (deadline != null && Date.now() / 1000 >= deadline) { warn(`cannot reach ${name}; --timeout passed (the job may still be running)`); quit(WAIT_TIMEOUT); } - if (++drops > 60) die(`cannot reach ${name}; giving up (the job may still be running: boxery jobs ${name})`); + if (++drops > 60) die(`cannot reach ${name}; giving up (the job may still be running: ${BOXERY} jobs ${name})`); warn(`lost the connection to ${name}; reconnecting (the job keeps running)`); await closeMaster(name); await new Promise((res) => setTimeout(res, 5000)); diff --git a/core/boxery-core.mjs b/core/boxery-core.mjs index ceb2b85..c8cf30f 100644 --- a/core/boxery-core.mjs +++ b/core/boxery-core.mjs @@ -417,8 +417,19 @@ export async function sshOk(vm, script, opts = {}) { // ---------------------------------------------------------------- why a VM can't be reached +/** A boxery command for a hint about the current host's VMs: `boxery --host NAME COMMAND` when the person named a + * host (BOXERY_CLI: controller/lib.mjs invokedAs) or this isn't the default host (another host's VM in cp, an + * agent's host session), else `boxery COMMAND`, as host/util.mjs hint does for the host's own messages. + * @param {string} command e.g. "ls" */ +export function cliHint(command) { + let name = null, def = null; + try { name = currentHost().name; } catch { /* no host selected (formatting alone): plain boxery */ } + try { def = defaultHost(); } catch { /* a malformed default-host file must not replace the message */ } + return `boxery${name && (/^boxery --host /.test(process.env.BOXERY_CLI ?? "") || name !== def) ? ` --host ${name}` : ""} ${command}`; +} + /** What the host says of a VM it doesn't have, and where to look. @param {string} vm */ -export const noSuchVm = (vm) => `no such vm: ${vm} on host ${currentHost().name} (boxery ls lists them)`; +export const noSuchVm = (vm) => `no such vm: ${vm} on host ${currentHost().name} (${cliHint("ls")} lists them)`; /** A VM's problem, for a person or an agent. known: the host's records explain it (no such VM, not running, a * pool VM without a lease); otherwise message is what ssh said. missing: the host has no such VM, so whatever @@ -457,11 +468,11 @@ export async function vmProblem(vm, { env, signal } = {}) { const v = vms.find((r) => r.name === vm); if (!v) return { message: noSuchVm(vm), known: true, missing: true }; if (v.state && !["running", "idle"].includes(v.state)) - return { message: /ing$/.test(v.state) ? `VM ${vm} is ${v.state}; try again when it's running (boxery ls shows its state)` : `VM ${vm} is ${v.state}; start it: boxery start ${vm}`, known: true }; + return { message: /ing$/.test(v.state) ? `VM ${vm} is ${v.state}; try again when it's running (${cliHint("ls")} shows its state)` : `VM ${vm} is ${v.state}; start it: ${cliHint(`start ${vm}`)}`, known: true }; if (v.lease) { const mine = findLease(vm); - if (!mine) return { message: `VM ${vm} is in the host's shared pool: only the holder of a lease on it can reach it, and this machine holds none (boxery acquire leases a pool VM; boxery leases lists yours)`, known: true }; - if (mine.expires * 1000 < Date.now()) return { message: `your lease on VM ${vm} has expired, so it no longer lets you in (boxery leases lists yours; boxery acquire leases a pool VM again)`, known: true }; + if (!mine) return { message: `VM ${vm} is in the host's shared pool: only the holder of a lease on it can reach it, and this machine holds none (${cliHint("acquire")} leases a pool VM; ${cliHint("leases")} lists yours)`, known: true }; + if (mine.expires * 1000 < Date.now()) return { message: `your lease on VM ${vm} has expired, so it no longer lets you in (${cliHint("leases")} lists yours; ${cliHint("acquire")} leases a pool VM again)`, known: true }; } return { message: `VM "${vm}" unreachable over ssh: ${said || (probe.code == null ? "timed out" : "connection failed")}`, known: false }; } @@ -1181,7 +1192,7 @@ export function formatVms(vms) { const outdated = vms.filter((v) => v.guest?.status === "outdated"); if (!outdated.length) return table; // Patching restarts VMs and is the user's call: agents only point it out. - return `${table}\noutdated guest software: ${outdated.map((v) => `${v.name} (${(v.guest?.reasons ?? []).join(", ")})`).join("; ")}. Tell the user; they can update it with: boxery patch NAME`; + return `${table}\noutdated guest software: ${outdated.map((v) => `${v.name} (${(v.guest?.reasons ?? []).join(", ")})`).join("; ")}. Tell the user; they can update it with: ${cliHint("patch NAME")}`; } /** VM's grants (listGrants: this machine's records). With none recorded, the host is asked whether VM exists, so diff --git a/core/desktop.mjs b/core/desktop.mjs index 0136d6e..370caef 100644 --- a/core/desktop.mjs +++ b/core/desktop.mjs @@ -6,7 +6,7 @@ // previous session's for new logins; connections already open stay. import { spawn } from "node:child_process"; import net from "node:net"; -import { assertName, currentHost, sshRun } from "./boxery-core.mjs"; +import { assertName, cliHint, currentHost, sshRun } from "./boxery-core.mjs"; import { profileConfig } from "./profile.mjs"; const SETUP = 'if test -e /etc/boxery/headless; then echo headless\nelif command -v boxery-vnc-password >/dev/null; then p=$(boxery-vnc-password --new) && echo "password $p"\nelse echo nopassword; fi'; @@ -32,8 +32,8 @@ export async function prepareDesktop(name, { terminal = false } = {}) { let pw = "", warning = null; if (out === "headless") throw new Error(`${name} is headless (boxery new --headless): it has no desktop`); else if (out.startsWith("password ")) { pw = out.slice(9); if (!/^[A-Za-z0-9]+$/.test(pw)) throw new Error(`unexpected VNC password from ${name}`); } - else if (out === "nopassword") warning = `${name}'s desktop has no VNC password: its image predates it, so while this tunnel is open any process on this machine (or a web page) can use it. Rebuild the desktop base (boxery build-base) and create the VM again.`; - else throw new Error(`couldn't set up the desktop of ${name} (is it running? boxery ls)${why ? `: ${why}` : ""}`); + else if (out === "nopassword") warning = `${name}'s desktop has no VNC password: its image predates it, so while this tunnel is open any process on this machine (or a web page) can use it. Rebuild the desktop base (${cliHint("build-base")}) and create the VM again.`; + else throw new Error(`couldn't set up the desktop of ${name} (is it running? ${cliHint("ls")})${why ? `: ${why}` : ""}`); const port = await freePort(16080); return { url: `http://127.0.0.1:${port}/vnc.html?autoconnect=1&resize=remote&reconnect=1${pw ? `#password=${pw}` : ""}`, port, warning }; } @@ -72,7 +72,7 @@ export async function openDesktop(name, { open = true } = {}) { if (!(await freePortAt(port))) { await new Promise((r) => setTimeout(r, 200)); up = alive(); } else await new Promise((r) => setTimeout(r, 100)); } - if (!up) { child.kill(); throw new Error(`the tunnel to ${name}'s desktop didn't come up (is it running? boxery ls)`); } + if (!up) { child.kill(); throw new Error(`the tunnel to ${name}'s desktop didn't come up (is it running? ${cliHint("ls")})`); } const opened = open ? await openUrl(url) : false; return { url, warning, opened, close: () => { child.kill(); }, ended }; } diff --git a/core/leases.mjs b/core/leases.mjs index 82a3fff..efe636c 100644 --- a/core/leases.mjs +++ b/core/leases.mjs @@ -8,7 +8,7 @@ import { spawn } from "node:child_process"; import { chmodSync, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync } from "node:fs"; import { hostname } from "node:os"; import path from "node:path"; -import { currentHost, VALID_NAME } from "./boxery-core.mjs"; +import { cliHint, currentHost, VALID_NAME } from "./boxery-core.mjs"; import { reapplyPushed } from "./grant-operations.mjs"; import { writeAtomic } from "./fsutil.mjs"; import { closeMaster, hostLeaseJson, hostRun, writeSshConfig } from "./profile.mjs"; @@ -66,7 +66,7 @@ export function findLease(ref) { /** @param {string} ref */ function needLease(ref) { const r = typeof ref === "string" && ref ? findLease(ref) : null; - if (!r) throw new Error(`no local lease for '${ref ?? ""}' (boxery leases)`); + if (!r) throw new Error(`no local lease for '${ref ?? ""}' (${cliHint("leases")})`); return r; } diff --git a/docs/cli.md b/docs/cli.md index b8dc974..f495efc 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -430,7 +430,7 @@ Generated from the help `boxery help --all` shows (`controller/cli.mjs`); edit i `boxery-host help` lists every command; `boxery-host COMMAND --help` shows one. Generated from the same help (`host/help.mjs`); edit it there, then `npm run docs:cli`. `--profile NAME` before any command runs it in a second profile on this host (`~/.config/boxery-NAME`: its own backend, state, proxy port and services); `--profile NAME init --backend B` creates it with a free proxy port. `upgrade` keeps the code and each profile's state from before in `$BOXERY_CONF/pre-upgrade/` after a success too. -Commands in messages name what you typed. The follow-up commands `boxery` prints (`run --bg`'s logs and wait, `prompt`, `acquire`, `ls`) keep your `--host NAME`; and when `boxery` runs a host command for you, it passes `BOXERY_CLI` (`boxery`, or `boxery --host NAME` if you gave one), so a host error suggests `boxery --host lab snap-rm demo s1` rather than `boxery-host snap-rm demo s1`. Commands only boxery-host has (`init`, …) keep its name. Called directly, boxery-host names itself. +Commands in messages name what you typed. The follow-up commands `boxery` prints (`run --bg`'s logs and wait, `prompt`, `acquire`, `ls`) keep your `--host NAME`; and when `boxery` runs a host command for you, it passes `BOXERY_CLI` (`boxery`, or `boxery --host NAME` if you gave one), so a host error suggests `boxery --host lab snap-rm demo s1` rather than `boxery-host snap-rm demo s1`. Commands only boxery-host has (`init`, …) keep its name. Called directly, boxery-host names itself. Messages about a VM that can't be reached (`no such vm`, not running, a pool VM without a lease) name `--host NAME` when you gave one or when the VM's host isn't the default (another host's VM in `cp`, an agent's host session), since a bare `boxery start NAME` would go to the default host. diff --git a/host/capabilities.mjs b/host/capabilities.mjs index 1aaf9b0..90683fb 100644 --- a/host/capabilities.mjs +++ b/host/capabilities.mjs @@ -3,7 +3,7 @@ import { accessSync, constants } from "node:fs"; import path from "node:path"; import { BACKENDS, backendMetadata, capabilityStatus, declared, matchesPlatform, platformStatus } from "../backends/index.mjs"; -import { fail, log, print } from "./util.mjs"; +import { fail, hint, log, print } from "./util.mjs"; import { hostUsage } from "./help.mjs"; /** @import { Configuration, Requirement } from "../backends/index.mjs" */ /** @import { Runtime } from "./runtime.mjs" */ @@ -88,5 +88,5 @@ export function checkOperation(backend, command, args) { ?? (command === "pool" && args[0] === "add" ? "pools" : null); if (!feature) return; const c = metadata.capabilities[feature]; - if (c.status === "unsupported") fail(`${backend}: ${feature} is unavailable. ${c.note}. Discover alternatives with boxery backends --json.`); + if (c.status === "unsupported") fail(`${backend}: ${feature} is unavailable. ${c.note}. Discover alternatives with ${hint("backends --json")}.`); } diff --git a/host/patch.mjs b/host/patch.mjs index 19e4fac..ec065b4 100644 --- a/host/patch.mjs +++ b/host/patch.mjs @@ -69,7 +69,7 @@ export async function patchVm(rt, args) { /** @type {GuestEndpoint} */ let ep; try { ep = await rt.vms.sshEndpoint(name, { quiet: true }); } catch { return fail(`${name} is not running (start it first)`); } - const t0 = Date.now(), secs = () => Math.floor((Date.now() - t0) / 1000); + const t0 = performance.now(), secs = () => Math.floor((performance.now() - t0) / 1000); // monotonic: a wall clock can step back // A crash from here on leaves a pool VM between clean images: recovery puts it back to one (recovery.mjs). const action = row ? rt.intent("pool-patch", name) : ""; if (await rt.guest.run(ep, "sudo bash -s", { input: await pushScript(rt) }) !== 0) fail(`could not install this host's image layers in ${name}`); diff --git a/host/setup.mjs b/host/setup.mjs index 6081d08..329e610 100644 --- a/host/setup.mjs +++ b/host/setup.mjs @@ -10,7 +10,7 @@ import { checkBackend } from "./capabilities.mjs"; import { defaultConf, HOST_ENV } from "./config.mjs"; import { ensureHostKey, hasHostKey } from "./hostkeys.mjs"; import { baseUserdata } from "./seed.mjs"; -import { fail, jsonArray, log, print, readFd, sleep, table } from "./util.mjs"; +import { fail, hint, jsonArray, log, print, readFd, sleep, table } from "./util.mjs"; import { hostUsage } from "./help.mjs"; /** @import { Config } from "./config.mjs" */ /** @import { Runtime } from "./runtime.mjs" */ @@ -324,7 +324,7 @@ async function pinExisting(rt) { if (await ensureHostKey(rt, vm.name, await rt.vms.sshEndpoint(vm.name, { quiet: true }))) left.push(vm.name); } catch { left.push(vm.name); } } - if (left.length) log(`${left.length} VM(s) have no pinned ssh host key yet (${left.join(", ")}): boxery start pins a stopped one; for a running one run boxery pin NAME`); + if (left.length) log(`${left.length} VM(s) have no pinned ssh host key yet (${left.join(", ")}): ${hint("start NAME")} pins a stopped one; for a running one run ${hint("pin NAME")}`); } // ---------------------------------------------------------------- commands diff --git a/host/vms.mjs b/host/vms.mjs index ac8dd53..919600b 100644 --- a/host/vms.mjs +++ b/host/vms.mjs @@ -136,7 +136,7 @@ export async function createVm(rt, { name, shape, cpus, mem, disk, from, headles } else if (!await rt.vms.hasBase()) { fail(`no base image; run: ${hint("build-base")} (or: new ${name} --headless, which needs none)`); } - const t0 = Date.now(), secs = () => Math.floor((Date.now() - t0) / 1000); + const t0 = performance.now(), secs = () => Math.floor((performance.now() - t0) / 1000); // monotonic: a wall clock can step back // Opt-in diagnostics stay on stderr and never include seed contents, tokens or SSH commands. /** @template T @param {string} stage @param {() => Promise} fn @returns {Promise} */ const step = async (stage, fn) => { @@ -195,8 +195,8 @@ export async function createVm(rt, { name, shape, cpus, mem, disk, from, headles function warnOutdated(rt, name, rec, source) { const { status, reasons } = guestChecker(rt)(rec, { image: true }); // what it was built with; a reboot is the guest's own if (status !== "outdated" || !source) return; - const fix = source === "the desktop base" ? "; to make new desktop VMs current, rebuild the base (boxery build-base) once no VM depends on it" : ""; - log(`warning: ${name} is an outdated guest (${reasons.join(", ")}), as ${source} is; update it with: boxery patch ${name}${fix}`); + const fix = source === "the desktop base" ? `; to make new desktop VMs current, rebuild the base (${hint("build-base")}) once no VM depends on it` : ""; + log(`warning: ${name} is an outdated guest (${reasons.join(", ")}), as ${source} is; update it with: ${hint(`patch ${name}`)}${fix}`); } /** @param {Runtime} rt @param {string[]} args */ @@ -247,7 +247,7 @@ export async function fork(rt, args) { } const image = `${src}@fork-${stamp()}-${randomBytes(3).toString("hex")}`; const cleanup = rt.intent("fork-image", image); - const t0 = Date.now(), secs = () => Math.floor((Date.now() - t0) / 1000); + const t0 = performance.now(), secs = () => Math.floor((performance.now() - t0) / 1000); await captureVm(rt, src, image); log(`captured ${src} in ${secs()}s; booting ${dsts.length} fork(s)`); // Boot the forks in parallel under this operation's locks; print results in argument order. A failed @@ -266,7 +266,7 @@ export async function fork(rt, args) { await rt.vms.call("backend_image_rm", [image]); // Once for all the forks, naming SRC: patching it first gives current forks (#215). const { status, reasons } = guestChecker(rt)(buildRecord(rt.conf, image), { image: true }); - if (status === "outdated" && results.some((r) => r.status === "fulfilled")) log(`warning: ${src} is an outdated guest (${reasons.join(", ")}), and so are its forks; update them with: boxery patch NAME (patch ${src} first to fork current copies)`); + if (status === "outdated" && results.some((r) => r.status === "fulfilled")) log(`warning: ${src} is an outdated guest (${reasons.join(", ")}), and so are its forks; update them with: ${hint("patch NAME")} (patch ${src} first to fork current copies)`); deleteBuildRecord(rt.conf, image); rt.done(cleanup); log(`forked ${src} → ${dsts.join(" ")} in ${secs()}s`); @@ -335,13 +335,13 @@ export async function stop(rt, [name]) { const was = stoppedAs(rt, vm?.state ?? ""); if (was && (!vm?.tunnel || vm.tunnel === "down")) { log(`${name} is already ${was}`); return; } await rt.vms.call("backend_stop", [name]); - const wait = Number(rt.env?.BOXERY_STOP_WAIT) > 0 ? Number(rt.env?.BOXERY_STOP_WAIT) : 120, t0 = Date.now(); + const wait = Number(rt.env?.BOXERY_STOP_WAIT) > 0 ? Number(rt.env?.BOXERY_STOP_WAIT) : 120, t0 = performance.now(); for (let announced = false; ;) { const now = await inventoryEntry(rt, name); if (!now) { log(`${name} shutting down`); return; } // can't tell: as before const as = stoppedAs(rt, now.state); if (as) { log(`${name} ${as}`); return; } - if (Date.now() - t0 >= wait * 1000) fail(`${name} is still ${now.state || "running"} ${wait}s after it was asked to shut down; run stop again, or look at the guest's console`); + if (performance.now() - t0 >= wait * 1000) fail(`${name} is still ${now.state || "running"} ${wait}s after it was asked to shut down; run stop again, or look at the guest's console`); if (!announced) { log(`${name} shutting down`); announced = true; } await sleep(1000); } diff --git a/test/cli-families.test.mjs b/test/cli-families.test.mjs index 65591d1..539e081 100644 --- a/test/cli-families.test.mjs +++ b/test/cli-families.test.mjs @@ -194,7 +194,8 @@ test("malformed actions say what the family has, before any host, ssh or saved s [["access", "apply", "demo", "--json"], 2, /usage: boxery access apply NAME/], [["access", "apply", "demo", "--quiet", "x"], 2, /usage: boxery access apply NAME/], [["access", "ls", "Demo"], 1, /invalid VM name: Demo/], - [["job", "kill", "demo"], 1, /invalid job id/], + [["job", "kill", "demo"], 2, /^boxery: missing job id \(see: boxery jobs NAME\)\n$/], + [["job", "kill", "demo", "nope"], 1, /^boxery: invalid job id: nope \(see: boxery jobs NAME\)\n$/], [["job", "ls", "demo", "--frob"], 2, /^boxery: usage: boxery job ls NAME \[--json\]\n {7}boxery job ls NAME --prune/], [["lease", "ls", "--frob"], 2, /^boxery: usage: boxery lease ls \[--json\]\n$/], [["snapshot", "rm", "demo"], 2, /^boxery: usage: boxery snapshot rm NAME SNAP\n$/], diff --git a/test/hosts.test.mjs b/test/hosts.test.mjs index 8829047..bf9ea8a 100644 --- a/test/hosts.test.mjs +++ b/test/hosts.test.mjs @@ -323,6 +323,13 @@ test("an unreachable VM says why (#210): no such VM, stopped, a pool VM this mac assert.match(text(r), none); } assert.equal(existsSync(path.join(dir, "ghost-copy")), false); + // On a host that isn't the default, hints name it: a bare `boxery ls` would ask the default host. + const other = client(["--host", "beta"]); + assert.match(text(await other.tool("vm_bash", { vm: "ghost", command: "true" })), /^no such vm: ghost on host beta \(boxery --host beta ls lists them\)$/); + // A malformed default-host file doesn't replace the message. + writeFileSync(path.join(dir, "home", "default-host"), "not a host\n\n"); + try { assert.match(text(await other.tool("vm_bash", { vm: "ghost", command: "true" })), /^no such vm: ghost on host beta \(boxery --host beta ls lists them\)$/); } + finally { writeFileSync(path.join(dir, "home", "default-host"), "alpha\n"); } // A command's own 255 is its exit code: a fresh connection works, so the VM isn't unreachable. assert.match(text(await c.tool("vm_bash", { vm: "fakevm", command: "exit 255" })), /\[exit 255\]$/); }); diff --git a/test/shell/common/controller-local.sh b/test/shell/common/controller-local.sh index 64516c2..88bd31a 100755 --- a/test/shell/common/controller-local.sh +++ b/test/shell/common/controller-local.sh @@ -161,6 +161,9 @@ for c in "run nosuch true" "ssh nosuch true" "jobs nosuch" "sessions nosuch" "lo rc=0; out=$(eval "\"\$A\" $c" 2>&1 &1 &1) || rc=$? [[ $rc == 255 && $out != *boxery:* ]] && ok "run: the command's own exit 255 says nothing more" || bad "run exit 255: rc=$rc $out" # desktop, cp and grants say so too (#216); cp leaves nothing to clean up, since nothing could be staged. diff --git a/test/shell/logic/host-patch.sh b/test/shell/logic/host-patch.sh index efbcadd..d57e150 100644 --- a/test/shell/logic/host-patch.sh +++ b/test/shell/logic/host-patch.sh @@ -134,17 +134,17 @@ echo "== snapshots and images" grep -q "d1's snapshots were not patched (old): a VM made or reverted from one has its old software until you patch it" "$tmp/err" && ok "patch says the snapshots weren't patched" || bad "no snapshot note: $(cat "$tmp/err")" "$H" snaps d1 | grep -q $'^old\t.*outdated$' && ok "...and they stay outdated" || bad "snaps: $("$H" snaps d1)" "$H" new d2 --from d1@old >/dev/null 2>"$tmp/err"; [[ $(status d2) == "outdated layers changed" ]] && ok "a VM from an outdated image is outdated" || bad "d2: $(status d2)" -grep -qx "==> warning: d2 is an outdated guest (layers changed), as d1@old is; update it with: boxery patch d2" "$tmp/err" && ok "...and new says so (#215)" || bad "new warning: $(cat "$tmp/err")" +grep -qx "==> warning: d2 is an outdated guest (layers changed), as d1@old is; update it with: boxery-host patch d2" "$tmp/err" && ok "...and new says so (#215)" || bad "new warning: $(cat "$tmp/err")" "$H" revert d1 old >/dev/null 2>&1; [[ $(status d1) == "outdated layers changed" ]] && ok "so is a VM reverted to one" || bad "reverted d1: $(status d1)" "$H" fork d1 f1 f2 >/dev/null 2>"$tmp/err" -[[ $(grep -c 'outdated guest' "$tmp/err") == 1 ]] && grep -qx "==> warning: d1 is an outdated guest (layers changed), and so are its forks; update them with: boxery patch NAME (patch d1 first to fork current copies)" "$tmp/err" && +[[ $(grep -c 'outdated guest' "$tmp/err") == 1 ]] && grep -qx "==> warning: d1 is an outdated guest (layers changed), and so are its forks; update them with: boxery-host patch NAME (patch d1 first to fork current copies)" "$tmp/err" && ok "fork of an outdated VM: one warning, naming the source" || bad "fork warning: $(cat "$tmp/err")" "$H" rm f1 >/dev/null 2>&1; "$H" rm f2 >/dev/null 2>&1 # A desktop base built with other layers than the host's: every new desktop VM has its build-info. sed 's/^layers_hash=.*/layers_hash=0000/' "$(r h1)/etc/boxery/build-info" >"$tmp/first-boot-build-info" -"$H" new d3 >/dev/null 2>"$tmp/err" -grep -qx "==> warning: d3 is an outdated guest (layers changed), as the desktop base is; update it with: boxery patch d3; to make new desktop VMs current, rebuild the base (boxery build-base) once no VM depends on it" "$tmp/err" && - ok "new from an outdated desktop base: says so, with a fix that works now (#215)" || bad "base warning: $(cat "$tmp/err")" +BOXERY_CLI="boxery --host lab" "$H" new d3 >/dev/null 2>"$tmp/err" +grep -qx "==> warning: d3 is an outdated guest (layers changed), as the desktop base is; update it with: boxery --host lab patch d3; to make new desktop VMs current, rebuild the base (boxery --host lab build-base) once no VM depends on it" "$tmp/err" && + ok "new from an outdated desktop base: says so, with a fix that works now (#215), as the person typed it" || bad "base warning: $(cat "$tmp/err")" cp "$(r h1)/etc/boxery/build-info" "$tmp/first-boot-build-info" "$H" new d4 >/dev/null 2>"$tmp/err"; rm "$tmp/first-boot-build-info" ! grep -q warning "$tmp/err" && [[ $(status d4) == "current " ]] && ok "...a current one: no warning" || bad "d4: $(status d4) $(cat "$tmp/err")"