diff --git a/.github/workflows/publish-packs.yml b/.github/workflows/publish-packs.yml index 580b1c8188..7bf219ef7c 100644 --- a/.github/workflows/publish-packs.yml +++ b/.github/workflows/publish-packs.yml @@ -61,7 +61,7 @@ jobs: jq -r --arg n "$2" '.assets // [] | .[] | select(.name == $n) | .digest // empty' } commit=$(gh api "repos/$GITHUB_REPOSITORY/actions/runs/$BUILD_RUN" --jq .head_sha 2>/dev/null || echo "$GITHUB_SHA") - for name in proot directaudio tracking xbox comet; do + for name in proot directaudio tracking xbox comet butler; do file="packs/$name.tar.zst" [ -f "$file" ] || { echo "::error::$name.tar.zst is missing from Build APK run $BUILD_RUN"; exit 1; } sha=$(sha256sum "$file" | cut -d' ' -f1) diff --git a/app/build.gradle b/app/build.gradle index 04e2de43df..7334c8db4e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -90,7 +90,7 @@ def trackingPack = rootProject.file('tools/packs/tracking/release.env').readLine def prootPackPin = rootProject.file('tools/packs/proot/release.env').readLines() .findAll { it.contains('=') && !it.startsWith('#') } .collectEntries { def kv = it.split('=', 2); [(kv[0].trim()): kv[1].trim()] } -def addonPacks = ['proot', 'directaudio', 'tracking', 'xbox', 'comet'].collectEntries { name -> +def addonPacks = ['proot', 'directaudio', 'tracking', 'xbox', 'comet', 'butler'].collectEntries { name -> def pack = file("build/packs/${name}.tar.zst") if (!pack.isFile()) { if (ciBuild) throw new GradleException("Add-on pack ${pack} is missing: run tools/packs/build.sh app/build/packs") diff --git a/app/src/main/java/com/droiddeck/launcher/core/AddonPack.kt b/app/src/main/java/com/droiddeck/launcher/core/AddonPack.kt index d54a5fff5d..8f2da0d688 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/AddonPack.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/AddonPack.kt @@ -146,5 +146,7 @@ internal class AddonPack( listOf("version", "xodus-cli", "xodus-service")) val COMET = AddonPack("comet", BuildConfig.PACK_COMET_SHA256, BuildConfig.PACK_COMET_SIZE, listOf("version", "comet")) + val BUTLER = AddonPack("butler", BuildConfig.PACK_BUTLER_SHA256, BuildConfig.PACK_BUTLER_SIZE, + listOf("version", "butler", "7z.so", "libc7zip.so")) } } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/itch/ItchBuilds.kt b/app/src/main/java/com/droiddeck/launcher/stores/itch/ItchBuilds.kt new file mode 100644 index 0000000000..95712037d6 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/stores/itch/ItchBuilds.kt @@ -0,0 +1,114 @@ +package com.droiddeck.launcher.stores.itch + +import com.droiddeck.launcher.stores.StoreNet +import org.json.JSONArray +import org.json.JSONObject +import java.io.File +import java.io.FileOutputStream +import java.net.HttpURLConnection +import java.net.URL +import java.util.concurrent.atomic.AtomicBoolean + +internal object ItchBuilds { + private const val BASE = "https://api.itch.io" + private const val MAX_STEPS = 4 + + class Step(val buildId: Long, val patchFile: Long, val patchSize: Long, val signatureFile: Long) + + fun buildId(upload: JSONObject): String { + val value = upload.opt("build_id") ?: upload.opt("buildId") + return when (value) { + is Number -> value.toLong().takeIf { it > 0 }?.toString().orEmpty() + is String -> value.takeIf { it.all(Char::isDigit) }?.toLongOrNull()?.takeIf { it > 0 }?.toString().orEmpty() + else -> "" + } + } + + fun path(key: String, from: String, to: String, downloadKeyId: String): List? { + val fromId = from.toLongOrNull() ?: return null + val toId = to.toLongOrNull() ?: return null + val reply = ItchApi.get("/builds/$fromId/upgrade-paths/$toId" + keyQuery(downloadKeyId), key) ?: return null + return steps(reply, fromId, toId) { filesOf(key, it, downloadKeyId) } + } + + fun steps(reply: JSONObject, fromId: Long, toId: Long, filesFor: (JSONObject) -> JSONArray?): List? { + val builds = (reply.optJSONObject("upgrade_path") ?: reply.optJSONObject("upgradePath"))?.optJSONArray("builds") ?: return null + val ids = (0 until builds.length()).mapNotNull { builds.optJSONObject(it) } + val after = ids.filter { it.optLong("id") != fromId } + if (after.isEmpty() || after.size > MAX_STEPS || after.last().optLong("id") != toId) return null + val steps = after.map { build -> + val files = filesFor(build) ?: return null + val patch = pick(files, "patch") ?: return null + val signature = pick(files, "signature") + Step(build.optLong("id"), patch.optLong("id"), patch.optLong("size"), signature?.optLong("id") ?: 0L) + } + return steps.takeIf { it.last().signatureFile > 0 } + } + + fun fileUrl(buildId: Long, fileId: Long, downloadKeyId: String): String = + "$BASE/wharf/builds/$buildId/files/$fileId/download" + keyQuery(downloadKeyId) + + fun download(url: String, key: String, target: File, cancelled: AtomicBoolean, progress: (Long) -> Unit): Boolean { + val first = open(url, key) + try { + val code = first.responseCode + val location = first.getHeaderField("Location") + if (code in 300..399 && location != null) { + first.disconnect() + val next = URL(URL(url), location).toString() + if (!next.startsWith("https://")) return false + return save(open(next, null), target, cancelled, progress) + } + return save(first, target, cancelled, progress) + } finally { + runCatching { first.disconnect() } + } + } + + private fun save(conn: HttpURLConnection, target: File, cancelled: AtomicBoolean, progress: (Long) -> Unit): Boolean { + try { + if (conn.responseCode !in 200..299) return false + var done = 0L + val buffer = ByteArray(128 * 1024) + conn.inputStream.use { input -> + FileOutputStream(target).use { out -> + while (true) { + if (cancelled.get()) return false + val read = input.read(buffer) + if (read < 0) break + out.write(buffer, 0, read) + done += read + progress(done) + } + } + } + return true + } finally { + runCatching { conn.disconnect() } + } + } + + private fun open(url: String, key: String?): HttpURLConnection = + (URL(url).openConnection() as HttpURLConnection).apply { + connectTimeout = 30_000 + readTimeout = 60_000 + instanceFollowRedirects = false + setRequestProperty("User-Agent", StoreNet.BROWSER_UA) + setRequestProperty("Accept", "*/*") + if (key != null) setRequestProperty("Authorization", "Bearer $key") + } + + private fun filesOf(key: String, build: JSONObject, downloadKeyId: String): JSONArray? = + build.optJSONArray("files") + ?: ItchApi.get("/builds/${build.optLong("id")}" + keyQuery(downloadKeyId), key)?.optJSONObject("build")?.optJSONArray("files") + + private fun pick(files: JSONArray, type: String): JSONObject? { + val all = (0 until files.length()).mapNotNull { files.optJSONObject(it) } + .filter { it.optString("type") == type && it.optString("state", "uploaded") == "uploaded" } + return all.firstOrNull { subType(it) == "optimized" } ?: all.firstOrNull { subType(it) == "default" } + } + + private fun subType(file: JSONObject): String = file.optString("sub_type", file.optString("subType", "default")) + + private fun keyQuery(downloadKeyId: String): String = if (downloadKeyId.isBlank()) "" else "?download_key_id=$downloadKeyId" +} diff --git a/app/src/main/java/com/droiddeck/launcher/stores/itch/ItchInstaller.kt b/app/src/main/java/com/droiddeck/launcher/stores/itch/ItchInstaller.kt index 9aa36acd0f..d4dcf19830 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/itch/ItchInstaller.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/itch/ItchInstaller.kt @@ -62,12 +62,31 @@ internal class ItchInstaller( val scratch = StoreInstallRoot.scratchDir(app, Store.ITCH, item.id) scratch.mkdirs() val archive = File(scratch, filename.ifBlank { "download.bin" }) + val buildId = ItchBuilds.buildId(upload) val exe = try { - handle.stage(DownloadStage.DOWNLOAD) - download(key, downloadKeyId, uploadId, upload.optString("updated_at", upload.optString("updatedAt")), archive, size, handle) - if (cancelled.get()) return null - handle.stage(DownloadStage.INSTALL) - install(archive, filename, handle, resuming) + var patched = updating && !resuming && previous?.isInstalled == true && + patch(key, downloadKeyId, uploadId, buildId, size, scratch, handle) + if (cancelled.get()) { + if (patched) dropCaches(scratch) + return null + } + var picked: String? = null + if (patched) { + picked = install(archive, filename, handle, resuming, true) + if (picked == null) { + if (cancelled.get()) return null + handle.log("itch.io: the patched copy of ${item.title} has no exe, doing a full update") + patched = false + } + } + if (!patched) { + handle.stage(DownloadStage.DOWNLOAD) + download(key, downloadKeyId, uploadId, upload.optString("updated_at", upload.optString("updatedAt")), archive, size, handle) + if (cancelled.get()) return null + handle.stage(DownloadStage.INSTALL) + picked = install(archive, filename, handle, resuming, false) + } + picked } catch (t: Throwable) { if (!cancelled.get()) dropCaches(scratch) throw t @@ -90,7 +109,7 @@ internal class ItchInstaller( installedAt = System.currentTimeMillis(), cover = item.imageUrl, hero = item.imageUrl, - extra = mapOf("gameId" to gameId, "downloadKeyId" to downloadKeyId, "uploadId" to uploadId), + extra = mapOf("gameId" to gameId, "downloadKeyId" to downloadKeyId, "uploadId" to uploadId, "buildId" to buildId), cloud = false, ) StoreInstalls.complete(app, folder, sidecar) { done, steps -> handle.stageProgress(done.toLong(), steps.toLong()) } @@ -180,13 +199,37 @@ internal class ItchInstaller( } } - private fun install(archive: File, filename: String, handle: DownloadQueue.JobHandle, resuming: Boolean): String? { + private fun patch(key: String, downloadKeyId: String, uploadId: String, buildId: String, fullSize: Long, scratch: File, handle: DownloadQueue.JobHandle): Boolean { + val installed = previous?.extra.orEmpty() + val from = installed["buildId"].orEmpty() + if (installed["uploadId"] != uploadId || from.isBlank() || buildId.isBlank() || from == buildId) return false + val out = File(folder, ItchStaging.DIR) + ItchStaging.delete(out) + scratch.mkdirs() + val outcome = try { + ItchPatch.run(app, key, downloadKeyId, from, buildId, fullSize, folder, out, scratch, handle, cancelled) + } catch (t: Exception) { + ItchPatch.Outcome.Failed("${t.javaClass.simpleName} ${t.message}") + } + when (outcome) { + ItchPatch.Outcome.Applied -> { + handle.log("itch.io: patched ${item.title} from build $from to $buildId") + return true + } + ItchPatch.Outcome.Cancelled -> Unit + is ItchPatch.Outcome.Failed -> handle.log("itch.io: no patch for ${item.title}, doing a full update (${outcome.reason})") + } + ItchStaging.delete(out) + return false + } + + private fun install(archive: File, filename: String, handle: DownloadQueue.JobHandle, resuming: Boolean, patched: Boolean = false): String? { work = if (updating) File(folder, ItchStaging.DIR) else folder - if (updating) ItchStaging.delete(work) + if (updating && !patched) ItchStaging.delete(work) work.mkdirs() if (resuming) clearPartialInstall() val exe = try { - unpack(archive, filename, handle) + if (!patched) unpack(archive, filename, handle) val hint = filename.substringBeforeLast('.') var picked = StoreExe.pick(work, hint.ifBlank { null }, item.title) var passes = 0 diff --git a/app/src/main/java/com/droiddeck/launcher/stores/itch/ItchPatch.kt b/app/src/main/java/com/droiddeck/launcher/stores/itch/ItchPatch.kt new file mode 100644 index 0000000000..9feebb10d0 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/stores/itch/ItchPatch.kt @@ -0,0 +1,124 @@ +package com.droiddeck.launcher.stores.itch + +import android.content.Context +import com.droiddeck.launcher.core.AddonPack +import com.droiddeck.launcher.runtime.GuestCommand +import com.droiddeck.launcher.runtime.LinuxRuntime +import com.droiddeck.launcher.stores.StoreInstalls +import com.droiddeck.launcher.stores.download.DownloadQueue +import com.droiddeck.launcher.stores.download.DownloadStage +import java.io.File +import java.util.concurrent.atomic.AtomicBoolean + +internal object ItchPatch { + private const val DIR = "/usr/local/lib/droiddeck-butler" + + sealed interface Outcome { + data object Applied : Outcome + data object Cancelled : Outcome + data class Failed(val reason: String) : Outcome + } + + fun ready(context: Context): Boolean { + if (!AddonPack.BUTLER.available || !LinuxRuntime.isInstalled(context)) return false + if (!AddonPack.BUTLER.installed(context)) { + AddonPack.BUTLER.ensure(context) + return false + } + return stage(context) + } + + private val stageLock = Any() + + private fun stage(context: Context): Boolean = synchronized(stageLock) { stageLocked(context) } + + private fun stageLocked(context: Context): Boolean { + val pack = AddonPack.BUTLER.dir(context) + val root = File(LinuxRuntime.rootDir(context), DIR.removePrefix("/")) + val packaged = File(pack, "version").readText() + if (runCatching { File(root, "version").readText() }.getOrNull() == packaged && File(root, "butler").isFile) return true + root.mkdirs() + pack.listFiles().orEmpty().filter { it.isFile && it.name != "version" && it.name != AddonPack.COMPLETE }.forEach { source -> + val staged = File(root, source.name + ".staged") + source.inputStream().use { input -> staged.outputStream().use { input.copyTo(it) } } + staged.setExecutable(true, false) + check(staged.renameTo(File(root, source.name))) + } + File(root, "version").writeText(packaged) + return true + } + + fun run( + app: Context, key: String, downloadKeyId: String, from: String, to: String, fullSize: Long, installed: File, out: File, scratch: File, + handle: DownloadQueue.JobHandle, cancelled: AtomicBoolean, + ): Outcome { + if (!ready(app)) return Outcome.Failed("the patch tool is not ready") + val steps = ItchBuilds.path(key, from, to, downloadKeyId) ?: return Outcome.Failed("no patch path from build $from to $to") + if (fullSize > 0 && steps.sumOf { it.patchSize } > fullSize) return Outcome.Failed("the patches are larger than a full download") + val dir = File(scratch, "patches").apply { deleteRecursively(); mkdirs() } + try { + handle.stage(DownloadStage.DOWNLOAD) + val total = steps.sumOf { it.patchSize } + var finished = 0L + val patches = steps.mapIndexed { index, step -> + val file = File(dir, "$index.pwr") + val base = finished + val ok = ItchBuilds.download(ItchBuilds.fileUrl(step.buildId, step.patchFile, downloadKeyId), key, file, cancelled) { + handle.progress(base + it, total) + } + if (cancelled.get()) return Outcome.Cancelled + if (!ok) return Outcome.Failed("build ${step.buildId}: the patch did not download") + finished += step.patchSize + file + } + val last = steps.last() + val signature = File(dir, "final.sig") + val got = ItchBuilds.download(ItchBuilds.fileUrl(last.buildId, last.signatureFile, downloadKeyId), key, signature, cancelled) {} + if (cancelled.get()) return Outcome.Cancelled + if (!got) return Outcome.Failed("build ${last.buildId}: the signature did not download") + handle.stage(DownloadStage.INSTALL) + return apply(app, patches, signature, installed, out, scratch, cancelled) + } finally { + StoreInstalls.deleteTree(dir) + } + } + + private fun apply(app: Context, patches: List, signature: File, installed: File, out: File, scratch: File, cancelled: AtomicBoolean): Outcome { + var source = installed + var intermediate: File? = null + try { + patches.forEachIndexed { index, patch -> + val finalStep = index == patches.lastIndex + val target = if (finalStep) out else File(scratch, "patched-$index") + ItchStaging.delete(target) + target.mkdirs() + val staging = File(scratch, "butler-staging-$index").apply { deleteRecursively(); mkdirs() } + val args = mutableListOf("$DIR/butler", "apply", "--assume-yes", "--staging-dir", staging.absolutePath, "-d", target.absolutePath) + if (finalStep) args += listOf("--signature", signature.absolutePath) + args += listOf(patch.absolutePath, source.absolutePath) + val binds = listOf(installed, out, scratch).map { it.absolutePath } + .filter { path -> listOf(app.filesDir, app.cacheDir).none { path.startsWith(it.absolutePath + "/") } } + .distinct().takeIf { it.isNotEmpty() } + val tail = ArrayDeque() + val code = try { + GuestCommand.run(app, args, logName = "itch-butler", extraBinds = binds, fastPath = true, cancelled = cancelled) { line -> + if (!line.startsWith("proot ")) { + if (tail.size == 4) tail.removeFirst() + tail.addLast(line) + } + } + } finally { + StoreInstalls.deleteTree(staging) + } + if (cancelled.get()) return Outcome.Cancelled + if (code != 0) return Outcome.Failed("butler exited $code: ${tail.joinToString(" | ")}") + intermediate?.let { StoreInstalls.deleteTree(it) } + intermediate = if (finalStep) null else target + source = target + } + return Outcome.Applied + } finally { + intermediate?.let { StoreInstalls.deleteTree(it) } + } + } +} diff --git a/app/src/test/java/com/droiddeck/launcher/stores/itch/ItchBuildsTest.kt b/app/src/test/java/com/droiddeck/launcher/stores/itch/ItchBuildsTest.kt new file mode 100644 index 0000000000..a9630d9e8d --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/stores/itch/ItchBuildsTest.kt @@ -0,0 +1,57 @@ +package com.droiddeck.launcher.stores.itch + +import org.json.JSONArray +import org.json.JSONObject +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNull +import org.junit.Test + +@org.junit.runner.RunWith(org.robolectric.RobolectricTestRunner::class) +@org.robolectric.annotation.Config(sdk = [33], application = android.app.Application::class) +class ItchBuildsTest { + private fun file(id: Int, type: String, sub: String, size: Int = 10) = + JSONObject().put("id", id).put("type", type).put("sub_type", sub).put("size", size).put("state", "uploaded") + + private fun build(id: Int, vararg files: JSONObject) = JSONObject().put("id", id).put("files", JSONArray(files.toList())) + + private fun path(vararg builds: JSONObject) = JSONObject().put("upgrade_path", JSONObject().put("builds", JSONArray(builds.toList()))) + + @Test fun buildIdReadsBothKeyStylesAndIgnoresMissingValues() { + assertEquals("55", ItchBuilds.buildId(JSONObject().put("build_id", 55))) + assertEquals("56", ItchBuilds.buildId(JSONObject().put("buildId", "56"))) + assertEquals("", ItchBuilds.buildId(JSONObject().put("build_id", JSONObject.NULL))) + assertEquals("", ItchBuilds.buildId(JSONObject().put("build_id", 0))) + assertEquals("", ItchBuilds.buildId(JSONObject().put("build_id", "00"))) + assertEquals("57", ItchBuilds.buildId(JSONObject().put("build_id", "057"))) + assertEquals("", ItchBuilds.buildId(JSONObject())) + } + + @Test fun pathSkipsTheInstalledBuildAndPrefersOptimizedPatches() { + val reply = path( + build(1, file(11, "patch", "default")), + build(2, file(21, "patch", "default", 5), file(22, "patch", "optimized", 3), file(23, "signature", "default")), + ) + val steps = ItchBuilds.steps(reply, 1, 2) { it.optJSONArray("files") }!! + assertEquals(1, steps.size) + assertEquals(2L, steps.single().buildId) + assertEquals(22L, steps.single().patchFile) + assertEquals(3L, steps.single().patchSize) + assertEquals(23L, steps.single().signatureFile) + } + + @Test fun pathIsRefusedWithoutASignatureOrAPatchOrTheRightEnd() { + val noSignature = path(build(1), build(2, file(21, "patch", "default"))) + assertNull(ItchBuilds.steps(noSignature, 1, 2) { it.optJSONArray("files") }) + val noPatch = path(build(1), build(2, file(23, "signature", "default"))) + assertNull(ItchBuilds.steps(noPatch, 1, 2) { it.optJSONArray("files") }) + val wrongEnd = path(build(1), build(3, file(31, "patch", "default"), file(32, "signature", "default"))) + assertNull(ItchBuilds.steps(wrongEnd, 1, 2) { it.optJSONArray("files") }) + assertNull(ItchBuilds.steps(JSONObject(), 1, 2) { it.optJSONArray("files") }) + } + + @Test fun pathNeedsFilesFromALookupWhenTheBuildListsNone() { + val reply = path(JSONObject().put("id", 1), JSONObject().put("id", 2)) + val steps = ItchBuilds.steps(reply, 1, 2) { JSONArray().put(file(21, "patch", "default")).put(file(23, "signature", "default")) }!! + assertEquals(21L, steps.single().patchFile) + } +} diff --git a/docs/development/itch-butler.md b/docs/development/itch-butler.md new file mode 100644 index 0000000000..be13e5e0f4 --- /dev/null +++ b/docs/development/itch-butler.md @@ -0,0 +1,24 @@ +# itch.io patch updates with butler + +An update to an itch game that was published with butler can be applied as a patch instead of downloading the whole upload again. Everything else keeps the full update described in [itch-updates.md](itch-updates.md). + +## Pack + +`butler`, `7z.so` and `libc7zip.so` ship as the `butler` add-on pack (`tools/packs/build.sh`). The pack is fetched from `broth.itch.zone` by version, and `tools/packs/butler/release.env` pins the version and the SHA-256 of the zip. The `linux-arm64` build needs glibc 2.29. The first patch update that finds no pack starts its download and does a full update; later updates use it. + +## When a patch is used + +All of these must hold, or the update falls back to the full download: + +- the installed copy and the new upload are the same upload id and both have a build id (`buildId` is kept in the sidecar's `extra`) +- the upgrade path `/builds/{installed}/upgrade-paths/{new}` has at most four builds, each with a patch file, and the last one has a signature +- the patches together are no larger than the full upload +- `butler apply` exits 0 and the result matches the new build's signature + +## How it is applied + +Patches and the signature are fetched from `/wharf/builds/{build}/files/{file}/download` with the API key; the redirect to storage is followed without the key. `butler apply -d` writes the whole new game into `.droiddeck-update` inside the game folder and leaves the installed files alone, files the game wrote (saves) are ignored, and `--signature` makes butler check the result against the new build. From there the update is the same as a full one: the executable is picked, `ItchStaging.merge` swaps the files in, and the record is rewritten. A failure at any point deletes the staging folder and continues with the full download. + +## What is not verified + +The upgrade-path and build-file field names (`upgrade_path`, `files`, `sub_type`) and the `download_key_id` query on the file download follow the published API listing and butler's own request paths, and have not been tried against a real game. A game whose install does not match its build exactly, for example one whose files were flattened on install, falls back to the full update. diff --git a/tools/packs/build.sh b/tools/packs/build.sh index 27611ab0b4..b6089111cb 100755 --- a/tools/packs/build.sh +++ b/tools/packs/build.sh @@ -18,6 +18,8 @@ out=$(cd "$out" && pwd) linuxfs="$repo/app/src/main/assets/linuxfs/usr/local/lib" # shellcheck source=tracking/release.env source "$here/tracking/release.env" +# shellcheck source=butler/release.env +source "$here/butler/release.env" work=$(mktemp -d) trap 'rm -rf "$work"' EXIT @@ -83,3 +85,10 @@ pack tracking "$work/tracking" hand_landmarker.task hand_landmarker_lite.task po libopencv_java4.so libmediapipe_tasks_jni.so pack xbox "$linuxfs/droiddeck-xbox" version xodus-cli xodus-service pack comet "$linuxfs/droiddeck-comet" version comet + +mkdir "$work/butler" +fetch "https://broth.itch.zone/butler/linux-arm64/${BUTLER_VERSION}/archive/default" \ + "$BUTLER_ZIP_SHA256" "$work/butler.zip" +unzip -q -j "$work/butler.zip" butler 7z.so libc7zip.so -d "$work/butler" +printf '%s\n' "$BUTLER_VERSION" > "$work/butler/version" +pack butler "$work/butler" version butler 7z.so libc7zip.so diff --git a/tools/packs/butler/release.env b/tools/packs/butler/release.env new file mode 100644 index 0000000000..2fa3600006 --- /dev/null +++ b/tools/packs/butler/release.env @@ -0,0 +1,2 @@ +BUTLER_VERSION=15.32.0 +BUTLER_ZIP_SHA256=4f2da37785fd9cbc15052427490e4e4f5cd735a019f21554d6273fa9a3490152 diff --git a/tools/release/runtime_inputs.py b/tools/release/runtime_inputs.py index 6db216383a..6eff505e85 100644 --- a/tools/release/runtime_inputs.py +++ b/tools/release/runtime_inputs.py @@ -19,7 +19,7 @@ PACKED = {'assets/linuxfs/usr/local/lib/droiddeck-xbox/': 'xbox', 'assets/linuxf PACKED_FILES = {'lib/arm64-v8a/libproot.so': ('proot', 'libproot.so'), 'lib/arm64-v8a/libproot-loader.so': ('proot', 'libproot-loader.so')} PACKED_LIBRARIES = ['lib/arm64-v8a/libopencv_java4.so', 'lib/arm64-v8a/libmediapipe_tasks_jni.so'] -PACK_NAMES = ['proot', 'directaudio', 'tracking', 'xbox', 'comet'] +PACK_NAMES = ['proot', 'directaudio', 'tracking', 'xbox', 'comet', 'butler'] SOURCE_PATHS = ['app/build.gradle', 'app/src/main/cpp/fakeinput_steam.cpp', 'app/src/main/assets/pulseaudio.tzst', 'tools/linuxfs', 'tools/proot', 'tools/aaudio-sink', 'tools/directaudio', 'tools/packs', 'tools/gamescope/release.env', 'tools/droiddeck-esync/release.env', diff --git a/tools/tests/test_runtime_inputs.py b/tools/tests/test_runtime_inputs.py index e368290e31..1ace64e406 100644 --- a/tools/tests/test_runtime_inputs.py +++ b/tools/tests/test_runtime_inputs.py @@ -48,6 +48,7 @@ class RuntimeInputsTest(unittest.TestCase): for name, (pack, rel) in runtime.PACKED_FILES.items(): proot[rel] = (self.root / runtime.outputs(self.root)[name]).read_bytes() self.pack('proot', proot) + self.pack('butler', {'butler': b'butler', '7z.so': b'7z', 'libc7zip.so': b'c7zip', 'version': b'15.32.0'}) for prefix, name in runtime.PACKED.items(): base = self.root / 'app/src/main' / prefix self.pack(name, {path.relative_to(base).as_posix(): path.read_bytes() for path in base.rglob('*') if path.is_file()})