feat(recomps): a Recomps tab that installs recomps and links store-owned game files

Adds More > Recomps: a curated catalog of recompiled and reimplemented
games. Each card installs the best build for the device (native arm64
Linux, x86-64 Linux through FEX, or Windows through Proton as an added
game), finds the game's data in a Steam, GOG or Epic install the player
already has, and passes that folder to the program at launch. ROM-based
recomps say which dump they need and never download one.

The catalog ships in assets and can be replaced by recomps.json in
DroidDeck-Components. tools/recomps/pin_catalog.py pins each entry to a
release so installs skip the rate-limited GitHub API.
This commit is contained in:
Kurt Himebauch committed 2026-12-01 11:13:14 -05:00
1 parent 9dfbc05933
commit 91b2f5483d
17 files changed
+1484 -12

No files matched your search

@@ -1,5 +1,7 @@
package com.droiddeck.launcher.ui
import com.droiddeck.launcher.runtime.RecompData
import com.droiddeck.launcher.stores.Store
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
@@ -70,6 +72,7 @@ internal val previewCases: List<PreviewCase> = listOf(
PreviewCase("library-empty", storesLoaded) { Launcher("games", games = emptyList()) },
PreviewCase("stores", storesLoaded) { Launcher("stores") },
PreviewCase("downloads") { Launcher("downloads") },
PreviewCase("recomps") { RecompsTab() },
PreviewCase("settings") { Launcher("setup") },
PreviewCase("runtime-missing") { Launcher("setup", ready = false) },
PreviewCase("session-menu-controller") { SessionMenu(SessionDrawerPage.CONTROLLER) },
@@ -81,3 +84,27 @@ internal val previewCases: List<PreviewCase> = listOf(
PreviewCase("session-menu-docked-display") { DockedMenu(SessionDrawerPage.DISPLAY) },
PreviewCase("bottom-panel-bar") { BottomPanelBar() },
)
/** The Recomps tab with one recomp installed, one game found on Steam, one owned but not installed and one to buy. */
@Composable
private fun RecompsTab(): Unit {
val ctx = androidx.compose.ui.platform.LocalContext.current
androidx.compose.runtime.remember {
val list = com.droiddeck.launcher.runtime.RecompCatalog.bundled(ctx)
val states: Map<String, RecompData.State> = list.associate { e ->
e.id to when (e.id) {
"ironwail" -> RecompData.State.Found(Store.STEAM, java.io.File("/q"), "/root/.local/share/Steam/steamapps/common/Quake")
"fallout2-ce" -> RecompData.State.Owned(Store.GOG, null)
"devilutionx" -> RecompData.State.Incomplete(Store.GOG, java.io.File("/d"))
else -> if (e.data.kind == com.droiddeck.launcher.runtime.RecompCatalog.DataKind.STORE) RecompData.State.Missing(e.data.stores) else RecompData.State.BringYourOwn(e.data)
}
}
val installed = mapOf("zelda64recomp" to com.droiddeck.launcher.runtime.RecompInstaller.Installed(
"zelda64recomp", "script:zelda-64-recompiled", "v1.2.1", "", "linux-arm64", java.io.File("/z")))
val newer = mapOf("zelda64recomp" to com.droiddeck.launcher.runtime.RecompInstaller.Release("v1.2.2", "", "", "", null))
com.droiddeck.launcher.store.RecompsState.show(list, installed, states, newer)
}
Launcher("recomps")
}
@DroidDeckPreviews @Composable private fun RecompsTabPreview() = RecompsTab()
+208
View File
@@ -0,0 +1,208 @@
{
"schema": 1,
"recomps": [
{
"id": "zelda64recomp",
"name": "Zelda 64: Recompiled",
"game": "The Legend of Zelda: Majora's Mask",
"origin": "N64",
"type": "recomp",
"repo": "Zelda64Recomp/Zelda64Recomp",
"license": "GPL-3.0",
"art": "https://raw.githubusercontent.com/Zelda64Recomp/Zelda64Recomp/dev/icons/512.png",
"builds": {
"linux-arm64": { "asset": "^Zelda64Recompiled-.*-Linux-ARM64\\.zip$", "entry": "Zelda64Recompiled" },
"linux-x64": { "asset": "^Zelda64Recompiled-.*-Linux-X64\\.zip$", "entry": "Zelda64Recompiled" },
"windows-x64": { "asset": "^Zelda64Recompiled-.*-Windows\\.zip$", "entry": "Zelda64Recompiled.exe" }
},
"data": {
"kind": "rom",
"label": "Majora's Mask (USA) N64 ROM",
"sha1": ["d6133ace5afaa0882cf214cf88daba39e266c078"],
"note": "Choose the ROM from the recomp's own start screen."
}
},
{
"id": "starfox64recomp",
"name": "Starfox 64: Recompiled",
"game": "Star Fox 64",
"origin": "N64",
"type": "recomp",
"repo": "sonicdcer/Starfox64Recomp",
"license": "GPL-3.0",
"art": "https://raw.githubusercontent.com/sonicdcer/Starfox64Recomp/main/icons/512.png",
"builds": {
"linux-arm64": { "asset": "^Starfox64Recompiled-.*-Linux-ARM64-Release\\.zip$", "entry": "Starfox64Recompiled" },
"linux-x64": { "asset": "^Starfox64Recompiled-.*-Linux-X64-Release\\.zip$", "entry": "Starfox64Recompiled" },
"windows-x64": { "asset": "^Starfox64Recompiled-.*-Windows-.*\\.zip$", "entry": "Starfox64Recompiled.exe" }
},
"data": {
"kind": "rom",
"label": "Star Fox 64 (USA) N64 ROM",
"note": "Choose the ROM from the recomp's own start screen."
}
},
{
"id": "banjorecomp",
"name": "Banjo: Recompiled",
"game": "Banjo-Kazooie",
"origin": "N64",
"type": "recomp",
"repo": "BanjoRecomp/BanjoRecomp",
"license": "GPL-3.0",
"art": "https://raw.githubusercontent.com/BanjoRecomp/BanjoRecomp/main/icons/app.png",
"builds": {
"linux-arm64": { "asset": "^BanjoRecompiled-.*-Linux-ARM64\\.tar\\.gz$", "entry": "BanjoRecompiled" },
"linux-x64": { "asset": "^BanjoRecompiled-.*-Linux-X64\\.tar\\.gz$", "entry": "BanjoRecompiled" },
"windows-x64": { "asset": "^BanjoRecompiled-.*-Windows\\.zip$", "entry": "BanjoRecompiled.exe" }
},
"data": {
"kind": "rom",
"label": "Banjo-Kazooie (USA) N64 ROM",
"note": "Choose the ROM from the recomp's own start screen."
}
},
{
"id": "2ship2harkinian",
"name": "2 Ship 2 Harkinian",
"game": "The Legend of Zelda: Majora's Mask",
"origin": "N64",
"type": "port",
"repo": "2ship2harkinian/2ship2harkinian",
"license": "CC0-1.0",
"art": "https://raw.githubusercontent.com/2ship2harkinian/2ship2harkinian/develop/mm/linux/2s2hIcon.png",
"builds": {
"linux-x64": { "asset": "^2Ship-.*-Linux\\.zip$", "entry": "2ship.appimage" },
"windows-x64": { "asset": "^2Ship-.*-Win64\\.zip$", "entry": "2ship.exe" }
},
"data": {
"kind": "rom",
"label": "Majora's Mask (USA) N64 ROM",
"sha1": ["d6133ace5afaa0882cf214cf88daba39e266c078"],
"note": "The port asks for the ROM on first start and builds its asset archive from it."
}
},
{
"id": "unleashedrecomp",
"name": "Unleashed Recompiled",
"game": "Sonic Unleashed",
"origin": "Xbox 360",
"type": "recomp",
"repo": "hedge-dev/UnleashedRecomp",
"license": "GPL-3.0",
"builds": {
"windows-x64": { "asset": "^UnleashedRecomp-Windows\\.zip$", "entry": "UnleashedRecomp.exe" }
},
"data": {
"kind": "dump",
"label": "Sonic Unleashed Xbox 360 game files and title update",
"note": "The installer inside the recomp asks for your dumped game, update and DLC folders."
}
},
{
"id": "devilutionx",
"name": "DevilutionX",
"game": "Diablo",
"origin": "PC",
"type": "port",
"repo": "diasurgical/DevilutionX",
"license": "Sustainable Use License",
"art": "https://raw.githubusercontent.com/diasurgical/DevilutionX/master/Packaging/resources/icon.png",
"builds": {
"linux-arm64": { "asset": "^devilutionx-linux-aarch64\\.tar\\.xz$", "entry": "devilutionx", "args": ["--data-dir", "{data}"] },
"linux-x64": { "asset": "^devilutionx-linux-x86_64\\.tar\\.xz$", "entry": "devilutionx", "args": ["--data-dir", "{data}"] },
"windows-x64": { "asset": "^devilutionx-windows-x86_64\\.zip$", "entry": "devilutionx.exe" },
"android": { "asset": "^devilutionx-android\\.apk$" }
},
"data": {
"kind": "store",
"label": "Diablo (GOG)",
"stores": [{ "store": "gog", "id": "1412601690" }],
"probe": "DIABDAT.MPQ"
}
},
{
"id": "ironwail",
"name": "Ironwail",
"game": "Quake",
"origin": "PC",
"type": "port",
"repo": "andrei-drexler/ironwail",
"license": "GPL-2.0",
"art": "https://shared.steamstatic.com/store_item_assets/steam/apps/2310/library_600x900.jpg",
"builds": {
"linux-x64": { "asset": "^ironwail-.*-linux-x64\\.tar\\.gz$", "entry": "ironwail", "args": ["-basedir", "{data}"] },
"windows-x64": { "asset": "^ironwail-.*-win64\\.zip$", "entry": "ironwail.exe" }
},
"data": {
"kind": "store",
"label": "Quake (Steam or GOG)",
"stores": [{ "store": "steam", "id": "2310" }, { "store": "gog", "id": "1440166133" }],
"probe": "id1/pak0.pak"
}
},
{
"id": "openrct2",
"name": "OpenRCT2",
"game": "RollerCoaster Tycoon 2",
"origin": "PC",
"type": "port",
"repo": "OpenRCT2/OpenRCT2",
"license": "GPL-3.0",
"art": "https://shared.steamstatic.com/store_item_assets/steam/apps/285330/library_600x900.jpg",
"builds": {
"linux-x64": { "asset": "^OpenRCT2-.*-linux-x86_64\\.AppImage$" },
"windows-x64": { "asset": "^OpenRCT2-.*-windows-portable-x64\\.zip$", "entry": "openrct2.exe" },
"android": { "asset": "^OpenRCT2-.*-android\\.apk$" }
},
"data": {
"kind": "store",
"label": "RollerCoaster Tycoon 2 (Steam or GOG)",
"stores": [{ "store": "steam", "id": "285330" }, { "store": "gog", "id": "1207658957" }],
"probe": "Data/g1.dat",
"note": "OpenRCT2 asks for this folder on first start."
}
},
{
"id": "fallout2-ce",
"name": "Fallout 2 Community Edition",
"game": "Fallout 2",
"origin": "PC",
"type": "port",
"repo": "alexbatalov/fallout2-ce",
"license": "Sustainable Use License",
"art": "https://shared.steamstatic.com/store_item_assets/steam/apps/38410/library_600x900.jpg",
"builds": {
"linux-x64": { "asset": "^fallout2-ce-linux-x64\\.tar\\.gz$", "entry": "fallout2-ce", "workdir": "data" },
"windows-x64": { "asset": "^fallout2-ce-windows-x64\\.zip$", "entry": "fallout2-ce.exe" },
"android": { "asset": "^fallout2-ce-android\\.apk$" }
},
"data": {
"kind": "store",
"label": "Fallout 2 (Steam or GOG)",
"stores": [{ "store": "steam", "id": "38410" }, { "store": "gog", "id": "1440166436" }],
"probe": "master.dat"
}
},
{
"id": "openmw",
"name": "OpenMW",
"game": "The Elder Scrolls III: Morrowind",
"origin": "PC",
"type": "engine",
"repo": "OpenMW/openmw",
"license": "GPL-3.0",
"art": "https://shared.steamstatic.com/store_item_assets/steam/apps/22320/library_600x900.jpg",
"builds": {
"linux-x64": { "asset": "^openmw-[0-9.]+-Linux-64Bit\\.tar\\.gz$", "entry": "openmw-launcher" }
},
"data": {
"kind": "store",
"label": "Morrowind GOTY (Steam or GOG)",
"stores": [{ "store": "steam", "id": "22320" }, { "store": "gog", "id": "1440163901" }],
"probe": "Data Files/Morrowind.esm",
"note": "The OpenMW launcher's install wizard asks for the Morrowind folder."
}
}
]
}
@@ -0,0 +1,119 @@
package com.droiddeck.launcher.runtime
import android.content.Context
import android.util.Log
import com.droiddeck.launcher.core.Downloader
import com.droiddeck.launcher.stores.Store
import org.json.JSONArray
import org.json.JSONObject
object RecompCatalog {
private const val TAG = "RecompCatalog"
const val SCHEMA = 1
const val CATALOG_URL = "https://raw.githubusercontent.com/Droid-Deck/DroidDeck-Components/main/recomps.json"
const val BUNDLED = "recomps/catalog.json"
enum class Platform(val key: String) {
LINUX_ARM64("linux-arm64"), LINUX_X64("linux-x64"), WINDOWS_X64("windows-x64"), ANDROID("android");
companion object {
fun of(key: String) = entries.firstOrNull { it.key == key }
}
}
// A build DroidDeck can run, in the order it is preferred: native arm64 Linux, x86-64 Linux through FEX,
// then Windows through Proton. Android APKs are listed but installed by the system package installer.
val PREFERENCE = listOf(Platform.LINUX_ARM64, Platform.LINUX_X64, Platform.WINDOWS_X64)
class Build(
val platform: Platform, val asset: Regex, val entry: String, val args: List<String>, val inData: Boolean,
val file: String? = null, val sha256: String? = null,
)
enum class DataKind { STORE, ROM, DUMP, NONE }
class StoreRef(val store: Store, val id: String)
class Data(
val kind: DataKind, val label: String, val stores: List<StoreRef>, val probe: String?,
val sha1: List<String>, val note: String,
)
class Entry(
val id: String, val name: String, val game: String, val origin: String, val type: String,
val repo: String, val license: String, val homepage: String, val art: String?,
val builds: List<Build>, val data: Data, val prerelease: Boolean,
val tag: String? = null, val published: String = "",
) {
fun build(platform: Platform) = builds.firstOrNull { it.platform == platform }
fun preferred(): Build? = PREFERENCE.firstNotNullOfOrNull { build(it) }
val android get() = build(Platform.ANDROID)
}
@Volatile private var cached: List<Entry>? = null
fun load(context: Context, refresh: Boolean = false): List<Entry> {
if (!refresh) cached?.let { return it }
val remote = Downloader.downloadString(CATALOG_URL)?.let { parse(it) }?.takeIf { it.isNotEmpty() }
val list = remote ?: bundled(context)
cached = list
return list
}
fun bundled(context: Context): List<Entry> =
runCatching { context.assets.open(BUNDLED).use { it.readBytes().decodeToString() } }.getOrNull()?.let { parse(it) }.orEmpty()
fun parse(body: String): List<Entry>? = try {
val json = JSONObject(body)
if (json.optInt("schema", 0) > SCHEMA) {
Log.w(TAG, "catalog schema ${json.optInt("schema")} is newer than $SCHEMA")
null
} else {
val arr = json.getJSONArray("recomps")
(0 until arr.length()).mapNotNull { i -> runCatching { entry(arr.getJSONObject(i)) }.onFailure { Log.w(TAG, "entry $i: $it") }.getOrNull() }
.distinctBy { it.id }
}
} catch (e: Exception) {
Log.w(TAG, "catalog: $e"); null
}
private fun strings(arr: JSONArray?): List<String> = (0 until (arr?.length() ?: 0)).map { arr!!.getString(it) }
private fun entry(o: JSONObject): Entry {
val id = o.getString("id")
require(Regex("[a-z0-9][a-z0-9-]{0,47}").matches(id)) { "bad id $id" }
val repo = o.getString("repo")
require(Regex("[\\w.-]+/[\\w.-]+").matches(repo)) { "bad repo $repo" }
val builds = o.optJSONObject("builds")?.let { b ->
b.keys().asSequence().mapNotNull { key ->
val platform = Platform.of(key) ?: return@mapNotNull null
val spec = b.getJSONObject(key)
Build(platform, Regex(spec.getString("asset"), RegexOption.IGNORE_CASE), spec.optString("entry"), strings(spec.optJSONArray("args")),
spec.optString("workdir") == "data",
spec.optString("file").takeIf { it.isNotEmpty() && '/' !in it && it != "." && it != ".." },
spec.optString("sha256").lowercase().takeIf { Regex("[0-9a-f]{64}").matches(it) })
}.toList()
}.orEmpty()
val d = o.optJSONObject("data") ?: JSONObject()
val kind = runCatching { DataKind.valueOf(d.optString("kind", "none").uppercase()) }.getOrDefault(DataKind.NONE)
val stores = d.optJSONArray("stores")?.let { arr ->
(0 until arr.length()).mapNotNull { i ->
val s = arr.getJSONObject(i)
val store = Store.entries.firstOrNull { it.name.equals(s.getString("store"), ignoreCase = true) } ?: return@mapNotNull null
StoreRef(store, s.getString("id"))
}
}.orEmpty()
return Entry(
id, o.getString("name"), o.optString("game", o.getString("name")), o.optString("origin"), o.optString("type", "recomp"),
repo, o.optString("license"), o.optString("homepage", "https://github.com/$repo"), o.optString("art").takeIf { it.startsWith("https://") },
builds,
Data(kind, d.optString("label"), stores, d.optString("probe").takeIf { it.isNotEmpty() && ".." !in it && !it.startsWith("/") },
strings(d.optJSONArray("sha1")).map { it.lowercase() }, d.optString("note")),
o.optBoolean("prerelease", false),
o.optJSONObject("release")?.optString("tag")?.takeIf { it.isNotEmpty() },
o.optJSONObject("release")?.optString("published").orEmpty(),
)
}
}
@@ -0,0 +1,104 @@
package com.droiddeck.launcher.runtime
import android.content.Context
import com.droiddeck.launcher.stores.CatalogItem
import com.droiddeck.launcher.stores.Store
import com.droiddeck.launcher.stores.StoreInstallRoot
import com.droiddeck.launcher.stores.StoresState
import com.droiddeck.launcher.stores.steam.SteamClient
import com.droiddeck.launcher.stores.steam.SteamLibraryFolders
import java.io.File
object RecompData {
private const val PROBE_DEPTH = 3
sealed class State {
object NotNeeded : State()
class BringYourOwn(val data: RecompCatalog.Data) : State()
class Found(val store: Store, val host: File, val guest: String) : State()
class Owned(val store: Store, val item: CatalogItem?) : State()
class Missing(val refs: List<RecompCatalog.StoreRef>) : State()
class Incomplete(val store: Store, val host: File) : State()
}
class Install(val store: Store, val id: String, val host: File, val guest: String)
class Inputs(val installs: List<Install>, val owned: Set<String>, val items: Map<String, CatalogItem>)
fun key(store: Store, id: String) = "${store.name}:$id"
// Scans the folders that the store installs and the Steam client libraries cover; called off the main thread.
fun inputs(context: Context, steamOwned: Collection<Int>): Inputs {
val root = LinuxRuntime.rootDir(context)
val installs = mutableListOf<Install>()
StoresState.installed.forEach { game ->
installs += Install(game.sidecar.store, game.sidecar.id, game.folder, guestPath(context, root, game.folder))
}
runCatching {
SteamLibraryFolders.installed(SteamClient.libraries(context)).forEach { (appId, app) ->
val dir = app.installDir ?: return@forEach
installs += Install(Store.STEAM, appId.toString(), File(app.library.host, "steamapps/common/$dir"),
"${app.library.guest.trimEnd('/')}/steamapps/common/$dir")
}
}
val items = StoresState.library.flatMap { (store, list) -> list.filter { it.accessible }.map { key(store, it.id) to it } }.toMap()
val owned = items.keys + steamOwned.map { key(Store.STEAM, it.toString()) }
return Inputs(installs, owned, items)
}
private fun guestPath(context: Context, root: File, host: File): String {
val r = root.absolutePath.trimEnd('/')
val h = host.absolutePath
return if (h.startsWith("$r/")) h.removePrefix(r) else StoreInstallRoot.guestPath(context, host)
}
fun resolve(entry: RecompCatalog.Entry, inputs: Inputs, probe: (File, String) -> File? = ::probeDir): State {
val data = entry.data
return when (data.kind) {
RecompCatalog.DataKind.NONE -> State.NotNeeded
RecompCatalog.DataKind.ROM, RecompCatalog.DataKind.DUMP -> State.BringYourOwn(data)
RecompCatalog.DataKind.STORE -> {
var incomplete: State.Incomplete? = null
for (ref in data.stores) {
val install = inputs.installs.firstOrNull { it.store == ref.store && it.id == ref.id } ?: continue
val pattern = data.probe ?: return State.Found(ref.store, install.host, install.guest)
val dir = probe(install.host, pattern)
if (dir != null) {
val rel = dir.relativeTo(install.host).invariantSeparatorsPath.trim('/')
return State.Found(ref.store, dir, if (rel.isEmpty()) install.guest else "${install.guest.trimEnd('/')}/$rel")
}
incomplete = incomplete ?: State.Incomplete(ref.store, install.host)
}
incomplete?.let { return it }
data.stores.firstOrNull { key(it.store, it.id) in inputs.owned }?.let { ref ->
return State.Owned(ref.store, inputs.items[key(ref.store, ref.id)])
}
State.Missing(data.stores)
}
}
}
// Returns the shallowest folder under [root] that holds [relative], matching each path part without case,
// because Windows store builds ship names such as PAK0.PAK or DIABDAT.MPQ in any case.
fun probeDir(root: File, relative: String): File? {
val parts = relative.split('/').filter { it.isNotEmpty() }
if (parts.isEmpty()) return null
var level = listOf(root)
repeat(PROBE_DEPTH + 1) {
level.firstOrNull { resolveParts(it, parts) != null }?.let { return it }
level = level.flatMap { dir -> dir.listFiles()?.filter { it.isDirectory }?.sortedBy { it.name }.orEmpty() }
}
return null
}
private fun resolveParts(base: File, parts: List<String>): File? {
var cur = base
for ((i, part) in parts.withIndex()) {
val next = File(cur, part).takeIf { it.exists() }
?: cur.listFiles()?.firstOrNull { it.name.equals(part, ignoreCase = true) } ?: return null
if (i < parts.lastIndex && !next.isDirectory) return null
cur = next
}
return cur
}
}
@@ -0,0 +1,221 @@
package com.droiddeck.launcher.runtime
import android.content.Context
import android.system.Os
import com.droiddeck.launcher.R
import com.droiddeck.launcher.core.Downloader
import com.droiddeck.launcher.core.FileUtils
import com.droiddeck.launcher.core.Hashes
import com.droiddeck.launcher.frontend.AddedGames
import com.droiddeck.launcher.stores.StoreInstallRoot
import org.json.JSONArray
import java.io.File
import java.io.RandomAccessFile
object RecompInstaller {
const val META_ID = "recomp-id"
const val META_TAG = "recomp-tag"
const val META_PUBLISHED = "recomp-published"
const val META_PLATFORM = "recomp-platform"
const val META_DATA = "recomp-data"
const val WRAPPER = "droiddeck-recomp"
private const val WINDOWS_DIR = "Recomps"
private const val NESTED_LIMIT = 2
private val ARCHIVE = Regex("\\.(zip|7z|tar|tgz|tar\\.(gz|xz|bz2|zst))$", RegexOption.IGNORE_CASE)
class Release(val tag: String, val published: String, val asset: String, val url: String, val sha256: String?)
class Installed(val id: String, val appKey: String, val tag: String?, val published: String?, val platform: String?, val dir: File)
fun installed(context: Context): Map<String, Installed> {
val out = HashMap<String, Installed>()
fun scan(root: File, prefix: String) = root.listFiles()?.forEach { dir ->
val id = FileUtils.readString(File(dir, META_ID))?.trim()?.takeIf { it.isNotEmpty() } ?: return@forEach
out[id] = Installed(id, "$prefix:${dir.name}", read(dir, META_TAG), read(dir, META_PUBLISHED), read(dir, META_PLATFORM), dir)
}
scan(UserApps.root(context), "script")
AppImageManager.dir(context, "").parentFile?.let { scan(it, "appimage") }
windowsRoots(context).forEach { scan(it, "added") }
return out
}
private fun windowsRoots(context: Context): List<File> =
(AddedGames.roots(context).map { it.host } + StoreInstallRoot.installRoot(context)).map { File(it, WINDOWS_DIR) }.distinct()
private fun windowsTarget(context: Context, entry: RecompCatalog.Entry): File =
File(AddedGames.roots(context).firstOrNull()?.host?.takeIf { it.canWrite() } ?: StoreInstallRoot.installRoot(context), "$WINDOWS_DIR/${entry.id}")
fun remove(context: Context, installed: Installed) {
AddedGames.remove(context, installed.dir)
FileUtils.delete(installed.dir)
}
private fun read(dir: File, name: String) = FileUtils.readString(File(dir, name))?.trim()?.takeIf { it.isNotEmpty() }
// The wrapper reads the linked folder at launch, so relinking a store install never needs a reinstall.
fun link(installed: Installed, guest: String?) {
val file = File(installed.dir, META_DATA)
if (guest == null) file.delete() else if (read(installed.dir, META_DATA) != guest) FileUtils.writeString(file, guest)
}
// The catalog pins a release so installs download straight from the release, which GitHub does not
// rate-limit; the releases API, limited to 60 unauthenticated calls an hour per address, only finds newer ones.
fun pinned(entry: RecompCatalog.Entry, build: RecompCatalog.Build): Release? {
val tag = entry.tag ?: return null
val file = build.file ?: return null
return Release(tag, entry.published, file,
"https://github.com/${entry.repo}/releases/download/${android.net.Uri.encode(tag)}/${android.net.Uri.encode(file)}", build.sha256)
}
fun latest(entry: RecompCatalog.Entry, build: RecompCatalog.Build): Release? {
val body = Downloader.downloadString("https://api.github.com/repos/${entry.repo}/releases?per_page=15") ?: return null
return pickRelease(body, build.asset, entry.prerelease)
}
internal fun pickRelease(body: String, asset: Regex, prerelease: Boolean): Release? {
val releases = runCatching { JSONArray(body) }.getOrNull() ?: return null
val candidates = (0 until releases.length()).mapNotNull { i ->
val r = releases.getJSONObject(i)
if (r.optBoolean("draft")) return@mapNotNull null
val assets = r.optJSONArray("assets") ?: return@mapNotNull null
val a = (0 until assets.length()).map { assets.getJSONObject(it) }.firstOrNull { asset.containsMatchIn(it.getString("name")) }
?: return@mapNotNull null
r.optBoolean("prerelease") to Release(r.optString("tag_name"), r.optString("published_at"), a.getString("name"),
a.getString("browser_download_url"), Hashes.githubSha256(a.optString("digest")))
}
return (candidates.firstOrNull { prerelease || !it.first } ?: candidates.firstOrNull())?.second
}
fun isNewer(release: Release, installed: Installed): Boolean =
release.tag != installed.tag && isAfter(release, installed)
private fun isAfter(release: Release, installed: Installed): Boolean =
if (!installed.published.isNullOrEmpty() && release.published.isNotEmpty()) release.published > installed.published
else release.tag != installed.tag
fun install(
context: Context, entry: RecompCatalog.Entry, build: RecompCatalog.Build, wanted: Release?, onProgress: (String, Int) -> Unit,
): String? {
if (!LinuxRuntime.isInstalled(context)) return context.getString(R.string.user_apps_runtime_required)
val release = wanted ?: pinned(entry, build) ?: run {
onProgress(context.getString(R.string.user_apps_github_checking, entry.repo), -1)
val body = Downloader.downloadString("https://api.github.com/repos/${entry.repo}/releases?per_page=15")
?: return context.getString(R.string.user_apps_github_unreachable, entry.repo)
pickRelease(body, build.asset, entry.prerelease) ?: return context.getString(R.string.recomps_no_build, entry.repo)
}
val work = File(context.cacheDir, "recomps").apply { mkdirs() }
val download = File(work, release.asset)
val stage = File(work, "stage-${entry.id}")
try {
val label = context.getString(R.string.user_apps_downloading, release.asset)
val ok = Downloader.downloadFile(release.url, download, true, release.sha256) { f -> onProgress(label, if (f < 0) -1 else Math.round(f * 100f)) }
if (!ok) return context.getString(R.string.user_apps_download_failed)
val meta = mapOf(META_ID to entry.id, META_TAG to release.tag, META_PUBLISHED to release.published, META_PLATFORM to build.platform.key)
val previous = installed(context)[entry.id]
val problem = if (build.platform == RecompCatalog.Platform.WINDOWS_X64) {
installWindows(context, entry, build, download, meta, previous, onProgress)
} else if (download.name.endsWith(".appimage", ignoreCase = true)) {
AppImageManager.import(context, download, entry.name, null, meta) { onProgress(it, -1) }
} else {
FileUtils.delete(stage)
stage.mkdirs()
onProgress(context.getString(R.string.recomps_unpacking, release.asset), -1)
unpack(context, download, stage)
val found = findEntry(stage, build.entry) ?: return context.getString(R.string.recomps_entry_missing, build.entry)
if (found.name.endsWith(".appimage", ignoreCase = true)) {
AppImageManager.import(context, found, entry.name, null, meta) { onProgress(it, -1) }
} else {
UserApps.addPrepared(context, entry.name, null, meta) { dir ->
val files = File(dir, "files")
if (!stage.renameTo(files)) throw IllegalStateException(context.getString(R.string.user_apps_failed))
markExecutables(files)
val rel = found.relativeTo(stage).invariantSeparatorsPath
FileUtils.writeString(File(files, WRAPPER), wrapper(rel, build))
File(files, WRAPPER).setExecutable(true, false)
WRAPPER
}
}
}
if (problem == null && previous != null && previous.dir != windowsTarget(context, entry)) {
val data = read(previous.dir, META_DATA)
FileUtils.delete(previous.dir)
installed(context)[entry.id]?.let { link(it, data) }
}
return problem
} catch (e: Exception) {
return e.message ?: context.getString(R.string.user_apps_failed)
} finally {
download.delete()
FileUtils.delete(stage)
}
}
private fun installWindows(
context: Context, entry: RecompCatalog.Entry, build: RecompCatalog.Build, download: File, meta: Map<String, String>,
previous: Installed?, onProgress: (String, Int) -> Unit,
): String? {
val target = windowsTarget(context, entry)
if (previous?.dir == target) AddedGames.remove(context, target)
FileUtils.delete(target)
target.mkdirs()
onProgress(context.getString(R.string.recomps_unpacking, download.name), -1)
if (download.name.endsWith(".exe", ignoreCase = true)) download.copyTo(File(target, download.name), true)
else unpack(context, download, target)
val exe = findEntry(target, build.entry.ifEmpty { download.name }) ?: return context.getString(R.string.recomps_entry_missing, build.entry)
meta.forEach { (k, v) -> FileUtils.writeString(File(target, k), v) }
return when (AddedGames.addExe(context, exe)) {
is AddedGames.AddResult.Added, is AddedGames.AddResult.Existing, is AddedGames.AddResult.Switched -> null
else -> context.getString(R.string.recomps_add_failed)
}
}
private fun unpack(context: Context, archive: File, into: File) {
var file = archive
val binds = if (listOf(context.filesDir, context.cacheDir).any { into.absolutePath.startsWith(it.absolutePath + "/") }) null
else listOf(into.absolutePath)
repeat(NESTED_LIMIT) { depth ->
val tail = ArrayDeque<String>()
val code = GuestCommand.run(context, listOf("/usr/bin/bsdtar", "-xf", file.absolutePath, "-C", into.absolutePath),
logName = "recomps", extraBinds = binds, fastPath = true) { line ->
if (!line.startsWith("proot ")) { if (tail.size == 4) tail.removeFirst(); tail.addLast(line) }
}
if (code != 0) throw IllegalStateException(context.getString(R.string.recomps_unpack_failed, code) + tail.joinToString(" | ", ": "))
if (depth > 0) file.delete()
val only = into.listFiles()?.singleOrNull()?.takeIf { it.isFile && ARCHIVE.containsMatchIn(it.name) } ?: return
file = only
}
}
internal fun findEntry(root: File, name: String): File? {
if (name.isEmpty()) return null
var level = listOf(root)
repeat(4) {
level.forEach { dir -> dir.listFiles()?.firstOrNull { it.isFile && it.name == name }?.let { return it } }
level.forEach { dir -> dir.listFiles()?.firstOrNull { it.isFile && it.name.equals(name, ignoreCase = true) }?.let { return it } }
level = level.flatMap { dir -> dir.listFiles()?.filter { it.isDirectory }?.sortedBy { it.name }.orEmpty() }
}
return null
}
private fun markExecutables(root: File) {
root.walkTopDown().maxDepth(6).filter { it.isFile && !java.nio.file.Files.isSymbolicLink(it.toPath()) && isElf(it) }
.forEach { runCatching { Os.chmod(it.path, 0b111_101_101) } }
}
private fun isElf(f: File): Boolean = runCatching {
RandomAccessFile(f, "r").use { val b = ByteArray(4); it.read(b) == 4 && b[0] == 0x7f.toByte() && b[1] == 'E'.code.toByte() && b[2] == 'L'.code.toByte() && b[3] == 'F'.code.toByte() }
}.getOrDefault(false)
private fun quote(s: String) = "'" + s.replace("'", "'\\''") + "'"
internal fun wrapper(entry: String, build: RecompCatalog.Build): String {
val program = "\"\$here\"/" + quote(entry)
val args = build.args.joinToString(" ") { arg ->
if ("{data}" in arg) arg.split("{data}").joinToString("\"\$data\"") { if (it.isEmpty()) "" else quote(it) } else quote(arg)
}
val enter = if (build.inData) " cd \"\$data\" || exit 1\n" else ""
return "#!/bin/sh\nhere=\$PWD\ndata=\$(cat ../$META_DATA 2>/dev/null)\n" +
"if [ -n \"\$data\" ]; then\n$enter exec $program${if (args.isEmpty()) "" else " $args"} \"\$@\"\nfi\n" +
"exec $program \"\$@\"\n"
}
}
@@ -74,7 +74,7 @@ object UserApps {
class ScriptPlan(val folder: File, val copy: Boolean, val bytes: Long)
private fun root(context: Context) = File(LinuxRuntime.rootDir(context), GUEST_DIR.substring(1))
internal fun root(context: Context) = File(LinuxRuntime.rootDir(context), GUEST_DIR.substring(1))
private fun overrides(context: Context, flatpakId: String) = File(root(context), "$FLATPAK_OVERRIDES/$flatpakId")
@@ -247,6 +247,27 @@ object UserApps {
}
}
// [prepare] fills the new app folder's `files` and returns the entry's name there, or throws.
internal fun addPrepared(context: Context, name: String, icon: File?, meta: Map<String, String>, prepare: (File) -> String): String? {
if (!LinuxRuntime.isInstalled(context)) return context.getString(R.string.user_apps_runtime_required)
val base = root(context).apply { mkdirs() }
val dir = File(base, AppImageManager.idFor(name, base.list()?.toSet() ?: emptySet()))
return try {
dir.mkdirs()
val entry = prepare(dir)
FileUtils.writeString(File(dir, "entry"), entry)
FileUtils.writeString(File(dir, "name"), name)
if (icon != null && !saveIcon(icon, File(dir, "icon.png"))) Log.w(TAG, "icon ${icon.path} could not be read")
meta.forEach { (k, v) -> FileUtils.writeString(File(dir, k), v) }
writeScriptEntry(context, dir)
null
} catch (e: Exception) {
Log.e(TAG, "prepared $name", e)
FileUtils.delete(dir)
e.message ?: context.getString(R.string.user_apps_failed)
}
}
private fun writeScriptEntry(context: Context, dir: File) {
val id = dir.name
val icon = if (File(dir, "icon.png").isFile) "$GUEST_DIR/$id/icon.png" else "utilities-terminal"
@@ -0,0 +1,76 @@
package com.droiddeck.launcher.store
import android.content.Context
import android.os.Handler
import android.os.Looper
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import com.droiddeck.launcher.R
import com.droiddeck.launcher.runtime.RecompCatalog
import com.droiddeck.launcher.runtime.RecompData
import com.droiddeck.launcher.runtime.RecompInstaller
object RecompsState {
private val main = Handler(Looper.getMainLooper())
var entries by mutableStateOf<List<RecompCatalog.Entry>>(emptyList())
private set
var installed by mutableStateOf<Map<String, RecompInstaller.Installed>>(emptyMap())
private set
var data by mutableStateOf<Map<String, RecompData.State>>(emptyMap())
private set
var updates by mutableStateOf<Map<String, RecompInstaller.Release>>(emptyMap())
private set
var loading by mutableStateOf(false)
private set
private var seq = 0
private var checked = false
internal var fixed = false
private set
internal fun show(
list: List<RecompCatalog.Entry>, have: Map<String, RecompInstaller.Installed>, states: Map<String, RecompData.State>,
newer: Map<String, RecompInstaller.Release>,
) {
fixed = true
entries = list; installed = have; data = states; updates = newer; loading = false
}
fun refresh(context: Context, steamOwned: Collection<Int>, reloadCatalog: Boolean = false) {
if (fixed) return
val app = context.applicationContext
val n = ++seq
loading = entries.isEmpty()
Thread({
val list = runCatching { RecompCatalog.load(app, reloadCatalog) }.getOrDefault(emptyList())
val have = runCatching { RecompInstaller.installed(app) }.getOrDefault(emptyMap())
val inputs = runCatching { RecompData.inputs(app, steamOwned) }.getOrNull()
val states = list.associate { e -> e.id to (inputs?.let { RecompData.resolve(e, it) } ?: RecompData.State.Missing(e.data.stores)) }
have.forEach { (id, i) -> RecompInstaller.link(i, (states[id] as? RecompData.State.Found)?.guest) }
main.post {
if (n != seq) return@post
entries = list; installed = have; data = states; loading = false
}
if (!checked && have.isNotEmpty()) {
checked = true
val found = list.filter { it.id in have }.mapNotNull { e ->
val i = have.getValue(e.id)
val build = RecompCatalog.Platform.of(i.platform.orEmpty())?.let { e.build(it) } ?: return@mapNotNull null
val newest = (RecompInstaller.pinned(e, build) ?: runCatching { RecompInstaller.latest(e, build) }.getOrNull())
?.takeIf { RecompInstaller.isNewer(it, i) }
newest?.let { e.id to it }
}.toMap()
main.post { updates = found }
}
}, "recomps-refresh").start()
}
fun install(context: Context, entry: RecompCatalog.Entry, steamOwned: Collection<Int>, release: RecompInstaller.Release? = null) {
val build = installed[entry.id]?.platform?.let { RecompCatalog.Platform.of(it) }?.let { entry.build(it) } ?: entry.preferred() ?: return
UserAppsState.run(context, entry.name, R.string.recomps_installed, after = {
updates = updates - entry.id
refresh(context, steamOwned)
}) { app, progress -> RecompInstaller.install(app, entry, build, release, progress) }
}
}
@@ -69,7 +69,7 @@ object UserAppsState {
UserApps.update(app, target, release, progress).also { if (it == null) main.post { updates = updates - target.key } }
}
private fun run(context: Context, label: String, done: Int, work: (Context, (String, Int) -> Unit) -> String?) {
internal fun run(context: Context, label: String, done: Int, after: () -> Unit = {}, work: (Context, (String, Int) -> Unit) -> String?) {
if (working != null) return
val app = context.applicationContext
working = label; stage = null; percent = -1; lastError = null
@@ -85,6 +85,7 @@ object UserAppsState {
if (problem == null) Toast.makeText(app, app.getString(done, label), Toast.LENGTH_SHORT).show()
refresh(app)
StoreState.refresh(app)
after()
}
}, "user-apps-work").start()
}
@@ -267,6 +267,10 @@ private fun Content(
SteamTabPage(selected, a, modifier.padding(horizontal = padH).padding(top = padV))
return
}
if (selected == "recomps") {
RecompsPage(s, a, onSelect, modifier.padding(horizontal = padH).padding(top = padV))
return
}
if (selected == "updates") {
UpdatesPage(s, a, modifier.padding(horizontal = padH).padding(top = padV))
return
@@ -56,6 +56,7 @@ import androidx.compose.material.icons.filled.Terminal
import androidx.compose.material.icons.filled.Apps
import androidx.compose.material.icons.filled.Settings
import androidx.compose.material.icons.filled.SdStorage
import androidx.compose.material.icons.filled.Memory
import androidx.compose.material.icons.filled.Movie
import androidx.compose.material.icons.filled.Sync
import androidx.compose.material.icons.filled.MoreHoriz
@@ -208,6 +209,7 @@ internal fun railLabelIcon(key: String): Pair<Int, ImageVector> = when (key) {
"sync" -> R.string.rail_sync to Icons.Filled.Sync
"decky" -> R.string.rail_decky to DeckyIcon
"boot-movies" -> R.string.rail_boot_movies to Icons.Filled.Movie
"recomps" -> R.string.rail_recomps to Icons.Filled.Memory
NavTabs.MORE -> R.string.rail_more to Icons.Filled.MoreHoriz
else -> R.string.rail_updates to updatesIcon(RunningBuild.kind())
}
@@ -26,10 +26,10 @@ internal object DeveloperTools {
internal object NavTabs {
const val MORE = "more"
val ALL = listOf("steam", "desktop", "games", "downloads", "setup", "updates", "stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies", "android-apps", "agent")
val DEFAULT_SHELVED = setOf("stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies", "agent")
val ALL = listOf("steam", "desktop", "games", "downloads", "setup", "updates", "stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies", "recomps", "android-apps", "agent")
val DEFAULT_SHELVED = setOf("stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies", "recomps", "agent")
val DEFAULT_HIDDEN = setOf("android-apps", "agent")
private val SHELVED_WHEN_NEW = setOf("storage", "sync", "decky", "boot-movies", "agent")
private val SHELVED_WHEN_NEW = setOf("storage", "sync", "decky", "boot-movies", "recomps", "agent")
private val OLD_ORDER = listOf("steam", "games", "soundtracks", "stores", "downloads", "desktop", "agent", "components", "android-apps", "storage", "sync", "setup", "updates")
private val OLD_SHELVED = setOf("soundtracks", "agent", "storage", "sync")
private const val LAYOUT_VERSION = 2
@@ -0,0 +1,239 @@
package com.droiddeck.launcher.ui
import android.content.Intent
import android.net.Uri
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import coil.compose.AsyncImage
import com.droiddeck.launcher.R
import com.droiddeck.launcher.frontend.Library
import com.droiddeck.launcher.runtime.RecompCatalog
import com.droiddeck.launcher.runtime.RecompData
import com.droiddeck.launcher.runtime.RecompInstaller
import com.droiddeck.launcher.store.RecompsState
import com.droiddeck.launcher.store.UserAppsState
import com.droiddeck.launcher.stores.Store
import com.droiddeck.launcher.stores.StoresState
internal enum class RecompFilter { ALL, OWNED, BRING, INSTALLED }
internal class RecompRow(
val entry: RecompCatalog.Entry, val data: RecompData.State, val installed: RecompInstaller.Installed?,
val update: RecompInstaller.Release?,
)
internal fun recompRows(): List<RecompRow> = RecompsState.entries.map { e ->
RecompRow(e, RecompsState.data[e.id] ?: RecompData.State.Missing(e.data.stores), RecompsState.installed[e.id], RecompsState.updates[e.id])
}
internal fun RecompRow.matches(filter: RecompFilter): Boolean = when (filter) {
RecompFilter.ALL -> true
RecompFilter.OWNED -> data is RecompData.State.Found || data is RecompData.State.Owned || data is RecompData.State.Incomplete
RecompFilter.BRING -> data is RecompData.State.BringYourOwn
RecompFilter.INSTALLED -> installed != null
}
// Installed first, then the ones whose game you already own, then the rest, each alphabetical.
internal fun RecompRow.rank(): Int = when {
installed != null -> 0
data is RecompData.State.Found -> 1
data is RecompData.State.Owned || data is RecompData.State.Incomplete -> 2
data is RecompData.State.BringYourOwn -> 3
else -> 4
}
@Composable
internal fun RecompsPage(s: FrontEndState, a: FrontEndActions, onSelect: (String) -> Unit, modifier: Modifier) {
val ctx = LocalContext.current
val steamOwned = s.steamGames.filter { it.source == Library.SOURCE_STEAM }.map { it.appId }
LaunchedEffect(steamOwned.size, StoresState.installed.size, StoresState.library.size) {
RecompsState.refresh(ctx, steamOwned)
UserAppsState.refresh(ctx)
}
var filter by rememberSaveable { mutableStateOf(RecompFilter.ALL) }
val rows = recompRows().sortedWith(compareBy<RecompRow> { it.rank() }.thenBy { it.entry.name.lowercase() })
Column(modifier.verticalScroll(rememberScrollState()).padding(bottom = 24.dp)) {
PageHeader(stringResource(R.string.rail_recomps))
Lede(stringResource(R.string.recomps_lede))
Row(Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()).padding(bottom = 12.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
RecompFilter.entries.forEach { f ->
val count = rows.count { it.matches(f) }
TabChip("${filterLabel(f)} · $count", filter == f, Modifier.testTag("recomps-filter-${f.name.lowercase()}")) { filter = f }
}
}
UserAppsState.lastError?.let { Note(it) }
val shown = rows.filter { it.matches(filter) }
when {
RecompsState.loading -> Text("…", color = MaterialTheme.colorScheme.onSurfaceVariant)
rows.isEmpty() -> Note(stringResource(R.string.recomps_empty))
shown.isEmpty() -> Note(stringResource(R.string.recomps_none_here))
else -> BoxWithConstraints(Modifier.fillMaxWidth()) {
val columns = if (maxWidth >= 820.dp) 2 else 1
val gap = 12.dp
Column(verticalArrangement = Arrangement.spacedBy(gap)) {
shown.chunked(columns).forEachIndexed { r, line ->
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(gap)) {
line.forEachIndexed { c, row ->
RecompCard(row, s, a, onSelect, first = r == 0 && c == 0, steamOwned = steamOwned, modifier = Modifier.weight(1f))
}
repeat(columns - line.size) { Spacer(Modifier.weight(1f)) }
}
}
}
}
}
}
}
@Composable
private fun filterLabel(f: RecompFilter) = stringResource(when (f) {
RecompFilter.ALL -> R.string.recomps_filter_all
RecompFilter.OWNED -> R.string.recomps_filter_owned
RecompFilter.BRING -> R.string.recomps_filter_bring
RecompFilter.INSTALLED -> R.string.recomps_filter_installed
})
@Composable
private fun buildLabel(platform: RecompCatalog.Platform?) = stringResource(when (platform) {
RecompCatalog.Platform.LINUX_ARM64 -> R.string.recomps_build_linux_arm64
RecompCatalog.Platform.LINUX_X64 -> R.string.recomps_build_linux_x64
RecompCatalog.Platform.WINDOWS_X64 -> R.string.recomps_build_windows_x64
else -> R.string.recomps_build_none
})
private fun storeName(store: Store) = store.shortLabel
@Composable
private fun dataLine(data: RecompData.State): Pair<String, Boolean>? = when (data) {
RecompData.State.NotNeeded -> null
is RecompData.State.Found -> stringResource(R.string.recomps_data_found, storeName(data.store)) to true
is RecompData.State.Owned -> stringResource(R.string.recomps_data_owned, storeName(data.store)) to false
is RecompData.State.Incomplete -> stringResource(R.string.recomps_data_incomplete, storeName(data.store)) to false
is RecompData.State.Missing -> stringResource(R.string.recomps_data_missing, data.refs.map { storeName(it.store) }.distinct().joinToString(" / ")) to false
is RecompData.State.BringYourOwn -> stringResource(R.string.recomps_data_bring, data.data.label) to false
}
internal fun storeUrl(ref: RecompCatalog.StoreRef, game: String): String = when (ref.store) {
Store.STEAM -> "https://store.steampowered.com/app/${ref.id}/"
Store.GOG -> "https://www.gog.com/en/games?query=" + Uri.encode(game)
else -> "https://www.google.com/search?q=" + Uri.encode("${ref.store.shortLabel} $game")
}
@OptIn(ExperimentalLayoutApi::class)
@Composable
private fun RecompCard(
row: RecompRow, s: FrontEndState, a: FrontEndActions, onSelect: (String) -> Unit, first: Boolean, steamOwned: List<Int>, modifier: Modifier,
) {
val ctx = LocalContext.current
val colors = MaterialTheme.colorScheme
val pal = LocalPalette.current
val e = row.entry
val shape = RoundedCornerShape(18.dp)
val build = row.installed?.platform?.let { RecompCatalog.Platform.of(it) } ?: e.preferred()?.platform
val busy = UserAppsState.working
val mine = busy == e.name
val open = { url: String -> runCatching { ctx.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)) } }
Column(
modifier.testTag("recomp-${e.id}").clip(shape).background(colors.surface).border(1.dp, pal.line, shape).padding(14.dp),
verticalArrangement = Arrangement.spacedBy(10.dp),
) {
Row(horizontalArrangement = Arrangement.spacedBy(12.dp), verticalAlignment = Alignment.CenterVertically) {
Box(Modifier.size(64.dp).clip(Shape12).background(artBrush(hueOf(e.name))), contentAlignment = Alignment.Center) {
Text(e.name.take(1), fontSize = 26.sp, fontWeight = FontWeight.Bold, color = colors.onBackground.copy(alpha = 0.6f))
if (e.art != null) AsyncImage(model = e.art, contentDescription = null, contentScale = ContentScale.Crop, modifier = Modifier.matchParentSize())
}
Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(2.dp)) {
Text(e.name, fontSize = 16.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis)
val kind = stringResource(if (e.type == "recomp") R.string.recomps_kind_recomp else R.string.recomps_kind_port, e.origin)
Text("${e.game} · $kind", fontSize = 12.sp, color = colors.onSurfaceVariant, maxLines = 2, overflow = TextOverflow.Ellipsis)
}
}
FlowRow(horizontalArrangement = Arrangement.spacedBy(6.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {
Chip(buildLabel(build), ok = row.installed != null)
dataLine(row.data)?.let { (t, ok) -> Chip(t, ok) }
if (e.android != null) Chip(stringResource(R.string.recomps_android_too), ok = false)
}
val found = row.data as? RecompData.State.Found
if (found != null) Text(stringResource(R.string.recomps_data_folder, found.guest), fontSize = 11.sp, color = colors.onSurfaceVariant,
maxLines = 1, overflow = TextOverflow.Ellipsis)
if (row.data is RecompData.State.BringYourOwn && row.data.data.note.isNotEmpty()) {
Text(row.data.data.note, fontSize = 11.sp, color = colors.onSurfaceVariant, maxLines = 2, overflow = TextOverflow.Ellipsis)
}
if (mine && UserAppsState.stage != null) Text(UserAppsState.stage.orEmpty(), fontSize = 11.sp, color = pal.signal, maxLines = 1, overflow = TextOverflow.Ellipsis)
val focus = if (first) Modifier.paneEntry() else Modifier.paneItem("recomp:${e.id}")
FlowRow(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {
val inst = row.installed
val progress = if (mine) UserAppsState.percent.takeIf { it >= 0 }?.let { it / 100f } else null
when {
inst == null -> PrimaryButton(stringResource(R.string.recomps_install), enabled = build != null && busy == null && s.ready, main = true,
compact = true, progress = progress, modifier = focus.testTag("recomp-install-${e.id}")) {
RecompsState.install(ctx, e, steamOwned)
}
inst.appKey.startsWith("added:") -> PrimaryButton(stringResource(R.string.recomps_open_games), main = true, compact = true, modifier = focus) {
onSelect("games")
}
else -> PrimaryButton(stringResource(R.string.recomps_play), main = true, compact = true, enabled = !s.busy, modifier = focus.testTag("recomp-play-${e.id}")) {
UserAppsState.items.firstOrNull { it.key == inst.appKey }?.let(a.onUserApp)
}
}
if (inst != null && row.update != null) SecondaryButton(stringResource(R.string.recomps_update, row.update.tag), enabled = busy == null,
compact = true, progress = progress) { RecompsState.install(ctx, e, steamOwned, row.update) }
when (val d = row.data) {
is RecompData.State.Owned -> if (d.item != null) SecondaryButton(stringResource(R.string.recomps_install_game), compact = true) {
StoresState.requestInstall(ctx, d.item)
} else SecondaryButton(stringResource(R.string.recomps_store_page), compact = true) {
e.data.stores.firstOrNull { it.store == d.store }?.let { open(storeUrl(it, e.game)) }
}
is RecompData.State.Missing -> d.refs.firstOrNull()?.let { ref ->
SecondaryButton(stringResource(R.string.recomps_store_page), compact = true) { open(storeUrl(ref, e.game)) }
}
else -> {}
}
if (inst != null) SecondaryButton(stringResource(R.string.recomps_remove), enabled = busy == null, compact = true) {
if (inst.appKey.startsWith("added:")) {
UserAppsState.run(ctx, e.name, R.string.recomps_removed, after = { RecompsState.refresh(ctx, steamOwned) }) { app, _ ->
RecompInstaller.remove(app, inst); null
}
} else UserAppsState.items.firstOrNull { it.key == inst.appKey }?.let { app ->
UserAppsState.run(ctx, e.name, R.string.recomps_removed, after = { RecompsState.refresh(ctx, steamOwned) }) { c, p ->
com.droiddeck.launcher.runtime.UserApps.remove(c, app, p)
}
}
} else SecondaryButton(stringResource(R.string.recomps_project), compact = true) { open(e.homepage) }
}
}
}
+36
View File
@@ -4405,6 +4405,42 @@
<string name="decky_release_channel">Release channel</string>
<string name="rail_decky">Decky</string>
<string name="rail_boot_movies">Boot movies</string>
<string name="rail_recomps">Recomps</string>
<string name="recomps_lede">PC builds of classic games, made by recompiling or reimplementing them. DroidDeck installs the build and finds the game files you already own. It never downloads ROMs or game files.</string>
<string name="recomps_filter_all">All</string>
<string name="recomps_filter_owned">You own the game</string>
<string name="recomps_filter_bring">Bring your own files</string>
<string name="recomps_filter_installed">Installed</string>
<string name="recomps_empty">The recomp list couldn\'t be loaded.</string>
<string name="recomps_none_here">Nothing here yet.</string>
<string name="recomps_kind_recomp">%1$s recomp</string>
<string name="recomps_kind_port">%1$s port</string>
<string name="recomps_build_linux_arm64">Linux ARM64 · native</string>
<string name="recomps_build_linux_x64">Linux x86-64 · FEX</string>
<string name="recomps_build_windows_x64">Windows · Proton</string>
<string name="recomps_build_none">No build DroidDeck can run</string>
<string name="recomps_android_too">Android app too</string>
<string name="recomps_data_found">Game files found (%1$s)</string>
<string name="recomps_data_owned">You own it on %1$s. Install it first</string>
<string name="recomps_data_incomplete">Installed on %1$s, but the needed files are missing</string>
<string name="recomps_data_missing">Needs %1$s</string>
<string name="recomps_data_bring">Needs your own %1$s</string>
<string name="recomps_data_folder">Game folder: %1$s</string>
<string name="recomps_install">Install</string>
<string name="recomps_play">Play</string>
<string name="recomps_open_games">Open in Games</string>
<string name="recomps_update">Update to %1$s</string>
<string name="recomps_remove">Remove</string>
<string name="recomps_install_game">Install game</string>
<string name="recomps_store_page">Store page</string>
<string name="recomps_project">Project page</string>
<string name="recomps_installed">%1$s installed</string>
<string name="recomps_removed">%1$s removed</string>
<string name="recomps_no_build">No release of %1$s has a build DroidDeck can run</string>
<string name="recomps_unpacking">Unpacking %1$s</string>
<string name="recomps_unpack_failed">Unpacking failed (exit %1$d)</string>
<string name="recomps_entry_missing">The download has no %1$s</string>
<string name="recomps_add_failed">The Windows build couldn\'t be added to your games</string>
<string name="decky_tab_installed">Installed · %1$d</string>
<string name="decky_tab_store">Store</string>
<string name="decky_tab_zip">From ZIP</string>
@@ -0,0 +1,169 @@
package com.droiddeck.launcher.runtime
import com.droiddeck.launcher.stores.CatalogItem
import com.droiddeck.launcher.stores.Store
import java.io.File
import java.util.concurrent.TimeUnit
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TemporaryFolder
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
@RunWith(RobolectricTestRunner::class)
class RecompsTest {
@get:Rule val temporary = TemporaryFolder()
private val bundled by lazy { RecompCatalog.parse(File("src/main/assets/${RecompCatalog.BUNDLED}").readText())!! }
@Test fun theBundledCatalogParsesAndEveryEntryHasARunnableBuild() {
assertTrue(bundled.size >= 8)
assertEquals(bundled.size, bundled.map { it.id }.distinct().size)
for (e in bundled) {
assertNotNull(e.id, e.preferred())
for (b in e.builds.filter { it.platform != RecompCatalog.Platform.ANDROID && it.platform != RecompCatalog.Platform.WINDOWS_X64 }) {
assertTrue("${e.id} ${b.platform} needs an entry or an AppImage", b.entry.isNotEmpty() || b.asset.pattern.contains("AppImage", ignoreCase = true))
}
if (e.data.kind == RecompCatalog.DataKind.STORE) {
assertTrue(e.id, e.data.stores.isNotEmpty())
assertNotNull(e.id, e.data.probe)
}
}
}
@Test fun nativeArmIsPreferredOverFexAndFexOverProton() {
val zelda = bundled.first { it.id == "zelda64recomp" }
assertEquals(RecompCatalog.Platform.LINUX_ARM64, zelda.preferred()?.platform)
assertEquals(RecompCatalog.Platform.LINUX_X64, bundled.first { it.id == "ironwail" }.preferred()?.platform)
assertEquals(RecompCatalog.Platform.WINDOWS_X64, bundled.first { it.id == "unleashedrecomp" }.preferred()?.platform)
}
@Test fun aNewerSchemaAndBadEntriesAreRefused() {
assertNull(RecompCatalog.parse("""{"schema": 99, "recomps": []}"""))
val list = RecompCatalog.parse("""{"schema":1,"recomps":[
{"id":"ok","name":"Ok","repo":"a/b","builds":{"linux-x64":{"asset":"x","entry":"x"}}},
{"id":"../evil","name":"Bad","repo":"a/b"},
{"id":"bad-repo","name":"Bad","repo":"https://evil"},
{"id":"probe","name":"P","repo":"a/b","data":{"kind":"store","stores":[{"store":"steam","id":"1"},{"store":"nowhere","id":"2"}],"probe":"../etc"}}
]}""")!!
assertEquals(listOf("ok", "probe"), list.map { it.id })
assertNull(list[1].data.probe)
assertEquals(listOf(Store.STEAM), list[1].data.stores.map { it.store })
}
@Test fun theNewestStableReleaseWithAMatchingAssetIsPicked() {
val body = """[
{"tag_name":"v3","draft":true,"assets":[{"name":"Game-Linux-ARM64.zip","browser_download_url":"https://d/3"}]},
{"tag_name":"v2-rc","prerelease":true,"published_at":"2026-02-01T00:00:00Z","assets":[{"name":"Game-Linux-ARM64.zip","browser_download_url":"https://d/2"}]},
{"tag_name":"v1","published_at":"2026-01-01T00:00:00Z","assets":[
{"name":"Game-Windows.zip","browser_download_url":"https://d/w"},
{"name":"Game-Linux-ARM64.zip","browser_download_url":"https://d/1","digest":"sha256:${"a".repeat(64)}"}]}
]"""
val asset = Regex("^Game-Linux-ARM64\\.zip$", RegexOption.IGNORE_CASE)
val stable = RecompInstaller.pickRelease(body, asset, prerelease = false)!!
assertEquals("v1", stable.tag)
assertEquals("https://d/1", stable.url)
assertEquals("a".repeat(64), stable.sha256)
assertEquals("v2-rc", RecompInstaller.pickRelease(body, asset, prerelease = true)!!.tag)
assertNull(RecompInstaller.pickRelease(body, Regex("macOS"), prerelease = false))
}
@Test fun aPinnedReleaseDownloadsStraightFromTheReleaseWithItsDigest() {
val e = RecompCatalog.parse("""{"schema":1,"recomps":[{"id":"z","name":"Z","repo":"o/r","release":{"tag":"v 1+2","published":"p"},
"builds":{"linux-arm64":{"asset":"x","entry":"z","file":"Z Linux.zip","sha256":"${"B".repeat(64)}"},
"linux-x64":{"asset":"y","entry":"z","file":"../bad","sha256":"short"}}}]}""")!!.single()
val arm = RecompInstaller.pinned(e, e.build(RecompCatalog.Platform.LINUX_ARM64)!!)!!
assertEquals("https://github.com/o/r/releases/download/v%201%2B2/Z%20Linux.zip", arm.url)
assertEquals("b".repeat(64), arm.sha256)
assertEquals("v 1+2", arm.tag)
assertNull(RecompInstaller.pinned(e, e.build(RecompCatalog.Platform.LINUX_X64)!!))
val installed = RecompInstaller.Installed("z", "script:z", "v 1+2", "p", "linux-arm64", temporary.root)
assertTrue(!RecompInstaller.isNewer(arm, installed))
assertTrue(RecompInstaller.isNewer(RecompInstaller.Release("v2", "q", "", "", null), installed))
}
@Test fun theWrapperPassesTheLinkedFolderOnlyWhenOneIsLinked() {
val app = temporary.newFolder("app")
val files = File(app, "files/Game-1.0").apply { mkdirs() }
File(files, "game").apply {
writeText("#!/bin/sh\necho \"cwd=\$PWD\"\nfor a in \"\$@\"; do echo \"arg=\$a\"; done\n")
setExecutable(true)
}
val build = RecompCatalog.Build(RecompCatalog.Platform.LINUX_X64, Regex("x"), "game", listOf("--data-dir", "{data}", "-x", "it's"), inData = false)
val wrapper = File(app, "files/${RecompInstaller.WRAPPER}").apply { writeText(RecompInstaller.wrapper("Game-1.0/game", build)) }
assertEquals(listOf("cwd=${app.canonicalPath}/files"), run(wrapper, "files").filter { it.startsWith("cwd") }.map { it.replace(app.path, app.canonicalPath) })
assertEquals(emptyList<String>(), run(wrapper, "files").filter { it.startsWith("arg") })
val data = temporary.newFolder("Game Data")
File(app, RecompInstaller.META_DATA).writeText(data.path)
assertEquals(listOf("arg=--data-dir", "arg=${data.path}", "arg=-x", "arg=it's", "arg=extra"),
run(wrapper, "files", "extra").filter { it.startsWith("arg") })
val inData = RecompCatalog.Build(RecompCatalog.Platform.LINUX_X64, Regex("x"), "game", emptyList(), inData = true)
wrapper.writeText(RecompInstaller.wrapper("Game-1.0/game", inData))
assertEquals(listOf("cwd=${data.canonicalPath}"), run(wrapper, "files").filter { it.startsWith("cwd") }.map { it.replace(data.path, data.canonicalPath) })
}
private fun run(wrapper: File, cwd: String, vararg args: String): List<String> {
val p = ProcessBuilder(listOf("/bin/sh", wrapper.name) + args).directory(File(wrapper.parentFile.parentFile, cwd)).redirectErrorStream(true).start()
p.waitFor(10, TimeUnit.SECONDS)
return p.inputStream.bufferedReader().readLines()
}
@Test fun theEntryIsFoundInsideAVersionedFolder() {
val root = temporary.newFolder("stage")
File(root, "ironwail-0.8.2-linux-x64").mkdirs()
File(root, "ironwail-0.8.2-linux-x64/ironwail").writeText("x")
File(root, "ironwail-0.8.2-linux-x64/ironwail.pak").writeText("x")
assertEquals("ironwail-0.8.2-linux-x64/ironwail", RecompInstaller.findEntry(root, "ironwail")!!.relativeTo(root).path)
assertNull(RecompInstaller.findEntry(root, "missing"))
}
@Test fun gameFilesAreProbedWithoutCaseAtTheShallowestFolder() {
val install = temporary.newFolder("Quake")
File(install, "rerelease/id1").mkdirs()
File(install, "rerelease/id1/pak0.pak").writeText("x")
File(install, "Id1").mkdirs()
File(install, "Id1/PAK0.PAK").writeText("x")
assertEquals(install, RecompData.probeDir(install, "id1/pak0.pak"))
File(install, "Id1/PAK0.PAK").delete()
assertEquals(File(install, "rerelease"), RecompData.probeDir(install, "id1/pak0.pak"))
assertNull(RecompData.probeDir(install, "DIABDAT.MPQ"))
}
@Test fun storeDataResolvesToTheInstalledCopyThenOwnershipThenAStoreLink() {
val quake = bundled.first { it.id == "ironwail" }
val dir = temporary.newFolder("steamapps", "common", "Quake")
File(dir, "id1").mkdirs()
File(dir, "id1/PAK0.PAK").writeText("x")
val gogInstall = RecompData.Install(Store.GOG, "1440166133", temporary.newFolder("gog-quake"), "/root/Games/Stores/GOG/Quake")
val steamInstall = RecompData.Install(Store.STEAM, "2310", dir, "/root/.local/share/Steam/steamapps/common/Quake")
val found = RecompData.resolve(quake, RecompData.Inputs(listOf(gogInstall, steamInstall), emptySet(), emptyMap()))
found as RecompData.State.Found
assertEquals(Store.STEAM, found.store)
assertEquals("/root/.local/share/Steam/steamapps/common/Quake", found.guest)
val incomplete = RecompData.resolve(quake, RecompData.Inputs(listOf(gogInstall), emptySet(), emptyMap()))
assertEquals(Store.GOG, (incomplete as RecompData.State.Incomplete).store)
val item = CatalogItem(Store.GOG, "1440166133", "Quake", null)
val owned = RecompData.resolve(quake, RecompData.Inputs(emptyList(), setOf(RecompData.key(Store.GOG, "1440166133")), mapOf(RecompData.key(Store.GOG, "1440166133") to item)))
assertEquals(item, (owned as RecompData.State.Owned).item)
val missing = RecompData.resolve(quake, RecompData.Inputs(emptyList(), emptySet(), emptyMap()))
assertEquals(listOf(Store.STEAM, Store.GOG), (missing as RecompData.State.Missing).refs.map { it.store })
assertTrue(RecompData.resolve(bundled.first { it.id == "zelda64recomp" }, RecompData.Inputs(emptyList(), emptySet(), emptyMap())) is RecompData.State.BringYourOwn)
}
@Test fun aNestedFolderInTheInstallGivesANestedGuestPath() {
val diablo = bundled.first { it.id == "devilutionx" }
val host = temporary.newFolder("Diablo")
File(host, "hellfire").mkdirs()
File(host, "hellfire/diabdat.mpq").writeText("x")
val state = RecompData.resolve(diablo, RecompData.Inputs(listOf(RecompData.Install(Store.GOG, "1412601690", host, "/mnt/droiddeck-stores/abc/GOG/Diablo")), emptySet(), emptyMap()))
assertEquals("/mnt/droiddeck-stores/abc/GOG/Diablo/hellfire", (state as RecompData.State.Found).guest)
}
}
@@ -41,7 +41,7 @@ class NavTabsTest {
@Test fun aFreshInstallShowsTheDefaultBarMoreAndHiddenTabs() {
assertEquals(listOf("steam", "desktop", "games", "downloads", "setup", "updates", NavTabs.MORE), navigationKeys(state()))
assertEquals(listOf("stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies"), NavTabs.more(state()))
assertEquals(listOf("stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies", "recomps"), NavTabs.more(state()))
assertEquals(TabPlace.HIDDEN, NavTabs.place(state(), "android-apps"))
assertEquals(TabPlace.HIDDEN, NavTabs.place(state(), "agent"))
assertFalse(com.droiddeck.launcher.agent.AgentTab.shown)
@@ -72,7 +72,7 @@ class NavTabsTest {
@Test fun shelvedTabsLeaveTheBarAndAddMoreAtTheEnd() {
place("desktop", TabPlace.MORE)
val s = state()
assertEquals(listOf("desktop", "stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies"), NavTabs.more(s))
assertEquals(listOf("desktop", "stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies", "recomps"), NavTabs.more(s))
assertEquals(NavTabs.MORE, navigationKeys(s).last())
assertFalse("desktop" in navigationKeys(s))
}
@@ -101,7 +101,7 @@ class NavTabsTest {
NavTabs.load(ctx)
val s = state()
assertEquals(listOf("steam", "games", "desktop", "components", "setup", "updates", NavTabs.MORE), navigationKeys(s))
assertEquals(listOf("storage", "sync", "decky", "boot-movies"), NavTabs.more(s))
assertEquals(listOf("storage", "sync", "decky", "boot-movies", "recomps"), NavTabs.more(s))
listOf("stores", "downloads", "soundtracks", "android-apps", "agent").forEach { assertEquals(it, TabPlace.HIDDEN, NavTabs.place(s, it)) }
val prefs = ctx.getSharedPreferences("session", Context.MODE_PRIVATE)
assertFalse(prefs.contains("gameStoresEnabled"))
@@ -123,7 +123,7 @@ class NavTabsTest {
assertEquals(TabPlace.HIDDEN, NavTabs.place(state(), "stores"))
assertEquals(TabPlace.MORE, NavTabs.place(state(), "components"))
assertEquals(TabPlace.BAR, NavTabs.place(state(), "downloads"))
assertEquals(listOf("components", "storage", "sync", "decky", "boot-movies"), NavTabs.more(state()))
assertEquals(listOf("components", "storage", "sync", "decky", "boot-movies", "recomps"), NavTabs.more(state()))
}
@Test fun movingSwapsWithTheNextVisibleTabAndPersists() {
@@ -134,9 +134,9 @@ class NavTabsTest {
}
@Test fun tabsMissingFromASavedOrderSlotInAfterTheirDefaultNeighbour() {
assertEquals(listOf("updates", "stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies", "android-apps", "agent", "steam", "desktop", "games", "downloads", "setup"),
assertEquals(listOf("updates", "stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies", "recomps", "android-apps", "agent", "steam", "desktop", "games", "downloads", "setup"),
NavTabs.arrange(listOf("updates", "steam")))
assertEquals(listOf("games", "downloads", "steam", "setup", "stores", "soundtracks", "desktop", "components", "storage", "sync", "decky", "boot-movies", "android-apps", "agent", "updates"),
assertEquals(listOf("games", "downloads", "steam", "setup", "stores", "soundtracks", "desktop", "components", "storage", "sync", "decky", "boot-movies", "recomps", "android-apps", "agent", "updates"),
NavTabs.arrange(listOf("games", "steam", "setup", "stores", "desktop", "components", "android-apps", "updates", "bogus")))
}
@@ -145,7 +145,7 @@ class NavTabsTest {
.putString("navTabOrder", "steam,games,soundtracks,stores,desktop,agent,components,android-apps,setup,updates")
.putString("navTabShelved", "soundtracks").commit()
NavTabs.load(ctx)
assertEquals(listOf("soundtracks", "storage", "sync", "decky", "boot-movies"), NavTabs.more(state()))
assertEquals(listOf("soundtracks", "storage", "sync", "decky", "boot-movies", "recomps"), NavTabs.more(state()))
place("sync", TabPlace.BAR)
NavTabs.load(ctx)
assertTrue("sync" in navigationKeys(state()))
+162
View File
@@ -0,0 +1,162 @@
# Recomps
The Recomps tab (More → Recomps, key `recomps`) lists PC builds of console and PC games made
by static recompilation, decompilation or engine reimplementation. It installs the build that
runs best on the device and links the game files the player already owns from a store
DroidDeck is signed in to. It never downloads ROMs, disc images or game files.
## The ecosystem (researched 2026-11-30)
- **Recomp Launcher** (`elripalda/RecompLauncher`, GPL-3.0; Xarishark is its most active
contributor). A Tauri desktop launcher for Windows, Linux x86-64 and macOS. It has no Android
or arm64 Linux build. Its catalog `https://recomplauncher.com/pc-catalog.json` lists about 2,270
apps, each with fields such as `repo, tag, assets{windows|linux|macos}, files{sha256}, needs,
setup_steps`. It never ships game data: "Easy Setup" asks for the player's disc or folder,
then runs the recomp's own prepare step. Recomps can describe that step in a
`recomplauncher.json` in their release (schema at
`https://recomplauncher.com/schema/recomplauncher.json`). The FAQ says it is free, has no ads
and keeps usage stats opt-in. The catalog data has no stated licence, and many `needs` lines
are machine-written.
- **Recompa** (`kalasyan/recompa`, GPL-3.0). An Android hub for recomps shipped as APKs. Its
`https://recompa.app/index.json` lists about 790 ports with Android package names, signer
hashes, ABIs and game-data requirements (accepted sha1s, conversions such as v64→z64, and
where the file goes). The data has no stated licence.
- **PortMaster** (`PortsMaster/PortMaster-New`, MIT). Its `ports.json` lists about 1,500 arm64
Linux ports. 266 of them link a Steam page and about 64 a GOG page, so they can be matched to
owned games. Ports expect PortMaster's runtime (`control.txt`, gptokeyb, gl4es).
- Most recomps need a console dump: N64 ROMs (Zelda64Recomp, Starfox64Recomp, BanjoRecomp, the
Ship of Harkinian family) or Xbox 360 files (XenonRecomp: UnleashedRecomp, MarathonRecomp).
The ones that fit DroidDeck's stores are source ports and engine reimplementations whose data
is sold on Steam or GOG: OpenMW (Morrowind), DevilutionX (Diablo, GOG), OpenRCT2, Fallout 1/2
CE, Quake ports, Xash3D (Half-Life), Julius/Augustus (Caesar III), VCMI and fheroes2 (Heroes
III and II), CorsixTH and OpenLoco.
- N64Recomp projects (Zelda, Starfox, Banjo), DevilutionX, Xash3D and fheroes2 publish **arm64
Linux** builds, which run natively in DroidDeck's runtime. Most others publish x86-64 Linux,
which runs through FEX, and Windows, which runs through Proton.
## Catalog
`app/src/main/assets/recomps/catalog.json` is bundled. `RecompCatalog.load` prefers
`Droid-Deck/DroidDeck-Components/main/recomps.json` once that file exists, so the list can change
without an app release. Schema 1 (an app refuses a newer schema and uses the bundled copy):
```json
{
"id": "devilutionx", // [a-z0-9-], also the install's recomp-id
"name": "DevilutionX", "game": "Diablo", "origin": "PC", "type": "recomp|port|engine",
"repo": "diasurgical/DevilutionX", "license": "...", "art": "https://...",
"prerelease": false,
"release": { "tag": "1.5.5", "published": "..." }, // written by tools/recomps/pin_catalog.py
"builds": {
"linux-arm64": { "asset": "<regex>", "entry": "devilutionx", "args": ["--data-dir", "{data}"],
"file": "devilutionx-linux-aarch64.tar.xz", "sha256": "..." },
"linux-x64": { "asset": "...", "entry": "...", "workdir": "data" },
"windows-x64": { "asset": "...", "entry": "devilutionx.exe" },
"android": { "asset": "..." }
},
"data": {
"kind": "store|rom|dump|none", "label": "Diablo (GOG)",
"stores": [{ "store": "gog", "id": "1412601690" }], // Store enum names; Steam ids are appids
"probe": "DIABDAT.MPQ", // relative path that marks the data folder
"sha1": ["..."], "note": "..."
}
}
```
The build is chosen in the order linux-arm64 (native), linux-x64 (FEX), windows-x64 (Proton).
Android builds are only listed for now.
Run `tools/recomps/pin_catalog.py` (needs `gh` signed in or `GITHUB_TOKEN` set) after changing the
catalog. It pins every entry to its newest matching release and records the file names and
GitHub's sha256 digests. `--check` exits 1 when a pin is out of date, which a scheduled job in
DroidDeck-Components can use. Installs download the pinned file from
`github.com/<repo>/releases/download/`, which GitHub does not rate-limit. The releases API (60
unauthenticated calls an hour, shared by every device on one address) is used only for entries
without a pin. On a household with several devices, that budget was already spent by update
checks during testing.
## Installing
`RecompInstaller.install`:
1. Downloads the asset, checking its sha256.
2. **Linux build:** `bsdtar` in the guest unpacks it into the app cache, keeping modes and
symlinks, and unpacks once more when the result is a single archive (Zelda's zip holds a
tar.gz). It then finds `entry` up to four folders down. An AppImage, whether downloaded
directly or found inside the archive, goes to `AppImageManager.import`. Anything else becomes
a user app (`UserApps.addPrepared`): the unpacked tree moves to
`/opt/droiddeck-apps/<id>/files`, and a `droiddeck-recomp` wrapper becomes its entry.
`droiddeck-script-run` launches it, so `droiddeck-fex` decides between native and FEX from
the folder's ELFs, exactly as for any added Linux app. It also shows on the Desktop page.
3. **Windows build:** unpacks into `<first Games folder or the store install root>/Recomps/<id>`
and registers the exe with `AddedGames.addExe`. It then appears in the Library (Custom) and
runs through Proton.
4. Writes `recomp-id`, `recomp-tag`, `recomp-published` and `recomp-platform` beside the
install. `RecompInstaller.installed` finds installs by those files. An update installs the
new release first and then deletes the old folder, carrying the data link over.
## Game data
`RecompData.inputs` collects the installs DroidDeck knows about:
- store installs, from their `.droiddeck-store.json` sidecar;
- Steam client libraries, from `SteamLibraryFolders.installed`, giving each game's host and
guest path;
- owned games, from `StoresState.library` and the Steam games on the Steam page.
`RecompData.resolve` returns one of these states:
| State | When | Card |
|---|---|---|
| Found | an install holds `probe` (each path part matched without case, shallowest folder up to 3 levels down) | green "Game files found (Steam)", and the guest folder |
| Incomplete | installed, but `probe` is missing | "Installed on GOG, but the needed files are missing" |
| Owned | owned, not installed | "Install game" starts the store install |
| Missing | not owned | "Store page" |
| BringYourOwn | ROM or dump | the label and the recomp's own instructions |
Found writes the guest folder to `recomp-data`. The wrapper reads it at every launch: it passes
`args` with `{data}` replaced, or, for `workdir: data` (Fallout 2 CE reads from its working
directory), `cd`s there first. Without a link it starts the program with no extra arguments, so
the recomp's own folder picker still works. AppImage installs (OpenRCT2) cannot take the
arguments, so the card shows the folder to choose in the program.
## UI
A page header, one line saying what the tab does, and filter chips with counts: All, You own
the game, Bring your own files, Installed. Cards are sorted installed first, then found, owned,
bring-your-own and the rest. Each card shows art (the project icon, or the store's 600×900
capsule), the game and kind, a build chip (green once installed), a data chip and an "Android
app too" chip. Its actions are Install, or Play / Open in Games; Update to <tag> when the catalog
pins a newer release; the store action; and Remove or Project page. The page shows two columns
from 820 dp and one below. Controller focus enters on the first card's primary button.
## Tested
- Zelda 64: Recompiled v1.2.2, linux-arm64, on the Retroid Pocket Duo: Install from the card,
Play, and it reached its own Select ROM screen natively. The top screen shows the page; the
bottom screen's rail is labelled Recomps.
- Pocket FIT Elite (portrait 1080×1920): the More tile and the single-column page. Installing an
x86-64 build (Ironwail) failed there before pinning, because the releases API answered 403
(rate limit). That failure led to the pinned downloads.
- Unit tests: `RecompsTest`, which runs the wrapper under `/bin/sh` and covers release picking,
data probing and resolution and catalog validation, and `NavTabsTest`.
## Not done yet
- **Android APKs (Recompa).** Install the `android` build through `PackageInstaller`, verify it
against Recompa's `signer_sha256`, and hand ROMs over with their `delivery` rules. Consuming
Recompa's `index.json` needs its author's permission (the data has no licence).
- **Recomp Launcher's catalog and `recomplauncher.json`.** Xarishark offered help on the DroidDeck
Discord (2026-11-12). Two things would be worth asking for:
- permission to read `pc-catalog.json`, or a feed filtered to entries with arm64 or x86-64
Linux builds;
- support for its `inputs` / `prepare` steps, so recomps that build from the player's dump
(Unleashed, Marathon) can be set up from DroidDeck.
- **Linking your own folder.** For data copied from a PC: a folder picker that sets `recomp-data`
by hand.
- **ROM checks.** Hash a chosen ROM against `sha1` and say whether it is the right one.
- **Steam ownership** relies on the Steam page's library or the Steam store sign-in. A game
installed by the Steam client counts as Found regardless.
- **Recomp setup steps.** Some recomps build themselves from the player's data with bundled
Python (Recompia). They need executable storage, so they must stay inside the Linux root, never
under `/media`; see the Discord thread on Recompia from 2026-11-15.
+83
View File
@@ -0,0 +1,83 @@
#!/usr/bin/env python3
"""Pin every recomp in the catalog to its newest matching release.
Installs download the pinned file from github.com/<repo>/releases/download/, which is not rate-limited,
and check it against the sha256 GitHub publishes for the asset. Run with `gh` signed in, or GITHUB_TOKEN set.
"""
import argparse
import json
import os
import re
import subprocess
import sys
import urllib.request
DEFAULT = os.path.join(os.path.dirname(__file__), "..", "..", "app", "src", "main", "assets", "recomps", "catalog.json")
def releases(repo):
token = os.environ.get("GITHUB_TOKEN")
url = f"https://api.github.com/repos/{repo}/releases?per_page=15"
if token:
req = urllib.request.Request(url, headers={"Authorization": f"Bearer {token}", "Accept": "application/vnd.github+json"})
with urllib.request.urlopen(req, timeout=30) as r:
return json.load(r)
out = subprocess.run(["gh", "api", url.removeprefix("https://api.github.com/")], capture_output=True, text=True, check=True)
return json.loads(out.stdout)
def pick(rels, pattern, prerelease):
rx = re.compile(pattern, re.IGNORECASE)
found = []
for r in rels:
if r.get("draft"):
continue
asset = next((a for a in r.get("assets", []) if rx.search(a["name"])), None)
if asset:
found.append((r, asset))
stable = [f for f in found if prerelease or not f[0].get("prerelease")]
return (stable or found or [None])[0]
def pin(entry):
rels = releases(entry["repo"])
picks = {key: pick(rels, b["asset"], entry.get("prerelease", False)) for key, b in entry.get("builds", {}).items()}
tags = {p[0]["tag_name"] for p in picks.values() if p}
if len(tags) != 1:
raise SystemExit(f"{entry['id']}: builds resolve to releases {sorted(tags) or 'none'}; fix the asset patterns")
release = next(p[0] for p in picks.values() if p)
entry["release"] = {"tag": release["tag_name"], "published": release.get("published_at", "")}
for key, b in entry["builds"].items():
p = picks[key]
if not p or p[0]["tag_name"] != release["tag_name"]:
raise SystemExit(f"{entry['id']} {key}: no asset in {release['tag_name']} matches {b['asset']}")
b["file"] = p[1]["name"]
digest = p[1].get("digest") or ""
if digest.startswith("sha256:"):
b["sha256"] = digest.split(":", 1)[1]
else:
b.pop("sha256", None)
return release["tag_name"]
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("catalog", nargs="?", default=DEFAULT)
parser.add_argument("--check", action="store_true", help="exit 1 when a pin is out of date instead of writing")
args = parser.parse_args()
with open(args.catalog, encoding="utf-8") as f:
catalog = json.load(f)
before = json.dumps(catalog, sort_keys=True)
for entry in catalog["recomps"]:
print(f"{entry['id']}: {pin(entry)}")
changed = json.dumps(catalog, sort_keys=True) != before
if args.check:
sys.exit(1 if changed else 0)
if changed:
with open(args.catalog, "w", encoding="utf-8") as f:
json.dump(catalog, f, indent=2, ensure_ascii=False)
f.write("\n")
if __name__ == "__main__":
main()