feat(proton): list prerelease builds under Experimental and install from any archive (#2889)

* feat(proton): install prerelease builds

* fix(proton): harden prerelease archive installs

* refactor(proton): drop the superseded test build path

* fix(proton): list only current prerelease builds and label the file install

* fix(proton): hide prerelease rows that are already installed

* fix(proton): keep relative links and modes when unpacking zip and 7z builds

* fix(proton): name file installs without the archive suffix

* fix(proton): confirm a release is gone before removing its build and tighten archive handling

* Show the Experimental section without Developer tools

* Share the refresh guard, recheck sessions before removal, skip other architectures

The update check guard is shared between menu instances and held until the result is published, so a recreated screen joins the running check and results arrive in order. Automatic removal rechecks for a running session after each release lookup. Experimental assets for other CPU architectures are ignored, and in-tree links may start with the current directory.

* Keep an experimental build in place when a session starts during its removal

Removal and session start now share one lock. The tree is renamed out of the
tools folder under that lock only while no session is running, and deleted
afterwards, so a session that starts first keeps its build.
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-11-19 13:41:57 -05:00
1 parent 71989b4cdb
commit de73e429cc
45 files changed
+897 -392

No files matched your search

@@ -202,7 +202,7 @@ class CompatLaunchTest {
val entered = CountDownLatch(1)
val finish = CountDownLatch(1)
protons.protonBusyId = null
protons.installer = { _, _, progress ->
protons.installer = { _, progress ->
progress("Verifying download", 64)
entered.countDown()
check(finish.await(5, TimeUnit.SECONDS))
@@ -7,6 +7,7 @@ import android.os.Looper
import androidx.compose.ui.geometry.Rect
import com.droiddeck.launcher.frontend.AutoComponents
import com.droiddeck.launcher.runtime.LinuxRuntime
import com.droiddeck.launcher.session.ExperimentalProtons
import com.droiddeck.launcher.session.ProtonExtras
import com.droiddeck.launcher.session.SessionState
import com.droiddeck.launcher.session.SessionPhase
@@ -25,7 +26,9 @@ import org.robolectric.Shadows.shadowOf
import org.robolectric.annotation.Config
import org.robolectric.util.ReflectionHelpers
import java.io.File
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
import java.util.concurrent.atomic.AtomicInteger
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [28], manifest = Config.NONE)
@@ -60,7 +63,7 @@ class ProtonMenuAutoTest {
menu.protonProblem = null
menu.protonStage = null
menu.protonPercent = -1
menu.installer = { tool, _, progress ->
menu.installer = { tool, progress ->
progress("Installing ${tool.name}", 50)
install("${tool.prefix}-11-12")
null
@@ -88,6 +91,67 @@ class ProtonMenuAutoTest {
File(this, "proton").apply { writeText(""); setExecutable(true) }
}
private fun prerelease(tag: String) = ExperimentalProtons.Release(tag, "$tag.tar.xz", "https://github.com/o/r/releases/download/$tag/$tag.tar.xz", null, 1L)
private fun recreatedMenu(refreshes: AtomicInteger, tag: String) = ProtonMenu(activity, Handler(Looper.getMainLooper())) { idle }.apply {
installer = menu.installer
latestCheck = { false }
experimentalRefresh = {
refreshes.incrementAndGet()
listOf(prerelease(tag))
}
}
@Test
fun aRecreatedMenuJoinsTheRunningRefresh() {
idle = false
val started = CountDownLatch(1)
val gate = CountDownLatch(1)
val refreshes = AtomicInteger()
menu.latestCheck = { false }
menu.experimentalRefresh = {
started.countDown()
gate.await(5, TimeUnit.SECONDS)
listOf(prerelease("first"))
}
menu.checkUpdates()
assertTrue(started.await(5, TimeUnit.SECONDS))
val recreated = recreatedMenu(refreshes, "second")
recreated.checkUpdates()
gate.countDown()
waitUntil { recreated.experimentalReleases.map { it.tag } == listOf("first") }
assertEquals(0, refreshes.get())
recreated.checkUpdates()
waitUntil { recreated.experimentalReleases.map { it.tag } == listOf("second") }
assertEquals(1, refreshes.get())
}
@Test
fun aFinishedRefreshIsPublishedBeforeTheNextOneStarts() {
idle = false
val finished = CountDownLatch(1)
val refreshes = AtomicInteger()
menu.experimentalReleases = emptyList()
menu.latestCheck = { false }
menu.experimentalRefresh = {
finished.countDown()
listOf(prerelease("older"))
}
menu.checkUpdates()
assertTrue(finished.await(5, TimeUnit.SECONDS))
val recreated = recreatedMenu(refreshes, "newer")
repeat(20) {
recreated.checkUpdates()
Thread.sleep(10)
}
assertEquals(0, refreshes.get())
assertTrue(recreated.experimentalReleases.isEmpty())
waitUntil { recreated.experimentalReleases.map { it.tag } == listOf("older") }
recreated.checkUpdates()
waitUntil { recreated.experimentalReleases.map { it.tag } == listOf("newer") }
assertEquals(1, refreshes.get())
}
private fun waitUntil(done: () -> Boolean) {
val deadline = System.nanoTime() + 5_000_000_000L
while (System.nanoTime() < deadline) {
@@ -116,7 +180,7 @@ class ProtonMenuAutoTest {
@Test fun downloadsWaitForTheSessionNetworkPowerAndOtherInstallWork() {
install("DroidDeck-Proton-11-11.1")
menu.installer = { tool, _, _ -> attempts.add(tool.id); "failed" }
menu.installer = { tool, _ -> attempts.add(tool.id); "failed" }
SessionState.running = true
menu.ensureAutoUpdates()
SessionState.running = false
@@ -139,11 +203,11 @@ class ProtonMenuAutoTest {
@Test fun aFinishedInstallStartsTheComponentCheckAndAFailedOneDoesNot() {
var checks = 0
val watched = ProtonMenu(activity, Handler(Looper.getMainLooper()), onInstalled = { checks++ }) { idle }
watched.installer = { tool, _, _ -> install("${tool.prefix}-11-12"); null }
watched.installer = { tool, _ -> install("${tool.prefix}-11-12"); null }
watched.installProton("droiddeck")
waitUntil { watched.protonBusyId == null && checks == 1 }
assertEquals(1, checks)
watched.installer = { _, _, _ -> "failed" }
watched.installer = { _, _ -> "failed" }
watched.installProton("ge")
waitUntil { watched.protonBusyId == null }
assertEquals(1, checks)
@@ -152,7 +216,7 @@ class ProtonMenuAutoTest {
@Test fun aFailedUpdateDoesNotLoopOrBlockOtherInstalledFamilies() {
val ge = install("GE-Proton11-11")
install("DroidDeck-Proton-11-11.1")
menu.installer = { tool, _, _ ->
menu.installer = { tool, _ ->
attempts.add(tool.id)
if (tool.id == "ge") throw IllegalStateException("download failed")
install("${tool.prefix}-11-12")
@@ -171,7 +235,7 @@ class ProtonMenuAutoTest {
@Test fun anUninstalledRuntimeOrCurrentProtonDoesNotStartADownload() {
install("DroidDeck-Proton-11-12")
menu.installer = { tool, _, _ -> attempts.add(tool.id); null }
menu.installer = { tool, _ -> attempts.add(tool.id); null }
menu.ensureAutoUpdates()
assertTrue(attempts.isEmpty())
install("GE-Proton11-11")
@@ -183,12 +247,12 @@ class ProtonMenuAutoTest {
@Test fun aFailedReleaseIsNotRetriedAfterRecreatingTheLauncher() {
install("DroidDeck-Proton-11-11.1")
menu.installer = { tool, _, _ -> attempts.add(tool.id); "failed" }
menu.installer = { tool, _ -> attempts.add(tool.id); "failed" }
menu.ensureAutoUpdates()
waitUntil { menu.protonBusyId == null }
val recreated = Robolectric.buildActivity(Activity::class.java).setup().get()
val next = ProtonMenu(recreated, Handler(Looper.getMainLooper()))
next.installer = { tool, _, _ -> attempts.add(tool.id); "failed" }
next.installer = { tool, _ -> attempts.add(tool.id); "failed" }
next.ensureAutoUpdates()
assertNull(next.protonBusyId)
assertEquals(listOf("droiddeck"), attempts)
@@ -208,7 +272,7 @@ class ProtonMenuAutoTest {
}
@Test fun droidDeckProtonIsInstalledWhenMissingUnlessTheUserRemovedIt() {
menu.installer = { tool, test, _ -> attempts.add(if (test) "test" else tool.id); install("${tool.prefix}-11-12"); null }
menu.installer = { tool, _ -> attempts.add(tool.id); install("${tool.prefix}-11-12"); null }
ProtonExtras.setDeclined(activity, true)
menu.ensureAutoUpdates()
assertNull(menu.protonBusyId)
@@ -222,11 +286,11 @@ class ProtonMenuAutoTest {
menu.removeProton("droiddeck")
waitUntil { menu.protonBusyId == null }
assertTrue(ProtonExtras.declined(activity))
menu.installer = { _, _, _ -> "failed" }
menu.installer = { _, _ -> "failed" }
menu.installProton("droiddeck")
waitUntil { menu.protonBusyId == null }
assertTrue(ProtonExtras.declined(activity))
menu.installer = { tool, _, _ -> install("${tool.prefix}-11-12"); null }
menu.installer = { tool, _ -> install("${tool.prefix}-11-12"); null }
menu.installProton("droiddeck")
waitUntil { menu.protonBusyId == null }
assertFalse(ProtonExtras.declined(activity))
@@ -236,7 +300,7 @@ class ProtonMenuAutoTest {
install("DroidDeck-Proton-11-11.1")
val launcher = Robolectric.buildActivity(FrontEndActivity::class.java).get()
val protons = ReflectionHelpers.getField<ProtonMenu>(launcher, "protons")
protons.installer = { tool, _, _ -> attempts.add(tool.id); "failed" }
protons.installer = { tool, _ -> attempts.add(tool.id); "failed" }
Motion.refresh(launcher)
LaunchOrigin.mark(Rect(0f, 0f, 100f, 100f), "game")
launcher.startActivity(Intent(launcher, SessionActivity::class.java))
@@ -1,7 +1,17 @@
package com.droiddeck.launcher.session
import java.io.File
import java.io.RandomAccessFile
import java.nio.file.Files
import org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry
import org.apache.commons.compress.archivers.sevenz.SevenZOutputFile
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream
import android.app.Activity
import org.json.JSONArray
import org.json.JSONObject
import org.junit.Before
import org.robolectric.Robolectric
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNull
@@ -17,6 +27,75 @@ import org.robolectric.annotation.Config
@Config(sdk = [28], manifest = Config.NONE)
class ExperimentalProtonsTest {
@get:Rule val temp = TemporaryFolder()
private lateinit var activity: Activity
@Before
fun setup() {
activity = Robolectric.buildActivity(Activity::class.java).setup().get()
}
@Test
fun fileLabelsDropTheWholeArchiveSuffix() {
assertEquals("Build-12.8-r34", ExperimentalProtons.fileLabel("Build-12.8-r34.tar.xz"))
assertEquals("Build-12.8-r34", ExperimentalProtons.fileLabel("Build-12.8-r34.tar"))
assertEquals("Build-12.8-r34", ExperimentalProtons.fileLabel("Build-12.8-r34.7z"))
assertEquals("Build-12.8-r34", ExperimentalProtons.fileLabel("Build-12.8-r34.tgz"))
assertEquals("Experimental-Build", ExperimentalProtons.dirName("Build", ExperimentalProtons.fileLabel("Build.tar.gz")))
}
@Test
fun installedReleasesLeaveTheAvailableRows() {
val rows = listOf("r34", "r35").map { ExperimentalProtons.Release(it, "$it.tar.xz", "https://example.invalid/$it", null, 1L) }
val installed = listOf(
ExperimentalProtons.Installed("Experimental-r34", "r34", "release", "r34"),
ExperimentalProtons.Installed("Experimental-file", "file", "file"),
)
assertEquals(listOf("r35"), ExperimentalProtons.available(rows, installed).map { it.tag })
assertEquals(listOf("r34", "r35"), ExperimentalProtons.available(rows, emptyList()).map { it.tag })
}
@Test
fun releaseRowsOnlyUsePublishedPrereleaseTarAssets() {
val tool = ProtonExtras.tools.first { it.id == ProtonExtras.OWN }
val releases = JSONArray("""
[{"tag_name":"stable","prerelease":false,"published_at":"2026-11-10T00:00:00Z","assets":[{"name":"stable-aarch64.tar.gz","browser_download_url":"https://example/stable"}]},
{"tag_name":"pre","prerelease":true,"published_at":"2026-11-12T00:00:00Z","assets":[{"name":"pre-aarch64.tar.xz","browser_download_url":"https://example/pre"}]},
{"tag_name":"superseded","prerelease":true,"published_at":"2026-10-25T00:00:00Z","assets":[{"name":"superseded-aarch64.tar.gz","browser_download_url":"https://example/superseded"}]},
{"tag_name":"sources","prerelease":true,"published_at":"2026-11-13T00:00:00Z","assets":[{"name":"wine-gecko-x86.tar.xz","browser_download_url":"https://example/sources"}]},
{"tag_name":"draft","draft":true,"prerelease":true,"published_at":"2026-11-14T00:00:00Z","assets":[{"name":"draft-aarch64.tar.gz","browser_download_url":"https://example/draft"}]},
{"tag_name":"no-tar","prerelease":true,"published_at":"2026-11-15T00:00:00Z","assets":[{"name":"no-tar.sha512sum","browser_download_url":"https://example/sum"}]}]
""".trimIndent())
assertEquals(listOf("pre"), ProtonExtras.assets(tool, releases, true).map { it.tag })
}
@Test
fun markerRoundTripKeepsReleaseTag() {
val dir = File(com.droiddeck.launcher.runtime.LinuxRuntime.rootDir(activity), "root/.local/share/Steam/compatibilitytools.d/Experimental-pre").apply { mkdirs() }
File(dir, ".droiddeck-experimental.json").writeText(JSONObject().put("label", "Experimental-pre").put("source", "pre").put("releaseTag", "pre").toString())
assertEquals("pre", ExperimentalProtons.installed(activity).single().releaseTag)
}
@Test
fun missingReleaseTagsAreAutoRemovedButFileBuildsAreNot() {
val complete = ProtonExtras.ReleaseFetch(JSONArray().put(JSONObject().put("tag_name", "kept").put("prerelease", true)), true)
val partial = ProtonExtras.ReleaseFetch(JSONArray().put(JSONObject().put("tag_name", "gone").put("prerelease", true)), false)
val stable = ProtonExtras.ReleaseFetch(JSONArray().put(JSONObject().put("tag_name", "gone").put("prerelease", false)), false)
assertTrue(ExperimentalProtons.shouldRemove("gone", complete) { true })
assertFalse(ExperimentalProtons.shouldRemove("gone", complete) { false })
assertFalse(ExperimentalProtons.shouldRemove("gone", partial) { true })
assertTrue(ExperimentalProtons.shouldRemove("gone", stable) { false })
assertFalse(ExperimentalProtons.shouldRemove(null, complete) { true })
}
@Test
fun archiveTypeUsesMagicBytes() {
val zip = temp.newFile("wrong-name.bin").apply { writeBytes(byteArrayOf(0x50, 0x4B, 0x03, 0x04)) }
val seven = temp.newFile("seven.data").apply { writeBytes(byteArrayOf(0x37, 0x7A, 0xBC.toByte(), 0xAF.toByte(), 0x27, 0x1C)) }
val tar = temp.newFile("tar.data").apply { RandomAccessFile(this, "rw").use { it.seek(257); it.write("ustar".toByteArray()) } }
assertEquals(ExperimentalProtons.ArchiveType.ZIP, ExperimentalProtons.archiveType(zip))
assertEquals(ExperimentalProtons.ArchiveType.SEVEN_Z, ExperimentalProtons.archiveType(seven))
assertEquals(ExperimentalProtons.ArchiveType.TAR, ExperimentalProtons.archiveType(tar))
}
@Test
fun namesNeverCollideWithReleasedBuilds() {
@@ -74,6 +153,207 @@ class ExperimentalProtonsTest {
assertTrue(File(kept, "file").isFile)
}
@Test
fun directZipKeepsExecutableModeAndInTreeLinks() {
val archive = temp.newFile("tree.zip")
ZipArchiveOutputStream(archive).use { zip ->
zip.putArchiveEntry(ZipArchiveEntry("build/proton").apply { unixMode = 0x81ED })
zip.write("binary".toByteArray())
zip.closeArchiveEntry()
zip.putArchiveEntry(ZipArchiveEntry("build/link").apply { unixMode = 0xA1FF })
zip.write("proton".toByteArray())
zip.closeArchiveEntry()
zip.putArchiveEntry(ZipArchiveEntry("build/files/lib/up").apply { unixMode = 0xA1FF })
zip.write("../../proton".toByteArray())
zip.closeArchiveEntry()
}
val unpacked = temp.newFolder("direct")
ExperimentalProtons.extractDirect(archive, unpacked, ExperimentalProtons.ArchiveType.ZIP)
assertTrue(File(unpacked, "build/proton").canExecute())
assertTrue(Files.isSymbolicLink(File(unpacked, "build/link").toPath()))
assertEquals("proton", Files.readSymbolicLink(File(unpacked, "build/link").toPath()).toString())
assertEquals("../../proton", Files.readSymbolicLink(File(unpacked, "build/files/lib/up").toPath()).toString())
assertEquals("binary", File(unpacked, "build/files/lib/up").readText())
}
@Test
fun directArchivesFillReadOnlyDirectoriesBeforeLockingThem() {
val archive = temp.newFile("locked.zip")
ZipArchiveOutputStream(archive).use { zip ->
zip.putArchiveEntry(ZipArchiveEntry("build/files/").apply { unixMode = 0x416D })
zip.closeArchiveEntry()
zip.putArchiveEntry(ZipArchiveEntry("build/files/data").apply { unixMode = 0x81A4 })
zip.write("data".toByteArray())
zip.closeArchiveEntry()
}
val unpacked = temp.newFolder("locked")
ExperimentalProtons.extractDirect(archive, unpacked, ExperimentalProtons.ArchiveType.ZIP)
val directory = File(unpacked, "build/files")
assertEquals("data", File(directory, "data").readText())
assertFalse(directory.canWrite())
directory.setWritable(true)
}
@Test
fun directSevenZipKeepsExecutableModeAndInTreeLinks() {
val archive = temp.newFile("tree.7z")
SevenZOutputFile(archive).use { seven ->
fun add(name: String, mode: Int, text: String) {
val entry = SevenZArchiveEntry().apply {
this.name = name
hasWindowsAttributes = true
windowsAttributes = (mode shl 16) or 0x8000
}
seven.putArchiveEntry(entry)
seven.write(text.toByteArray())
seven.closeArchiveEntry()
}
add("build/proton", 0x81ED, "binary")
add("build/files/lib/up", 0xA1FF, "../../proton")
add("build/plain", 0x81A4, "data")
}
val unpacked = temp.newFolder("seven")
ExperimentalProtons.extractDirect(archive, unpacked, ExperimentalProtons.ArchiveType.SEVEN_Z)
assertTrue(File(unpacked, "build/proton").canExecute())
assertFalse(File(unpacked, "build/plain").canExecute())
assertEquals("../../proton", Files.readSymbolicLink(File(unpacked, "build/files/lib/up").toPath()).toString())
}
@Test
fun directArchivesAllowCurrentDirectoryBeforeAClimb() {
val archive = temp.newFile("dot.zip")
ZipArchiveOutputStream(archive).use { zip ->
zip.putArchiveEntry(ZipArchiveEntry("build/lib/wine").apply { unixMode = 0x81ED })
zip.write("binary".toByteArray())
zip.closeArchiveEntry()
zip.putArchiveEntry(ZipArchiveEntry("build/bin/wine").apply { unixMode = 0xA1FF })
zip.write("./../lib/wine".toByteArray())
zip.closeArchiveEntry()
}
val unpacked = temp.newFolder("dot")
ExperimentalProtons.extractDirect(archive, unpacked, ExperimentalProtons.ArchiveType.ZIP)
assertEquals("./../lib/wine", Files.readSymbolicLink(File(unpacked, "build/bin/wine").toPath()).toString())
assertEquals("binary", File(unpacked, "build/bin/wine").readText())
}
@Test
fun directArchivesRejectLinksThatClimbAfterACurrentDirectoryAndAName() {
for (link in listOf("./top/../outside", "./../a/./../..", "top/./../outside")) {
val archive = temp.newFile()
ZipArchiveOutputStream(archive).use { zip ->
zip.putArchiveEntry(ZipArchiveEntry("build/a/b/out").apply { unixMode = 0xA1FF })
zip.write(link.toByteArray())
zip.closeArchiveEntry()
}
val result = runCatching { ExperimentalProtons.extractDirect(archive, temp.newFolder(), ExperimentalProtons.ArchiveType.ZIP) }
assertTrue(link, result.exceptionOrNull() is ExperimentalProtons.UnsafeArchiveException)
}
}
@Test
fun reconcileKeepsBuildsWhenASessionStartsDuringTheLookup() {
val tools = File(com.droiddeck.launcher.runtime.LinuxRuntime.rootDir(activity), "root/.local/share/Steam/compatibilitytools.d")
val dirs = listOf("Experimental-gone-a", "Experimental-gone-b").map { name ->
File(tools, name).apply {
mkdirs()
File(this, ".droiddeck-experimental.json").writeText(JSONObject().put("label", name).put("source", name).put("releaseTag", name).toString())
}
}
val complete = ProtonExtras.ReleaseFetch(JSONArray(), true)
var lookups = 0
try {
ExperimentalProtons.reconcile(activity, complete) {
lookups++
SessionState.running = true
true
}
} finally {
SessionState.running = false
}
assertEquals(1, lookups)
assertTrue(dirs.all { it.isDirectory })
ExperimentalProtons.reconcile(activity, complete) { true }
assertTrue(dirs.none { it.exists() })
}
@Test
fun removeWaitsForAStartingSessionAndThenKeepsTheBuild() {
val tools = File(com.droiddeck.launcher.runtime.LinuxRuntime.rootDir(activity), "root/.local/share/Steam/compatibilitytools.d")
val dir = File(tools, "Experimental-starting").apply {
mkdirs()
File(this, ".droiddeck-experimental.json").writeText(JSONObject().put("label", name).put("source", name).toString())
File(this, "proton").writeText("build")
}
var removed: Boolean? = null
val removal = Thread { removed = ExperimentalProtons.remove(activity, dir.name) }
try {
synchronized(SessionState.startLock) {
removal.start()
val deadline = System.nanoTime() + 10_000_000_000L
while (removal.state != Thread.State.BLOCKED && System.nanoTime() < deadline) Thread.sleep(5)
assertEquals(Thread.State.BLOCKED, removal.state)
assertTrue(File(dir, "proton").isFile)
SessionState.running = true
}
removal.join(10_000)
assertEquals(false, removed)
assertTrue(File(dir, "proton").isFile)
} finally {
SessionState.running = false
removal.join(10_000)
}
assertTrue(ExperimentalProtons.remove(activity, dir.name))
assertTrue(!dir.exists())
assertTrue(File(tools, ".droiddeck-experimental-gone").list().isNullOrEmpty())
}
@Test
fun directArchivesRejectLinksThatClimbAfterAName() {
val archive = temp.newFile("climb.zip")
ZipArchiveOutputStream(archive).use { zip ->
zip.putArchiveEntry(ZipArchiveEntry("build/a/b/top").apply { unixMode = 0xA1FF })
zip.write("../../..".toByteArray())
zip.closeArchiveEntry()
zip.putArchiveEntry(ZipArchiveEntry("build/a/b/out").apply { unixMode = 0xA1FF })
zip.write("top/../outside".toByteArray())
zip.closeArchiveEntry()
}
val result = runCatching { ExperimentalProtons.extractDirect(archive, temp.newFolder("climb-out"), ExperimentalProtons.ArchiveType.ZIP) }
assertTrue(result.exceptionOrNull() is ExperimentalProtons.UnsafeArchiveException)
}
@Test
fun directZipRejectsEscapingLinksAndEntries() {
val linkArchive = temp.newFile("link.zip")
ZipArchiveOutputStream(linkArchive).use { zip ->
zip.putArchiveEntry(ZipArchiveEntry("build/link").apply { unixMode = 0xA1FF })
zip.write("../../outside".toByteArray())
zip.closeArchiveEntry()
}
val entryArchive = temp.newFile("entry.zip")
ZipArchiveOutputStream(entryArchive).use { zip ->
zip.putArchiveEntry(ZipArchiveEntry("../outside"))
zip.write("x".toByteArray())
zip.closeArchiveEntry()
}
val linkResult = runCatching { ExperimentalProtons.extractDirect(linkArchive, temp.newFolder("link-out"), ExperimentalProtons.ArchiveType.ZIP) }
val entryResult = runCatching { ExperimentalProtons.extractDirect(entryArchive, temp.newFolder("entry-out"), ExperimentalProtons.ArchiveType.ZIP) }
assertTrue(linkResult.exceptionOrNull() is ExperimentalProtons.UnsafeArchiveException)
assertTrue(entryResult.exceptionOrNull() is ExperimentalProtons.UnsafeArchiveException)
}
@Test
fun staleDownloadCleanupOnlyDeletesItsOwnUnlistedFiles() {
val downloads = File(activity.filesDir, "proton-downloads").apply { mkdirs() }
val stale = File(downloads, "droiddeck-gone-archive.tar.xz").apply { writeText("partial") }
val kept = File(downloads, "droiddeck-kept-archive.tar.xz").apply { writeText("partial") }
val other = File(downloads, "other-archive.tar.xz").apply { writeText("partial") }
ExperimentalProtons.removeStaleDownloads(activity, setOf("kept"))
assertFalse(stale.exists())
assertTrue(kept.exists())
assertTrue(other.exists())
}
@Test
fun checksumFileWithoutADigestIsRejected() {
assertNull(ExperimentalProtons.checksumIn("not a checksum\n"))
@@ -30,7 +30,7 @@ class ProtonExtrasTest {
.apply { if (digest != null) put("digest", digest) }
private fun release(tag: String, vararg assets: JSONObject, prerelease: Boolean = false, draft: Boolean = false) = JSONObject()
.put("tag_name", tag).put("prerelease", prerelease).put("draft", draft)
.put("tag_name", tag).put("prerelease", prerelease).put("draft", draft).put("published_at", "2026-11-12T00:00:00Z")
.put("assets", JSONArray().apply { assets.forEach { put(it) } })
private fun droiddeckRelease(ver: String, prerelease: Boolean = false) = release(
@@ -48,6 +48,34 @@ class ProtonExtrasTest {
File(this, "proton").apply { writeText(""); setExecutable(true) }
}
@Test
fun experimentalRowsUseTheReleaseNameAndTagDetail() {
val current = release("DroidDeck-Bionic-12.8-r34", asset("DroidDeck-Bionic-12.8-r34-aarch64.tar.xz"), prerelease = true)
.put("name", "DroidDeck Bionic 12.8 r34")
val selectedAsset = ProtonExtras.assetOf(tool("droiddeck"), current, experimental = true)!!
val selected = ProtonExtras.assets(tool("droiddeck"), JSONArray().put(current), true).single()
assertEquals("DroidDeck-Bionic-12.8-r34-aarch64.tar.xz", selectedAsset.name)
assertEquals("DroidDeck Bionic 12.8 r34", selected.releaseName)
assertEquals("DroidDeck-Bionic-12.8-r34", selected.tag)
}
@Test
fun experimentalAssetsIgnoreChecksumSidecars() {
val sidecarOnly = release("DroidDeck-Bionic-12.8-r36", asset("DroidDeck-Bionic-12.8-r36-aarch64.tar.xz.sha512sum"))
assertEquals(null, ProtonExtras.assetOf(tool("droiddeck"), sidecarOnly, experimental = true))
}
@Test
fun experimentalAssetsSkipOtherArchitectures() {
val foreign = release("DroidDeck-Bionic-12.8-r37", asset("DroidDeck-Bionic-12.8-r37-x86_64.tar.xz"), asset("DroidDeck-Bionic-12.8-r37-amd64.tar.gz"), prerelease = true)
val mixed = release("DroidDeck-Bionic-12.8-r38", asset("DroidDeck-Bionic-12.8-r38-x86_64.tar.xz"), asset("DroidDeck-Bionic-12.8-r38.tar.xz"), prerelease = true)
val named = release("DroidDeck-Bionic-12.8-r39", asset("DroidDeck-Bionic-12.8-r39-aarch64.tar.xz"), asset("DroidDeck-Bionic-12.8-r39-x86_64.tar.xz"), prerelease = true)
assertEquals(null, ProtonExtras.assetOf(tool("droiddeck"), foreign, experimental = true))
assertEquals("DroidDeck-Bionic-12.8-r38.tar.xz", ProtonExtras.assetOf(tool("droiddeck"), mixed, experimental = true)!!.name)
assertEquals("DroidDeck-Bionic-12.8-r39-aarch64.tar.xz", ProtonExtras.assetOf(tool("droiddeck"), named, experimental = true)!!.name)
assertTrue(ProtonExtras.assets(tool("droiddeck"), JSONArray().put(foreign), true).isEmpty())
}
@Test
fun theThreeSourcesInOrder() {
assertEquals(listOf("ge", "cachyos", "droiddeck"), ProtonExtras.tools.map { it.id })
@@ -72,6 +100,14 @@ class ProtonExtrasTest {
assertNull(picked.sha256)
}
@Test
fun ownExperimentalReleaseUsesItsCurrentBionicTarballShape() {
val current = release("DroidDeck-Bionic-12.8-r34", asset("DroidDeck-Bionic-12.8-r34-aarch64.tar.xz"), asset("DroidDeck-Bionic-12.8-r34-aarch64.sha512sum"), prerelease = true)
val rows = ProtonExtras.assets(tool("droiddeck"), JSONArray().put(current), prerelease = true)
assertEquals(listOf("DroidDeck-Bionic-12.8-r34"), rows.map { it.tag })
assertTrue(ProtonExtras.assets(tool("droiddeck"), JSONArray().put(release("DroidDeck-Bionic-12.8-r35", asset("DroidDeck-Bionic-12.8-r35-aarch64.sha512sum"), prerelease = true)), true).isEmpty())
}
@Test
fun githubsDigestIsKeptBesideTheSha512File() {
val sum = "ab".repeat(32)
@@ -83,20 +119,6 @@ class ProtonExtrasTest {
assertTrue(picked.sha512!!.endsWith("GE-Proton11-7-aarch64.sha512sum"))
}
@Test
fun aTestBuildChoosesACompatibleArchiveWithVerification() {
val release = release(
"DroidDeck-Proton-11-12.9",
asset("DroidDeck-Proton-11-12.9-aarch64.tar.gz"),
asset("DroidDeck-Proton-11-12.9-aarch64.tar.xz", "sha256:" + "ab".repeat(32)),
prerelease = true,
)
val releases = JSONArray().put(release).put(droiddeckRelease("11-12.8"))
val picked = ProtonExtras.pickAsset(tool("droiddeck"), releases, test = true)!!
assertEquals("DroidDeck-Proton-11-12.9-aarch64.tar.xz", picked.name)
assertEquals("ab".repeat(32), picked.sha256)
}
@Test
fun prereleasesDraftsAndReleasesWithoutAnArm64BuildAreSkipped() {
val releases = JSONArray()
@@ -274,64 +296,11 @@ class ProtonExtrasTest {
assertEquals("DroidDeck-Proton-11-11.4", ProtonExtras.update(context, tool("droiddeck")))
}
@Test
fun theNewestPrereleaseAheadOfTheLatestReleaseIsTheTestBuild() {
val releases = JSONArray()
.put(release("DroidDeck-Bionic-12.8-r25", asset("DroidDeck-Bionic-12.8-r25-aarch64.tar.xz"), prerelease = true))
.put(droiddeckRelease("11-12.9", prerelease = true))
.put(droiddeckRelease("11-12.8"))
assertEquals("DroidDeck-Proton-11-12.9", ProtonExtras.pickAsset(tool("droiddeck"), releases, test = true)!!.tag)
assertEquals("DroidDeck-Proton-11-12.8", ProtonExtras.pickAsset(tool("droiddeck"), releases)!!.tag)
}
@Test
fun aPrereleaseOlderThanTheLatestReleaseIsNotOffered() {
val releases = JSONArray()
.put(droiddeckRelease("11-12.9"))
.put(droiddeckRelease("11-12.8", prerelease = true))
assertNull(ProtonExtras.pickAsset(tool("droiddeck"), releases, test = true))
assertNull(ProtonExtras.pickAsset(tool("droiddeck"), JSONArray().put(droiddeckRelease("11-12.8")), test = true))
}
@Test
fun aTestBuildIsOfferedOnlyWhenNotInstalledAndNewer() {
assertEquals("DroidDeck-Proton-11-12.9", ProtonExtras.testFor(emptyList(), "DroidDeck-Proton-11-12.9"))
assertEquals("DroidDeck-Proton-11-12.9", ProtonExtras.testFor(listOf("DroidDeck-Proton-11-12.8"), "DroidDeck-Proton-11-12.9"))
assertNull(ProtonExtras.testFor(listOf("DroidDeck-Proton-11-12.9"), "DroidDeck-Proton-11-12.9"))
assertNull(ProtonExtras.testFor(listOf("DroidDeck-Proton-11-13.0"), "DroidDeck-Proton-11-12.9"))
assertNull(ProtonExtras.testFor(listOf("DroidDeck-Proton-11-12.8"), null))
}
@Test
fun theHighestEligibleTestBuildWinsWhateverTheListOrder() {
val releases = JSONArray()
.put(droiddeckRelease("11-12.7", prerelease = true))
.put(droiddeckRelease("11-12.9", prerelease = true))
.put(droiddeckRelease("11-12.8.5", prerelease = true))
.put(droiddeckRelease("11-12.8"))
assertEquals("DroidDeck-Proton-11-12.9", ProtonExtras.pickAsset(tool("droiddeck"), releases, test = true)!!.tag)
}
@Test
fun noTestBuildWithoutAStableBaseline() {
val releases = JSONArray().put(droiddeckRelease("11-12.9", prerelease = true))
assertNull(ProtonExtras.pickAsset(tool("droiddeck"), releases, test = true))
}
@Test
fun aTestBuildWithNoChecksumIsNotOffered() {
val releases = JSONArray()
.put(release("DroidDeck-Proton-11-12.10", asset("DroidDeck-Proton-11-12.10-aarch64.tar.gz"), prerelease = true))
.put(droiddeckRelease("11-12.9", prerelease = true))
.put(droiddeckRelease("11-12.8"))
assertEquals("DroidDeck-Proton-11-12.9", ProtonExtras.pickAsset(tool("droiddeck"), releases, test = true)!!.tag)
}
@Test
fun laterPagesAreReadOnlyUntilAStableBaselineIsFound() {
val tool = tool("droiddeck")
val pages = mapOf(
1 to JSONArray().put(droiddeckRelease("11-12.10", prerelease = true)),
1 to JSONArray().apply { repeat(15) { put(droiddeckRelease("11-12.${10 - it}", prerelease = true)) } },
2 to JSONArray().put(droiddeckRelease("11-12.8")),
3 to JSONArray().put(droiddeckRelease("11-12.7")),
)
@@ -339,7 +308,6 @@ class ProtonExtrasTest {
val all = ProtonExtras.releases(tool) { asked += it; pages[it] ?: JSONArray() }!!
assertEquals(listOf(1, 2), asked)
assertEquals("DroidDeck-Proton-11-12.8", ProtonExtras.pickAsset(tool, all)!!.tag)
assertEquals("DroidDeck-Proton-11-12.10", ProtonExtras.pickAsset(tool, all, test = true)!!.tag)
asked.clear()
ProtonExtras.releases(tool) { asked += it; pages.getValue(2) }
@@ -353,35 +321,20 @@ class ProtonExtrasTest {
asked.clear()
assertNull(ProtonExtras.releases(tool) { page ->
asked += page
if (page == 1) JSONArray().put(droiddeckRelease("11-12.10", prerelease = true)) else null
if (page == 1) JSONArray().apply { repeat(15) { put(droiddeckRelease("11-12.${10 - it}", prerelease = true)) } } else null
})
assertEquals(listOf(1, 2), asked)
}
@Test
fun anIncompleteLookupKeepsTheCachedTestBuildAndACompletedLookupClearsIt() {
val tool = tool("droiddeck")
val cache = JSONObject().put(tool.id, JSONObject().put("tag", "DroidDeck-Proton-11-12.8").put("test", "DroidDeck-Proton-11-12.9"))
ProtonExtras.updateLatest(cache, tool, null, 1L)
assertEquals("DroidDeck-Proton-11-12.9", cache.getJSONObject(tool.id).getString("test"))
ProtonExtras.updateLatest(cache, tool, JSONArray().put(droiddeckRelease("11-12.8")), 1L)
assertFalse(cache.getJSONObject(tool.id).has("test"))
}
@Test
fun aTestInstallLeavesTheStableEntryAndAStableInstallKeepsTheTestOffer() {
val tool = tool("droiddeck")
val cache = JSONObject().put(tool.id, JSONObject().put("tag", "DroidDeck-Proton-11-12.8").put("test", "DroidDeck-Proton-11-12.9"))
assertFalse(ProtonExtras.recordLatest(cache, tool, "DroidDeck-Proton-11-12.9", true, 2L))
assertEquals("DroidDeck-Proton-11-12.8", cache.getJSONObject(tool.id).getString("tag"))
assertEquals("DroidDeck-Proton-11-12.9", cache.getJSONObject(tool.id).getString("test"))
assertEquals("DroidDeck-Proton-11-12.9", ProtonExtras.testFor(emptyList(), cache.getJSONObject(tool.id).getString("test")))
assertFalse(ProtonExtras.recordLatest(cache, tool, "DroidDeck-Proton-11-12.7", false, 2L))
assertTrue(ProtonExtras.recordLatest(cache, tool, "DroidDeck-Proton-11-12.8", false, 2L))
assertEquals("DroidDeck-Proton-11-12.9", cache.getJSONObject(tool.id).getString("test"))
assertEquals(2L, cache.getJSONObject(tool.id).getLong("at"))
assertTrue(ProtonExtras.recordLatest(cache, tool, "DroidDeck-Proton-11-13.0", false, 3L))
assertFalse(cache.getJSONObject(tool.id).has("test"))
fun anOldTestButtonInstallRemainsAUsableInstalledBuild() {
val context = RuntimeEnvironment.getApplication()
val tools = File(LinuxRuntime.rootDir(context), "root/.local/share/Steam/compatibilitytools.d")
val installed = installTool(tools, "DroidDeck-Proton 11-12.9")
val releases = File(context.filesDir, "proton-extras.json")
releases.writeText(JSONObject().put(installed.name, "DroidDeck-Proton-11-12.9").toString())
assertEquals(listOf(installed.name), ProtonExtras.installedAll(context, tool("droiddeck")))
assertEquals(listOf("DroidDeck-Proton-11-12.9"), ProtonExtras.installedTags(context, tool("droiddeck")))
}
@Test
@@ -390,4 +343,28 @@ class ProtonExtrasTest {
assertEquals("DroidDeck-Proton-11-12.8", ProtonExtras.pickAsset(tool("droiddeck"), releases)!!.tag)
assertNull(ProtonExtras.pickAsset(tool("droiddeck"), JSONArray("[null]")))
}
@Test
fun failedOrPartialReleaseFetchDoesNotPretendMissingBuildsAreGone() {
val tool = tool("droiddeck")
assertNull(ProtonExtras.releasesForRemoval(tool) { null })
val asked = mutableListOf<Int>()
val result = ProtonExtras.releasesForRemoval(tool) { page ->
asked += page
if (page == 1) JSONArray().apply { repeat(15) { put(droiddeckRelease("11-12.${10 - it}", prerelease = true)) } } else null
}
assertNull(result)
assertEquals(listOf(1, 2), asked)
}
@Test
fun aShortReleasePageCompletesTheRemovalLookup() {
val asked = mutableListOf<Int>()
val result = ProtonExtras.releasesForRemoval(tool("droiddeck")) { page ->
asked += page
JSONArray().put(droiddeckRelease("11-12.8", prerelease = true))
}
assertTrue(result!!.complete)
assertEquals(listOf(1), asked)
}
}