Windows components: install .msi packages (XNA, PhysX, GFWL, MSXML...) without running them (#347)

* Windows components: install .msi packages (XNA, PhysX, GFWL, MSXML...) without running them

droiddeck-msi-install reads a Windows Installer package's tables with msiinfo and unpacks its
cabinets with cabextract, then lays out what Wine's msiexec would have installed: files at their
64-bit Windows paths (Program Files (x86), syswow64...), .NET assemblies in the GAC, side-by-side
assemblies in winsxs, and the registry values in the view the component writes through. Conditions,
features and the folder-setting custom actions are evaluated as on Windows 10 64-bit; what needs
the package's own code (DXSETUP, self-registration) is listed in the component's notes.

droiddeck-wincomponents puts a component's drive_c tree into the prefix (keeping the prefix's own
spelling of each folder) and writes its registry values into system.reg/user.reg before launch,
following Wine's link keys (Wow6432Node\Classes, CurrentControlSet...). Turning it off puts every
value back and takes an added PATH entry out again.

The app installs these from the Windows components menu like the DLL ones: it downloads the .msi
into the runtime and runs the installer there (GuestCommand). msitools 0.106 and cabextract 1.11
come from Arch Linux ARM, pinned in tools/msitools/packages.txt and hosted on the msitools-0.106-r1
release. wine-gecko stays hidden (Proton ships it) and wine-mono keeps waiting (uninstall step).

* Windows components: open with the top switch focused, by touch or by pad

The dialog's window starts in touch mode, where a switch cannot take focus, and the first switch
was asked once, two frames after the list loaded, only when a pad opened it - racing the dialog's
own Done focus. Now it always puts the window in pad mode, holds Done while the list loads and
then asks the top switch every frame until it has focus.

* Windows components: give msitools its own libraries; show a failed install on its row

msiinfo and cabextract sit with their libraries in /usr/local/lib/droiddeck-msitools, which the
loader does not search: every .msi install stopped at "libmsi-1.0.so.0: cannot open shared
object file". droiddeck-msi-install now runs them with that folder on LD_LIBRARY_PATH.

A failed install also says so under the component itself ("Could not install: ..."), not
only at the foot of the dialog, past the list.

---------

Co-authored-by: The412Banner <the412banner@users.noreply.github.com>
This commit is contained in:
The412BannerandThe412Banner authored and GitHub committed 2026-10-06 14:14:28 -04:00
1 parent 2278274588
commit 7484f43dba
14 files changed
+3163 -28

No files matched your search

@@ -32,6 +32,7 @@ object SessionFiles {
val files = arrayOf(
"usr/local/bin/droiddeck-game-env" to "usr/local/bin/droiddeck-game-env",
"usr/local/bin/droiddeck-wincomponents" to "usr/local/bin/droiddeck-wincomponents",
"usr/local/bin/droiddeck-msi-install" to "usr/local/bin/droiddeck-msi-install",
"usr/local/bin/droiddeck-esync" to "usr/local/bin/droiddeck-esync",
"usr/local/bin/droiddeck-steam-compat" to "usr/local/bin/droiddeck-steam-compat",
"usr/local/bin/droiddeck-fex" to "usr/local/bin/droiddeck-fex",
@@ -106,6 +107,10 @@ object SessionFiles {
"usr/local/lib/mangoapp/libtraceevent.so.1",
"usr/local/lib/mangoapp/libtracefs.so.1",
).map { it to it }
// What the Windows components installer reads .msi packages with (tools/msitools).
val msitools = listOf("msiinfo", "cabextract", "libmsi-1.0.so.0", "libgsf-1.so.114", "libgcab-1.0.so.0")
.map { "usr/local/lib/droiddeck-msitools/$it" } +
listOf("NOTICE", "GPL-2", "GPL-3", "LGPL-2.1").map { "usr/local/share/licenses/droiddeck-msitools/$it" }
// The patched wlroots (tools/wlroots) the desktop loads for its vulkan / gles2 renderers.
val wlroots = if (File(root, "usr/bin/labwc").isFile) {
arrayOf("usr/local/lib/droiddeck-wlroots/libwlroots-0.20.so" to "usr/local/lib/droiddeck-wlroots/libwlroots-0.20.so")
@@ -117,7 +122,7 @@ object SessionFiles {
"usr/local/bin/gamescope" to "usr/local/bin/gamescope",
"usr/local/lib/droiddeck/uruntime" to "usr/local/lib/droiddeck/uruntime",
"usr/local/share/licenses/uruntime/LICENSE" to "usr/local/share/licenses/uruntime/LICENSE",
) + wlroots + mangoapp + fexPreloads).filter { (asset, _) ->
) + wlroots + mangoapp + msitools.map { it to it } + fexPreloads).filter { (asset, _) ->
val dir = asset.substringBeforeLast('/')
runCatching { context.assets.list("linuxfs/$dir")?.contains(asset.substringAfterLast('/')) == true }.getOrDefault(false)
}
@@ -6,6 +6,7 @@ import android.util.Log
import com.droiddeck.launcher.core.ArchivePaths
import com.droiddeck.launcher.core.Downloader
import com.droiddeck.launcher.core.FileUtils
import com.droiddeck.launcher.runtime.GuestCommand
import com.droiddeck.launcher.runtime.LinuxRuntime
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream
import org.apache.commons.compress.compressors.xz.XZCompressorInputStream
@@ -28,9 +29,12 @@ import java.util.zip.ZipInputStream
* ~/.config/droiddeck/wincomponents.json, and droiddeck-wincomponents copies the picked components
* into the game's prefix at every launch (see that script for why every launch).
*
* Only components made of file copies and overrides install this way. One that runs a Windows
* installer (install_exe/install_msi), unpacks a cabinet or edits the prefix's registry is listed
* with the reason it cannot be installed yet.
* A component whose installer is a Windows Installer package (.msi: XNA, PhysX, Games for Windows
* Live, MSXML...) installs here too, without running it: droiddeck-msi-install reads the package's
* tables in the runtime and lays out its files (Program Files, the .NET GAC, winsxs) and registry
* values the way Wine's msiexec would, under the same store folder. One that runs any other
* installer (.exe), unpacks a cabinet or edits the prefix's registry by itself is listed with the
* reason it cannot be installed yet.
*/
object WinComponents {
private const val TAG = "WinComponents"
@@ -43,6 +47,11 @@ object WinComponents {
// at the same path, so the native file at that path is the one the registration loads.
private val FILE_STEPS = setOf("download_archive", "archive_extract", "copy_dll", "copy_file", "override_dll", "register_dll")
private val INSTALLER_STEPS = setOf("install_exe", "install_msi")
private const val MSI_INSTALL = "/usr/local/bin/droiddeck-msi-install"
/** Where a downloaded .msi waits for the installer, inside the runtime so it can read it. */
private const val MSI_CACHE = "$STORE/.packages"
/** Catalog entries Proton already provides newer copies of, which an install would only shadow. */
private val PROTON_PROVIDES = setOf("gecko")
fun validId(id: String): Boolean = ID.matches(id) && ".." !in id
@@ -57,6 +66,11 @@ object WinComponents {
enum class Support { READY, NEEDS_INSTALLER, UNSUPPORTED }
/** A step that installs a Windows Installer package, which droiddeck-msi-install does here. */
private fun isMsi(step: Step): Boolean = step.action in INSTALLER_STEPS && step.str("url").startsWith("https://") &&
(step.action == "install_msi" || listOf(step.str("file_name"), step.str("url").substringBefore('?'))
.any { it.endsWith(".msi", ignoreCase = true) })
fun fetch(): List<Component>? {
val body = Downloader.downloadString(CATALOG_URL) ?: return null
return try {
@@ -80,9 +94,12 @@ object WinComponents {
/** Whether [c] can be installed here, its bundled components included. */
fun support(c: Component, all: Map<String, Component>, depth: Int = 0): Support {
if (c.status != "ready" || depth > 8) return Support.UNSUPPORTED
if (c.status != "ready" || depth > 8 || c.name in PROTON_PROVIDES) return Support.UNSUPPORTED
val installers = c.steps.filter { it.action in INSTALLER_STEPS }
val own = when {
c.steps.any { it.action in INSTALLER_STEPS } -> Support.NEEDS_INSTALLER
installers.isNotEmpty() && installers.all { isMsi(it) } &&
c.steps.all { it in installers || it.action == "delete_dlls" || it.action in FILE_STEPS && fileStepOk(it) } -> Support.READY
installers.isNotEmpty() -> Support.NEEDS_INSTALLER
c.steps.all { it.action in FILE_STEPS && fileStepOk(it) } -> Support.READY
else -> Support.UNSUPPORTED
}
@@ -147,7 +164,20 @@ object WinComponents {
val staging = File(root, "$STORE/.${c.name}.new").apply { FileUtils.delete(this); mkdirs() }
val overrides = ArrayList<String>()
var source: File? = null
var msi: JSONObject? = null
for (step in c.steps) when (step.action) {
// A component may have several packages (PowerShell's 32- and 64-bit): each adds to the
// same folder, the first one names the component.
"install_msi", "install_exe" -> {
val (result, problem) = installMsi(context, c, step, staging, onProgress)
if (result == null) return problem
msi = msi?.apply {
val notes = optJSONArray("notes") ?: JSONArray().also { put("notes", it) }
result.optJSONArray("notes")?.let { for (i in 0 until it.length()) notes.put(it.get(i)) }
} ?: result
}
// A catalog step that makes room for the installer's own copy; ours is copied anyway.
"delete_dlls" -> Unit
"download_archive", "archive_extract" -> {
val url = step.str("url")
if (!url.startsWith("http")) continue
@@ -196,17 +226,60 @@ object WinComponents {
"register_dll" -> Unit
else -> return "unsupported step ${step.action}"
}
val version = Regex("""\b(\d+\.\d+(\.\d+)*)\b""").find(c.description)?.value ?: "catalog"
FileUtils.writeString(File(staging, "component.json"), JSONObject()
val version = msi?.optString("version")?.takeIf { it.isNotEmpty() }
?: Regex("""\b(\d+\.\d+(\.\d+)*)\b""").find(c.description)?.value ?: "catalog"
val meta = JSONObject()
.put("id", c.name).put("version", version)
.put("overrides", JSONArray(overrides.distinct()))
.put("requires", JSONArray(c.dependencies)).toString(1))
.put("requires", JSONArray(c.dependencies))
msi?.let { meta.put("kind", "msi").put("product", it.optString("product")).put("notes", it.optJSONArray("notes") ?: JSONArray()) }
FileUtils.writeString(File(staging, "component.json"), meta.toString(1))
val target = File(root, "$STORE/${c.name}")
FileUtils.delete(target)
if (!staging.renameTo(target)) return "could not place the files"
return null
}
/**
* Downloads the component's .msi into the runtime and has droiddeck-msi-install lay it out in
* [staging]. Returns the installer's result (product, version, counts, notes), or null and why.
* Everything the installer prints also goes to Download/DroidDeck/tools.
*/
private fun installMsi(context: Context, c: Component, step: Step, staging: File, onProgress: (String, Int) -> Unit): Pair<JSONObject?, String> {
val root = LinuxRuntime.rootDir(context)
val url = step.str("url")
val name = url.substringBefore('?').substringAfterLast('/')
val cache = File(root, MSI_CACHE).apply { mkdirs() }
val file = File(cache, "${c.name}.msi")
try {
if (!Downloader.downloadFile(url, file, false) { f -> onProgress("${c.name}: $name", if (f < 0) -1 else Math.round(f * 100f)) }) {
return null to "download failed: $name"
}
step.str("file_checksum").takeIf { it.length == 32 }?.let { md5 ->
if (!digest(file, "MD5").equals(md5, ignoreCase = true)) return null to "checksum mismatch: $name"
}
onProgress("${c.name}: installing", -1)
var result: JSONObject? = null
var problem: String? = null
val status = GuestCommand.run(context, listOf(MSI_INSTALL, "/$MSI_CACHE/${file.name}", "/$STORE/${staging.name}"),
logName = "wincomponents-${c.name}") { line ->
when {
line.startsWith("progress ") -> onProgress("${c.name}: ${line.removePrefix("progress ")}", -1)
line.startsWith("result ") -> result = runCatching { JSONObject(line.removePrefix("result ")) }.getOrNull()
line.startsWith("error ") -> problem = line.removePrefix("error ")
}
}
val done = result
if (status != 0 || done == null) return null to (problem ?: "the installer stopped (status $status)")
return done to ""
} catch (e: Exception) {
Log.e(TAG, "msi ${c.name}", e)
return null to (e.message ?: "the installer failed")
} finally {
file.delete()
}
}
private fun digest(file: File, algorithm: String): String {
val md = MessageDigest.getInstance(algorithm)
FileInputStream(file).use { input ->
@@ -26,6 +26,9 @@ import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.clip
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.input.InputMode
import androidx.compose.ui.platform.LocalInputModeManager
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
@@ -59,6 +62,7 @@ private fun installable(name: String, all: Map<String, WinComponents.Component>)
return if (twin != null && WinComponents.support(twin, all) == Support.READY) dll else name
}
@OptIn(androidx.compose.ui.ExperimentalComposeUiApi::class)
@Composable
internal fun WinComponentsDialog(
appKey: String, gameName: String, gameDir: File?, byPad: Boolean,
@@ -80,13 +84,18 @@ internal fun WinComponentsDialog(
var picks by remember { mutableStateOf(WinComponents.picks(context, appKey)) }
var progress by remember { mutableStateOf<Pair<String, Int>?>(null) }
var error by remember { mutableStateOf<String?>(null) }
// The component the error is about, so it shows on its own row and not only at the bottom.
var failed by remember { mutableStateOf<String?>(null) }
var showWaiting by remember { mutableStateOf(false) }
// With a pad: Done holds focus while the list loads, then the first component takes it; LB and RB
// jump between the sections, since the full list runs past sixty switches.
// Done holds focus while the list loads, then the top switch takes it - opened by touch or by
// pad, so the d-pad always has somewhere to start; LB and RB jump between the sections, since
// the full list runs past sixty switches.
val recFocus = remember { FocusRequester() }
val allFocus = remember { FocusRequester() }
val waitFocus = remember { FocusRequester() }
val doneFocus = remember { FocusRequester() }
val inputMode = LocalInputModeManager.current
var switchFocused by remember { mutableStateOf(false) }
LaunchedEffect(Unit) {
val (entries, found) = withContext(Dispatchers.IO) {
@@ -110,6 +119,7 @@ internal fun WinComponentsDialog(
// then is ignored here.
if (progress != null) return
error = null
failed = null
if (!on) { setPicks(picks - id); return }
val all = catalog.orEmpty()
val c = all[id]
@@ -121,7 +131,7 @@ internal fun WinComponentsDialog(
}
progress = null
installed = withContext(Dispatchers.IO) { WinComponents.installedIds(context).toSet() }
if (problem != null) error = problem else setPicks(picks + id)
if (problem != null) { error = problem; failed = id } else setPicks(picks + id)
}
}
@@ -144,14 +154,21 @@ internal fun WinComponentsDialog(
runCatching { sections[section].requestFocus() }
}
LaunchedEffect(all != null) {
if (!byPad || all == null) return@LaunchedEffect
repeat(2) { withFrameNanos { } }
// The dialog's window starts in touch mode, where a switch cannot hold focus at all.
inputMode.requestInputMode(InputMode.Keyboard)
section = 0
runCatching { sections.first().requestFocus() }
val target = if (all == null) doneFocus else sections.first()
switchFocused = false
// It animates in and the list composes over a few frames: ask until the switch has it.
repeat(60) {
withFrameNanos { }
runCatching { target.requestFocus() }
withFrameNanos { }
if (switchFocused || (target !== recFocus && target !== allFocus)) return@LaunchedEffect
}
}
AppDialog(shown, close, "winComponents", wide = true, modifier = Modifier.bumpers({ jump(-1) }, { jump(1) })) {
PadFocus(byPad, doneFocus)
DialogHeader(gameName, stringResource(R.string.wincomp_title))
Small(stringResource(R.string.wincomp_applies))
if (byPad) Small(stringResource(R.string.wincomp_pad_hint))
@@ -162,6 +179,7 @@ internal fun WinComponentsDialog(
val c = all?.get(id)
val support = supportOf(id)
val status = when {
id == failed && error != null -> stringResource(R.string.wincomp_failed, error.orEmpty())
id in here && id !in picks -> stringResource(R.string.wincomp_already_here)
id in installed -> stringResource(R.string.wincomp_downloaded)
support == Support.NEEDS_INSTALLER -> stringResource(R.string.wincomp_needs_installer)
@@ -173,7 +191,8 @@ internal fun WinComponentsDialog(
val usable = support == Support.READY
ComponentRow(
WinComponentNames.of(id), detail, checked = id in picks, enabled = usable || id in picks,
dim = !usable, modifier = if (usable && focus != null) Modifier.focusRequester(focus) else Modifier,
dim = !usable, modifier = (if (usable && focus != null) Modifier.focusRequester(focus) else Modifier)
.onFocusChanged { if (it.isFocused) switchFocused = true },
) { on -> toggle(id, on) }
}
/** The section's requester goes to its first switch that can take focus. */