From ead105d5bf8cde21bc4a7905b8e664a296f99aca Mon Sep 17 00:00:00 2001 From: wtclaude Date: Mon, 14 Sep 2026 13:07:23 -0500 Subject: [PATCH] feat(doctor): the one host prerequisite the Asset Bridge added (Phase 9a) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `libgdiplus`, on Linux hosts only. ServUO targets net48, so on Linux it runs under Mono, and Mono's `System.Drawing` is a thin layer over that library -- which sits in the DECODE path, not merely the encode: `Ultima.Frame` writes ARGB1555 through a LockBits pointer, so without it the shard cannot read one sprite out of the operator's UO client. docs/link/v8.md §17.2 took all three answers to this rather than one -- the prerequisite in SHARD_PREREQS.md, a named NO_IMAGING status instead of an error, and a `doctor` check. The first two shipped in phase 1. This is the third, and SHARD_PREREQS.md has been claiming it existed since then. Three things about the row are deliberate: - **Linux only, and absent elsewhere.** A Windows host ships System.Drawing with .NET Framework and has nothing to check, so there is no row rather than a row saying "not applicable" on three quarters of the hosts that run this. - **A warning, never a failure.** Names and the shard's own spawn files have no pixels in them, so a host without this library still runs a useful bridge, and `doctor`'s exit code -- which monitoring reads -- must not go red over one absent feature. - **`ldconfig -p` first, paths second.** The loader's own cache is the same question Mono asks at runtime, so a distro that puts the file somewhere unusual answers correctly; the path probe is the fallback for a slim container with no ldconfig, and a missing ldconfig degrades to it rather than taking doctor down. The verdict is split from the detection so the mark and the wording are testable on a host that has the library and one that does not; all three tests are Linux-gated, which is where CI runs. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_016wDDVXWMDz82WqE1i969r4 --- src/doctor.rs | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) diff --git a/src/doctor.rs b/src/doctor.rs index fc7861a..c309197 100644 --- a/src/doctor.rs +++ b/src/doctor.rs @@ -158,6 +158,10 @@ pub fn run(cli: &Cli) -> Result { // ── The bundle ─────────────────────────────────────────────────────────── rows.push(bundle_row(&record)); + // ── The host ───────────────────────────────────────────────────────────── + // Linux only, and absent entirely elsewhere (see `imaging_row`). + rows.extend(imaging_row()); + // ── Backups ────────────────────────────────────────────────────────────── rows.push(backup_row(&layout)); @@ -755,6 +759,71 @@ fn bundle_row(record: &InstallRecord) -> Row { Row::warn("Bundle", detail).note("run `update` to move both halves to one checked combination") } +/// `libgdiplus` on a Linux shard host — the one host prerequisite the Asset Bridge added +/// (docs/link/v8.md §4.4, docs/link/SHARD_PREREQS.md). +/// +/// ServUO targets `net48`, so on Linux it runs under Mono, and Mono's `System.Drawing` is a thin +/// layer over this library — which sits in the **decode** path, not merely the encode: without it +/// the shard cannot read a single sprite out of the operator's UO client. Windows hosts ship +/// `System.Drawing` with .NET Framework and need nothing, which is why this row exists only on +/// Linux rather than reporting "not applicable" on three quarters of the hosts that run it. +/// +/// **A `⚠`, never a `✗`.** Everything else on this plane works without it: the cliloc table and +/// the shard's own spawn files have no pixels in them, and a bridge that serves names and an atlas +/// but no artwork is a working bridge with one feature missing. It is also not the last word — the +/// shard reports `NO_IMAGING` on the asset plane itself, from inside the process that would do the +/// decoding. This row exists to move that discovery from "the bestiary is empty, weeks later" to +/// "the host is missing a package, now". +#[cfg(target_os = "linux")] +fn imaging_row() -> Option { + Some(imaging_verdict(imaging_present())) +} + +/// Is the library on this host? Two answers, in the order that is most likely to be right. +#[cfg(target_os = "linux")] +fn imaging_present() -> bool { + // `ldconfig -p` is the loader's own cache, which is the same question Mono asks at runtime — + // strictly better than probing paths, because a distro that puts the file somewhere unusual has + // told the loader about it and would otherwise read here as missing. + let cached = crate::util::run("ldconfig", &["-p"]) + .ok() + .map(|o| String::from_utf8_lossy(&o.stdout).contains("libgdiplus.so")) + .unwrap_or(false); + + // The fallback is for a host with no `ldconfig` on PATH (a slim container, mostly), where a + // present library would otherwise be reported absent. + cached + || [ + "/usr/lib/libgdiplus.so", + "/usr/lib64/libgdiplus.so", + "/usr/lib/x86_64-linux-gnu/libgdiplus.so", + "/usr/lib/aarch64-linux-gnu/libgdiplus.so", + "/usr/local/lib/libgdiplus.so", + ] + .iter() + .any(|p| Path::new(p).exists()) +} + +/// The operator-visible half, split out so the wording and the mark are testable on a host that +/// has the library and on one that does not — which the detection itself is not. +#[cfg(target_os = "linux")] +fn imaging_verdict(found: bool) -> Row { + if found { + return Row::ok("Imaging (libgdiplus)", "present"); + } + Row::warn("Imaging (libgdiplus)", "not found on this host") + .note("this shard cannot decode artwork out of its UO client — creature portraits and") + .note("item pictures will be absent; names and the spawn atlas are unaffected") + .note("install it: apt-get install libgdiplus / dnf install libgdiplus") + .note("see docs/link/SHARD_PREREQS.md — Windows hosts need nothing") +} + +/// Windows and macOS hosts do not need it, so there is no row to print. +#[cfg(not(target_os = "linux"))] +fn imaging_row() -> Option { + None +} + #[cfg(test)] mod tests { use super::*; @@ -913,4 +982,39 @@ mod tests { assert_eq!(row.mark, Mark::Ok); assert!(row.detail.contains("operator-owned"), "{}", row.detail); } + + // ── The host row (Linux only; see `imaging_row`) ───────────────────────── + + #[cfg(target_os = "linux")] + #[test] + fn a_missing_libgdiplus_warns_and_names_the_package() { + let row = imaging_verdict(false); + // A ⚠, never a ✗: the cliloc table and the spawn atlas have no pixels in them, so a host + // without this library still runs a useful bridge. `doctor`'s exit code must not turn red + // over one absent feature. + assert_eq!(row.mark, Mark::Warn); + let notes = row.notes.join(" "); + assert!(notes.contains("apt-get install libgdiplus"), "{notes}"); + assert!(notes.contains("SHARD_PREREQS.md"), "{notes}"); + } + + #[cfg(target_os = "linux")] + #[test] + fn a_present_libgdiplus_is_one_quiet_ok_line() { + let row = imaging_verdict(true); + assert_eq!(row.mark, Mark::Ok); + assert!( + row.notes.is_empty(), + "a satisfied prerequisite needs no advice" + ); + } + + #[cfg(target_os = "linux")] + #[test] + fn detection_answers_rather_than_panicking_on_a_host_with_no_ldconfig() { + // The value depends on the host and is not asserted — what is asserted is that a missing + // `ldconfig` degrades to the path probe instead of taking `doctor` down, which is the rule + // every row in this module follows. + let _ = imaging_present(); + } }