From 3e1fc3e60e577037b4d909ae0040a880c0a0e4e9 Mon Sep 17 00:00:00 2001 From: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com> Date: Tue, 24 Nov 2026 18:32:38 -0500 Subject: [PATCH] fix(xbox): a bundle with resource packages installs from its application package (#3172) * fix(xbox): a bundle with resource packages installs from its application package * fix(xbox): repair the patch hunk for the hoist tests --- tools/xbox/droiddeck-legacy-install.patch | 96 ++++++++++++++++++++++- 1 file changed, 93 insertions(+), 3 deletions(-) diff --git a/tools/xbox/droiddeck-legacy-install.patch b/tools/xbox/droiddeck-legacy-install.patch index 8de0ebded6..7058294b13 100644 --- a/tools/xbox/droiddeck-legacy-install.patch +++ b/tools/xbox/droiddeck-legacy-install.patch @@ -154,7 +154,7 @@ new file mode 100755 index 0000000..d43c5fc --- /dev/null +++ b/crates/xodus-cli/src/commands/legacy_install.rs -@@ -0,0 +1,1285 @@ +@@ -0,0 +1,1375 @@ +//! Installs a legacy Store title: resolve, license, download, extract. +//! +//! `streaming` only understands MSIXVC, where the container *is* the game and @@ -1108,10 +1108,14 @@ index 0000000..d43c5fc + if candidates.is_empty() { + return Ok(()); + } ++ let found = candidates.len(); ++ let applications = application_packages(candidates.clone()); ++ if !applications.is_empty() || found != 1 { ++ candidates = applications; ++ } + if candidates.len() != 1 { + return Err(format!( -+ "Extraction left {} package folders; expected exactly one", -+ candidates.len() ++ "Extraction left {found} package folders; expected exactly one application package" + )); + } + let inner = candidates.remove(0); @@ -1153,6 +1157,39 @@ index 0000000..d43c5fc + Ok(()) +} + ++/// A bundle can extract its application package beside resource packages (languages, ++/// scales) that declare no application; only the application package holds the game. ++/// When several declare one, the x64 package wins if it is the only x64 one. ++fn application_packages(candidates: Vec) -> Vec { ++ let applications: Vec = candidates.into_iter().filter(|folder| declares_application(folder)).collect(); ++ if applications.len() > 1 { ++ let x64: Vec = applications ++ .iter() ++ .filter(|folder| manifest_text(folder).contains("processorarchitecture=\"x64\"")) ++ .cloned() ++ .collect(); ++ if x64.len() == 1 { ++ return x64; ++ } ++ } ++ applications ++} ++ ++fn manifest_text(folder: &Path) -> String { ++ [LEGACY_MANIFEST, MANIFEST] ++ .iter() ++ .filter_map(|name| std::fs::read_to_string(folder.join(name)).ok()) ++ .collect::>() ++ .join(" ++") ++ .to_ascii_lowercase() ++} ++ ++fn declares_application(folder: &Path) -> bool { ++ let text = manifest_text(folder); ++ text.contains(" bool { @@ -1334,6 +1371,59 @@ index 0000000..d43c5fc + } + + #[test] ++ fn hoist_lifts_the_application_package_and_leaves_resource_packages() { ++ let root = scratch("resource-packages"); ++ let app = root.join("Game.x64"); ++ std::fs::create_dir_all(&app).unwrap(); ++ std::fs::write(app.join(LEGACY_MANIFEST), "").unwrap(); ++ std::fs::write(app.join("Game.exe"), b"MZ").unwrap(); ++ for language in ["Game.language-de", "Game.language-fr", "Game.scale-200"] { ++ let resource = root.join(language); ++ std::fs::create_dir_all(&resource).unwrap(); ++ std::fs::write(resource.join(LEGACY_MANIFEST), "").unwrap(); ++ } ++ ++ hoist(&root).unwrap(); ++ ++ assert!(root.join("Game.exe").is_file()); ++ assert!(root.join(LEGACY_MANIFEST).is_file()); ++ assert!(root.join("Game.language-de").join(LEGACY_MANIFEST).is_file()); ++ std::fs::remove_dir_all(&root).ok(); ++ } ++ ++ #[test] ++ fn hoist_prefers_the_x64_package_when_several_declare_an_application() { ++ let root = scratch("two-applications"); ++ for (name, arch) in [("Game.x86", "x86"), ("Game.x64", "x64")] { ++ let folder = root.join(name); ++ std::fs::create_dir_all(&folder).unwrap(); ++ let manifest = format!(""); ++ std::fs::write(folder.join(LEGACY_MANIFEST), manifest).unwrap(); ++ std::fs::write(folder.join(format!("{arch}.exe")), b"MZ").unwrap(); ++ } ++ ++ hoist(&root).unwrap(); ++ ++ assert!(root.join("x64.exe").is_file()); ++ assert!(!root.join("x86.exe").exists()); ++ std::fs::remove_dir_all(&root).ok(); ++ } ++ ++ #[test] ++ fn hoist_still_refuses_when_several_packages_declare_an_application() { ++ let root = scratch("ambiguous-applications"); ++ for name in ["One", "Two"] { ++ let folder = root.join(name); ++ std::fs::create_dir_all(&folder).unwrap(); ++ std::fs::write(folder.join(LEGACY_MANIFEST), "").unwrap(); ++ } ++ ++ assert!(hoist(&root).unwrap_err().contains("expected exactly one")); ++ std::fs::remove_dir_all(&root).ok(); ++ } ++ ++ ++ #[test] + fn hoist_still_refuses_to_overwrite_a_game_file_on_a_fresh_install() { + let root = scratch("fresh-collision"); + std::fs::write(root.join("Game.exe"), b"other").unwrap();