fix(wincomponents): count held component files and skip replaced files in x64 guests

This commit is contained in:
maxjivi05 committed 2026-11-14 21:06:53 -05:00
1 parent 1e4ad00dcf
commit b50399ecca
2 files changed
+33 -4

No files matched your search

@@ -509,7 +509,8 @@ def component_guests(compat, proton, machines, planned, owned):
except OSError:
present = []
names.update(entry.name for entry in present if entry.name.lower().endswith(".dll") and not entry.is_symlink()
and ("drive_c/windows/system32/" + entry.name).lower() not in removed and plain_x64(entry.path))
and ("drive_c/windows/system32/" + entry.name).lower() not in removed
and ("drive_c/windows/system32/" + entry.name).lower() not in planned_rels and plain_x64(entry.path))
names.update(Path(rel).name for rel in removed.values()
if rel.lower().endswith(".dll") and (compat / BACKUP / rel).is_file() and plain_x64(compat / BACKUP / rel))
if not names:
@@ -588,9 +589,13 @@ def apply(compat_path, app_id, selection=SELECTION, store=STORE, pending=PENDING
saved_requires = dict(saved_requires, **{cid: loose})
inferred.add(cid)
kept_overrides, kept_requires = {}, {}
planned = [entry for cid in expand(store, ids, saved_requires) for entry in (component(store, cid) or ([], [], [], []))[1]]
guests = component_guests(compat, proton, machines, planned, state["files"])
for cid in expand(store, ids, saved_requires):
expanded = expand(store, ids, saved_requires)
planned = [entry for cid in expanded for entry in (component(store, cid) or ([], [], [], []))[1]]
retained = {cid for cid in expanded if component(store, cid) is None
and (cid in saved_requires or cid in recorded or cid in owners or cid in registry_owners)}
guests = component_guests(compat, proton, machines, planned,
{rel: cid for rel, cid in state["files"].items() if cid not in retained})
for cid in expanded:
found = component(store, cid)
if found is None:
if cid in saved_requires or cid in recorded or cid in owners or cid in registry_owners:
+24
View File
@@ -147,6 +147,30 @@ class WinComponentsTest(unittest.TestCase):
self.apply(proton)
self.assertEqual(MODULE["pe_machine"](self.pfx / "system32/d3dx9_43.dll"), 0x8664)
def test_arm64_d3dx9_replacing_an_x64_copy_does_not_keep_an_x64_compiler(self):
proton = self.proton()
self.pfx.joinpath("system32").mkdir(parents=True)
self.pfx.joinpath("system32/d3dx9_43.dll").write_bytes(self.pe_image(0x8664))
self.component("d3dx9", ["d3dx9_43"], {"system32/d3dx9_43.dll": pe_image_importing(0xAA64)})
self.component("d3dcompiler", ["d3dcompiler_43"], {"system32/d3dcompiler_43.dll": self.pe_image(0x8664)})
self.pick("d3dx9", "d3dcompiler")
self.apply(proton)
self.assertEqual(MODULE["pe_machine"](self.pfx / "system32/d3dx9_43.dll"), 0xAA64)
self.assertFalse((self.pfx / "system32/d3dcompiler_43.dll").exists())
def test_held_component_files_still_count_as_x64_importers(self):
proton = self.proton()
self.component("d3dx9", ["d3dx9_43"], {"system32/d3dx9_43.dll": self.pe_image(0x8664)})
self.component("d3dcompiler", ["d3dcompiler_43"], {"system32/d3dcompiler_43.dll": self.pe_image(0x8664)})
self.pick("d3dx9", "d3dcompiler")
self.apply(proton)
for path in sorted((self.store / "d3dx9").rglob("*"), reverse=True):
path.rmdir() if path.is_dir() else path.unlink()
(self.store / "d3dx9").rmdir()
self.apply(proton)
self.assertEqual(MODULE["pe_machine"](self.pfx / "system32/d3dx9_43.dll"), 0x8664)
self.assertEqual(MODULE["pe_machine"](self.pfx / "system32/d3dcompiler_43.dll"), 0x8664)
def test_x64_compiler_alone_is_skipped_while_the_builtin_d3dx9_imports_it(self):
proton = self.proton()
self.component("d3dcompiler", ["d3dcompiler_43"], {