mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 20:45:43 +00:00
feat(recomps): add Decomp Buddy's catalog and plans, and install arm64 twins
Decomp Buddy's catalog.json and plans.json become the first source: its plans name the exact release file, the program in it, a scanned sha256 and the game files needed. The 32 MB plans file is read as a stream. Store installs are matched with Decomp Buddy's title rules, and a plan's expected file finds the folder inside the install. Before installing an x86-64 Linux build, the release is checked for its arm64 twin with a plain download request. When a project's own download fails, Decomp Buddy's scanned copy is used. Debian packages unpack to their data.tar, and installs are also matched by repo.
This commit is contained in:
1 parent
d55da2f3c7
commit
3f0952fece
10 files changed
+465
-86
No files matched your search
@@ -110,7 +110,8 @@ DroidDeck is [GPL-3.0](LICENSE). Steam and Proton belong to Valve Corporation. V
|
||||
<details>
|
||||
<summary><b>Recomps</b></summary>
|
||||
|
||||
- The Recomps tab lists the two community catalogs below, read straight from their sites. Each entry shows which catalog it came from.
|
||||
- The Recomps tab lists the three community catalogs below, read straight from their sites. Each entry shows which catalog it came from.
|
||||
- [Decomp Buddy](https://decompbuddy.com) ([TanookiStudios/decomp-buddy](https://github.com/TanookiStudios/decomp-buddy), GPL-3.0) by Maddie at [Tanooki Studios](https://tanookistudios.com): its `catalog.json` and `plans.json` supply most entries, their exact release files, programs and scanned checksums, and the game files each needs. Matching a PC port to a Steam, GOG or Epic install follows its `src/stores.js` title rules, and arm64 Linux files are found the way its `armSibling` finds them. When a project's own download is gone, DroidDeck falls back to Decomp Buddy's scanned copy ([donate](https://decompbuddy.com/donate) to keep those online).
|
||||
- [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.
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
package com.droiddeck.launcher.runtime
|
||||
|
||||
import android.util.JsonReader
|
||||
import android.util.JsonToken
|
||||
import java.io.File
|
||||
import java.io.Reader
|
||||
|
||||
// Decomp Buddy's plans.json (about 16 MB) holds, per repo and platform, the release file to download, the
|
||||
// program in it and the game files it needs. It is read as a stream, keeping only those fields.
|
||||
object DecompBuddyPlans {
|
||||
class GameFile(val label: String, val filename: String?, val how: String?, val kind: String?)
|
||||
|
||||
class Target(
|
||||
val gameTitle: String?, val method: String?, val asset: String?, val tag: String?, val executable: String?,
|
||||
val sha256: String?, val pkg: String?, val files: List<GameFile>,
|
||||
)
|
||||
|
||||
class Plan(val tag: String?, val targets: Map<String, Target>)
|
||||
|
||||
private val WANTED = setOf("windows", "linux", "linux-arm64", "android")
|
||||
|
||||
fun read(file: File): Map<String, Plan> = file.bufferedReader().use { read(it) }
|
||||
|
||||
fun read(source: Reader): Map<String, Plan> {
|
||||
val out = HashMap<String, Plan>()
|
||||
JsonReader(source).use { r ->
|
||||
r.beginObject()
|
||||
while (r.hasNext()) {
|
||||
if (r.nextName() != "plans" || r.peek() != JsonToken.BEGIN_OBJECT) { r.skipValue(); continue }
|
||||
r.beginObject()
|
||||
while (r.hasNext()) {
|
||||
val key = r.nextName()
|
||||
plan(r)?.let { out[key.lowercase()] = it }
|
||||
}
|
||||
r.endObject()
|
||||
}
|
||||
r.endObject()
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
private fun JsonReader.str(): String? = if (peek() == JsonToken.STRING) nextString() else { skipValue(); null }
|
||||
|
||||
private fun plan(r: JsonReader): Plan? {
|
||||
if (r.peek() != JsonToken.BEGIN_OBJECT) { r.skipValue(); return null }
|
||||
var tag: String? = null
|
||||
val targets = HashMap<String, Target>()
|
||||
r.beginObject()
|
||||
while (r.hasNext()) when (r.nextName()) {
|
||||
"tag" -> tag = r.str()
|
||||
"targets" -> if (r.peek() != JsonToken.BEGIN_OBJECT) r.skipValue() else {
|
||||
r.beginObject()
|
||||
while (r.hasNext()) {
|
||||
val id = r.nextName()
|
||||
if (id in WANTED) target(r)?.let { targets[id] = it } else r.skipValue()
|
||||
}
|
||||
r.endObject()
|
||||
}
|
||||
else -> r.skipValue()
|
||||
}
|
||||
r.endObject()
|
||||
return if (targets.isEmpty()) null else Plan(tag, targets)
|
||||
}
|
||||
|
||||
// A repo with several games under one target (a collection) is set up from its first.
|
||||
private fun target(r: JsonReader): Target? {
|
||||
if (r.peek() != JsonToken.BEGIN_OBJECT) { r.skipValue(); return null }
|
||||
var first: Target? = null
|
||||
r.beginObject()
|
||||
while (r.hasNext()) {
|
||||
if (r.nextName() != "games" || r.peek() != JsonToken.BEGIN_ARRAY) { r.skipValue(); continue }
|
||||
r.beginArray()
|
||||
while (r.hasNext()) { val g = game(r); if (first == null) first = g }
|
||||
r.endArray()
|
||||
}
|
||||
r.endObject()
|
||||
return first
|
||||
}
|
||||
|
||||
private fun game(r: JsonReader): Target? {
|
||||
if (r.peek() != JsonToken.BEGIN_OBJECT) { r.skipValue(); return null }
|
||||
var title: String? = null
|
||||
var method: String? = null; var asset: String? = null; var tag: String? = null
|
||||
var exe: String? = null; var sha: String? = null; var pkg: String? = null
|
||||
val files = mutableListOf<GameFile>()
|
||||
r.beginObject()
|
||||
while (r.hasNext()) when (r.nextName()) {
|
||||
"game_title" -> title = r.str()
|
||||
"build" -> if (r.peek() != JsonToken.BEGIN_OBJECT) r.skipValue() else {
|
||||
r.beginObject()
|
||||
while (r.hasNext()) when (r.nextName()) {
|
||||
"method" -> method = r.str()
|
||||
"release_asset" -> asset = r.str()
|
||||
"release_tag" -> tag = r.str()
|
||||
"executable" -> exe = r.str()
|
||||
"package_id" -> pkg = r.str()
|
||||
"scanned" -> if (r.peek() != JsonToken.BEGIN_OBJECT) r.skipValue() else {
|
||||
r.beginObject()
|
||||
while (r.hasNext()) if (r.nextName() == "sha256") sha = r.str() else r.skipValue()
|
||||
r.endObject()
|
||||
}
|
||||
else -> r.skipValue()
|
||||
}
|
||||
r.endObject()
|
||||
}
|
||||
"game_files" -> if (r.peek() != JsonToken.BEGIN_ARRAY) r.skipValue() else {
|
||||
r.beginArray()
|
||||
while (r.hasNext()) {
|
||||
if (r.peek() != JsonToken.BEGIN_OBJECT) { r.skipValue(); continue }
|
||||
var label = ""; var name: String? = null; var how: String? = null; var kind: String? = null
|
||||
r.beginObject()
|
||||
while (r.hasNext()) when (r.nextName()) {
|
||||
"label" -> label = r.str().orEmpty()
|
||||
"expected_filename" -> name = r.str()
|
||||
"how_provided" -> how = r.str()
|
||||
"kind" -> kind = r.str()
|
||||
else -> r.skipValue()
|
||||
}
|
||||
r.endObject()
|
||||
files += GameFile(label, name, how, kind)
|
||||
}
|
||||
r.endArray()
|
||||
}
|
||||
else -> r.skipValue()
|
||||
}
|
||||
r.endObject()
|
||||
return Target(title, method, asset, tag, exe, sha, pkg, files)
|
||||
}
|
||||
}
|
||||
@@ -8,17 +8,25 @@ 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.
|
||||
// The list is Decomp Buddy's, 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, in that order of precedence.
|
||||
object RecompCatalog {
|
||||
private const val TAG = "RecompCatalog"
|
||||
private const val MAX_AGE_MS = 6L * 60 * 60 * 1000
|
||||
|
||||
class Feed(val id: String, val name: String, val url: String)
|
||||
|
||||
val DECOMP_BUDDY = Feed("decomp-buddy", "Decomp Buddy", "https://tanookistudios.com/decomp-buddy/catalog.json")
|
||||
val DECOMP_BUDDY_PLANS = Feed("decomp-buddy-plans", "Decomp Buddy", "https://tanookistudios.com/decomp-buddy/plans.json")
|
||||
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)
|
||||
val FEEDS = listOf(DECOMP_BUDDY, RECOMP_LAUNCHER, RECOMPA)
|
||||
private val DOWNLOADS = listOf(DECOMP_BUDDY, DECOMP_BUDDY_PLANS, RECOMP_LAUNCHER, RECOMPA)
|
||||
|
||||
// Decomp Buddy keeps a malware-scanned copy of each release file it plans, named by sha256. It is
|
||||
// donation-funded, so the copy is used only when the project's own download is gone.
|
||||
fun mirrorUrl(sha256: String, name: String) = "https://files.decompbuddy.com/$sha256/${android.net.Uri.encode(name)}"
|
||||
|
||||
enum class Platform(val key: String) {
|
||||
LINUX_ARM64("linux-arm64"), LINUX_X64("linux-x64"), WINDOWS_X64("windows-x64"), ANDROID("android");
|
||||
@@ -35,11 +43,13 @@ object RecompCatalog {
|
||||
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 tag: String? = null, val published: String = "",
|
||||
val mirrored: Boolean = false,
|
||||
)
|
||||
|
||||
enum class DataKind { ROM, DUMP, NONE }
|
||||
|
||||
class Data(val kind: DataKind, val label: String, val sha1: List<String> = emptyList(), val note: String = "")
|
||||
// [file] is the name a plan expects inside the game's folder, which finds the folder in a store install.
|
||||
class Data(val kind: DataKind, val label: String, val sha1: List<String> = emptyList(), val note: String = "", val file: String? = null)
|
||||
|
||||
class Entry(
|
||||
val id: String, val name: String, val game: String, val origin: String, val type: String,
|
||||
@@ -53,7 +63,7 @@ object RecompCatalog {
|
||||
|
||||
val android get() = build(Platform.ANDROID)
|
||||
|
||||
val pc get() = origin.equals("PC", ignoreCase = true)
|
||||
val pc get() = origin in PC_ORIGINS
|
||||
}
|
||||
|
||||
@Volatile private var cached: List<Entry>? = null
|
||||
@@ -61,19 +71,23 @@ object RecompCatalog {
|
||||
fun load(context: Context, refresh: Boolean = false): List<Entry> {
|
||||
if (!refresh) cached?.let { return it }
|
||||
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 files = DOWNLOADS.associateWith { feed -> runCatching { fetch(feed, dir, refresh) }.onFailure { Log.w(TAG, "${feed.id}: $it") }.getOrNull() }
|
||||
fun <T> read(feed: Feed, parse: (File) -> List<T>): List<T> =
|
||||
files[feed]?.let { f -> runCatching { parse(f) }.onFailure { Log.w(TAG, "${feed.id}: $it") }.getOrNull() }.orEmpty()
|
||||
val plans = files[DECOMP_BUDDY_PLANS]?.let { f -> runCatching { DecompBuddyPlans.read(f) }.onFailure { Log.w(TAG, "plans: $it") }.getOrNull() }.orEmpty()
|
||||
val list = merge(
|
||||
bodies[RECOMP_LAUNCHER]?.let { runCatching { fromRecompLauncher(JSONObject(it)) }.getOrNull() }.orEmpty(),
|
||||
bodies[RECOMPA]?.let { runCatching { fromRecompa(JSONObject(it)) }.getOrNull() }.orEmpty(),
|
||||
read(DECOMP_BUDDY) { fromDecompBuddy(JSONObject(it.readText()), plans) },
|
||||
read(RECOMP_LAUNCHER) { fromRecompLauncher(JSONObject(it.readText())) },
|
||||
read(RECOMPA) { fromRecompa(JSONObject(it.readText())) },
|
||||
)
|
||||
if (list.isNotEmpty()) cached = list
|
||||
return list
|
||||
}
|
||||
|
||||
private fun fetch(feed: Feed, dir: File, force: Boolean): String? {
|
||||
private fun fetch(feed: Feed, dir: File, force: Boolean): File? {
|
||||
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()
|
||||
if (!force && file.isFile && System.currentTimeMillis() - file.lastModified() < MAX_AGE_MS) return file
|
||||
val conn = (URL(feed.url).openConnection() as HttpURLConnection).apply {
|
||||
connectTimeout = 15_000; readTimeout = 60_000
|
||||
setRequestProperty("User-Agent", "DroidDeck")
|
||||
@@ -81,20 +95,19 @@ object RecompCatalog {
|
||||
}
|
||||
return try {
|
||||
when (conn.responseCode) {
|
||||
HttpURLConnection.HTTP_NOT_MODIFIED -> { file.setLastModified(System.currentTimeMillis()); file.readText() }
|
||||
HttpURLConnection.HTTP_NOT_MODIFIED -> { file.setLastModified(System.currentTimeMillis()); file }
|
||||
HttpURLConnection.HTTP_OK -> {
|
||||
val body = conn.inputStream.bufferedReader().use { it.readText() }
|
||||
val tmp = File(dir, "${feed.id}.json.part")
|
||||
tmp.writeText(body)
|
||||
conn.inputStream.use { input -> tmp.outputStream().use { input.copyTo(it) } }
|
||||
tmp.renameTo(file)
|
||||
conn.getHeaderField("ETag")?.let { FileUtils.writeString(etag, it) }
|
||||
body
|
||||
file
|
||||
}
|
||||
else -> file.takeIf { it.isFile }?.readText()
|
||||
else -> file.takeIf { it.isFile }
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "${feed.id}: $e")
|
||||
file.takeIf { it.isFile }?.readText()
|
||||
file.takeIf { it.isFile }
|
||||
} finally {
|
||||
conn.disconnect()
|
||||
}
|
||||
@@ -125,6 +138,61 @@ object RecompCatalog {
|
||||
|
||||
private fun JSONObject.str(key: String) = optString(key).takeIf { it.isNotEmpty() && it != "null" }
|
||||
|
||||
private val PC_ORIGINS = setOf("PC", "DOS")
|
||||
|
||||
private val CONSOLES = mapOf(
|
||||
"PC (Windows)" to "PC", "IBM PC (MS-DOS)" to "DOS", "PlayStation" to "PS1", "PlayStation 2" to "PS2", "PlayStation 3" to "PS3",
|
||||
"PlayStation 4" to "PS4", "PlayStation Portable" to "PSP", "PlayStation Vita" to "Vita", "Nintendo 64" to "N64",
|
||||
"Nintendo Switch" to "Switch", "Nintendo Switch 2" to "Switch 2", "Game Boy Advance" to "GBA", "Game Boy" to "Game Boy",
|
||||
"Game Boy Color" to "Game Boy Color", "Nintendo DS" to "DS", "Nintendo 3DS" to "3DS", "Others" to "",
|
||||
)
|
||||
|
||||
// Decomp Buddy's games with a published plan: the plan names the exact release file, its program and the
|
||||
// game files it needs. Linux plans name the x86-64 file; its arm64 twin is looked for at install.
|
||||
internal fun fromDecompBuddy(json: JSONObject, plans: Map<String, DecompBuddyPlans.Plan>): List<Entry> {
|
||||
val games = json.optJSONArray("games") ?: return emptyList()
|
||||
return (0 until games.length()).mapNotNull { i -> runCatching { decompBuddyGame(games.getJSONObject(i), plans) }.getOrNull() }
|
||||
}
|
||||
|
||||
private fun decompBuddyGame(g: JSONObject, plans: Map<String, DecompBuddyPlans.Plan>): Entry? {
|
||||
if (g.str("host") != "github") return null
|
||||
val repo = g.str("repo")?.takeIf { REPO.matches(it) } ?: return null
|
||||
val plan = plans[g.str("id")?.lowercase() ?: return null] ?: return null
|
||||
fun build(platform: Platform, t: DecompBuddyPlans.Target?): Build? {
|
||||
t ?: return null
|
||||
if (t.method != "release") return null
|
||||
val file = safeName(t.asset) ?: return null
|
||||
if (platform == Platform.ANDROID && !file.endsWith(".apk", ignoreCase = true)) return null
|
||||
if (platform == Platform.WINDOWS_X64 && Regex("arm64|aarch64|win32|x86(?![_-]64)|i[36]86", RegexOption.IGNORE_CASE).containsMatchIn(file)) return null
|
||||
val exe = t.executable?.substringAfterLast('/')?.substringAfterLast('\\')
|
||||
return Build(platform, Regex("^" + Regex.escape(file) + "$", RegexOption.IGNORE_CASE), safeName(exe).orEmpty(), file,
|
||||
sha256(t.sha256), pkg = t.pkg?.takeIf { platform == Platform.ANDROID && PACKAGE.matches(it) },
|
||||
tag = t.tag ?: plan.tag, published = g.str("updatedAt").orEmpty(), mirrored = sha256(t.sha256) != null)
|
||||
}
|
||||
val targets = plan.targets
|
||||
val builds = listOfNotNull(
|
||||
build(Platform.LINUX_ARM64, targets["linux-arm64"]),
|
||||
build(Platform.LINUX_X64, targets["linux"])?.takeIf { b -> !Regex("arm64|aarch64", RegexOption.IGNORE_CASE).containsMatchIn(b.file!!) },
|
||||
build(Platform.WINDOWS_X64, targets["windows"]),
|
||||
build(Platform.ANDROID, targets["android"])?.takeIf { it.pkg != null },
|
||||
)
|
||||
if (builds.isEmpty()) return null
|
||||
val first = targets["linux"] ?: targets["windows"] ?: targets.values.first()
|
||||
val needs = first.files.firstOrNull { it.kind == null || it.kind == "game" }
|
||||
val origin = g.str("console").orEmpty().let { CONSOLES[it] ?: it }
|
||||
val data = when {
|
||||
needs == null -> Data(DataKind.NONE, "")
|
||||
else -> Data(if (origin in PC_ORIGINS) DataKind.DUMP else DataKind.ROM, needs.label, note = g.str("description").orEmpty(),
|
||||
file = needs.filename?.takeIf { needs.how == "folder" || needs.how == "command_line" }?.let { safeName(it) })
|
||||
}
|
||||
val id = g.str("slug") ?: return null
|
||||
return Entry(
|
||||
id, g.str("title") ?: id, first.gameTitle ?: g.str("title") ?: id, origin,
|
||||
if ("recomp" in repo.lowercase()) "recomp" else "port", repo, "", g.str("repoUrl") ?: "https://github.com/$repo",
|
||||
g.str("iconUrl") ?: g.str("boxartUrl"), builds, data, listOf(DECOMP_BUDDY.id), g.optLong("downloads"),
|
||||
)
|
||||
}
|
||||
|
||||
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() }
|
||||
@@ -212,22 +280,29 @@ object RecompCatalog {
|
||||
)
|
||||
}
|
||||
|
||||
// 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> {
|
||||
// An earlier catalog wins every field it sets; a later one with the same repo (or id) adds builds it lacks.
|
||||
internal fun merge(vararg catalogs: List<Entry>): List<Entry> {
|
||||
val out = LinkedHashMap<String, Entry>()
|
||||
val byRepo = HashMap<String, String>()
|
||||
for (e in launcher + recompa) {
|
||||
for (e in catalogs.flatMap { it }) {
|
||||
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 } }
|
||||
val builds = base.builds.map { b ->
|
||||
e.build(b.platform)?.takeIf { b.platform == Platform.ANDROID && b.signer == null && it.signer != null && it.pkg == b.pkg } ?: b
|
||||
} + e.builds.filter { b -> base.builds.none { it.platform == b.platform } }
|
||||
val data = when {
|
||||
base.data.kind == DataKind.NONE -> e.data
|
||||
base.data.sha1.isEmpty() && e.data.sha1.isNotEmpty() -> Data(base.data.kind, base.data.label, e.data.sha1, base.data.note, base.data.file)
|
||||
else -> base.data
|
||||
}
|
||||
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,
|
||||
base.homepage, base.art ?: e.art, builds, data,
|
||||
(base.sources + e.sources).distinct(), maxOf(base.popularity, e.popularity), base.setup ?: e.setup,
|
||||
)
|
||||
}
|
||||
return out.values.toList()
|
||||
|
||||
@@ -25,13 +25,33 @@ object RecompData {
|
||||
|
||||
class Inputs(val installs: List<Install>, val owned: List<Owner>)
|
||||
|
||||
private val EDITION = Regex(
|
||||
"\\b(game of the year|goty|definitive|enhanced|complete|classic|gold|anniversary|special|deluxe|ultimate|remastered)( edition)?\\b|\\bedition\\b",
|
||||
)
|
||||
// Decomp Buddy's rules (src/stores.js): "Fallout 2: A Post Nuclear Role Playing Game" is Fallout 2, "Fallout 2" is
|
||||
// not Fallout, a possessive in front ("Sid Meier's Civilization II") is dropped, and only store editions such as
|
||||
// GOTY or Gold may follow the title.
|
||||
private val EDITION = Regex("^ (?:goty|game of the year|gold|complete|deluxe|definitive|anniversary|steam)(?: edition)?$")
|
||||
|
||||
internal fun titleKey(title: String): String =
|
||||
title.lowercase().replace(Regex("[™®©]"), "").replace(Regex("[:\\-–—_'’.,!?&()\\[\\]]"), " ")
|
||||
.replace(EDITION, " ").replace(Regex("^the "), "").filter { it.isLetterOrDigit() }
|
||||
internal fun norm(title: String): String = title.lowercase().replace(Regex("[™®©]"), "").replace("&", " and ")
|
||||
.replace(Regex("\\([^)]*\\)"), " ").replace(Regex("^[\\w.]+(?: [\\w.]+)?'s "), "")
|
||||
.replace(Regex("[^a-z0-9:–-]+"), " ").replace(Regex("\\s+"), " ").trim()
|
||||
|
||||
internal fun sameGame(wanted: String, store: String): Boolean {
|
||||
val t = norm(wanted).takeIf { it.isNotEmpty() } ?: return false
|
||||
val n = norm(store)
|
||||
return n == t || listOf(":", " -", " –", " :").any { n.startsWith(t + it) } || (n.startsWith("$t ") && EDITION.matches(n.substring(t.length)))
|
||||
}
|
||||
|
||||
// The folder holding [name] (any case, up to 4 folders down), which is where the port expects to be pointed.
|
||||
internal fun folderWith(dir: File, name: String): File? {
|
||||
val want = name.lowercase()
|
||||
val stack = ArrayDeque(listOf(dir to 0))
|
||||
while (stack.isNotEmpty()) {
|
||||
val (d, depth) = stack.removeLast()
|
||||
val entries = d.listFiles() ?: continue
|
||||
if (entries.any { it.name.lowercase() == want }) return d
|
||||
if (depth < 4) entries.filter { it.isDirectory }.forEach { stack.addLast(it to depth + 1) }
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
fun inputs(context: Context, steamOwned: Collection<Pair<Int, String>>): Inputs {
|
||||
val root = LinuxRuntime.rootDir(context)
|
||||
@@ -59,11 +79,13 @@ object RecompData {
|
||||
|
||||
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) }
|
||||
val file = entry.data.file
|
||||
for (install in inputs.installs.filter { sameGame(entry.game, it.title) }) {
|
||||
val dir = if (file == null) install.host else folderWith(install.host, file) ?: continue
|
||||
val rel = dir.relativeTo(install.host).invariantSeparatorsPath.trim('/')
|
||||
return State.Found(install.store, dir, if (rel.isEmpty()) install.guest else "${install.guest.trimEnd('/')}/$rel")
|
||||
}
|
||||
inputs.owned.firstOrNull { sameGame(entry.game, it.title) }?.let { return State.Owned(it.store, it.item) }
|
||||
}
|
||||
return if (entry.data.kind == RecompCatalog.DataKind.NONE) State.NotNeeded else State.BringYourOwn(entry.data)
|
||||
}
|
||||
|
||||
@@ -18,20 +18,21 @@ object RecompInstaller {
|
||||
const val META_TAG = "recomp-tag"
|
||||
const val META_PUBLISHED = "recomp-published"
|
||||
const val META_PLATFORM = "recomp-platform"
|
||||
const val META_REPO = "recomp-repo"
|
||||
const val WRAPPER = "droiddeck-recomp"
|
||||
private const val WINDOWS_DIR = "Recomps"
|
||||
private const val NESTED_LIMIT = 2
|
||||
private val ARCHIVE = Regex("\\.(zip|7z|tar|tgz|tar\\.(gz|xz|bz2|zst))$", RegexOption.IGNORE_CASE)
|
||||
private const val NESTED_LIMIT = 3
|
||||
private val ARCHIVE = Regex("\\.(zip|7z|tar|tgz|deb|tar\\.(gz|xz|bz2|zst))$", RegexOption.IGNORE_CASE)
|
||||
|
||||
class Release(val tag: String, val published: String, val asset: String, val url: String, val sha256: String?)
|
||||
|
||||
class Installed(val id: String, val appKey: String, val tag: String?, val published: String?, val platform: String?, val dir: File)
|
||||
class Installed(val id: String, val appKey: String, val tag: String?, val published: String?, val platform: String?, val dir: File, val repo: String? = null)
|
||||
|
||||
fun installed(context: Context): Map<String, Installed> {
|
||||
val out = HashMap<String, Installed>()
|
||||
fun scan(root: File, prefix: String) = root.listFiles()?.forEach { dir ->
|
||||
val id = FileUtils.readString(File(dir, META_ID))?.trim()?.takeIf { it.isNotEmpty() } ?: return@forEach
|
||||
out[id] = Installed(id, "$prefix:${dir.name}", read(dir, META_TAG), read(dir, META_PUBLISHED), read(dir, META_PLATFORM), dir)
|
||||
out[id] = Installed(id, "$prefix:${dir.name}", read(dir, META_TAG), read(dir, META_PUBLISHED), read(dir, META_PLATFORM), dir, read(dir, META_REPO))
|
||||
}
|
||||
scan(UserApps.root(context), "script")
|
||||
AppImageManager.dir(context, "").parentFile?.let { scan(it, "appimage") }
|
||||
@@ -61,6 +62,28 @@ object RecompInstaller {
|
||||
return Release(tag, build.published, file, url, build.sha256)
|
||||
}
|
||||
|
||||
// The arm64 file released beside an x86-64 Linux one under the same name with the other CPU (Decomp Buddy's
|
||||
// armSibling rule), found with a plain request to the release download, which is not rate-limited.
|
||||
internal fun armNames(name: String): List<String> =
|
||||
listOf(Regex("x86[-_]64", RegexOption.IGNORE_CASE), Regex("amd64", RegexOption.IGNORE_CASE), Regex("\\bx64\\b", RegexOption.IGNORE_CASE))
|
||||
.filter { it.containsMatchIn(name) }.flatMap { re -> listOf("aarch64", "arm64", "ARM64").map { name.replace(re, it) } }.distinct()
|
||||
|
||||
private fun armTwin(entry: RecompCatalog.Entry, release: Release): Release? {
|
||||
if (!release.url.startsWith("https://github.com/")) return null
|
||||
val base = release.url.substringBeforeLast('/')
|
||||
for (name in armNames(release.asset)) {
|
||||
val url = "$base/${android.net.Uri.encode(name)}"
|
||||
val found = runCatching {
|
||||
val c = (java.net.URL(url).openConnection() as java.net.HttpURLConnection).apply {
|
||||
requestMethod = "HEAD"; connectTimeout = 10_000; readTimeout = 10_000; instanceFollowRedirects = true
|
||||
}
|
||||
try { c.responseCode == 200 } finally { c.disconnect() }
|
||||
}.getOrDefault(false)
|
||||
if (found) return Release(release.tag, release.published, name, url, null)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
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, false)
|
||||
@@ -98,17 +121,30 @@ object RecompInstaller {
|
||||
?: return context.getString(R.string.user_apps_github_unreachable, entry.repo)
|
||||
pickRelease(body, build.asset, false) ?: return context.getString(R.string.recomps_no_build, entry.repo)
|
||||
}
|
||||
val twin = if (build.platform == RecompCatalog.Platform.LINUX_X64) armTwin(entry, release) else null
|
||||
val platform = if (twin != null) RecompCatalog.Platform.LINUX_ARM64 else build.platform
|
||||
return fetchAndInstall(context, entry, build, platform, twin ?: release, onProgress)
|
||||
}
|
||||
|
||||
private fun fetchAndInstall(
|
||||
context: Context, entry: RecompCatalog.Entry, build: RecompCatalog.Build, platform: RecompCatalog.Platform, release: Release,
|
||||
onProgress: (String, Int) -> Unit,
|
||||
): String? {
|
||||
val android = platform == RecompCatalog.Platform.ANDROID
|
||||
val work = File(context.cacheDir, "recomps").apply { mkdirs() }
|
||||
val download = File(work, release.asset)
|
||||
val stage = File(work, "stage-${entry.id}")
|
||||
try {
|
||||
val label = context.getString(R.string.user_apps_downloading, release.asset)
|
||||
val ok = Downloader.downloadFile(release.url, download, true, release.sha256) { f -> onProgress(label, if (f < 0) -1 else Math.round(f * 100f)) }
|
||||
val progress = java.util.function.Consumer<Float> { f -> onProgress(label, if (f < 0) -1 else Math.round(f * 100f)) }
|
||||
val mirror = release.sha256?.takeIf { build.mirrored && release.asset == build.file }?.let { RecompCatalog.mirrorUrl(it, release.asset) }
|
||||
val ok = Downloader.downloadFile(release.url, download, true, release.sha256, progress) ||
|
||||
mirror != null && Downloader.downloadFile(mirror, download.also { it.delete() }, false, release.sha256, progress)
|
||||
if (!ok) return context.getString(R.string.user_apps_download_failed)
|
||||
val meta = mapOf(META_ID to entry.id, META_TAG to release.tag, META_PUBLISHED to release.published, META_PLATFORM to build.platform.key)
|
||||
val meta = mapOf(META_ID to entry.id, META_TAG to release.tag, META_PUBLISHED to release.published, META_PLATFORM to platform.key, META_REPO to entry.repo)
|
||||
if (android) return RecompAndroid.install(context, entry, build, release, download)
|
||||
val previous = installed(context)[entry.id]
|
||||
val problem = if (build.platform == RecompCatalog.Platform.WINDOWS_X64) {
|
||||
val problem = if (platform == RecompCatalog.Platform.WINDOWS_X64) {
|
||||
installWindows(context, entry, build, download, meta, previous, onProgress)
|
||||
} else if (download.name.endsWith(".appimage", ignoreCase = true)) {
|
||||
AppImageManager.import(context, download, entry.name, null, meta) { onProgress(it, -1) }
|
||||
@@ -175,6 +211,13 @@ object RecompInstaller {
|
||||
}
|
||||
if (code != 0) throw IllegalStateException(context.getString(R.string.recomps_unpack_failed, code) + tail.joinToString(" | ", ": "))
|
||||
if (depth > 0) file.delete()
|
||||
// A .deb unpacks to debian-binary, control.tar.* and data.tar.*; the program is in data.tar.
|
||||
val debData = into.listFiles()?.takeIf { files -> files.any { it.name == "debian-binary" } }?.firstOrNull { it.name.startsWith("data.tar") }
|
||||
if (debData != null) {
|
||||
into.listFiles()?.filter { it.name == "debian-binary" || it.name.startsWith("control.tar") }?.forEach { it.delete() }
|
||||
file = debData
|
||||
return@repeat
|
||||
}
|
||||
val only = into.listFiles()?.singleOrNull()?.takeIf { it.isFile && ARCHIVE.containsMatchIn(it.name) } ?: return
|
||||
file = only
|
||||
}
|
||||
|
||||
@@ -48,8 +48,11 @@ object RecompsState {
|
||||
loading = entries.isEmpty()
|
||||
Thread({
|
||||
val list = runCatching { RecompCatalog.load(app, reloadCatalog) }.getOrDefault(emptyList())
|
||||
val have = runCatching { RecompAndroid.installed(app, list) }.getOrDefault(emptyMap()) +
|
||||
val found = runCatching { RecompAndroid.installed(app, list) }.getOrDefault(emptyMap()) +
|
||||
runCatching { RecompInstaller.installed(app) }.getOrDefault(emptyMap())
|
||||
// Catalogs can rename an entry; an install also belongs to the entry with its repo.
|
||||
val byRepo = found.values.filter { it.repo != null }.associateBy { it.repo!!.lowercase() }
|
||||
val have = list.mapNotNull { e -> (found[e.id] ?: byRepo[e.repo.lowercase()])?.let { e.id to it } }.toMap()
|
||||
val inputs = runCatching { RecompData.inputs(app, steamOwned) }.getOrNull()
|
||||
val states = list.associate { e -> e.id to (inputs?.let { RecompData.resolve(e, it) } ?: RecompData.State.BringYourOwn(e.data)) }
|
||||
main.post {
|
||||
@@ -60,7 +63,7 @@ object RecompsState {
|
||||
checked = true
|
||||
val found = list.filter { it.id in have }.mapNotNull { e ->
|
||||
val i = have.getValue(e.id)
|
||||
val build = RecompCatalog.Platform.of(i.platform.orEmpty())?.let { e.build(it) } ?: return@mapNotNull null
|
||||
val build = RecompCatalog.Platform.of(i.platform.orEmpty())?.let { buildFor(e, it) } ?: return@mapNotNull null
|
||||
val newest = (RecompInstaller.pinned(e, build) ?: runCatching { RecompInstaller.latest(e, build) }.getOrNull())
|
||||
?.takeIf { RecompInstaller.isNewer(it, i) }
|
||||
newest?.let { e.id to it }
|
||||
@@ -71,11 +74,15 @@ object RecompsState {
|
||||
}
|
||||
|
||||
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 build = installed[entry.id]?.platform?.let { RecompCatalog.Platform.of(it) }?.let { buildFor(entry, 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 = {
|
||||
updates = updates - entry.id
|
||||
refresh(context, steamOwned)
|
||||
}) { app, progress -> RecompInstaller.install(app, entry, build, release, progress) }
|
||||
}
|
||||
|
||||
// An arm64 install found as the twin of an x86-64 Linux release updates through that release.
|
||||
private fun buildFor(entry: RecompCatalog.Entry, platform: RecompCatalog.Platform) =
|
||||
entry.build(platform) ?: entry.build(RecompCatalog.Platform.LINUX_X64).takeIf { platform == RecompCatalog.Platform.LINUX_ARM64 }
|
||||
}
|
||||
@@ -203,7 +203,7 @@ 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.BringYourOwn -> stringResource(R.string.recomps_data_bring, data.data.label.removePrefix("Your ").removePrefix("your ")) to false
|
||||
is RecompData.State.BringYourOwn -> stringResource(R.string.recomps_data_bring, data.data.label.replace(Regex("^(your own |your )", RegexOption.IGNORE_CASE), "")) to false
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalLayoutApi::class)
|
||||
|
||||
@@ -4445,7 +4445,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">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_credits">This list is the Decomp Buddy catalog (decompbuddy.com, by Maddie at Tanooki Studios), 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>
|
||||
|
||||
@@ -114,11 +114,96 @@ class RecompsTest {
|
||||
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™ GOTY Edition", 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 titlesFollowDecompBuddysRules() {
|
||||
assertTrue(RecompData.sameGame("Fallout 2", "Fallout 2: A Post Nuclear Role Playing Game"))
|
||||
assertTrue(RecompData.sameGame("The Elder Scrolls III: Morrowind", "The Elder Scrolls III: Morrowind® Game of the Year Edition"))
|
||||
assertTrue(RecompData.sameGame("Civilization II", "Sid Meier's Civilization II"))
|
||||
assertTrue(RecompData.sameGame("Diablo", "Diablo + Hellfire".replace(" + Hellfire", " Gold")))
|
||||
assertTrue(!RecompData.sameGame("Fallout", "Fallout 2"))
|
||||
assertTrue(!RecompData.sameGame("Quake", "Quake II"))
|
||||
assertTrue(!RecompData.sameGame("", "Quake"))
|
||||
}
|
||||
|
||||
private val decompBuddyFeed = JSONObject("""{"schema":1,"games":[
|
||||
{"id":"github:diasurgical/devilutionx","slug":"diablo-pc","title":"Diablo","console":"PC (Windows)","repo":"diasurgical/DevilutionX",
|
||||
"host":"github","repoUrl":"https://github.com/diasurgical/DevilutionX","iconUrl":"https://i/d.png","downloads":50,"updatedAt":"2026-11-01T00:00:00Z",
|
||||
"platforms":["Windows","Linux","Linux (ARM)","Android"]},
|
||||
{"id":"github:zelda64recomp/zelda64recomp","slug":"majoras-mask-n64","title":"Majora's Mask","console":"Nintendo 64","repo":"Zelda64Recomp/Zelda64Recomp","host":"github"},
|
||||
{"id":"github:o/noplan","slug":"no-plan","title":"No Plan","console":"Xbox","repo":"o/noplan","host":"github"},
|
||||
{"id":"gitlab:o/lab","slug":"lab","title":"Lab","console":"PC (Windows)","repo":"o/lab","host":"gitlab"}
|
||||
]}""")
|
||||
|
||||
private val decompBuddyPlans = """{"updatedAt":"x","plans":{
|
||||
"github:diasurgical/devilutionx":{"tag":"1.5.5","generatedAt":"g","targets":{
|
||||
"linux":{"redirect_repo":null,"games":[{"game_title":"Diablo","console":"PC","build":{"method":"release","release_asset":"devilutionx-linux-x86_64.tar.xz",
|
||||
"release_tag":"1.5.5","executable":"devilutionx","scanned":{"sha256":"${"1".repeat(64)}","size":1}},
|
||||
"game_files":[{"label":"DIABDAT.MPQ from Diablo","expected_filename":"DIABDAT.MPQ","how_provided":"folder","kind":"game","accepted_formats":[".mpq"]}],
|
||||
"first_run":["a"],"notes":[],"mods":{"supported":false}}]},
|
||||
"windows":{"games":[{"game_title":"Diablo","build":{"method":"release","release_asset":"devilutionx-windows-x86_64.zip","release_tag":"1.5.5",
|
||||
"executable":"bin\\devilutionx.exe","scanned":{"sha256":"${"2".repeat(64)}"}},"game_files":[]}]},
|
||||
"android":{"games":[{"build":{"method":"release","release_asset":"devilutionx-android.apk","release_tag":"1.5.5","package_id":"org.diasurgical.devilutionx",
|
||||
"scanned":{"sha256":"${"3".repeat(64)}"}},"game_files":[]}]},
|
||||
"macos-arm64":{"games":[{"build":{"method":"release","release_asset":"d.dmg"}}]}}},
|
||||
"github:zelda64recomp/zelda64recomp":{"tag":"v1.2.2","targets":{"windows":{"games":[{"build":{"method":"source","release_asset":"x.zip"}}]}}}
|
||||
}}"""
|
||||
|
||||
@Test fun decompBuddyPlansStreamIntoBuildsWithTheirProgramChecksumAndNeededFile() {
|
||||
val plans = DecompBuddyPlans.read(java.io.StringReader(decompBuddyPlans))
|
||||
assertEquals(setOf("linux", "windows", "android"), plans.getValue("github:diasurgical/devilutionx").targets.keys)
|
||||
val list = RecompCatalog.fromDecompBuddy(decompBuddyFeed, plans)
|
||||
assertEquals(listOf("diablo-pc"), list.map { it.id })
|
||||
val d = list.single()
|
||||
assertEquals("PC", d.origin)
|
||||
assertTrue(d.pc)
|
||||
val linux = d.build(RecompCatalog.Platform.LINUX_X64)!!
|
||||
assertEquals("devilutionx", linux.entry)
|
||||
assertEquals("devilutionx-linux-x86_64.tar.xz", linux.file)
|
||||
assertTrue(linux.mirrored)
|
||||
assertEquals("devilutionx.exe", d.build(RecompCatalog.Platform.WINDOWS_X64)!!.entry)
|
||||
assertEquals("org.diasurgical.devilutionx", d.android!!.pkg)
|
||||
assertNull(d.android!!.signer)
|
||||
assertEquals("DIABDAT.MPQ", d.data.file)
|
||||
assertEquals("https://github.com/diasurgical/DevilutionX/releases/download/1.5.5/devilutionx-linux-x86_64.tar.xz", RecompInstaller.pinned(d, linux)!!.url)
|
||||
assertEquals("https://files.decompbuddy.com/${"1".repeat(64)}/devilutionx-linux-x86_64.tar.xz", RecompCatalog.mirrorUrl("1".repeat(64), linux.file!!))
|
||||
}
|
||||
|
||||
@Test fun decompBuddyComesFirstAndRecompaAddsItsSignerToTheSameApk() {
|
||||
val plans = DecompBuddyPlans.read(java.io.StringReader(decompBuddyPlans))
|
||||
val recompa = JSONObject("""{"ports":[{"id":"devilutionx","upstream":"https://github.com/diasurgical/devilutionX","forks":[{"repo":"diasurgical/devilutionX",
|
||||
"package":"org.diasurgical.devilutionx","signer_sha256":"${"9".repeat(64)}","downloads":1,
|
||||
"release":{"tag":"1.5.5","asset":{"name":"devilutionx-android.apk","url":"https://h/d.apk","sha256":"${"3".repeat(64)}"}}}]}]}""")
|
||||
val all = RecompCatalog.merge(RecompCatalog.fromDecompBuddy(decompBuddyFeed, plans), RecompCatalog.fromRecompLauncher(launcherFeed), RecompCatalog.fromRecompa(recompa))
|
||||
val d = all.first { it.id == "diablo-pc" }
|
||||
assertEquals(listOf(RecompCatalog.DECOMP_BUDDY.id, RecompCatalog.RECOMPA.id), d.sources)
|
||||
assertEquals("9".repeat(64), d.android!!.signer)
|
||||
assertEquals("Diablo", d.name)
|
||||
assertEquals(listOf("diablo-pc", "zelda64recomp", "ironwail", "otherm"), all.map { it.id })
|
||||
}
|
||||
|
||||
@Test fun theNeededFileFindsTheFolderInsideAStoreInstall() {
|
||||
val plans = DecompBuddyPlans.read(java.io.StringReader(decompBuddyPlans))
|
||||
val d = RecompCatalog.fromDecompBuddy(decompBuddyFeed, plans).single()
|
||||
val gog = temporary.newFolder("Diablo GOG")
|
||||
File(gog, "hellfire").mkdirs()
|
||||
File(gog, "hellfire/diabdat.mpq").writeText("x")
|
||||
val install = RecompData.Install(Store.GOG, "Diablo + Hellfire".substringBefore(" +"), gog, "/root/Games/Stores/GOG/Diablo")
|
||||
val found = RecompData.resolve(d, RecompData.Inputs(listOf(install), emptyList()))
|
||||
assertEquals("/root/Games/Stores/GOG/Diablo/hellfire", (found as RecompData.State.Found).guest)
|
||||
File(gog, "hellfire/diabdat.mpq").delete()
|
||||
assertTrue(RecompData.resolve(d, RecompData.Inputs(listOf(install), emptyList())) is RecompData.State.BringYourOwn)
|
||||
}
|
||||
|
||||
@Test fun theArm64TwinOfAnX64FileKeepsItsName() {
|
||||
assertEquals(listOf("Game-aarch64.tar.gz", "Game-arm64.tar.gz", "Game-ARM64.tar.gz"), RecompInstaller.armNames("Game-x86_64.tar.gz"))
|
||||
assertEquals(listOf("Zelda64Recompiled-v1.2.2-Linux-aarch64.zip", "Zelda64Recompiled-v1.2.2-Linux-arm64.zip", "Zelda64Recompiled-v1.2.2-Linux-ARM64.zip"),
|
||||
RecompInstaller.armNames("Zelda64Recompiled-v1.2.2-Linux-X64.zip"))
|
||||
assertEquals(emptyList<String>(), RecompInstaller.armNames("Game-Linux.zip"))
|
||||
}
|
||||
|
||||
@Test fun theWrapperStartsTheProgramFromItsOwnFolder() {
|
||||
|
||||
+56
-39
@@ -36,41 +36,47 @@ DroidDeck is signed in to. It never downloads ROMs, disc images or game files.
|
||||
|
||||
## Catalog
|
||||
|
||||
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.
|
||||
DroidDeck keeps no catalog. `RecompCatalog` downloads three community catalogs, caches them in
|
||||
`files/recomps/`, revalidates each with its ETag after 6 hours, and merges them on the device. An
|
||||
earlier catalog wins every field it sets; a later one with the same GitHub repo (or id) adds builds the
|
||||
entry lacks.
|
||||
|
||||
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.
|
||||
1. **Decomp Buddy** (`TanookiStudios/decomp-buddy`, GPL-3.0):
|
||||
- `https://tanookistudios.com/decomp-buddy/catalog.json`, about 4,900 games.
|
||||
- `plans.json`, about 32 MB. `DecompBuddyPlans` reads it as a stream and keeps only the `windows`,
|
||||
`linux`, `linux-arm64` and `android` targets: the release file, its tag, the program, the scanned
|
||||
sha256, the Android package and the game files needed.
|
||||
- Games without a `release` plan are left out.
|
||||
2. **Recomp Launcher** (`https://recomplauncher.com/pc-catalog.json`):
|
||||
- `assets` globs and `files` pins; `boot.start` / `start_linux` name the program.
|
||||
- `setup_required` / `setup_steps` become the setup note.
|
||||
- Archived, `soon`, non-GitHub, `installer` / `not-a-game` / `source` entries and Flatpak bundles are
|
||||
left out.
|
||||
3. **Recompa** (`https://recompa.app/index.json`): Android APKs with a package name and signing
|
||||
certificate. A Recompa signer is added to a Decomp Buddy APK with the same package.
|
||||
|
||||
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:
|
||||
As of 2026-12-01 this gives 4,764 entries, 1,812 of them found in more than one catalog:
|
||||
|
||||
| Build | Entries |
|
||||
|---|---|
|
||||
| Linux arm64 | 40 |
|
||||
| Linux x86-64 | 1,141 |
|
||||
| Windows x86-64 | 2,007 |
|
||||
| Android | 768 |
|
||||
| Linux arm64 | 214 |
|
||||
| Linux x86-64 | 2,349 |
|
||||
| Windows x86-64 | 4,036 |
|
||||
| Android | 836 |
|
||||
|
||||
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 two parses and the merge take about 1.3 s on a desktop JVM. 96% of builds name their release
|
||||
file, so they download without the GitHub releases API.
|
||||
|
||||
The build is chosen in the order linux-arm64 (native), android, linux-x64 (FEX), windows-x64
|
||||
(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.
|
||||
(Proton).
|
||||
- **Linux x86-64:** before installing, the release is checked for an arm64 twin, the same file name
|
||||
with `aarch64`/`arm64` in place of `x86_64`/`amd64`/`x64` (Decomp Buddy's `armSibling` rule). The
|
||||
check uses a plain request to the download URL. If the twin exists, it is installed natively instead.
|
||||
- **No program named:** an AppImage, else the executable ELF closest to the project's name (Linux), or
|
||||
`GameExePicker`'s best exe (Windows).
|
||||
- **Download fails:** if the project's own download fails and Decomp Buddy scanned that file, it is
|
||||
fetched from `files.decompbuddy.com/<sha256>/<name>`. That copy is a fallback only, because Decomp
|
||||
Buddy's hosting runs on donations.
|
||||
|
||||
## Installing
|
||||
|
||||
@@ -78,8 +84,8 @@ The build is chosen in the order linux-arm64 (native), android, linux-x64 (FEX),
|
||||
|
||||
1. Downloads the asset, checking its sha256.
|
||||
2. **Linux build:** `bsdtar` in the guest unpacks it into the app cache, keeping modes and
|
||||
symlinks, and unpacks once more when the result is a single archive (Zelda's zip holds a
|
||||
tar.gz). It then finds `entry` up to four folders down. An AppImage, whether downloaded
|
||||
symlinks, and unpacks again when the result is a single archive (Zelda's zip holds a tar.gz) or
|
||||
a Debian package (its `data.tar`), up to three levels. 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, which starts the program from
|
||||
@@ -93,22 +99,29 @@ The build is chosen in the order linux-arm64 (native), android, linux-x64 (FEX),
|
||||
then installs it through `PackageInstaller` (`RecompAndroid`). The confirmation prompt comes from
|
||||
the system. The install shows as Play and Remove on the card, and in the Apps tab. The installed tag
|
||||
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
|
||||
5. Writes `recomp-id`, `recomp-tag`, `recomp-published`, `recomp-platform` and `recomp-repo` beside the
|
||||
install. `RecompInstaller.installed` finds installs by those files. An install belongs to the entry
|
||||
with its id, or else its repo, since a higher-ranked catalog can rename an entry. An update installs the
|
||||
new release first and then deletes the old folder.
|
||||
|
||||
## Game data
|
||||
|
||||
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.
|
||||
For PC ports (Decomp Buddy's "PC (Windows)" and "IBM PC (MS-DOS)", Recomp Launcher's `pc`), `RecompData`
|
||||
matches the game's title against the player's installs (store sidecars and Steam client libraries) and
|
||||
owned games. It uses Decomp Buddy's rules:
|
||||
- A subtitle after a colon or dash is fine, so "Fallout 2: A Post Nuclear Role Playing Game" is
|
||||
Fallout 2.
|
||||
- A leading possessive such as "Sid Meier's" is dropped.
|
||||
- Only store-edition words (GOTY, Gold, Complete, Definitive, ...) may follow the title, so "Fallout 2"
|
||||
is not "Fallout".
|
||||
|
||||
- **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.
|
||||
Where a plan names the file the port needs in a folder (`expected_filename`, for example `DIABDAT.MPQ`),
|
||||
the folder holding that file inside the install is the one shown. An install without that file does not
|
||||
count.
|
||||
|
||||
Console recomps are never matched, because no store sells their dumps.
|
||||
- **Installed:** "Installed on Steam" and the guest folder to point the port at.
|
||||
- **Owned:** "Install game".
|
||||
- **Otherwise:** what the catalog says the game needs. Console recomps are never matched.
|
||||
|
||||
## UI
|
||||
|
||||
@@ -151,6 +164,10 @@ same code.
|
||||
matching, release picking, program guessing and the wrapper (run under `/bin/sh`). `NavTabsTest`
|
||||
covers the tab.
|
||||
|
||||
- GZDoom 4.14.2 from Decomp Buddy's `linux-arm64` plan (a `.deb` naming no program), on the Pocket FIT:
|
||||
installed in about 5 s and started natively to its own "Cannot find a game IWAD" screen. With all
|
||||
three catalogs the FIT loaded 4,764 entries in 6 s.
|
||||
|
||||
## Not done yet
|
||||
|
||||
- **Recompa delivery rules.** Hand a chosen ROM to an Android port the way Recompa's `delivery`
|
||||
|
||||
Reference in new issue
Block a user