mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 13:05:47 +00:00
fix(components): keep the mscoree shim when a component orders it native
This commit is contained in:
1 parent
4a5e20bf98
commit
d7787706dd
5 files changed
+77
-11
No files matched your search
@@ -488,6 +488,12 @@ object WinComponents {
|
||||
return dir
|
||||
}
|
||||
|
||||
internal fun nativeDlls(c: Component): List<String> = c.steps.filter { it.action == "override_dll" }.flatMap { step ->
|
||||
listOf(step.str("dll") to step.str("type")) + (step.json.optJSONArray("bundle")?.let { b ->
|
||||
(0 until b.length()).map { b.getJSONObject(it).let { o -> o.optString("value") to o.optString("data") } }
|
||||
} ?: emptyList())
|
||||
}.filter { (dll, type) -> type == "native" && validId(dll) }.map { it.first.lowercase() }.distinct()
|
||||
|
||||
private fun installPackage(context: Context, c: Component, step: Step, staging: File, onProgress: (Progress) -> Unit): Pair<JSONObject?, String> {
|
||||
val root = LinuxRuntime.rootDir(context)
|
||||
val url = step.str("url")
|
||||
@@ -505,7 +511,9 @@ object WinComponents {
|
||||
onProgress(Progress(c.name, "installing", Phase.INSTALL, 0))
|
||||
var result: JSONObject? = null
|
||||
var problem: String? = null
|
||||
val status = GuestCommand.run(context, guest(listOf(MSI_INSTALL, "/$MSI_CACHE/${file.name}", "/$STORE/${staging.name}")),
|
||||
val native = nativeDlls(c)
|
||||
val flags = if (native.isEmpty()) emptyList() else listOf("--native", native.joinToString(","))
|
||||
val status = GuestCommand.run(context, guest(listOf(MSI_INSTALL) + flags + listOf("/$MSI_CACHE/${file.name}", "/$STORE/${staging.name}")),
|
||||
logName = "wincomponents-${c.name}") { line ->
|
||||
when {
|
||||
line.startsWith("progress ") -> engineLine(line.removePrefix("progress ")).let { (text, pct) -> onProgress(Progress(c.name, text, Phase.INSTALL, pct)) }
|
||||
|
||||
@@ -31,6 +31,14 @@ class WinComponentsSupportTest {
|
||||
step("install_msi", "url" to "$base/ps-x86.msi"), step("install_msi", "url" to "$base/ps-x64.msi"))))
|
||||
}
|
||||
|
||||
@Test fun onlyDllsOrderedNativeAreKeptFromDownlevelSystemComponents() {
|
||||
val c = component("dotnet40", step("override_dll", "dll" to "MSCOREE", "type" to "native"),
|
||||
step("override_dll", "dll" to "fusion", "type" to "builtin"), step("override_dll", "dll" to "msvcr100"),
|
||||
step("override_dll", "dll" to "../x", "type" to "native"), step("install_exe", "url" to "$base/dotnet40.exe"))
|
||||
assertEquals(listOf("mscoree"), WinComponents.nativeDlls(c))
|
||||
assertEquals(emptyList<String>(), WinComponents.nativeDlls(component("xna40", step("install_msi", "url" to "$base/xna40.msi"))))
|
||||
}
|
||||
|
||||
@Test fun builtInArm64RuntimeIsRegistryOnlyInBothViews() {
|
||||
val c = WinComponents.builtInArm64Runtime()
|
||||
assertEquals(Support.READY, support(c))
|
||||
|
||||
Vendored
+1
-1
Submodule external/MaliBridge updated: 64a3f22354...95a1e600a5.
@@ -50,6 +50,8 @@ SYSTEM_PROPERTIES = {
|
||||
"Msix64": "6", "ALLUSERS": "1", "Privileged": "1", "AdminUser": "1", "MsiNTProductType": "1",
|
||||
"UILevel": "2", "INSTALLLEVEL": "1", "ProgramFilesFolder": None, "VersionMsi": "5.00",
|
||||
}
|
||||
DOWNLEVEL_PROPERTIES = {"VersionNT": "502", "VersionNT64": "502", "WindowsBuild": "3790", "ServicePackLevel": "2"}
|
||||
SYSTEM_DIRS = ("drive_c/windows/system32", "drive_c/windows/syswow64")
|
||||
|
||||
COMPONENT_64BIT = 0x100
|
||||
FILE_NONCOMPRESSED = 0x2000
|
||||
@@ -318,8 +320,9 @@ def clr_version(path):
|
||||
|
||||
|
||||
class Installer:
|
||||
def __init__(self, msi, out, package=None, span=None):
|
||||
def __init__(self, msi, out, package=None, span=None, native=()):
|
||||
self.pkg = package or Package(msi)
|
||||
self.native = {name.lower() for name in native}
|
||||
self.out = Path(out)
|
||||
self.span = span or Span()
|
||||
self.notes = []
|
||||
@@ -462,10 +465,19 @@ class Installer:
|
||||
owners = mapped.get(name)
|
||||
if owners is not None and not owners & self.included_features:
|
||||
continue
|
||||
if not self.conditions.evaluate(row.get("Condition", ""), default=True):
|
||||
if not self.conditions.evaluate(row.get("Condition", ""), default=True) and not self.downlevel_native(row):
|
||||
continue
|
||||
self.included_components.add(name)
|
||||
|
||||
def downlevel_native(self, row):
|
||||
if not self.native or (self.directory(row.get("Directory_", "")) or "").lower() not in SYSTEM_DIRS:
|
||||
return False
|
||||
key = next((f for f in self.pkg.table("File") if f["File"] == row.get("KeyPath")), None)
|
||||
if key is None or Path(long_name(key["FileName"])).stem.lower() not in self.native:
|
||||
return False
|
||||
props = dict(self.props, **DOWNLEVEL_PROPERTIES)
|
||||
return Conditions(props, self.feature_state, self.component_state).evaluate(row.get("Condition", ""), default=False)
|
||||
|
||||
def assemblies(self):
|
||||
names = {}
|
||||
for row in self.pkg.table("MsiAssemblyName"):
|
||||
@@ -874,7 +886,7 @@ def choose_packages(found, root):
|
||||
return chosen
|
||||
|
||||
|
||||
def install_wrapper(path, out):
|
||||
def install_wrapper(path, out, native=()):
|
||||
total = {"product": "", "version": "", "counts": {"files": 0, "assemblies": 0, "registry": 0}, "notes": [], "packages": []}
|
||||
with tempfile.TemporaryDirectory(dir=str(out.parent), prefix=".unpack-") as work:
|
||||
dest = Path(work) / "x"
|
||||
@@ -887,7 +899,7 @@ def install_wrapper(path, out):
|
||||
lo, hi = 0.1 + 0.9 * index / len(packages), 0.1 + 0.9 * (index + 1) / len(packages)
|
||||
progress("package %d of %d: %s" % (index + 1, len(packages), package.name), lo)
|
||||
try:
|
||||
result = Installer(str(package), out, span=Span(lo, hi)).install()
|
||||
result = Installer(str(package), out, span=Span(lo, hi), native=native).install()
|
||||
except MsiError as error:
|
||||
if "installs nothing" in str(error) and len(packages) > 1:
|
||||
total["notes"].append("%s: %s" % (package.name, error))
|
||||
@@ -939,6 +951,10 @@ def unpack_only(path, dest):
|
||||
|
||||
def main():
|
||||
args = sys.argv[1:]
|
||||
native = []
|
||||
while len(args) > 1 and args[0] == "--native":
|
||||
native += [name for name in args[1].split(",") if name]
|
||||
args = args[2:]
|
||||
if len(args) == 3 and args[0] == "--unpack":
|
||||
try:
|
||||
result = unpack_only(Path(args[1]), Path(args[2]))
|
||||
@@ -948,16 +964,16 @@ def main():
|
||||
print("result " + json.dumps(result), flush=True)
|
||||
return 0
|
||||
if len(args) != 2:
|
||||
print("usage: droiddeck-msi-install <package.msi | installer.exe> <component dir>\n"
|
||||
print("usage: droiddeck-msi-install [--native dll,...] <package.msi | installer.exe> <component dir>\n"
|
||||
" droiddeck-msi-install --unpack <archive> <dir>", file=sys.stderr)
|
||||
return 2
|
||||
source, out = Path(args[0]), Path(args[1])
|
||||
out.mkdir(parents=True, exist_ok=True)
|
||||
try:
|
||||
if kind_of(source) == "msi":
|
||||
result = Installer(str(source), out).install()
|
||||
result = Installer(str(source), out, native=native).install()
|
||||
else:
|
||||
result = install_wrapper(source, out)
|
||||
result = install_wrapper(source, out, native)
|
||||
except MsiError as error:
|
||||
print("error " + str(error), flush=True)
|
||||
return 1
|
||||
|
||||
@@ -29,8 +29,8 @@ def rows(columns, *values):
|
||||
return [dict(zip(names, value)) for value in values]
|
||||
|
||||
|
||||
def installer(tables, out="/tmp/unused", summary=None):
|
||||
return MSI["Installer"]("fake.msi", out, FakePackage(tables, summary))
|
||||
def installer(tables, out="/tmp/unused", summary=None, native=()):
|
||||
return MSI["Installer"]("fake.msi", out, FakePackage(tables, summary), native=native)
|
||||
|
||||
|
||||
class ToolsTest(unittest.TestCase):
|
||||
@@ -118,6 +118,40 @@ class LayoutTest(unittest.TestCase):
|
||||
inst.select()
|
||||
self.assertEqual(inst.included_components, {"Up", "Wide"})
|
||||
|
||||
def downlevel_shim(self, native, directory="SysShim", key="ShimDll", condition="VersionNT < 600"):
|
||||
inst = installer({
|
||||
"Directory": rows("Directory Directory_Parent DefaultDir",
|
||||
("TARGETDIR", "", "SourceDir"),
|
||||
("ProgramFilesFolder", "TARGETDIR", "PFiles"),
|
||||
("AppDir", "ProgramFilesFolder", "App"),
|
||||
("SysShim", "TARGETDIR", "Win")),
|
||||
"CustomAction": rows("Action Type Source Target", ("SetSys", "51", "SysShim", "[SystemFolder]")),
|
||||
"InstallExecuteSequence": rows("Action Condition Sequence", ("SetSys", "", "1")),
|
||||
"Feature": rows("Feature Feature_Parent Level", ("Main", "", "1")),
|
||||
"Component": rows("Component Directory_ Attributes Condition KeyPath",
|
||||
("Shim", directory, "0", condition, key),
|
||||
("Old", "SysShim", "0", "VersionNT < 600", "OldDll"),
|
||||
("Vista", "SysShim", "0", "VersionNT = 600", "VistaDll")),
|
||||
"FeatureComponents": rows("Feature_ Component_", ("Main", "Shim"), ("Main", "Old"), ("Main", "Vista")),
|
||||
"File": rows("File Component_ FileName", ("ShimDll", "Shim", "MSCOREE.DLL|mscoree.dll"),
|
||||
("OldDll", "Old", "dxva2.dll"), ("VistaDll", "Vista", "mscoree.dll")),
|
||||
}, native=native)
|
||||
inst.run_set_actions()
|
||||
inst.select()
|
||||
return inst.included_components
|
||||
|
||||
def test_a_native_override_keeps_a_system_file_newer_windows_ships_itself(self):
|
||||
self.assertEqual(self.downlevel_shim(["mscoree"]), {"Shim"})
|
||||
|
||||
def test_without_a_native_override_os_version_conditions_still_apply(self):
|
||||
self.assertEqual(self.downlevel_shim([]), set())
|
||||
self.assertEqual(self.downlevel_shim(["mscorwks"]), set())
|
||||
|
||||
def test_only_system_folders_and_downlevel_conditions_are_relaxed(self):
|
||||
self.assertEqual(self.downlevel_shim(["mscoree"], directory="AppDir"), set())
|
||||
self.assertEqual(self.downlevel_shim(["mscoree"], condition="VersionNT = 600"), set())
|
||||
self.assertEqual(self.downlevel_shim(["mscoree"], condition="VersionNT < 600 AND VersionNT64"), {"Shim"})
|
||||
|
||||
def test_a_duplicate_onto_the_file_itself_is_skipped(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
src = Path(tmp) / "cab" / "dotnet.exe"
|
||||
|
||||
Reference in new issue
Block a user