mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 21:15:43 +00:00
feat(recomps): read Recomp Launcher's and Recompa's catalogs directly, with no catalog of our own
The tab now downloads both community catalogs, caches them with their ETags and merges them on the device, so there is nothing for DroidDeck to maintain. The curated list, the bundled catalog and the build and pin scripts are gone. Ownership of a PC port's game is matched by title against the player's installs and store libraries, and the wrapper just starts the program from its own folder.
This commit is contained in:
1 parent
a2118089c3
commit
22b1c21a02
15 files changed
+455
-1371
No files matched your search
@@ -110,7 +110,7 @@ DroidDeck is [GPL-3.0](LICENSE). Steam and Proton belong to Valve Corporation. V
|
||||
<details>
|
||||
<summary><b>Recomps</b></summary>
|
||||
|
||||
- The Recomps tab's list combines DroidDeck's own entries with two community catalogs, rebuilt by `tools/recomps/build_catalog.py`. Each entry shows which catalog it came from.
|
||||
- The Recomps tab lists the two community catalogs below, read straight from their sites. Each entry shows which catalog it came from.
|
||||
- [Recomp Launcher](https://recomplauncher.com) ([elripalda/RecompLauncher](https://github.com/elripalda/RecompLauncher), GPL-3.0) by [@elripalda](https://github.com/elripalda), [@Xarishark](https://github.com/Xarishark) and contributors: its `pc-catalog.json` supplies the Windows and Linux recomps, their release pins and checksums, start programs, setup notes and the game data each needs.
|
||||
- [Recompa](https://recompa.app) ([kalasyan/recompa](https://github.com/kalasyan/recompa), GPL-3.0) by [@kalasyan](https://github.com/kalasyan): its `index.json` supplies the Android ports, their APK checksums, package names and signing certificates, and the ROMs or files each needs.
|
||||
- Every game's build is downloaded from its own developers' releases and keeps its own licence. DroidDeck ships no ROMs or game files.
|
||||
|
||||
@@ -85,20 +85,27 @@ internal val previewCases: List<PreviewCase> = listOf(
|
||||
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. */
|
||||
/** The Recomps tab with one recomp installed, one game installed from Steam, one owned on GOG and an Android port. */
|
||||
@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)
|
||||
}
|
||||
}
|
||||
fun entry(id: String, name: String, game: String, origin: String, platform: com.droiddeck.launcher.runtime.RecompCatalog.Platform,
|
||||
needs: String, sources: List<String>) =
|
||||
com.droiddeck.launcher.runtime.RecompCatalog.Entry(id, name, game, origin, if (origin == "PC") "port" else "recomp", "o/$id", "", "",
|
||||
null, listOf(com.droiddeck.launcher.runtime.RecompCatalog.Build(platform, Regex("x"))),
|
||||
com.droiddeck.launcher.runtime.RecompCatalog.Data(com.droiddeck.launcher.runtime.RecompCatalog.DataKind.ROM, needs), sources)
|
||||
val list = listOf(
|
||||
entry("zelda64recomp", "Zelda 64: Recompiled", "The Legend of Zelda: Majora's Mask", "N64", com.droiddeck.launcher.runtime.RecompCatalog.Platform.LINUX_ARM64, "Majora's Mask (USA) N64 ROM", listOf("recomp-launcher")),
|
||||
entry("ironwail", "Ironwail", "Quake", "PC", com.droiddeck.launcher.runtime.RecompCatalog.Platform.LINUX_X64, "Quake's id1 folder", listOf("recomp-launcher")),
|
||||
entry("fallout2-ce", "Fallout 2 Community Edition", "Fallout 2", "PC", com.droiddeck.launcher.runtime.RecompCatalog.Platform.WINDOWS_X64, "Fallout 2's master.dat", listOf("recomp-launcher", "recompa")),
|
||||
entry("shipwright", "Ship of Harkinian", "The Legend of Zelda: Ocarina of Time", "N64", com.droiddeck.launcher.runtime.RecompCatalog.Platform.ANDROID, "Ocarina of Time ROM", listOf("recompa")),
|
||||
)
|
||||
val states: Map<String, RecompData.State> = mapOf(
|
||||
"zelda64recomp" to RecompData.State.BringYourOwn(list[0].data),
|
||||
"ironwail" to RecompData.State.Found(Store.STEAM, java.io.File("/q"), "/root/.local/share/Steam/steamapps/common/Quake"),
|
||||
"fallout2-ce" to RecompData.State.Owned(Store.GOG, null),
|
||||
"shipwright" to RecompData.State.BringYourOwn(list[3].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))
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
{"schema":1,"sources":{"droiddeck":{"name":"DroidDeck","url":"https://github.com/Droid-Deck/DroidDeck"},"recomp-launcher":{"name":"Recomp Launcher","url":"https://recomplauncher.com","updated":"2026-12-01T02:17:39+00:00"},"recompa":{"name":"Recompa","url":"https://recompa.app","updated":"2026-12-01T00:18:11Z"}},"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","file":"Zelda64Recompiled-v1.2.2-Linux-ARM64.zip","sha256":"2e49b96aced578363065e1764ca96eaa5590cb6f7e80efd10e8ce1a08462b933"},"linux-x64":{"asset":"^Zelda64Recompiled-.*-Linux-X64\\.zip$","entry":"Zelda64Recompiled","file":"Zelda64Recompiled-v1.2.2-Linux-X64.zip","sha256":"de8b19cdb4e3ad0c10fd6d8127f7a6cc2a9eba106d89c753439178b718887c42"},"windows-x64":{"asset":"^Zelda64Recompiled-.*-Windows\\.zip$","entry":"Zelda64Recompiled.exe","file":"Zelda64Recompiled-v1.2.2-Windows.zip","sha256":"d02b95f1cf5e4d44d6587fa6136c6db521f61aa41ba8700c05f91bea8b0a26d0"}},"data":{"kind":"rom","label":"Majora's Mask (USA) N64 ROM","sha1":["d6133ace5afaa0882cf214cf88daba39e266c078"],"note":"Choose the ROM from the recomp's own start screen."},"release":{"tag":"v1.2.2","published":"2025-08-27T00:58:35Z"},"sources":["droiddeck","recomp-launcher"],"popularity":415396},{"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","file":"Starfox64Recompiled-v1.0.3-Linux-ARM64-Release.zip","sha256":"85408daa5ceac1fc208a744b0a35fb316c417d62c709761aceb242353fb2a1c0"},"linux-x64":{"asset":"^Starfox64Recompiled-.*-Linux-X64-Release\\.zip$","entry":"Starfox64Recompiled","file":"Starfox64Recompiled-v1.0.3-Linux-X64-Release.zip","sha256":"e74932bd0edb6186a015dabaa87b6b24af3d3b5511ff3b0293a2c3331840cdf0"},"windows-x64":{"asset":"^Starfox64Recompiled-.*-Windows-.*\\.zip$","entry":"Starfox64Recompiled.exe","file":"Starfox64Recompiled-v1.0.3-Windows-RelWithDebInfo.zip","sha256":"768c18b0aeb325a0102f722338f09a270a76eeebea29154764147a93d0bde530"}},"data":{"kind":"rom","label":"Star Fox 64 (USA) N64 ROM","note":"Choose the ROM from the recomp's own start screen."},"release":{"tag":"1.0.3","published":"2025-12-30T04:13:00Z"},"sources":["droiddeck","recomp-launcher"],"popularity":33951},{"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","file":"BanjoRecompiled-v1.0.2-Linux-ARM64.tar.gz","sha256":"53515be8bc453bc32ed8cbc72e3cd06350ab4a28bd94b0aa6499d4b963a83757"},"linux-x64":{"asset":"^BanjoRecompiled-.*-Linux-X64\\.tar\\.gz$","entry":"BanjoRecompiled","file":"BanjoRecompiled-v1.0.2-Linux-X64.tar.gz","sha256":"a34a4d361221171ea638e0165301fff817c53b9cd46167c5affd37867cfc7ad0"},"windows-x64":{"asset":"^BanjoRecompiled-.*-Windows\\.zip$","entry":"BanjoRecompiled.exe","file":"BanjoRecompiled-v1.0.2-Windows.zip","sha256":"fc34aad48e06681878bedd13b88d5332a2f21f6a98cafc931c94d54892a4dd92"}},"data":{"kind":"rom","label":"Banjo-Kazooie (USA) N64 ROM","note":"Choose the ROM from the recomp's own start screen."},"release":{"tag":"v1.0.2","published":"2026-07-31T19:43:17Z"},"sources":["droiddeck","recomp-launcher"],"popularity":161572},{"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","file":"2Ship-Battler-Bravo-Linux.zip","sha256":"6cdd4fe06f3f9b095e99c86fef70b9265cc921fb6faa7ba1e18e94e90ed0b345"},"windows-x64":{"asset":"^2Ship-.*-Win64\\.zip$","entry":"2ship.exe","file":"2Ship-Battler-Bravo-Win64.zip","sha256":"a46664a01623ad5d7cc82d29a9889699f6a98c9501c7a959a089f34380c1f078"},"android":{"asset":"^2s2h\\.apk$","file":"2s2h.apk","url":"https://github.com/Waterdish/2ship2harkinian-Android/releases/download/v1.1.2P1/2s2h.apk","sha256":"737280de7dda915a4e6ae1d22baae5c220a08a5aaa6f054886036c8d889a0bbf","package":"com.dishii.mm","signer":"92e4da94a3395ffc9fe9f52aa73f8490d7435171c7915fafcc29babdda356629"}},"data":{"kind":"rom","label":"Majora's Mask (USA) N64 ROM","sha1":["d6133Line truncated
|
||||
@@ -2,16 +2,23 @@ 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 com.droiddeck.launcher.core.FileUtils
|
||||
import org.json.JSONObject
|
||||
import java.io.File
|
||||
import java.net.HttpURLConnection
|
||||
import java.net.URL
|
||||
|
||||
// The list is Recomp Launcher's and Recompa's own catalogs, read as their apps publish them. DroidDeck keeps
|
||||
// no catalog of its own: it caches each feed, revalidates it with its ETag, and merges them by GitHub repo.
|
||||
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"
|
||||
private const val MAX_AGE_MS = 6L * 60 * 60 * 1000
|
||||
|
||||
class Feed(val id: String, val name: String, val url: String)
|
||||
|
||||
val RECOMP_LAUNCHER = Feed("recomp-launcher", "Recomp Launcher", "https://recomplauncher.com/pc-catalog.json")
|
||||
val RECOMPA = Feed("recompa", "Recompa", "https://recompa.app/index.json")
|
||||
val FEEDS = listOf(RECOMP_LAUNCHER, RECOMPA)
|
||||
|
||||
enum class Platform(val key: String) {
|
||||
LINUX_ARM64("linux-arm64"), LINUX_X64("linux-x64"), WINDOWS_X64("windows-x64"), ANDROID("android");
|
||||
@@ -24,115 +31,205 @@ object RecompCatalog {
|
||||
// Native arm64 Linux first, then an Android APK, then x86-64 Linux through FEX, then Windows through Proton.
|
||||
val PREFERENCE = listOf(Platform.LINUX_ARM64, Platform.ANDROID, Platform.LINUX_X64, Platform.WINDOWS_X64)
|
||||
|
||||
const val SOURCE_DROIDDECK = "droiddeck"
|
||||
const val SOURCE_RECOMP_LAUNCHER = "recomp-launcher"
|
||||
const val SOURCE_RECOMPA = "recompa"
|
||||
|
||||
class Build(
|
||||
val platform: Platform, val asset: Regex, val entry: String, val args: List<String>, val inData: Boolean,
|
||||
val platform: Platform, val asset: Regex, val entry: String = "",
|
||||
val file: String? = null, val sha256: String? = null, val url: String? = null,
|
||||
val pkg: String? = null, val signer: String? = null,
|
||||
val pkg: String? = null, val signer: String? = null, val tag: String? = null, val published: String = "",
|
||||
)
|
||||
|
||||
enum class DataKind { STORE, ROM, DUMP, NONE }
|
||||
enum class DataKind { 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 Data(val kind: DataKind, val label: String, val sha1: List<String> = emptyList(), 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 = "",
|
||||
val sources: List<String> = listOf(SOURCE_DROIDDECK), val popularity: Long = 0, val setup: String? = null,
|
||||
val androidTag: String? = null, val androidPublished: String = "",
|
||||
val builds: List<Build>, val data: Data,
|
||||
val sources: List<String>, val popularity: Long = 0, val setup: String? = null,
|
||||
) {
|
||||
fun build(platform: Platform) = builds.firstOrNull { it.platform == platform }
|
||||
|
||||
fun preferred(): Build? = PREFERENCE.firstNotNullOfOrNull { build(it) }
|
||||
|
||||
fun tagFor(platform: Platform) = if (platform == Platform.ANDROID) androidTag ?: tag else tag
|
||||
|
||||
fun publishedFor(platform: Platform) = if (platform == Platform.ANDROID && androidTag != null) androidPublished else published
|
||||
|
||||
val android get() = build(Platform.ANDROID)
|
||||
|
||||
val pc get() = origin.equals("PC", ignoreCase = true)
|
||||
}
|
||||
|
||||
@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
|
||||
val dir = File(context.filesDir, "recomps").apply { mkdirs() }
|
||||
val bodies = FEEDS.associateWith { feed -> runCatching { fetch(feed, dir, refresh) }.onFailure { Log.w(TAG, "${feed.id}: $it") }.getOrNull() }
|
||||
val list = merge(
|
||||
bodies[RECOMP_LAUNCHER]?.let { runCatching { fromRecompLauncher(JSONObject(it)) }.getOrNull() }.orEmpty(),
|
||||
bodies[RECOMPA]?.let { runCatching { fromRecompa(JSONObject(it)) }.getOrNull() }.orEmpty(),
|
||||
)
|
||||
if (list.isNotEmpty()) 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 }
|
||||
private fun fetch(feed: Feed, dir: File, force: Boolean): String? {
|
||||
val file = File(dir, "${feed.id}.json")
|
||||
val etag = File(dir, "${feed.id}.etag")
|
||||
if (!force && file.isFile && System.currentTimeMillis() - file.lastModified() < MAX_AGE_MS) return file.readText()
|
||||
val conn = (URL(feed.url).openConnection() as HttpURLConnection).apply {
|
||||
connectTimeout = 15_000; readTimeout = 60_000
|
||||
setRequestProperty("User-Agent", "DroidDeck")
|
||||
if (file.isFile) FileUtils.readString(etag)?.trim()?.takeIf { it.isNotEmpty() }?.let { setRequestProperty("If-None-Match", it) }
|
||||
}
|
||||
return try {
|
||||
when (conn.responseCode) {
|
||||
HttpURLConnection.HTTP_NOT_MODIFIED -> { file.setLastModified(System.currentTimeMillis()); file.readText() }
|
||||
HttpURLConnection.HTTP_OK -> {
|
||||
val body = conn.inputStream.bufferedReader().use { it.readText() }
|
||||
val tmp = File(dir, "${feed.id}.json.part")
|
||||
tmp.writeText(body)
|
||||
tmp.renameTo(file)
|
||||
conn.getHeaderField("ETag")?.let { FileUtils.writeString(etag, it) }
|
||||
body
|
||||
}
|
||||
else -> file.takeIf { it.isFile }?.readText()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "${feed.id}: $e")
|
||||
file.takeIf { it.isFile }?.readText()
|
||||
} finally {
|
||||
conn.disconnect()
|
||||
}
|
||||
} 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 val ORIGINS = mapOf(
|
||||
"pc" to "PC", "n64" to "N64", "x360" to "Xbox 360", "xbox360" to "Xbox 360", "xbox" to "Xbox", "ps1" to "PS1", "ps2" to "PS2",
|
||||
"ps3" to "PS3", "ps4" to "PS4", "switch" to "Switch", "switch2" to "Switch 2", "snes" to "SNES", "nes" to "NES", "gc" to "GameCube",
|
||||
"wii" to "Wii", "gba" to "GBA", "nds" to "DS", "ds" to "DS", "3ds" to "3DS", "arcade" to "Arcade", "dreamcast" to "Dreamcast",
|
||||
"saturn" to "Saturn", "genesis" to "Genesis", "psp" to "PSP", "vita" to "Vita", "gb" to "Game Boy", "gbc" to "Game Boy Color",
|
||||
)
|
||||
private val ARCHIVE = Regex("\\.(zip|7z|tar|tgz|tar\\.(gz|xz|bz2|zst)|appimage|exe)$", RegexOption.IGNORE_CASE)
|
||||
private val REPO = Regex("[\\w.-]+/[\\w.-]+")
|
||||
private val SHA256 = Regex("[0-9a-f]{64}")
|
||||
private val SHA1 = Regex("[0-9a-f]{40}")
|
||||
private val PACKAGE = Regex("[A-Za-z][\\w]*(\\.[A-Za-z][\\w]*)+")
|
||||
private val GITHUB = Regex("^https?://github\\.com/([\\w.-]+/[\\w.-]+?)(?:\\.git)?/?$")
|
||||
private val HUBS = setOf("io.github.kalasyan.recompa")
|
||||
|
||||
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").takeIf { '/' !in it && it != "." && it != ".." }.orEmpty(), 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) },
|
||||
spec.optString("url").takeIf { it.startsWith("https://") },
|
||||
spec.optString("package").takeIf { Regex("[A-Za-z][\\w]*(\\.[A-Za-z][\\w]*)+").matches(it) },
|
||||
spec.optString("signer").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"))
|
||||
private fun origin(code: String) = code.lowercase().let { ORIGINS[it] ?: if (it == "other") "" else it.uppercase() }
|
||||
|
||||
private fun safeName(s: String?) = s?.takeIf { it.isNotEmpty() && '/' !in it && it != "." && it != ".." }
|
||||
|
||||
private fun sha256(s: String?) = s?.lowercase()?.takeIf { SHA256.matches(it) }
|
||||
|
||||
internal fun globRegex(glob: String) =
|
||||
Regex("^" + glob.split('*').joinToString(".*") { Regex.escape(it) } + "$", RegexOption.IGNORE_CASE)
|
||||
|
||||
private fun JSONObject.str(key: String) = optString(key).takeIf { it.isNotEmpty() && it != "null" }
|
||||
|
||||
internal fun fromRecompLauncher(json: JSONObject): List<Entry> {
|
||||
val apps = json.optJSONArray("apps") ?: return emptyList()
|
||||
return (0 until apps.length()).mapNotNull { i -> runCatching { recompLauncherApp(apps.getJSONObject(i)) }.getOrNull() }
|
||||
}
|
||||
|
||||
private fun recompLauncherApp(a: JSONObject): Entry? {
|
||||
if (a.optBoolean("archived") || a.optBoolean("soon")) return null
|
||||
if ((a.str("host") ?: "github") != "github") return null
|
||||
val repo = a.str("repo")?.takeIf { REPO.matches(it) } ?: return null
|
||||
val boot = a.optJSONObject("boot") ?: JSONObject()
|
||||
if (boot.str("kind") in setOf("installer", "not-a-game", "source")) return null
|
||||
val assets = a.optJSONObject("assets") ?: return null
|
||||
val files = a.optJSONObject("files") ?: JSONObject()
|
||||
val tag = a.str("tag")
|
||||
val published = a.str("released_at").orEmpty()
|
||||
val builds = listOf("linux", "windows").mapNotNull { os ->
|
||||
val glob = assets.str(os) ?: return@mapNotNull null
|
||||
if (glob.contains("flatpak", ignoreCase = true) || !ARCHIVE.containsMatchIn(glob)) return@mapNotNull null
|
||||
val platform = when {
|
||||
os == "linux" && Regex("aarch64|arm64", RegexOption.IGNORE_CASE).containsMatchIn(glob) -> Platform.LINUX_ARM64
|
||||
os == "linux" -> Platform.LINUX_X64
|
||||
Regex("arm64|aarch64|win32|x86(?![_-]64)", RegexOption.IGNORE_CASE).containsMatchIn(glob) -> return@mapNotNull null
|
||||
else -> Platform.WINDOWS_X64
|
||||
}
|
||||
}.orEmpty()
|
||||
val start = if (os == "linux") boot.str("start_linux") else boot.str("start")?.takeIf { it.endsWith(".exe", ignoreCase = true) }
|
||||
val pin = files.optJSONObject(os)
|
||||
val file = safeName(pin?.str("name")) ?: safeName(glob.takeIf { '*' !in it && tag != null })
|
||||
Build(platform, globRegex(glob), safeName(start).orEmpty(), file, sha256(pin?.str("sha256")), tag = tag, published = published)
|
||||
}
|
||||
if (builds.isEmpty()) return null
|
||||
val what = boot.optJSONObject("files")?.str("what") ?: a.str("needs")
|
||||
val steps = a.optJSONArray("setup_steps")
|
||||
val id = a.str("id") ?: return null
|
||||
val setup = if (!a.optBoolean("setup_required")) null
|
||||
else (0 until (steps?.length() ?: 0)).take(2).joinToString(" ") { steps!!.getString(it) }.ifEmpty { "" }
|
||||
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(),
|
||||
strings(o.optJSONArray("sources")).ifEmpty { listOf(SOURCE_DROIDDECK) },
|
||||
o.optLong("popularity", 0),
|
||||
o.optString("setup").takeIf { it.isNotEmpty() },
|
||||
o.optJSONObject("android_release")?.optString("tag")?.takeIf { it.isNotEmpty() },
|
||||
o.optJSONObject("android_release")?.optString("published").orEmpty(),
|
||||
id, a.str("name") ?: id, a.str("game") ?: a.str("name") ?: id, origin(a.str("origin").orEmpty()),
|
||||
if ("recomp" in (id + repo).lowercase()) "recomp" else "port", repo, a.str("license").orEmpty(),
|
||||
"https://github.com/$repo", a.str("icon") ?: a.str("cover"), builds,
|
||||
if (what != null) Data(DataKind.DUMP, what, note = a.str("blurb").orEmpty()) else Data(DataKind.NONE, ""),
|
||||
listOf(RECOMP_LAUNCHER.id), a.optLong("downloads"), setup,
|
||||
)
|
||||
}
|
||||
|
||||
internal fun fromRecompa(json: JSONObject): List<Entry> {
|
||||
val ports = json.optJSONArray("ports") ?: return emptyList()
|
||||
return (0 until ports.length()).mapNotNull { i -> runCatching { recompaPort(ports.getJSONObject(i)) }.getOrNull() }
|
||||
}
|
||||
|
||||
private fun recompaPort(p: JSONObject): Entry? {
|
||||
val req = p.optJSONObject("requirements") ?: JSONObject()
|
||||
val abi = req.optJSONArray("abi")
|
||||
if (abi != null && abi.length() > 0 && (0 until abi.length()).none { abi.getString(it) == "arm64-v8a" }) return null
|
||||
if (req.optInt("min_sdk", 0) > android.os.Build.VERSION.SDK_INT) return null
|
||||
val forks = p.optJSONArray("forks") ?: return null
|
||||
val fork = (0 until forks.length()).map { forks.getJSONObject(it) }.filter { f ->
|
||||
val asset = f.optJSONObject("release")?.optJSONObject("asset")
|
||||
sha256(asset?.str("sha256")) != null && sha256(f.str("signer_sha256")) != null &&
|
||||
f.str("package")?.let { PACKAGE.matches(it) } == true && asset?.str("url")?.startsWith("https://") == true
|
||||
}.maxByOrNull { it.optLong("downloads") } ?: return null
|
||||
if (fork.getString("package") in HUBS) return null
|
||||
val release = fork.getJSONObject("release")
|
||||
val asset = release.getJSONObject("asset")
|
||||
val android = Build(
|
||||
Platform.ANDROID, Regex("^" + Regex.escape(asset.getString("name")) + "$"), "", safeName(asset.str("name")),
|
||||
sha256(asset.str("sha256")), asset.getString("url"), fork.getString("package"), sha256(fork.str("signer_sha256")),
|
||||
release.str("tag"), release.str("published_at").orEmpty(),
|
||||
)
|
||||
val platform = p.str("original_platform").orEmpty()
|
||||
val needs = p.optJSONArray("assets")?.optJSONObject(0)
|
||||
val data = if (needs == null) Data(DataKind.NONE, "") else {
|
||||
val accepted = needs.optJSONArray("accepted")
|
||||
Data(
|
||||
if (platform == "pc" || platform == "other") DataKind.DUMP else DataKind.ROM, needs.str("label").orEmpty(),
|
||||
(0 until (accepted?.length() ?: 0)).mapNotNull { accepted!!.optJSONObject(it)?.str("sha1")?.lowercase()?.takeIf { s -> SHA1.matches(s) } },
|
||||
needs.str("instructions_md")?.replace(Regex("[`*_#>\\[\\]]"), "")?.trim()?.lineSequence()?.firstOrNull().orEmpty(),
|
||||
)
|
||||
}
|
||||
val repo = p.str("upstream")?.let { GITHUB.find(it)?.groupValues?.get(1) } ?: fork.str("repo")?.takeIf { REPO.matches(it) } ?: return null
|
||||
val id = p.str("id") ?: return null
|
||||
return Entry(
|
||||
id, fork.str("name") ?: p.str("name") ?: id, p.str("game") ?: p.str("name") ?: id, origin(platform), p.str("type") ?: "port",
|
||||
repo, "", "https://github.com/$repo", p.optJSONObject("art")?.str("cover"), listOf(android), data,
|
||||
listOf(RECOMPA.id), fork.optLong("downloads"),
|
||||
)
|
||||
}
|
||||
|
||||
// Recomp Launcher's entry wins every field it sets; a Recompa port of the same repo (or id) adds its APK.
|
||||
internal fun merge(launcher: List<Entry>, recompa: List<Entry>): List<Entry> {
|
||||
val out = LinkedHashMap<String, Entry>()
|
||||
val byRepo = HashMap<String, String>()
|
||||
for (e in launcher + recompa) {
|
||||
val base = (byRepo[e.repo.lowercase()] ?: e.id.takeIf { it in out })?.let { out[it] }
|
||||
if (base == null) {
|
||||
out[e.id] = e
|
||||
byRepo.putIfAbsent(e.repo.lowercase(), e.id)
|
||||
continue
|
||||
}
|
||||
val builds = base.builds + e.builds.filter { b -> base.builds.none { it.platform == b.platform } }
|
||||
out[base.id] = Entry(
|
||||
base.id, base.name, base.game, base.origin.ifEmpty { e.origin }, base.type, base.repo, base.license.ifEmpty { e.license },
|
||||
base.homepage, base.art ?: e.art, builds, if (base.data.kind == DataKind.NONE) e.data else base.data,
|
||||
(base.sources + e.sources).distinct(), maxOf(base.popularity, e.popularity), base.setup,
|
||||
)
|
||||
}
|
||||
return out.values.toList()
|
||||
}
|
||||
}
|
||||
@@ -9,41 +9,46 @@ import com.droiddeck.launcher.stores.steam.SteamClient
|
||||
import com.droiddeck.launcher.stores.steam.SteamLibraryFolders
|
||||
import java.io.File
|
||||
|
||||
// The catalogs name the game a PC port needs but not its store ids, so ownership is matched by title against
|
||||
// the player's own libraries. Console recomps need a dump, which no store sells, and are never matched.
|
||||
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 Install(val store: Store, val title: String, val host: File, val guest: String)
|
||||
|
||||
class Inputs(val installs: List<Install>, val owned: Set<String>, val items: Map<String, CatalogItem>)
|
||||
class Owner(val store: Store, val title: String, val item: CatalogItem?)
|
||||
|
||||
fun key(store: Store, id: String) = "${store.name}:$id"
|
||||
class Inputs(val installs: List<Install>, val owned: List<Owner>)
|
||||
|
||||
// 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 {
|
||||
private val EDITION = Regex(
|
||||
"\\b(game of the year|goty|definitive|enhanced|complete|classic|gold|anniversary|special|deluxe|ultimate|remastered)( edition)?\\b|\\bedition\\b",
|
||||
)
|
||||
|
||||
internal fun titleKey(title: String): String =
|
||||
title.lowercase().replace(Regex("[™®©]"), "").replace(Regex("[:\\-–—_'’.,!?&()\\[\\]]"), " ")
|
||||
.replace(EDITION, " ").replace(Regex("^the "), "").filter { it.isLetterOrDigit() }
|
||||
|
||||
fun inputs(context: Context, steamOwned: Collection<Pair<Int, String>>): 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))
|
||||
installs += Install(game.sidecar.store, game.sidecar.title, game.folder, guestPath(context, root, game.folder))
|
||||
}
|
||||
runCatching {
|
||||
SteamLibraryFolders.installed(SteamClient.libraries(context)).forEach { (appId, app) ->
|
||||
SteamLibraryFolders.installed(SteamClient.libraries(context)).forEach { (_, app) ->
|
||||
val dir = app.installDir ?: return@forEach
|
||||
installs += Install(Store.STEAM, appId.toString(), File(app.library.host, "steamapps/common/$dir"),
|
||||
installs += Install(Store.STEAM, app.name, 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)
|
||||
val owned = StoresState.library.flatMap { (store, list) -> list.filter { it.accessible }.map { Owner(store, it.title, it) } } +
|
||||
steamOwned.map { (_, name) -> Owner(Store.STEAM, name, null) }
|
||||
return Inputs(installs, owned)
|
||||
}
|
||||
|
||||
private fun guestPath(context: Context, root: File, host: File): String {
|
||||
@@ -52,53 +57,14 @@ object RecompData {
|
||||
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)
|
||||
fun resolve(entry: RecompCatalog.Entry, inputs: Inputs): State {
|
||||
if (entry.pc) {
|
||||
val key = titleKey(entry.game).takeIf { it.length >= 3 }
|
||||
if (key != null) {
|
||||
inputs.installs.firstOrNull { titleKey(it.title) == key }?.let { return State.Found(it.store, it.host, it.guest) }
|
||||
inputs.owned.firstOrNull { titleKey(it.title) == key }?.let { return State.Owned(it.store, it.item) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
return if (entry.data.kind == RecompCatalog.DataKind.NONE) State.NotNeeded else State.BringYourOwn(entry.data)
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,6 @@ object RecompInstaller {
|
||||
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
|
||||
@@ -53,24 +52,18 @@ object RecompInstaller {
|
||||
|
||||
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.
|
||||
// A feed that names the release file lets the install skip the releases API, which allows 60
|
||||
// unauthenticated calls an hour per address, shared by every device on it.
|
||||
fun pinned(entry: RecompCatalog.Entry, build: RecompCatalog.Build): Release? {
|
||||
val tag = entry.tagFor(build.platform) ?: return null
|
||||
val tag = build.tag ?: return null
|
||||
val file = build.file ?: return null
|
||||
val url = build.url ?: "https://github.com/${entry.repo}/releases/download/${android.net.Uri.encode(tag)}/${android.net.Uri.encode(file)}"
|
||||
return Release(tag, entry.publishedFor(build.platform), file, url, build.sha256)
|
||||
return Release(tag, build.published, file, url, 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)
|
||||
return pickRelease(body, build.asset, false)
|
||||
}
|
||||
|
||||
internal fun pickRelease(body: String, asset: Regex, prerelease: Boolean): Release? {
|
||||
@@ -103,7 +96,7 @@ object RecompInstaller {
|
||||
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)
|
||||
pickRelease(body, build.asset, false) ?: return context.getString(R.string.recomps_no_build, entry.repo)
|
||||
}
|
||||
val work = File(context.cacheDir, "recomps").apply { mkdirs() }
|
||||
val download = File(work, release.asset)
|
||||
@@ -134,17 +127,13 @@ object RecompInstaller {
|
||||
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))
|
||||
FileUtils.writeString(File(files, WRAPPER), wrapper(rel))
|
||||
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) }
|
||||
}
|
||||
if (problem == null && previous != null && previous.dir != windowsTarget(context, entry)) FileUtils.delete(previous.dir)
|
||||
return problem
|
||||
} catch (e: Exception) {
|
||||
return e.message ?: context.getString(R.string.user_apps_failed)
|
||||
@@ -247,14 +236,10 @@ object RecompInstaller {
|
||||
|
||||
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"
|
||||
// The program starts from its own folder, as it would after unpacking the release by hand.
|
||||
internal fun wrapper(entry: String): String {
|
||||
val dir = entry.substringBeforeLast('/', "")
|
||||
val enter = if (dir.isEmpty()) "" else "cd ${quote(dir)} || exit 127\n"
|
||||
return "#!/bin/sh\n$enter" + "exec ./${quote(entry.substringAfterLast('/'))} \"\$@\"\n"
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ object RecompsState {
|
||||
private set
|
||||
private var seq = 0
|
||||
private var checked = false
|
||||
private var lastSteam: List<Int> = emptyList()
|
||||
private var lastSteam: List<Pair<Int, String>> = emptyList()
|
||||
internal var fixed = false
|
||||
private set
|
||||
|
||||
@@ -39,7 +39,7 @@ object RecompsState {
|
||||
entries = list; installed = have; data = states; updates = newer; loading = false
|
||||
}
|
||||
|
||||
fun refresh(context: Context, steamOwned: Collection<Int>, reloadCatalog: Boolean = false) {
|
||||
fun refresh(context: Context, steamOwned: Collection<Pair<Int, String>>, reloadCatalog: Boolean = false) {
|
||||
if (fixed) return
|
||||
val app = context.applicationContext
|
||||
lastSteam = steamOwned.toList()
|
||||
@@ -51,8 +51,7 @@ object RecompsState {
|
||||
val have = runCatching { RecompAndroid.installed(app, list) }.getOrDefault(emptyMap()) +
|
||||
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) }
|
||||
val states = list.associate { e -> e.id to (inputs?.let { RecompData.resolve(e, it) } ?: RecompData.State.BringYourOwn(e.data)) }
|
||||
main.post {
|
||||
if (n != seq) return@post
|
||||
entries = list; installed = have; data = states; loading = false
|
||||
@@ -71,7 +70,7 @@ object RecompsState {
|
||||
}, "recomps-refresh").start()
|
||||
}
|
||||
|
||||
fun install(context: Context, entry: RecompCatalog.Entry, steamOwned: Collection<Int>, release: RecompInstaller.Release? = null) {
|
||||
fun install(context: Context, entry: RecompCatalog.Entry, steamOwned: Collection<Pair<Int, String>>, release: RecompInstaller.Release? = null) {
|
||||
val build = installed[entry.id]?.platform?.let { RecompCatalog.Platform.of(it) }?.let { entry.build(it) } ?: entry.preferred() ?: return
|
||||
val done = if (build.platform == RecompCatalog.Platform.ANDROID) R.string.recomps_android_started else R.string.recomps_installed
|
||||
UserAppsState.run(context, entry.name, done, after = {
|
||||
|
||||
@@ -59,12 +59,12 @@ internal class RecompRow(
|
||||
)
|
||||
|
||||
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])
|
||||
RecompRow(e, RecompsState.data[e.id] ?: RecompData.State.BringYourOwn(e.data), 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.OWNED -> data is RecompData.State.Found || data is RecompData.State.Owned
|
||||
RecompFilter.BRING -> data is RecompData.State.BringYourOwn
|
||||
RecompFilter.INSTALLED -> installed != null
|
||||
}
|
||||
@@ -73,7 +73,7 @@ internal fun RecompRow.matches(filter: RecompFilter): Boolean = when (filter) {
|
||||
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.Owned -> 2
|
||||
else -> 3
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ private const val SHOWN_LIMIT = 300
|
||||
@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 }
|
||||
val steamOwned = s.steamGames.filter { it.source == Library.SOURCE_STEAM }.map { it.appId to it.name }
|
||||
LaunchedEffect(steamOwned.size, StoresState.installed.size, StoresState.library.size) {
|
||||
RecompsState.refresh(ctx, steamOwned)
|
||||
UserAppsState.refresh(ctx)
|
||||
@@ -177,9 +177,7 @@ private fun buildLabel(platform: RecompCatalog.Platform?) = stringResource(when
|
||||
private fun storeName(store: Store) = store.shortLabel
|
||||
|
||||
private fun sourceName(source: String): String? = when (source) {
|
||||
RecompCatalog.SOURCE_RECOMP_LAUNCHER -> "Recomp Launcher"
|
||||
RecompCatalog.SOURCE_RECOMPA -> "Recompa"
|
||||
else -> null
|
||||
else -> RecompCatalog.FEEDS.firstOrNull { it.id == source }?.name
|
||||
}
|
||||
|
||||
@Composable
|
||||
@@ -187,21 +185,13 @@ private fun dataLine(data: RecompData.State): Pair<String, Boolean>? = when (dat
|
||||
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.removePrefix("Your ").removePrefix("your ")) 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,
|
||||
row: RecompRow, s: FrontEndState, a: FrontEndActions, onSelect: (String) -> Unit, first: Boolean, steamOwned: List<Pair<Int, String>>, modifier: Modifier,
|
||||
) {
|
||||
val ctx = LocalContext.current
|
||||
val colors = MaterialTheme.colorScheme
|
||||
@@ -265,11 +255,6 @@ private fun RecompCard(
|
||||
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 -> {}
|
||||
}
|
||||
|
||||
@@ -4420,10 +4420,8 @@
|
||||
<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_found">Installed on %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>
|
||||
@@ -4432,7 +4430,6 @@
|
||||
<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>
|
||||
@@ -4447,7 +4444,7 @@
|
||||
<string name="recomps_search">Search recomps</string>
|
||||
<string name="recomps_setup">Needs setup first</string>
|
||||
<string name="recomps_via">via %1$s</string>
|
||||
<string name="recomps_credits">The list combines DroidDeck\'s own entries with the Recomp Launcher catalog (recomplauncher.com, by elripalda and contributors) and the Recompa catalog (recompa.app, by kalasyan). Each game\'s build comes from its own developers.</string>
|
||||
<string name="recomps_credits">This list is the Recomp Launcher catalog (recomplauncher.com, by elripalda, Xarishark and contributors) and the Recompa catalog (recompa.app, by kalasyan), read from their sites. Each game\'s build comes from its own developers.</string>
|
||||
<string name="recomps_more_results">Showing %1$d of %2$d. Search to narrow the list.</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>
|
||||
|
||||
@@ -4,8 +4,8 @@ import com.droiddeck.launcher.stores.CatalogItem
|
||||
import com.droiddeck.launcher.stores.Store
|
||||
import java.io.File
|
||||
import java.util.concurrent.TimeUnit
|
||||
import org.json.JSONObject
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Rule
|
||||
@@ -18,39 +18,129 @@ import org.robolectric.RobolectricTestRunner
|
||||
class RecompsTest {
|
||||
@get:Rule val temporary = TemporaryFolder()
|
||||
|
||||
private val bundled by lazy { RecompCatalog.parse(File("src/main/assets/${RecompCatalog.BUNDLED}").readText())!! }
|
||||
private val launcherFeed = JSONObject("""{"apps":[
|
||||
{"id":"zelda64recomp","name":"Zelda 64: Recompiled","game":"The Legend of Zelda: Majora's Mask","origin":"n64",
|
||||
"repo":"Zelda64Recomp/Zelda64Recomp","tag":"v1.2.2","released_at":"2025-08-27T00:58:35Z","downloads":415396,
|
||||
"assets":{"windows":"Zelda64Recompiled-*-Windows.zip","linux":"Zelda64Recompiled-*-Linux-X64.zip","macos":"Z-*-macOS.zip"},
|
||||
"files":{"windows":{"name":"Zelda64Recompiled-v1.2.2-Windows.zip","sha256":"${"a".repeat(64)}"}},
|
||||
"needs":"Your own copy of The Legend of Zelda: Majora's Mask","boot":{"kind":"portable","start":"Zelda64Recompiled.exe"}},
|
||||
{"id":"ironwail","name":"Ironwail","game":"Quake","origin":"pc","repo":"andrei-drexler/ironwail","tag":"v0.8.2","downloads":10,
|
||||
"assets":{"linux":"ironwail-*-linux-x64.tar.gz","windows":"ironwail-*-win32.zip"},"boot":{"start_linux":"ironwail"},
|
||||
"needs":"Your Quake id1 folder"},
|
||||
{"id":"otherm","name":"Other M","origin":"wii","repo":"o/otherm","tag":"1.0","assets":{"windows":"OtherM.zip","linux":"OtherM-Flatpak.zip"},
|
||||
"setup_required":true,"setup_steps":["Run setup.bat once.","Then play."]},
|
||||
{"id":"gone","name":"Gone","repo":"o/gone","archived":true,"assets":{"windows":"g.zip"}},
|
||||
{"id":"tool","name":"Tool","repo":"o/tool","boot":{"kind":"not-a-game"},"assets":{"windows":"t.zip"}},
|
||||
{"id":"lab","name":"Lab","repo":"git.example/x/y","host":"gitlab","assets":{"windows":"l.zip"}}
|
||||
]}""")
|
||||
|
||||
@Test fun theBundledCatalogParsesAndEveryEntryHasARunnableBuild() {
|
||||
assertTrue(bundled.size >= 1000)
|
||||
assertEquals(bundled.size, bundled.map { it.id }.distinct().size)
|
||||
for (e in bundled) {
|
||||
assertNotNull(e.id, e.preferred())
|
||||
assertTrue(e.id, e.sources.isNotEmpty())
|
||||
e.android?.let { assertNotNull(e.id, it.pkg); assertNotNull(e.id, it.url) }
|
||||
if (e.data.kind == RecompCatalog.DataKind.STORE) {
|
||||
assertTrue(e.id, e.data.stores.isNotEmpty())
|
||||
assertNotNull(e.id, e.data.probe)
|
||||
}
|
||||
}
|
||||
val zelda = bundled.first { it.id == "zelda64recomp" }
|
||||
assertTrue(RecompCatalog.SOURCE_DROIDDECK in zelda.sources && RecompCatalog.SOURCE_RECOMP_LAUNCHER in zelda.sources)
|
||||
assertTrue(bundled.any { RecompCatalog.SOURCE_RECOMPA in it.sources && it.android != null })
|
||||
private val recompaFeed = JSONObject("""{"ports":[
|
||||
{"id":"zelda","name":"Majora","upstream":"https://github.com/Zelda64Recomp/Zelda64Recomp","original_platform":"n64",
|
||||
"requirements":{"abi":["arm64-v8a"],"min_sdk":24},"forks":[
|
||||
{"repo":"x/Zelda-Android","name":"Zelda Android","package":"com.z.mm","signer_sha256":"${"b".repeat(64)}","downloads":9,
|
||||
"release":{"tag":"a1","published_at":"p","asset":{"name":"z.apk","url":"https://h/z.apk","sha256":"${"c".repeat(64)}"}}},
|
||||
{"repo":"x/unsigned","package":"com.z.other","downloads":99,"release":{"tag":"t","asset":{"name":"u.apk","url":"https://h/u.apk"}}}]},
|
||||
{"id":"sm64","name":"SM64","upstream":"https://github.com/o/sm64","original_platform":"n64","type":"decomp",
|
||||
"assets":[{"label":"SM64 ROM","accepted":[{"sha1":"9BEF1128717F958171A4AFAC3ED78EE2BB4E86CE"}],"instructions_md":"Pick `sm64.z64`.\n"}],
|
||||
"forks":[{"repo":"y/sm64","package":"com.y.sm64","signer_sha256":"${"d".repeat(64)}",
|
||||
"release":{"tag":"r2","asset":{"name":"sm64.apk","url":"https://h/s.apk","sha256":"${"e".repeat(64)}"}}}]},
|
||||
{"id":"x86only","upstream":"https://github.com/o/x","requirements":{"abi":["x86_64"]},"forks":[]},
|
||||
{"id":"recompa-app","upstream":"https://github.com/kalasyan/recompa","forks":[{"repo":"kalasyan/recompa","package":"io.github.kalasyan.recompa",
|
||||
"signer_sha256":"${"f".repeat(64)}","release":{"tag":"v1","asset":{"name":"r.apk","url":"https://h/r.apk","sha256":"${"f".repeat(64)}"}}}]}
|
||||
]}""")
|
||||
|
||||
private val merged by lazy { RecompCatalog.merge(RecompCatalog.fromRecompLauncher(launcherFeed), RecompCatalog.fromRecompa(recompaFeed)) }
|
||||
private fun entry(id: String) = merged.first { it.id == id }
|
||||
|
||||
@Test fun recompLauncherAppsBecomeRunnableBuildsAndTheRestIsLeftOut() {
|
||||
assertEquals(listOf("zelda64recomp", "ironwail", "otherm", "sm64"), merged.map { it.id })
|
||||
val z = entry("zelda64recomp")
|
||||
assertEquals("N64", z.origin)
|
||||
assertEquals(setOf(RecompCatalog.Platform.LINUX_X64, RecompCatalog.Platform.WINDOWS_X64, RecompCatalog.Platform.ANDROID), z.builds.map { it.platform }.toSet())
|
||||
val win = z.build(RecompCatalog.Platform.WINDOWS_X64)!!
|
||||
assertEquals("Zelda64Recompiled.exe", win.entry)
|
||||
assertEquals("a".repeat(64), win.sha256)
|
||||
assertTrue(z.build(RecompCatalog.Platform.LINUX_X64)!!.asset.matches("Zelda64Recompiled-v1.2.2-Linux-X64.zip"))
|
||||
assertNull(z.build(RecompCatalog.Platform.LINUX_X64)!!.file)
|
||||
assertNull(entry("ironwail").build(RecompCatalog.Platform.WINDOWS_X64))
|
||||
assertEquals("ironwail", entry("ironwail").build(RecompCatalog.Platform.LINUX_X64)!!.entry)
|
||||
val m = entry("otherm")
|
||||
assertEquals(listOf(RecompCatalog.Platform.WINDOWS_X64), m.builds.map { it.platform })
|
||||
assertEquals("OtherM.zip", m.builds.single().file)
|
||||
assertEquals("Run setup.bat once. Then play.", m.setup)
|
||||
assertEquals("Wii", m.origin)
|
||||
}
|
||||
|
||||
@Test fun anAndroidBuildUsesItsOwnReleaseAndUrl() {
|
||||
val e = RecompCatalog.parse("""{"schema":1,"recomps":[{"id":"a","name":"A","repo":"o/r","release":{"tag":"v9"},
|
||||
"android_release":{"tag":"apk-3","published":"p3"},"sources":["recompa"],"popularity":5,
|
||||
"builds":{"linux-x64":{"asset":"x","file":"x.zip"},"android":{"asset":"a","file":"a.apk","url":"https://h/a.apk",
|
||||
"sha256":"${"c".repeat(64)}","package":"com.example.game","signer":"${"d".repeat(64)}"}}}]}""")!!.single()
|
||||
assertEquals(RecompCatalog.Platform.ANDROID, e.preferred()?.platform)
|
||||
val apk = RecompInstaller.pinned(e, e.android!!)!!
|
||||
assertEquals("apk-3", apk.tag)
|
||||
assertEquals("https://h/a.apk", apk.url)
|
||||
assertEquals("com.example.game", e.android!!.pkg)
|
||||
assertEquals("v9", RecompInstaller.pinned(e, e.build(RecompCatalog.Platform.LINUX_X64)!!)!!.tag)
|
||||
assertEquals(listOf(RecompCatalog.SOURCE_RECOMPA), e.sources)
|
||||
assertNull(RecompCatalog.parse("""{"schema":1,"recomps":[{"id":"b","name":"B","repo":"o/r","builds":{"android":{"asset":"a","package":"not a package"}}}]}""")!!
|
||||
.single().android!!.pkg)
|
||||
@Test fun recompaPortsAddSignedApksAndTheirRomNeeds() {
|
||||
val z = entry("zelda64recomp")
|
||||
assertEquals(listOf(RecompCatalog.RECOMP_LAUNCHER.id, RecompCatalog.RECOMPA.id), z.sources)
|
||||
assertEquals(RecompCatalog.Platform.ANDROID, z.preferred()?.platform)
|
||||
val apk = z.android!!
|
||||
assertEquals("com.z.mm", apk.pkg)
|
||||
assertEquals("b".repeat(64), apk.signer)
|
||||
val pin = RecompInstaller.pinned(z, apk)!!
|
||||
assertEquals("https://h/z.apk", pin.url)
|
||||
assertEquals("a1", pin.tag)
|
||||
assertEquals("c".repeat(64), pin.sha256)
|
||||
val s = entry("sm64")
|
||||
assertEquals(listOf(RecompCatalog.RECOMPA.id), s.sources)
|
||||
assertEquals(RecompCatalog.DataKind.ROM, s.data.kind)
|
||||
assertEquals(listOf("9bef1128717f958171a4afac3ed78ee2bb4e86ce"), s.data.sha1)
|
||||
assertEquals("Pick sm64.z64.", s.data.note)
|
||||
}
|
||||
|
||||
@Test fun aNamedReleaseFileDownloadsWithoutTheApi() {
|
||||
val m = entry("otherm")
|
||||
assertEquals("https://github.com/o/otherm/releases/download/1.0/OtherM.zip", RecompInstaller.pinned(m, m.builds.single())!!.url)
|
||||
assertNull(RecompInstaller.pinned(entry("ironwail"), entry("ironwail").builds.single()))
|
||||
}
|
||||
|
||||
@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,"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 stable = RecompInstaller.pickRelease(body, RecompCatalog.globRegex("Game-Linux-ARM64.zip"), prerelease = false)!!
|
||||
assertEquals("v1", stable.tag)
|
||||
assertEquals("a".repeat(64), stable.sha256)
|
||||
assertNull(RecompInstaller.pickRelease(body, Regex("macOS"), prerelease = false))
|
||||
}
|
||||
|
||||
@Test fun pcPortsMatchOwnedGamesByTitleAndConsoleRecompsNever() {
|
||||
val steam = RecompData.Install(Store.STEAM, "Quake", temporary.newFolder("Quake"), "/root/.local/share/Steam/steamapps/common/Quake")
|
||||
val found = RecompData.resolve(entry("ironwail"), RecompData.Inputs(listOf(steam), emptyList()))
|
||||
assertEquals("/root/.local/share/Steam/steamapps/common/Quake", (found as RecompData.State.Found).guest)
|
||||
val item = CatalogItem(Store.GOG, "1", "Quake", null)
|
||||
assertTrue(RecompData.resolve(entry("ironwail"), RecompData.Inputs(emptyList(), listOf(RecompData.Owner(Store.GOG, "Quake™ Classic", item)))) is RecompData.State.Owned)
|
||||
assertTrue(RecompData.resolve(entry("ironwail"), RecompData.Inputs(emptyList(), listOf(RecompData.Owner(Store.GOG, "Quake II", item)))) is RecompData.State.BringYourOwn)
|
||||
val majora = RecompData.Install(Store.STEAM, "The Legend of Zelda: Majora's Mask", temporary.root, "/x")
|
||||
assertTrue(RecompData.resolve(entry("zelda64recomp"), RecompData.Inputs(listOf(majora), emptyList())) is RecompData.State.BringYourOwn)
|
||||
assertEquals(RecompData.titleKey("The Elder Scrolls III: Morrowind® Game of the Year Edition"), RecompData.titleKey("Elder Scrolls III - Morrowind"))
|
||||
}
|
||||
|
||||
@Test fun theWrapperStartsTheProgramFromItsOwnFolder() {
|
||||
val files = temporary.newFolder("files")
|
||||
File(files, "Game-1.0").mkdirs()
|
||||
File(files, "Game-1.0/game").apply {
|
||||
writeText("#!/bin/sh\necho \"cwd=\$PWD\"\nfor a in \"\$@\"; do echo \"arg=\$a\"; done\n")
|
||||
setExecutable(true)
|
||||
}
|
||||
val wrapper = File(files, RecompInstaller.WRAPPER).apply { writeText(RecompInstaller.wrapper("Game-1.0/game")) }
|
||||
val p = ProcessBuilder("/bin/sh", wrapper.name, "it's").directory(files).redirectErrorStream(true).start()
|
||||
p.waitFor(10, TimeUnit.SECONDS)
|
||||
val out = p.inputStream.bufferedReader().readLines()
|
||||
assertEquals(listOf("cwd=${File(files, "Game-1.0").canonicalPath}", "arg=it's"), out.map { it.replace(files.path, files.canonicalPath) })
|
||||
}
|
||||
|
||||
@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")
|
||||
assertEquals("ironwail-0.8.2-linux-x64/ironwail", RecompInstaller.findEntry(root, "ironwail")!!.relativeTo(root).path)
|
||||
assertNull(RecompInstaller.findEntry(root, "missing"))
|
||||
}
|
||||
|
||||
@Test fun anUnnamedProgramIsGuessedFromTheArchive() {
|
||||
@@ -63,7 +153,8 @@ class RecompsTest {
|
||||
if (program) "/lib/ld-linux-x86-64.so.2".toByteArray().copyInto(bytes, 64)
|
||||
writeBytes(bytes)
|
||||
}
|
||||
val e = RecompCatalog.parse("""{"schema":1,"recomps":[{"id":"sonic-recomp","name":"Sonic Recompiled","repo":"o/SonicRecomp","builds":{"linux-x64":{"asset":"x"}}}]}""")!!.single()
|
||||
val e = RecompCatalog.Entry("sonic-recomp", "Sonic Recompiled", "Sonic", "Xbox 360", "recomp", "o/SonicRecomp", "", "", null,
|
||||
listOf(RecompCatalog.Build(RecompCatalog.Platform.LINUX_X64, Regex("x"))), RecompCatalog.Data(RecompCatalog.DataKind.NONE, ""), listOf("recompa"))
|
||||
elf("Game/libSDL2.so", 4000, program = false)
|
||||
elf("Game/lib/helper", 9000, program = false)
|
||||
elf("Game/crashpad", 5000, program = true)
|
||||
@@ -73,136 +164,10 @@ class RecompsTest {
|
||||
assertEquals(image, RecompInstaller.guessEntry(root, e))
|
||||
}
|
||||
|
||||
@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.ANDROID, bundled.first { it.id == "unleashedrecomp" }.preferred()?.platform)
|
||||
assertTrue(bundled.any { it.preferred()?.platform == RecompCatalog.Platform.WINDOWS_X64 })
|
||||
}
|
||||
|
||||
@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)
|
||||
@Test fun anInstalledAndroidPortWithoutARecordIsNeverOfferedAnUpdate() {
|
||||
val unknown = RecompInstaller.Installed("z", "android:com.z.mm", null, null, "android", temporary.root)
|
||||
assertTrue(!RecompInstaller.isNewer(RecompInstaller.Release("a2", "q", "", "", null), unknown))
|
||||
val known = RecompInstaller.Installed("z", "android:com.z.mm", "a1", "p", "android", temporary.root)
|
||||
assertTrue(RecompInstaller.isNewer(RecompInstaller.Release("a2", "q", "", "", null), known))
|
||||
}
|
||||
}
|
||||
+74
-110
@@ -36,82 +36,42 @@ DroidDeck is signed in to. It never downloads ROMs, disc images or game files.
|
||||
|
||||
## Catalog
|
||||
|
||||
`app/src/main/assets/recomps/catalog.json` is generated by `tools/recomps/build_catalog.py` from three
|
||||
sources. Do not edit it by hand.
|
||||
DroidDeck keeps no catalog. `RecompCatalog` downloads the two community catalogs, caches them in
|
||||
`files/recomps/`, revalidates each with its ETag after 6 hours, and merges them on the device. Parsing
|
||||
both takes about 0.4 s.
|
||||
|
||||
1. `tools/recomps/curated.json`, DroidDeck's own entries. These carry store ids, data probes and launch
|
||||
arguments, and win every field they set.
|
||||
2. Recomp Launcher's `https://recomplauncher.com/pc-catalog.json`, for Windows and Linux builds. The
|
||||
script uses these fields:
|
||||
- `assets` globs become patterns, and `files` provides pins and sha256s.
|
||||
- `boot.start` / `start_linux` name the program.
|
||||
- `boot.files.what` or `needs` describe the data.
|
||||
- `setup_required` / `setup_steps` become the "Needs setup first" note.
|
||||
- Archived, `soon`, non-GitHub and `installer` / `not-a-game` / `source` entries are left out.
|
||||
Flatpak bundles are skipped.
|
||||
3. Recompa's `https://recompa.app/index.json`, for Android APKs. The fork with the most downloads that
|
||||
has a sha256, a package and a signer becomes the `android` build. `assets[0]` becomes the data
|
||||
requirement, with accepted sha1s. Ports without arm64 are skipped.
|
||||
1. Recomp Launcher's `https://recomplauncher.com/pc-catalog.json` (about 2.4 MB gzipped) supplies
|
||||
Windows and Linux builds:
|
||||
- `assets` globs become patterns, and `files` names give pinned files and sha256s.
|
||||
- `boot.start` / `start_linux` name the program, `boot.files.what` or `needs` the data, and
|
||||
`setup_required` / `setup_steps` the setup note.
|
||||
- Archived, `soon`, non-GitHub and `installer` / `not-a-game` / `source` entries are left out, as
|
||||
are Flatpak bundles and 32-bit or arm64 Windows builds.
|
||||
2. Recompa's `https://recompa.app/index.json` (about 1.2 MB gzipped) supplies Android APKs. Each port
|
||||
uses its fork with the most downloads that has a sha256, a package and a signer. `assets[0]` becomes
|
||||
the data requirement, with accepted sha1s. Ports without arm64, or needing a newer SDK, are left out,
|
||||
as is Recompa's own app.
|
||||
|
||||
Entries are matched by GitHub repo, then by id. A match adds the other catalog's builds and lists that
|
||||
catalog in `sources`, which the card shows as "via Recomp Launcher" or "via Recompa". The README credits
|
||||
both catalogs. As of 2026-11-30 the build gives 2,647 entries (about 2.3 MB):
|
||||
A Recompa port with the same GitHub repo (or id) as a Recomp Launcher app adds its APK to that app.
|
||||
The card lists the catalogs an entry came from, and the README credits both. As of 2026-11-30 this
|
||||
gives 2,646 entries:
|
||||
|
||||
| Build | Entries |
|
||||
|---|---|
|
||||
| Linux arm64 | 44 |
|
||||
| Linux x86-64 | 1,142 |
|
||||
| Windows x86-64 | 2,009 |
|
||||
| Android | 769 |
|
||||
| Linux arm64 | 40 |
|
||||
| Linux x86-64 | 1,141 |
|
||||
| Windows x86-64 | 2,007 |
|
||||
| Android | 768 |
|
||||
|
||||
Linux globs without a pin are resolved through the releases API when `GITHUB_TOKEN` or a signed-in
|
||||
`gh` is available. Otherwise the app resolves them at install time.
|
||||
|
||||
`RecompCatalog.load` prefers `Droid-Deck/DroidDeck-Components/main/recomps.json` once it is
|
||||
published. A scheduled job there can run `build_catalog.py` daily. Schema 1, as written by the
|
||||
script (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": "..." }, // pin_catalog.py for curated entries, else the source catalog
|
||||
"android_release": { "tag": "...", "published": "..." }, // when the APK comes from another repo than the PC build
|
||||
"sources": ["droiddeck", "recomp-launcher", "recompa"], "popularity": 415396,
|
||||
"setup": "Run setup.sh with your game folder first.",
|
||||
"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": "...", "file": "...", "url": "https://...", "sha256": "...",
|
||||
"package": "org.diasurgical.devilutionx", "signer": "<cert sha256>" }
|
||||
},
|
||||
"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": "..."
|
||||
}
|
||||
}
|
||||
```
|
||||
82% of builds name their release file, so they download without the GitHub releases API. The others
|
||||
are resolved through that API at install time, which allows 60 unauthenticated calls an hour per
|
||||
address.
|
||||
|
||||
The build is chosen in the order linux-arm64 (native), android, linux-x64 (FEX), windows-x64
|
||||
(Proton). A build without `entry` gets one guessed after unpacking:
|
||||
(Proton). When the catalog names no program, one is guessed after unpacking:
|
||||
- Linux: an AppImage, else the executable ELF whose name is closest to the project's, nearest the top.
|
||||
- Windows: `GameExePicker`'s best exe.
|
||||
|
||||
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`:
|
||||
@@ -122,7 +82,8 @@ checks during testing.
|
||||
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.
|
||||
`/opt/droiddeck-apps/<id>/files`, and a `droiddeck-recomp` wrapper, which starts the program from
|
||||
its own folder, 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>`
|
||||
@@ -134,58 +95,57 @@ checks during testing.
|
||||
is kept in `files/recomps-android/<package>`.
|
||||
5. 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.
|
||||
new release first and then deletes the old folder.
|
||||
|
||||
## Game data
|
||||
|
||||
`RecompData.inputs` collects the installs DroidDeck knows about:
|
||||
The catalogs name the game a PC port needs (`game`), but not its store ids. For PC ports,
|
||||
`RecompData` compares that title with the player's installs (store sidecars and Steam client
|
||||
libraries) and owned games (`StoresState.library` and the Steam page). Titles are compared without
|
||||
case, punctuation, a leading "The", or edition words such as GOTY, Definitive, Enhanced or Complete.
|
||||
|
||||
- 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.
|
||||
- **Installed:** the card shows "Installed on Steam" and the guest folder to point the program at.
|
||||
- **Owned:** the card offers "Install game".
|
||||
- **Otherwise:** the card shows what the catalog says the game needs.
|
||||
|
||||
`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.
|
||||
Console recomps are never matched, because no store sells their dumps.
|
||||
|
||||
## 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.
|
||||
- **Top of the page:** a header, one line saying what the tab does, a search box (name, game,
|
||||
origin, repo), and filter chips with counts: All, You own the game, Bring your own files, Installed.
|
||||
- **List:** a lazy grid, two columns from 820 dp and one below, capped at 300 cards until the player
|
||||
searches. Cards are sorted installed first, then games installed from a store, then owned games,
|
||||
then the rest by download count.
|
||||
- **Each card:**
|
||||
- The catalog's art, the game and its origin.
|
||||
- Chips for the build (green once installed), the data, "Android app too", "Needs setup first",
|
||||
and "via Recomp Launcher" / "via Recompa".
|
||||
- Actions: Install, or Play / Open in Games; Update to <tag> when a feed names a newer release;
|
||||
Install game; and Remove or Project page.
|
||||
- **Credits:** a line at the end of the page names both catalogs.
|
||||
- **Focus:** 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.
|
||||
- Ironwail v0.8.2 (Quake), linux-x64, on the Duo through FEX: pinned install in about 5 s, then
|
||||
launch. With no Quake install linked, it asks for `-basedir`, which is the argument the
|
||||
wrapper passes once Steam or GOG Quake is found.
|
||||
- Pocket FIT Elite (portrait 1080×1920): the More tile and the single-column page. The first
|
||||
install attempt there got 403 from the releases API (rate limit), which led to the pinned
|
||||
downloads. After pinning, the install worked. Launching then stopped with exit 126: FEX needs
|
||||
the Steam Linux Runtime (sniper), and that device had never opened Steam. This applies to
|
||||
every x86 Linux app in DroidDeck; the card should say so (see below).
|
||||
- Unit tests: `RecompsTest`, which runs the wrapper under `/bin/sh` and covers release picking
|
||||
and pinning, data probing and resolution, and catalog validation, and `NavTabsTest`.
|
||||
These device runs used the earlier hand-made list. Each recomp is still installed and launched by the
|
||||
same code.
|
||||
|
||||
- **Retroid Pocket Duo:**
|
||||
- Zelda 64: Recompiled v1.2.2 (linux-arm64) installed and reached its own Select ROM screen natively.
|
||||
- Ironwail v0.8.2 (linux-x64) ran through FEX and asked for its `-basedir` (Quake's folder).
|
||||
- Ship of Harkinian (Android, Recompa): the APK passed the package and signer checks, Android's
|
||||
install prompt appeared, and after confirming it the card showed Play, which launched the app.
|
||||
- Ports already installed were recognised.
|
||||
- The top screen shows the page; the bottom screen's rail is labelled Recomps.
|
||||
- **Pocket FIT Elite (portrait 1080×1920):**
|
||||
- The More tile, the one-column page and installs work.
|
||||
- A launch of an x86 Linux build stopped with exit 126: FEX needs the Steam Linux Runtime
|
||||
(sniper), and that device had never opened Steam. This applies to every x86 Linux app in
|
||||
DroidDeck.
|
||||
- **Unit tests:** `RecompsTest` parses and merges sample feeds and covers pins, signed APKs, title
|
||||
matching, release picking, program guessing and the wrapper (run under `/bin/sh`). `NavTabsTest`
|
||||
covers the tab.
|
||||
|
||||
## Not done yet
|
||||
|
||||
@@ -196,13 +156,17 @@ from 820 dp and one below. Controller focus enters on the first card's primary b
|
||||
Xarishark offered help on the DroidDeck Discord (2026-11-12).
|
||||
- **Choosing a build.** Let the player choose another build when an entry has several (for example
|
||||
the Android port instead of the FEX one).
|
||||
- **Linking your own folder.** For data copied from a PC: a folder picker that sets `recomp-data`
|
||||
by hand.
|
||||
- **Linking your own folder.** For data copied from a PC: a folder picker the card remembers.
|
||||
- **Native builds the catalogs miss.** Recomp Launcher lists one Linux build per app, usually x86-64.
|
||||
Several projects (Zelda64Recomp, Starfox64Recomp, BanjoRecomp, DevilutionX) also publish arm64
|
||||
builds. Trying the arm64 sibling of a Linux asset first would run those natively instead of
|
||||
through FEX.
|
||||
- **ROM checks.** Hash a chosen ROM against `sha1` and say whether it is the right one.
|
||||
- **x86 runtime hint.** A linux-x64 build needs Steam opened once so the FEX runtime (sniper) is
|
||||
installed. Show that on the card, or fall back to the Windows build.
|
||||
- **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.
|
||||
installed by the Steam client counts as installed regardless. Title matching can miss renamed
|
||||
editions.
|
||||
- **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.
|
||||
@@ -1,290 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Build DroidDeck's recomp catalog from its curated list, Recomp Launcher's and Recompa's.
|
||||
|
||||
Sources, merged in this order (an earlier source wins a field; later ones add builds and credits):
|
||||
tools/recomps/curated.json DroidDeck's own entries: store ids, data probes, launch args
|
||||
https://recomplauncher.com/pc-catalog.json Recomp Launcher (github.com/elripalda/RecompLauncher):
|
||||
Windows and Linux builds of PC recomps and ports
|
||||
https://recompa.app/index.json Recompa (github.com/kalasyan/recompa): Android APKs
|
||||
|
||||
Entries are matched by GitHub repo, then by id. Only builds DroidDeck can run are kept (Linux x86-64 or
|
||||
arm64, Windows x86-64, Android arm64), and an entry with none is dropped. Every entry lists the catalogs it
|
||||
came from in "sources", which the Recomps tab shows. Pins use each catalog's tag and sha256; a Linux or Windows
|
||||
asset that only has a glob is resolved through the releases API when GITHUB_TOKEN or a signed-in `gh` is
|
||||
available, and otherwise keeps a pattern the app resolves at install time.
|
||||
"""
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import urllib.request
|
||||
|
||||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
CURATED = os.path.join(HERE, "curated.json")
|
||||
OUTPUT = os.path.join(HERE, "..", "..", "app", "src", "main", "assets", "recomps", "catalog.json")
|
||||
RL_URL = "https://recomplauncher.com/pc-catalog.json"
|
||||
RECOMPA_URL = "https://recompa.app/index.json"
|
||||
ORIGINS = {
|
||||
"pc": "PC", "n64": "N64", "x360": "Xbox 360", "xbox360": "Xbox 360", "xbox": "Xbox", "ps1": "PS1", "ps2": "PS2",
|
||||
"ps3": "PS3", "ps4": "PS4", "switch": "Switch", "snes": "SNES", "nes": "NES", "gc": "GameCube", "wii": "Wii",
|
||||
"gba": "GBA", "nds": "DS", "ds": "DS", "3ds": "3DS", "arcade": "Arcade", "dreamcast": "Dreamcast", "saturn": "Saturn",
|
||||
"genesis": "Genesis", "megadrive": "Mega Drive", "psp": "PSP", "vita": "Vita", "gb": "Game Boy", "gbc": "Game Boy Color",
|
||||
}
|
||||
ARCHIVE = re.compile(r"\.(zip|7z|tar|tgz|tar\.(gz|xz|bz2|zst)|appimage)$", re.I)
|
||||
ID = re.compile(r"[^a-z0-9-]+")
|
||||
HUBS = {"io.github.kalasyan.recompa"}
|
||||
|
||||
|
||||
def fetch(url, local=None):
|
||||
if local:
|
||||
with open(local, encoding="utf-8") as f:
|
||||
return json.load(f)
|
||||
req = urllib.request.Request(url, headers={"User-Agent": "DroidDeck-catalog-builder"})
|
||||
with urllib.request.urlopen(req, timeout=120) as r:
|
||||
return json.load(r)
|
||||
|
||||
|
||||
_releases = {}
|
||||
|
||||
|
||||
def releases(repo):
|
||||
if repo in _releases:
|
||||
return _releases[repo]
|
||||
token = os.environ.get("GITHUB_TOKEN")
|
||||
path = f"repos/{repo}/releases?per_page=15"
|
||||
data = None
|
||||
if token:
|
||||
req = urllib.request.Request("https://api.github.com/" + path, headers={"Authorization": f"Bearer {token}"})
|
||||
try:
|
||||
with urllib.request.urlopen(req, timeout=30) as r:
|
||||
data = json.load(r)
|
||||
except Exception:
|
||||
data = None
|
||||
elif subprocess.run(["gh", "auth", "status"], capture_output=True).returncode == 0:
|
||||
out = subprocess.run(["gh", "api", path], capture_output=True, text=True)
|
||||
data = json.loads(out.stdout) if out.returncode == 0 else None
|
||||
_releases[repo] = data
|
||||
return data
|
||||
|
||||
|
||||
def glob_regex(glob):
|
||||
return "^" + "".join(".*" if c == "*" else re.escape(c) for c in glob) + "$"
|
||||
|
||||
|
||||
def slug(s):
|
||||
return ID.sub("-", s.lower()).strip("-")[:48] or "recomp"
|
||||
|
||||
|
||||
def repo_of(url):
|
||||
m = re.match(r"https?://github\.com/([\w.-]+/[\w.-]+?)(?:\.git)?/?$", url or "")
|
||||
return m.group(1) if m else None
|
||||
|
||||
|
||||
def first_line(md):
|
||||
text = re.sub(r"[`*_#>\[\]]", "", md or "").strip()
|
||||
return text.splitlines()[0][:200] if text else ""
|
||||
|
||||
|
||||
def rl_builds(app, resolve):
|
||||
out = {}
|
||||
assets = app.get("assets") or {}
|
||||
files = app.get("files") or {}
|
||||
boot = app.get("boot") or {}
|
||||
tag = app.get("tag")
|
||||
for os_name in ("linux", "windows"):
|
||||
glob = assets.get(os_name)
|
||||
if not glob or "flatpak" in glob.lower() or not ARCHIVE.search(glob) and not glob.lower().endswith(".exe"):
|
||||
continue
|
||||
if os_name == "linux":
|
||||
key = "linux-arm64" if re.search(r"aarch64|arm64", glob, re.I) else "linux-x64"
|
||||
start = boot.get("start_linux") or ""
|
||||
else:
|
||||
if re.search(r"arm64|aarch64|win32|x86(?!_64|-64)", glob, re.I):
|
||||
continue
|
||||
key = "windows-x64"
|
||||
start = boot.get("start") if (boot.get("start") or "").lower().endswith(".exe") else ""
|
||||
build = {"asset": glob_regex(glob)}
|
||||
if start and "/" not in start:
|
||||
build["entry"] = start
|
||||
pinned = files.get(os_name) or {}
|
||||
if pinned.get("name"):
|
||||
build["file"] = pinned["name"]
|
||||
if re.fullmatch(r"[0-9a-f]{64}", pinned.get("sha256") or ""):
|
||||
build["sha256"] = pinned["sha256"]
|
||||
elif "*" not in glob and tag:
|
||||
build["file"] = glob
|
||||
elif resolve and tag:
|
||||
for r in releases(app["repo"]) or []:
|
||||
if r.get("tag_name") != tag:
|
||||
continue
|
||||
a = next((a for a in r.get("assets", []) if re.search(build["asset"], a["name"], re.I)), None)
|
||||
if a:
|
||||
build["file"] = a["name"]
|
||||
d = a.get("digest") or ""
|
||||
if d.startswith("sha256:"):
|
||||
build["sha256"] = d[7:]
|
||||
out[key] = build
|
||||
return out
|
||||
|
||||
|
||||
def from_rl(app, resolve):
|
||||
if app.get("archived") or app.get("soon") or (app.get("host") or "github") != "github" or not app.get("repo"):
|
||||
return None
|
||||
boot = app.get("boot") or {}
|
||||
if boot.get("kind") in ("installer", "not-a-game", "source"):
|
||||
return None
|
||||
builds = rl_builds(app, resolve)
|
||||
if not builds:
|
||||
return None
|
||||
files = boot.get("files") or {}
|
||||
what = files.get("what") or app.get("needs") or ""
|
||||
origin = (app.get("origin") or "").lower()
|
||||
entry = {
|
||||
"id": slug(app["id"]), "name": app.get("name") or app["id"], "game": app.get("game") or app.get("name") or app["id"],
|
||||
"origin": ORIGINS.get(origin, origin.upper()), "type": "recomp" if "recomp" in (app["id"] + app["repo"]).lower() else "port",
|
||||
"repo": app["repo"], "license": app.get("license") or "", "art": app.get("icon") or app.get("cover") or "",
|
||||
"popularity": int(app.get("downloads") or 0),
|
||||
"builds": builds,
|
||||
"data": {"kind": "dump", "label": what, "note": app.get("blurb") or ""} if what else {"kind": "none"},
|
||||
"sources": ["recomp-launcher"],
|
||||
}
|
||||
if app.get("tag"):
|
||||
entry["release"] = {"tag": app["tag"], "published": app.get("released_at") or ""}
|
||||
if app.get("setup_required"):
|
||||
steps = app.get("setup_steps") or []
|
||||
entry["setup"] = " ".join(steps[:2])[:300] if steps else "Needs a setup step on a PC first."
|
||||
return entry
|
||||
|
||||
|
||||
def best_fork(port):
|
||||
forks = [f for f in port.get("forks") or [] if ((f.get("release") or {}).get("asset") or {}).get("sha256")
|
||||
and f.get("signer_sha256") and f.get("package")]
|
||||
return max(forks, key=lambda f: (f.get("downloads") or 0), default=None)
|
||||
|
||||
|
||||
def from_recompa(port):
|
||||
req = port.get("requirements") or {}
|
||||
if req.get("abi") and "arm64-v8a" not in req["abi"]:
|
||||
return None
|
||||
if (req.get("min_sdk") or 0) > 34:
|
||||
return None
|
||||
fork = best_fork(port)
|
||||
if not fork or fork["package"] in HUBS:
|
||||
return None
|
||||
asset = fork["release"]["asset"]
|
||||
android = {
|
||||
"asset": "^" + re.escape(asset["name"]) + "$", "file": asset["name"], "url": asset["url"], "sha256": asset["sha256"],
|
||||
"package": fork["package"], "signer": fork["signer_sha256"],
|
||||
}
|
||||
data = {"kind": "none"}
|
||||
assets = port.get("assets") or []
|
||||
if assets:
|
||||
a = assets[0]
|
||||
data = {"kind": "rom" if port.get("original_platform") not in ("pc", "other") else "dump", "label": a.get("label") or "",
|
||||
"sha1": [x["sha1"].lower() for x in a.get("accepted") or [] if re.fullmatch(r"[0-9a-fA-F]{40}", x.get("sha1") or "")],
|
||||
"note": first_line(a.get("instructions_md"))}
|
||||
origin = (port.get("original_platform") or "").lower()
|
||||
return {
|
||||
"id": slug(port["id"]), "name": fork.get("name") or port.get("name") or port["id"], "game": port.get("game") or port.get("name") or "",
|
||||
"origin": ORIGINS.get(origin, origin.upper() if origin != "other" else ""), "type": port.get("type") or "port",
|
||||
"repo": repo_of(port.get("upstream")) or fork["repo"], "license": "", "art": (port.get("art") or {}).get("cover") or "",
|
||||
"popularity": int(fork.get("downloads") or 0),
|
||||
"release": {"tag": fork["release"].get("tag") or "", "published": fork["release"].get("published_at") or ""},
|
||||
"builds": {"android": android}, "data": data, "sources": ["recompa"],
|
||||
"android_release": {"tag": fork["release"].get("tag") or "", "published": fork["release"].get("published_at") or ""},
|
||||
}
|
||||
|
||||
|
||||
def merge(base, extra):
|
||||
for key, build in extra["builds"].items():
|
||||
if key not in base["builds"] or key == "android" and "package" not in base["builds"][key]:
|
||||
base["builds"][key] = build
|
||||
if key == "android":
|
||||
base["android_release"] = extra.get("android_release") or extra.get("release")
|
||||
for source in extra["sources"]:
|
||||
if source not in base.setdefault("sources", ["droiddeck"]):
|
||||
base["sources"].append(source)
|
||||
if (base.get("data") or {}).get("kind", "none") == "none" and extra["data"].get("kind") != "none":
|
||||
base["data"] = extra["data"]
|
||||
if "release" not in base and extra.get("release") and "android" not in extra["builds"]:
|
||||
base["release"] = extra["release"]
|
||||
for field in ("art", "license", "origin"):
|
||||
if not base.get(field) and extra.get(field):
|
||||
base[field] = extra[field]
|
||||
base["popularity"] = max(base.get("popularity", 0), extra.get("popularity", 0))
|
||||
if extra.get("setup") and not base.get("setup") and "droiddeck" not in base["sources"]:
|
||||
base["setup"] = extra["setup"]
|
||||
|
||||
|
||||
def build(curated, rl, recompa, resolve):
|
||||
out, by_repo, by_id = [], {}, {}
|
||||
|
||||
def add(entry):
|
||||
key = entry["repo"].lower()
|
||||
hit = by_repo.get(key) or by_id.get(entry["id"])
|
||||
if hit:
|
||||
merge(hit, entry)
|
||||
return
|
||||
base = entry["id"]
|
||||
n = 2
|
||||
while entry["id"] in by_id:
|
||||
entry["id"] = f"{base[:44]}-{n}"
|
||||
n += 1
|
||||
out.append(entry)
|
||||
by_repo.setdefault(key, entry)
|
||||
by_id[entry["id"]] = entry
|
||||
|
||||
for e in curated["recomps"]:
|
||||
e = json.loads(json.dumps(e))
|
||||
e.setdefault("sources", ["droiddeck"])
|
||||
add(e)
|
||||
for app in rl.get("apps") or []:
|
||||
e = from_rl(app, resolve)
|
||||
if e:
|
||||
add(e)
|
||||
for port in recompa.get("ports") or []:
|
||||
e = from_recompa(port)
|
||||
if e:
|
||||
add(e)
|
||||
for e in out:
|
||||
if "android_release" in e and e.get("release", {}).get("tag") == e["android_release"].get("tag"):
|
||||
del e["android_release"]
|
||||
if "release" not in e and "android_release" in e and set(e["builds"]) == {"android"}:
|
||||
e["release"] = e.pop("android_release")
|
||||
return {
|
||||
"schema": 1,
|
||||
"sources": {
|
||||
"droiddeck": {"name": "DroidDeck", "url": "https://github.com/Droid-Deck/DroidDeck"},
|
||||
"recomp-launcher": {"name": "Recomp Launcher", "url": "https://recomplauncher.com",
|
||||
"updated": rl.get("updated", "")},
|
||||
"recompa": {"name": "Recompa", "url": "https://recompa.app", "updated": recompa.get("generated_at", "")},
|
||||
},
|
||||
"recomps": out,
|
||||
}
|
||||
|
||||
|
||||
def main():
|
||||
p = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
p.add_argument("--recomp-launcher", help="local copy of pc-catalog.json")
|
||||
p.add_argument("--recompa", help="local copy of index.json")
|
||||
p.add_argument("--no-resolve", action="store_true", help="do not call the releases API for unpinned globs")
|
||||
p.add_argument("-o", "--output", default=OUTPUT)
|
||||
args = p.parse_args()
|
||||
with open(CURATED, encoding="utf-8") as f:
|
||||
curated = json.load(f)
|
||||
catalog = build(curated, fetch(RL_URL, args.recomp_launcher), fetch(RECOMPA_URL, args.recompa), not args.no_resolve)
|
||||
os.makedirs(os.path.dirname(os.path.abspath(args.output)), exist_ok=True)
|
||||
with open(args.output, "w", encoding="utf-8") as f:
|
||||
json.dump(catalog, f, ensure_ascii=False, separators=(",", ":"))
|
||||
f.write("\n")
|
||||
counts = {}
|
||||
for e in catalog["recomps"]:
|
||||
for k in e["builds"]:
|
||||
counts[k] = counts.get(k, 0) + 1
|
||||
print(f"{len(catalog['recomps'])} entries, builds {counts}, {os.path.getsize(args.output) // 1024} KB", file=sys.stderr)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,423 +0,0 @@
|
||||
{
|
||||
"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",
|
||||
"file": "Zelda64Recompiled-v1.2.2-Linux-ARM64.zip",
|
||||
"sha256": "2e49b96aced578363065e1764ca96eaa5590cb6f7e80efd10e8ce1a08462b933"
|
||||
},
|
||||
"linux-x64": {
|
||||
"asset": "^Zelda64Recompiled-.*-Linux-X64\\.zip$",
|
||||
"entry": "Zelda64Recompiled",
|
||||
"file": "Zelda64Recompiled-v1.2.2-Linux-X64.zip",
|
||||
"sha256": "de8b19cdb4e3ad0c10fd6d8127f7a6cc2a9eba106d89c753439178b718887c42"
|
||||
},
|
||||
"windows-x64": {
|
||||
"asset": "^Zelda64Recompiled-.*-Windows\\.zip$",
|
||||
"entry": "Zelda64Recompiled.exe",
|
||||
"file": "Zelda64Recompiled-v1.2.2-Windows.zip",
|
||||
"sha256": "d02b95f1cf5e4d44d6587fa6136c6db521f61aa41ba8700c05f91bea8b0a26d0"
|
||||
}
|
||||
},
|
||||
"data": {
|
||||
"kind": "rom",
|
||||
"label": "Majora's Mask (USA) N64 ROM",
|
||||
"sha1": [
|
||||
"d6133ace5afaa0882cf214cf88daba39e266c078"
|
||||
],
|
||||
"note": "Choose the ROM from the recomp's own start screen."
|
||||
},
|
||||
"release": {
|
||||
"tag": "v1.2.2",
|
||||
"published": "2025-08-27T00:58:35Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
"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",
|
||||
"file": "Starfox64Recompiled-v1.0.3-Linux-ARM64-Release.zip",
|
||||
"sha256": "85408daa5ceac1fc208a744b0a35fb316c417d62c709761aceb242353fb2a1c0"
|
||||
},
|
||||
"linux-x64": {
|
||||
"asset": "^Starfox64Recompiled-.*-Linux-X64-Release\\.zip$",
|
||||
"entry": "Starfox64Recompiled",
|
||||
"file": "Starfox64Recompiled-v1.0.3-Linux-X64-Release.zip",
|
||||
"sha256": "e74932bd0edb6186a015dabaa87b6b24af3d3b5511ff3b0293a2c3331840cdf0"
|
||||
},
|
||||
"windows-x64": {
|
||||
"asset": "^Starfox64Recompiled-.*-Windows-.*\\.zip$",
|
||||
"entry": "Starfox64Recompiled.exe",
|
||||
"file": "Starfox64Recompiled-v1.0.3-Windows-RelWithDebInfo.zip",
|
||||
"sha256": "768c18b0aeb325a0102f722338f09a270a76eeebea29154764147a93d0bde530"
|
||||
}
|
||||
},
|
||||
"data": {
|
||||
"kind": "rom",
|
||||
"label": "Star Fox 64 (USA) N64 ROM",
|
||||
"note": "Choose the ROM from the recomp's own start screen."
|
||||
},
|
||||
"release": {
|
||||
"tag": "1.0.3",
|
||||
"published": "2025-12-30T04:13:00Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
"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",
|
||||
"file": "BanjoRecompiled-v1.0.2-Linux-ARM64.tar.gz",
|
||||
"sha256": "53515be8bc453bc32ed8cbc72e3cd06350ab4a28bd94b0aa6499d4b963a83757"
|
||||
},
|
||||
"linux-x64": {
|
||||
"asset": "^BanjoRecompiled-.*-Linux-X64\\.tar\\.gz$",
|
||||
"entry": "BanjoRecompiled",
|
||||
"file": "BanjoRecompiled-v1.0.2-Linux-X64.tar.gz",
|
||||
"sha256": "a34a4d361221171ea638e0165301fff817c53b9cd46167c5affd37867cfc7ad0"
|
||||
},
|
||||
"windows-x64": {
|
||||
"asset": "^BanjoRecompiled-.*-Windows\\.zip$",
|
||||
"entry": "BanjoRecompiled.exe",
|
||||
"file": "BanjoRecompiled-v1.0.2-Windows.zip",
|
||||
"sha256": "fc34aad48e06681878bedd13b88d5332a2f21f6a98cafc931c94d54892a4dd92"
|
||||
}
|
||||
},
|
||||
"data": {
|
||||
"kind": "rom",
|
||||
"label": "Banjo-Kazooie (USA) N64 ROM",
|
||||
"note": "Choose the ROM from the recomp's own start screen."
|
||||
},
|
||||
"release": {
|
||||
"tag": "v1.0.2",
|
||||
"published": "2026-07-31T19:43:17Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
"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",
|
||||
"file": "2Ship-Battler-Bravo-Linux.zip",
|
||||
"sha256": "6cdd4fe06f3f9b095e99c86fef70b9265cc921fb6faa7ba1e18e94e90ed0b345"
|
||||
},
|
||||
"windows-x64": {
|
||||
"asset": "^2Ship-.*-Win64\\.zip$",
|
||||
"entry": "2ship.exe",
|
||||
"file": "2Ship-Battler-Bravo-Win64.zip",
|
||||
"sha256": "a46664a01623ad5d7cc82d29a9889699f6a98c9501c7a959a089f34380c1f078"
|
||||
}
|
||||
},
|
||||
"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."
|
||||
},
|
||||
"release": {
|
||||
"tag": "5.0.1",
|
||||
"published": "2026-08-25T17:54:43Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
"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",
|
||||
"file": "UnleashedRecomp-Windows.zip"
|
||||
}
|
||||
},
|
||||
"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."
|
||||
},
|
||||
"release": {
|
||||
"tag": "v1.0.3",
|
||||
"published": "2025-04-03T22:04:45Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
"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}"
|
||||
],
|
||||
"file": "devilutionx-linux-aarch64.tar.xz",
|
||||
"sha256": "71f34342cd750dc6dec1effefa250e90a5fe0f127e79d4c9c66f4d07706c3442"
|
||||
},
|
||||
"linux-x64": {
|
||||
"asset": "^devilutionx-linux-x86_64\\.tar\\.xz$",
|
||||
"entry": "devilutionx",
|
||||
"args": [
|
||||
"--data-dir",
|
||||
"{data}"
|
||||
],
|
||||
"file": "devilutionx-linux-x86_64.tar.xz",
|
||||
"sha256": "3c0a79afad682054c4d11a91728887617b9f5dfbd8b6810dbb9226c380474432"
|
||||
},
|
||||
"windows-x64": {
|
||||
"asset": "^devilutionx-windows-x86_64\\.zip$",
|
||||
"entry": "devilutionx.exe",
|
||||
"file": "devilutionx-windows-x86_64.zip",
|
||||
"sha256": "a20cfb62cd611f76aac78f9bf09a28f57794fbfe63ae6da9245deca446680b2b"
|
||||
},
|
||||
"android": {
|
||||
"asset": "^devilutionx-android\\.apk$",
|
||||
"file": "devilutionx-android.apk",
|
||||
"sha256": "c5a53ff35223e367eba75ef8ed2caa31ea8e78792d8aff00f2cee51a0566b28f"
|
||||
}
|
||||
},
|
||||
"data": {
|
||||
"kind": "store",
|
||||
"label": "Diablo (GOG)",
|
||||
"stores": [
|
||||
{
|
||||
"store": "gog",
|
||||
"id": "1412601690"
|
||||
}
|
||||
],
|
||||
"probe": "DIABDAT.MPQ"
|
||||
},
|
||||
"release": {
|
||||
"tag": "1.5.5",
|
||||
"published": "2025-10-30T17:00:17Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
"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}"
|
||||
],
|
||||
"file": "ironwail-0.8.2-linux-x64.tar.gz",
|
||||
"sha256": "fcb0219d13c50f64728892f0558b4761ba5578319a6cc01021fad981c6333aa5"
|
||||
},
|
||||
"windows-x64": {
|
||||
"asset": "^ironwail-.*-win64\\.zip$",
|
||||
"entry": "ironwail.exe",
|
||||
"file": "ironwail-0.8.2-win64.zip",
|
||||
"sha256": "0e54e9089ce72bad73c288148cfb5474a00b05d9e1da1c8feb0b76665faf7d01"
|
||||
}
|
||||
},
|
||||
"data": {
|
||||
"kind": "store",
|
||||
"label": "Quake (Steam or GOG)",
|
||||
"stores": [
|
||||
{
|
||||
"store": "steam",
|
||||
"id": "2310"
|
||||
},
|
||||
{
|
||||
"store": "gog",
|
||||
"id": "1440166133"
|
||||
}
|
||||
],
|
||||
"probe": "id1/pak0.pak"
|
||||
},
|
||||
"release": {
|
||||
"tag": "v0.8.2",
|
||||
"published": "2026-08-11T17:20:22Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
"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$",
|
||||
"file": "OpenRCT2-v0.5.7-linux-x86_64.AppImage",
|
||||
"sha256": "d02ecb52d946d1e5f00db53a164fadbd41bbb8636f6f5cdddb44d954a3bcdb64"
|
||||
},
|
||||
"windows-x64": {
|
||||
"asset": "^OpenRCT2-.*-windows-portable-x64\\.zip$",
|
||||
"entry": "openrct2.exe",
|
||||
"file": "OpenRCT2-v0.5.7-windows-portable-x64.zip",
|
||||
"sha256": "c8759848d0035a5de41985c5c6b8adb69aa197731f28a6f7e7441830912b0300"
|
||||
},
|
||||
"android": {
|
||||
"asset": "^OpenRCT2-.*-android\\.apk$",
|
||||
"file": "OpenRCT2-v0.5.7-android.apk",
|
||||
"sha256": "3cc3b3078a120ae5a65b259c21bc989765a7008883f3298604976c607032cb0d"
|
||||
}
|
||||
},
|
||||
"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."
|
||||
},
|
||||
"release": {
|
||||
"tag": "v0.5.7",
|
||||
"published": "2026-11-01T10:57:49Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
"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",
|
||||
"file": "fallout2-ce-linux-x64.tar.gz"
|
||||
},
|
||||
"windows-x64": {
|
||||
"asset": "^fallout2-ce-windows-x64\\.zip$",
|
||||
"entry": "fallout2-ce.exe",
|
||||
"file": "fallout2-ce-windows-x64.zip"
|
||||
},
|
||||
"android": {
|
||||
"asset": "^fallout2-ce-android\\.apk$",
|
||||
"file": "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"
|
||||
},
|
||||
"release": {
|
||||
"tag": "v1.3.0",
|
||||
"published": "2024-04-21T10:16:02Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
"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",
|
||||
"file": "openmw-0.51.0-Linux-64Bit.tar.gz",
|
||||
"sha256": "a39459e6adad06163eb0ffd4d80229e13aec8748211c3dfd5bf95c204ae68f0b"
|
||||
}
|
||||
},
|
||||
"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."
|
||||
},
|
||||
"release": {
|
||||
"tag": "openmw-0.51.0",
|
||||
"published": "2026-06-19T19:58:46Z"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
#!/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__), "curated.json")
|
||||
|
||||
|
||||
def releases(repo):
|
||||
token = os.environ.get("GITHUB_TOKEN")
|
||||
url = f"https://api.github.com/repos/{repo}/releases?per_page=15"
|
||||
if not token:
|
||||
out = subprocess.run(["gh", "api", url.removeprefix("https://api.github.com/")], capture_output=True, text=True)
|
||||
if out.returncode == 0:
|
||||
return json.loads(out.stdout)
|
||||
headers = {"Accept": "application/vnd.github+json"} | ({"Authorization": f"Bearer {token}"} if token else {})
|
||||
with urllib.request.urlopen(urllib.request.Request(url, headers=headers), timeout=30) as r:
|
||||
return json.load(r)
|
||||
|
||||
|
||||
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()
|
||||
@@ -1,83 +0,0 @@
|
||||
import importlib.util
|
||||
import json
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
|
||||
spec = importlib.util.spec_from_file_location(
|
||||
'build_catalog', Path(__file__).resolve().parents[1] / 'recomps' / 'build_catalog.py')
|
||||
build_catalog = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(build_catalog)
|
||||
|
||||
CURATED = {"schema": 1, "recomps": [{
|
||||
"id": "zelda64recomp", "name": "Zelda 64: Recompiled", "repo": "Zelda64Recomp/Zelda64Recomp",
|
||||
"builds": {"linux-arm64": {"asset": "^Z-ARM64\\.zip$", "entry": "Zelda64Recompiled"}},
|
||||
"data": {"kind": "rom", "label": "Majora's Mask ROM"},
|
||||
}]}
|
||||
|
||||
RL = {"updated": "2026-11-30", "apps": [
|
||||
{"id": "zelda64recomp", "name": "Zelda 64", "repo": "Zelda64Recomp/Zelda64Recomp", "tag": "v1.2.2", "origin": "n64",
|
||||
"assets": {"windows": "Z-*-Windows.zip", "linux": "Z-*-Linux-X64.zip"},
|
||||
"files": {"windows": {"name": "Z-v1.2.2-Windows.zip", "sha256": "a" * 64}}, "downloads": 10},
|
||||
{"id": "otherm-recomp", "name": "Other M", "repo": "o/otherm", "tag": "1.0", "origin": "wii", "downloads": 5,
|
||||
"assets": {"windows": "OtherM.zip", "linux": "OtherM-Flatpak.zip"}, "boot": {"kind": "portable", "start": "OtherM.exe",
|
||||
"files": {"what": "Your Metroid: Other M disc"}}, "setup_required": True, "setup_steps": ["Run setup.bat once."]},
|
||||
{"id": "gone", "name": "Gone", "repo": "o/gone", "archived": True, "assets": {"windows": "g.zip"}},
|
||||
{"id": "tool", "name": "Tool", "repo": "o/tool", "boot": {"kind": "not-a-game"}, "assets": {"windows": "t.zip"}},
|
||||
]}
|
||||
|
||||
RECOMPA = {"generated_at": "2026-11-30", "ports": [
|
||||
{"id": "zelda64recomp", "name": "Majora", "upstream": "https://github.com/Zelda64Recomp/Zelda64Recomp", "original_platform": "n64",
|
||||
"requirements": {"abi": ["arm64-v8a"]}, "forks": [
|
||||
{"repo": "x/Zelda-Android", "name": "Zelda Android", "package": "com.z.mm", "signer_sha256": "b" * 64, "downloads": 9,
|
||||
"release": {"tag": "a1", "published_at": "p", "asset": {"name": "z.apk", "url": "https://h/z.apk", "sha256": "c" * 64}}}]},
|
||||
{"id": "x86only", "name": "X", "upstream": "https://github.com/o/x", "requirements": {"abi": ["x86_64"]}, "forks": []},
|
||||
{"id": "sm64", "name": "SM64", "upstream": "https://github.com/o/sm64", "original_platform": "n64", "type": "decomp",
|
||||
"requirements": {"abi": ["arm64-v8a"]},
|
||||
"assets": [{"label": "SM64 ROM", "accepted": [{"sha1": "9BEF1128717F958171A4AFAC3ED78EE2BB4E86CE"}], "instructions_md": "Pick `sm64.z64`.\n"}],
|
||||
"forks": [{"repo": "y/sm64", "package": "com.y.sm64", "signer_sha256": "d" * 64, "downloads": 1,
|
||||
"release": {"tag": "r2", "asset": {"name": "sm64.apk", "url": "https://h/s.apk", "sha256": "e" * 64}}}]},
|
||||
]}
|
||||
|
||||
|
||||
class RecompsCatalogTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.catalog = build_catalog.build(json.loads(json.dumps(CURATED)), RL, RECOMPA, resolve=False)
|
||||
self.by_id = {e["id"]: e for e in self.catalog["recomps"]}
|
||||
|
||||
def test_curated_entries_win_and_gain_builds_and_credits_from_both_catalogs(self):
|
||||
z = self.by_id["zelda64recomp"]
|
||||
self.assertEqual(["droiddeck", "recomp-launcher", "recompa"], z["sources"])
|
||||
self.assertEqual("Zelda 64: Recompiled", z["name"])
|
||||
self.assertEqual({"linux-arm64", "linux-x64", "windows-x64", "android"}, set(z["builds"]))
|
||||
self.assertEqual("Z-v1.2.2-Windows.zip", z["builds"]["windows-x64"]["file"])
|
||||
self.assertEqual("a" * 64, z["builds"]["windows-x64"]["sha256"])
|
||||
self.assertEqual("com.z.mm", z["builds"]["android"]["package"])
|
||||
self.assertEqual("a1", z["android_release"]["tag"])
|
||||
|
||||
def test_recomp_launcher_entries_keep_setup_and_data_and_drop_what_cannot_run(self):
|
||||
m = self.by_id["otherm-recomp"]
|
||||
self.assertEqual(["windows-x64"], list(m["builds"]))
|
||||
self.assertEqual("OtherM.exe", m["builds"]["windows-x64"]["entry"])
|
||||
self.assertEqual("OtherM.zip", m["builds"]["windows-x64"]["file"])
|
||||
self.assertEqual("Your Metroid: Other M disc", m["data"]["label"])
|
||||
self.assertIn("setup.bat", m["setup"])
|
||||
self.assertEqual("Wii", m["origin"])
|
||||
self.assertNotIn("gone", self.by_id)
|
||||
self.assertNotIn("tool", self.by_id)
|
||||
|
||||
def test_recompa_android_ports_bring_their_rom_requirements(self):
|
||||
self.assertNotIn("x86only", self.by_id)
|
||||
s = self.by_id["sm64"]
|
||||
self.assertEqual(["recompa"], s["sources"])
|
||||
self.assertEqual("r2", s["release"]["tag"])
|
||||
self.assertEqual("https://h/s.apk", s["builds"]["android"]["url"])
|
||||
self.assertEqual(["9bef1128717f958171a4afac3ed78ee2bb4e86ce"], s["data"]["sha1"])
|
||||
self.assertEqual("rom", s["data"]["kind"])
|
||||
self.assertEqual("Pick sm64.z64.", s["data"]["note"])
|
||||
|
||||
def test_globs_become_anchored_patterns(self):
|
||||
self.assertEqual("^Z\\-.*\\-Linux\\-X64\\.zip$", build_catalog.glob_regex("Z-*-Linux-X64.zip"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user