fix(epic): install the Epic Games Launcher from its Linux .deb (#2281)

* fix(epic): install the Epic Games Launcher from its Linux .deb

Epic no longer serves the Linux AppImage: the installer URL answers 404
errors.com.epicgames.launcher.app_direct_url_not_found (30003), so Install
failed for everyone. Epic now ships EpicGamesLauncher-x86_64.deb
(0.113.0+g2164614).

- The installer downloads the .deb, checks its ar magic and the CDN ETag,
  and droiddeck-epic unpacks its data.tar.* member straight from the
  archive.
- The .deb links WebKitGTK 4.1, JavaScriptCoreGTK 4.1 and GTK 3, which the
  Steam Runtime 4 image does not ship. 32 Debian 13 amd64 packages, pinned
  by SHA-256 and size (60.2 MB download, 201 MB unpacked), are unpacked
  into the launcher's desktop/ folder (shared libraries only) and put on
  its LD_LIBRARY_PATH. Debian 13 matches the runtime's own base, so only
  sonames the runtime lacks are added. Each package falls back to
  snapshot.debian.org when the deb.debian.org pool has moved on.
- WebKit starts its helper processes from its built-in
  /usr/lib/x86_64-linux-gnu/webkit2gtk-4.1 path, so each launch links that
  folder in the runtime to the layer's copy.
- An installed AppImage launcher keeps starting through its AppRun; the
  next update check moves it to the .deb.

Closure checked offline: every ELF in the .deb and the layer resolves with
the runtime's own ld-linux-x86-64.so.2 inside a sandbox holding only the
runtime, the layer and libGLESv2 (0 missing, 0 version or undefined
symbol errors with LD_BIND_NOW).

Based on zooluis's research in #2268.

Co-authored-by: zooluis <150430329+zooluis@users.noreply.github.com>

* fix(epic): provide desktop GLib data paths

* fix(epic): keep archive symlinks from redirecting the desktop layer and icon

---------

Co-authored-by: zooluis <150430329+zooluis@users.noreply.github.com>
This commit is contained in:
MaxsTechReviewandzooluis authored and GitHub committed 2026-11-14 16:53:43 -05:00
1 parent 87c571f443
commit a3be5f7ae2
5 files changed
+417 -101

No files matched your search

+1
View File
@@ -92,6 +92,7 @@ DroidDeck is [GPL-3.0](LICENSE). Steam and Proton belong to Valve Corporation. V
- Epic Games and GOG build on [Phobos](https://github.com/phobos665)'s adaptation of [Legendary](https://github.com/legendary-gl/legendary) and [gogdl](https://github.com/Heroic-Games-Launcher/heroic-gogdl). GOG install script registry entries are read the way [Heroic Games Launcher](https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher) (GPL-3.0) reads them.
- Epic's official Linux launcher preview runs through FEX. That setup is outside Epic's listed Linux support.
- The launcher's .deb gets the WebKitGTK and GTK 3 libraries it needs from unmodified [Debian](https://www.debian.org) 13 packages, following [@zooluis](https://github.com/zooluis)'s research in [#2268](https://github.com/Droid-Deck/DroidDeck/pull/2268).
- Battle.net is by [@kayakyakr](https://github.com/kayakyakr). It runs Blizzard's own client in Proton (downloaded from Blizzard, not included) and shows key art from the [Battle.net Shop](https://shop.battle.net). Without Steam, its games see the pad as an Xbox 360 controller via `PROTON_SPOOF_STEAMINPUT_VIDPID` in [Proton](https://github.com/ValveSoftware/wine)'s `dlls/winebus.sys`.
- The EA store follows the EA app's protocols as documented by [ArmchairDevelopers](https://github.com/ArmchairDevelopers)' [Maxima](https://github.com/ArmchairDevelopers/Maxima) (GPL-3.0): sign-in, the GraphQL queries (included verbatim, since EA matches them by hash), build archives, online activation licences and the LSX game endpoint. The code is DroidDeck's own.
- Battle.net installs drive Blizzard's Agent the way [@barncastle](https://github.com/barncastle)'s [Battle.Net-Installer](https://github.com/barncastle/Battle.Net-Installer) does, with requests from [wowdev.wiki](https://wowdev.wiki/Agent). Read without taking code: [@mubaraknumann](https://github.com/mubaraknumann)'s [unifideck](https://github.com/mubaraknumann/unifideck), [@djmittens](https://github.com/djmittens)'s [neo-mittens](https://github.com/djmittens/neo-mittens) `bnetswitch`, [@BCD1210](https://github.com/BCD1210)'s [soju](https://github.com/BCD1210/soju) and [Lutris](https://github.com/lutris/lutris)'s `product.db` reader.
@@ -21,19 +21,61 @@ import java.security.MessageDigest
import java.util.concurrent.atomic.AtomicBoolean
internal object EpicClientSources {
const val LAUNCHER_URL = "https://launcher-public-service-prod06.ol.epicgames.com/launcher/api/installer/download/EpicGamesLauncher-x86_64.AppImage"
const val LAUNCHER_FILE = "EpicGamesLauncher-x86_64.AppImage"
const val LAUNCHER_URL = "https://launcher-public-service-prod06.ol.epicgames.com/launcher/api/installer/download/EpicGamesLauncher-x86_64.deb"
const val LAUNCHER_FILE = "EpicGamesLauncher-x86_64.deb"
const val RUNTIME_BASE = "https://repo.steampowered.com/steamrt4/images/"
const val RUNTIME_FILE = "com.valvesoftware.SteamRuntime.Platform-amd64,i386-steamrt4-runtime.tar.gz"
const val GLES_URL = "https://deb.debian.org/debian/pool/main/libg/libglvnd/libgles2_1.7.0-1+b2_amd64.deb"
const val GLES_FILE = "libgles2_1.7.0-1+b2_amd64.deb"
const val GLES_SHA256 = "e12c18aa77939d122ee1dea520ba0440b97dc19200b7396e03dff03a3ece74c1"
const val DEBIAN = "https://deb.debian.org/debian/"
const val SNAPSHOT = "https://snapshot.debian.org/archive/debian/20261101T000000Z/"
const val USER_AGENT = "DroidDeck"
private val VERSION = Regex("[A-Za-z0-9._+-]{1,64}")
private val SUM = Regex("^([0-9a-fA-F]{64})\\s+\\*?(.+)$")
class Source(val url: String, val version: String, val sha256: String? = null)
class Package(val path: String, val sha256: String, val size: Long) {
val file: String get() = path.substringAfterLast('/')
val urls: List<String> get() = listOf(DEBIAN + path, SNAPSHOT + path)
}
val DESKTOP = listOf(
Package("pool/main/a/abseil/libabsl20240722_20240722.0-4_amd64.deb", "78c6d7692890990a27cb1d5bbd95b7bfe47a4183ffafec5b30f689f9b58ec6f7", 491548L),
Package("pool/main/a/aom/libaom3_3.12.1-1+deb13u1_amd64.deb", "743eec7c94ae30295bc557ebac3dfae948e7390e89a2743c585d56297e9d312e", 1871712L),
Package("pool/main/a/aspell/libaspell15_0.60.8.1-4_amd64.deb", "8be22785198a4e5de1e2c3a157e8cd99ec7d5843c8ac96a174ec701ba4ac28e2", 337684L),
Package("pool/main/a/at-spi2-core/libatk-bridge2.0-0t64_2.56.2-1+deb13u2_amd64.deb", "c0fe87ea1bdca2f938eaa8286af5ad38ecd15cf18c6cfb5961d7d46ac3192325", 68516L),
Package("pool/main/a/at-spi2-core/libatspi2.0-0t64_2.56.2-1+deb13u2_amd64.deb", "65e9c9ecbd820fba2d04104cddd0bad33d256cbdfe0d1cb5365f10e363df2315", 81056L),
Package("pool/main/liba/libavif/libavif16_1.2.1-1.2_amd64.deb", "ba6c334454d3562560ad583fbe2c998e203b0fc5a0e0e91112ddcd3cff4704bb", 133120L),
Package("pool/main/libc/libcloudproviders/libcloudproviders0_0.3.6-2_amd64.deb", "a626bb23ed9ebc4bc3ce446b552048de63d76768bf0fb492754965c5ee28a7e4", 29232L),
Package("pool/main/c/colord/libcolord2_1.4.7-3_amd64.deb", "f11fd3b492781122edf0790f1e1fe24c51a41c67d4bb76cff84a9426c5654fa7", 139204L),
Package("pool/main/e/enchant-2/libenchant-2-2_2.8.2+dfsg1-3_amd64.deb", "83f208d89db1c48e6ede8a23e8ffa2bcddd4f99427bfd1279201247bbf27ca58", 56756L),
Package("pool/main/libe/libepoxy/libepoxy0_1.5.10-2_amd64.deb", "4c4c8024f2175086de65bca9fdc3fbb967f2863ebf249d489c66d0c8103dd3a3", 192728L),
Package("pool/main/libe/libevdev/libevdev2_1.13.4+dfsg-1_amd64.deb", "02e85fb9461b85b23f775d5fcf5a31c55d37bec40b63fd98ca5d3a2763714ae7", 32372L),
Package("pool/main/f/flite/libflite1_2.2-7_amd64.deb", "5945190970be7d4a1f71fb6f7e3e340ba2675e770605df0754051d617a6c5ee6", 12811404L),
Package("pool/main/libg/libgav1/libgav1-1_0.19.0-3+b1_amd64.deb", "94010041e59c7a8d2d3d1f5e62afd523f002b7b1caa3189419160b66d71c0195", 352956L),
Package("pool/main/g/gst-plugins-base1.0/libgstreamer-gl1.0-0_1.26.2-1+deb13u1_amd64.deb", "efacc61acbd44a6a067612e4592b9fe81efdc5011ed4c6cf7afd8ed83c5f834a", 269984L),
Package("pool/main/g/gst-plugins-base1.0/libgstreamer-plugins-base1.0-0_1.26.2-1+deb13u1_amd64.deb", "a20aedb3f89c162b4859cec37076f4eba54b0bcc7e5cb254a26cc4a877a88a1e", 997404L),
Package("pool/main/g/gstreamer1.0/libgstreamer1.0-0_1.26.2-2_amd64.deb", "08b463307fbde5496a346b1bb300b465cd22bd326f6f4634f482bf441af28a9b", 1421116L),
Package("pool/main/g/gtk+3.0/libgtk-3-0t64_3.24.49-3_amd64.deb", "4aa8828f01365f937f3bf69f812c8107ee4c8a2b208ffdd7656e8de5de81d98f", 2768812L),
Package("pool/main/h/hidapi/libhidapi-hidraw0_0.14.0-1+b2_amd64.deb", "89c546cb55be403ce63fe668baff2515979100a30fa07e2b97de186b9c07f01e", 12664L),
Package("pool/main/h/hunspell/libhunspell-1.7-0_1.7.2+really1.7.2-10+b4_amd64.deb", "a9427e5220e71f8c04c6c0f87826c6fef98e2bab6994a87d6d82e8a120790ecf", 236980L),
Package("pool/main/h/highway/libhwy1t64_1.2.0-2+b2_amd64.deb", "540c4ff28255fbfa89468061b722dfc2b773b0c1ecf163a063202482dea5b119", 676044L),
Package("pool/main/h/hyphen/libhyphen0_2.8.8-7+b2_amd64.deb", "fa9dca7b8cf1381fd52800c44a385c5725a78a88bd705f7c39b1046a5293435e", 30664L),
Package("pool/main/w/webkit2gtk/libjavascriptcoregtk-4.1-0_2.52.6-1~deb13u1_amd64.deb", "3383ebb3e13f31225c65f41112420be58493a3de112b5993cf5c417cfedc47c8", 7511632L),
Package("pool/main/j/jpeg-xl/libjxl0.11_0.11.2-0.1~deb13u2_amd64.deb", "cd1ca3a52cb0d8fdce1d994bcbf0663de28c64add1cfe8096639ae8fa9808824", 1133312L),
Package("pool/main/l/lcms2/liblcms2-2_2.16-2+deb13u2_amd64.deb", "32e53c2002ccea8c60c02779bea0ba49ac132fef702988a30d64af79b6617806", 160264L),
Package("pool/main/libm/libmanette/libmanette-0.2-0_0.2.12-1_amd64.deb", "98841a467692c46fd1870275113235691ebbfe71a3524f6b2a0fa7e9c33c6e56", 43752L),
Package("pool/main/o/orc/liborc-0.4-0t64_0.4.41-1_amd64.deb", "5b9afe78be0dd71399c0d4d7e5f26beb6ddf207279997942d8280be1b20bd58c", 189604L),
Package("pool/main/r/rust-rav1e/librav1e0.7_0.7.1-9+b2_amd64.deb", "d5b1373a8d6905ee4523faf1db7a626dc660e03836ec91b616e57ba386f47eb6", 946396L),
Package("pool/main/libs/libsecret/libsecret-1-0_0.21.7-1_amd64.deb", "949c5428cd3427486ac6c4dfc6d9400ce786c504c02334acc903c873aa52d14f", 111224L),
Package("pool/main/s/svt-av1/libsvtav1enc2_2.3.0+dfsg-1_amd64.deb", "cdaf961c3cc4fe78a19ff18c17d83d813f78a378fdcc4c86ccbb9b54e84ae599", 2489492L),
Package("pool/main/w/webkit2gtk/libwebkit2gtk-4.1-0_2.52.6-1~deb13u1_amd64.deb", "6471d989a61a56a7801e88e420789aa6b0eaba630a9787365bba8b9576b7ba1c", 24163372L),
Package("pool/main/libx/libxslt/libxslt1.1_1.1.35-1.2+deb13u3_amd64.deb", "c8e5a745ca3afaa079b01e0c00d80a241101d1ab840407fcd4bb423de3326160", 233128L),
Package("pool/main/liby/libyuv/libyuv0_0.0.1904.20250204-1_amd64.deb", "1a6827fe94fa5572a032332df7313ed408e9c0ad78f3a1248391bddc6d920ef2", 173700L),
)
fun launcher(): Source? {
val location = redirect(LAUNCHER_URL) ?: return null
val version = launcherVersion(location) ?: return null
@@ -142,12 +184,13 @@ internal object EpicClientSources {
private fun hex(bytes: ByteArray): String = bytes.joinToString("") { "%02x".format(it) }
fun isAppImage(file: File): Boolean = runCatching {
private val DEB_MAGIC = "!<arch>\ndebian-binary".toByteArray(Charsets.US_ASCII)
fun isDeb(file: File): Boolean = runCatching {
RandomAccessFile(file, "r").use { raf ->
val head = ByteArray(11)
val head = ByteArray(DEB_MAGIC.size)
raf.readFully(head)
head[0] == 0x7f.toByte() && head[1] == 'E'.code.toByte() && head[2] == 'L'.code.toByte() && head[3] == 'F'.code.toByte() &&
head[8] == 'A'.code.toByte() && head[9] == 'I'.code.toByte() && head[10] == 2.toByte()
head.contentEquals(DEB_MAGIC)
}
}.getOrDefault(false)
}
@@ -156,9 +199,10 @@ internal class EpicClientInstaller(private val app: Context) : DownloadQueue.Dow
private val cancelled = AtomicBoolean(false)
@Volatile private var connection: HttpURLConnection? = null
private class Part(val url: String, val file: File, val sha256: String?, val appImage: Boolean) {
var size = -1L
private class Part(val urls: List<String>, val file: File, val sha256: String?, val launcher: Boolean, var size: Long = -1L) {
var mirror = 0
var mismatch: String? = null
val url: String get() = urls[mirror]
}
override fun run(handle: DownloadQueue.JobHandle): String? {
@@ -173,17 +217,15 @@ internal class EpicClientInstaller(private val app: Context) : DownloadQueue.Dow
val needRuntime = !(before.runtimeVersion == runtime.version && File(state, "runtime/${runtime.version}/.droiddeck-ready").isFile)
val dir = EpicClient.downloadsDir(app).apply { mkdirs() }
val gles = EpicClientSources.gles()
val parts = buildList {
if (needApp) add(Part(launcher.url, File(dir, "${launcher.version}-${EpicClientSources.LAUNCHER_FILE}"), null, true))
if (needRuntime) {
add(Part(runtime.url, File(dir, "steamrt4-${runtime.version}.tar.gz"), runtime.sha256, false))
add(Part(gles.url, File(dir, EpicClientSources.GLES_FILE), gles.sha256, false))
}
}
val appPart = if (needApp) Part(listOf(launcher.url), File(dir, "${launcher.version}-${EpicClientSources.LAUNCHER_FILE}"), null, true) else null
val desktopParts = if (needApp) EpicClientSources.DESKTOP.map { Part(it.urls, File(dir, it.file), it.sha256, false, it.size) } else emptyList()
val runtimePart = if (needRuntime) Part(listOf(runtime.url), File(dir, "steamrt4-${runtime.version}.tar.gz"), runtime.sha256, false) else null
val glesPart = if (needRuntime) Part(listOf(gles.url), File(dir, EpicClientSources.GLES_FILE), gles.sha256, false) else null
val parts = listOfNotNull(appPart) + desktopParts + listOfNotNull(runtimePart, glesPart)
val keep = parts.flatMap { listOf(it.file.name, it.file.name + PARTIAL, it.file.name + TAG) }.toSet()
dir.listFiles()?.forEach { if (it.name !in keep) it.deleteRecursively() }
if (parts.isNotEmpty()) {
parts.forEach { it.size = length(it.url) }
parts.forEach { if (it.size <= 0) it.size = length(it.url) }
val total = parts.sumOf { it.size.coerceAtLeast(0L) }
val have = parts.sumOf { p -> if (p.file.isFile) p.file.length() else File(p.file.path + PARTIAL).length() }
val needed = (total - have).coerceAtLeast(0L) + (if (needApp) APP_ROOM else 0L) + (if (needRuntime) RUNTIME_ROOM else 0L)
@@ -202,8 +244,9 @@ internal class EpicClientInstaller(private val app: Context) : DownloadQueue.Dow
handle.stage(DownloadStage.INSTALL, app.getString(R.string.epic_client_unpacking))
val argv = mutableListOf(EpicClient.PROGRAM, "install", "--app-version", launcher.version, "--runtime-version", runtime.version)
fun guest(file: File) = EpicClient.guestPath(app, file) ?: throw IllegalStateException(app.getString(R.string.epic_client_unpack_failed, file.name))
if (needApp) argv += listOf("--app", guest(parts[0].file))
if (needRuntime) argv += listOf("--runtime", guest(parts[parts.size - 2].file), "--gles", guest(parts[parts.size - 1].file))
appPart?.let { argv += listOf("--app", guest(it.file)) }
desktopParts.forEach { argv += listOf("--desktop", guest(it.file)) }
if (runtimePart != null && glesPart != null) argv += listOf("--runtime", guest(runtimePart.file), "--gles", guest(glesPart.file))
var answer: JSONObject? = null
val code = GuestCommand.run(app, argv, fakeRoot = true, logName = "epic-client") { line ->
if (line.startsWith("{")) runCatching { JSONObject(line) }.getOrNull()?.let { answer = it }
@@ -298,6 +341,10 @@ internal class EpicClientInstaller(private val app: Context) : DownloadQueue.Dow
}
200 -> false
416 -> { partial.delete(); tag.delete(); throw IOException("HTTP 416") }
404, 410 -> {
if (part.mirror + 1 < part.urls.size) { part.mirror++; tag.delete() }
throw IOException("HTTP $code")
}
else -> throw IOException("HTTP $code")
}
val served = conn.getHeaderField("ETag")?.takeIf { it.isNotBlank() }
@@ -334,8 +381,8 @@ internal class EpicClientInstaller(private val app: Context) : DownloadQueue.Dow
part.sha256?.let { want ->
if (EpicClientSources.sha256(file) != want) { file.delete(); throw IOException("checksum mismatch") }
}
if (part.appImage) {
if (!EpicClientSources.isAppImage(file)) { file.delete(); throw IOException("not an AppImage") }
if (part.launcher) {
if (!EpicClientSources.isDeb(file)) { file.delete(); throw IOException("not a Debian package") }
if (EpicClientSources.etagMatches(file, etag) == false) {
val seen = EpicClientSources.sha256(file)
if (part.mismatch != seen) {
@@ -351,7 +398,7 @@ internal class EpicClientInstaller(private val app: Context) : DownloadQueue.Dow
const val PARTIAL = ".part"
const val TAG = ".etag"
const val ATTEMPTS = 6
const val APP_ROOM = 600L shl 20
const val APP_ROOM = 700L shl 20
const val RUNTIME_ROOM = 560L shl 20
}
}
@@ -225,8 +225,9 @@ class EpicClientTest {
}
@Test fun launcherVersionComesFromTheRedirect() {
val location = "https://content-download-egs.distro.on.epicgames.com/Builds/EGLv2/0.95.2%2Bgfa9ad49/Linux/EpicGamesLauncher-x86_64.AppImage?launcherfilename=EpicGamesLauncher-x86_64.AppImage"
assertEquals("0.95.2+gfa9ad49", EpicClientSources.launcherVersion(location))
val location = "https://content-download-egs.distro.on.epicgames.com/Builds/EGLv2/0.113.0%2Bg2164614/Linux/EpicGamesLauncher-x86_64.deb?launcherfilename=EpicGamesLauncher-x86_64.deb"
assertEquals("0.113.0+g2164614", EpicClientSources.launcherVersion(location))
assertTrue(EpicClientSources.LAUNCHER_URL.endsWith("/" + EpicClientSources.LAUNCHER_FILE))
assertNull(EpicClientSources.launcherVersion("http://content-download-egs.distro.on.epicgames.com/Builds/EGLv2/1.0/Linux/a"))
assertNull(EpicClientSources.launcherVersion("https://example.com/Builds/EGLv2/..%2F..%2Fetc/Linux/a"))
assertNull(EpicClientSources.launcherVersion("https://example.com/other/path"))
@@ -256,11 +257,33 @@ class EpicClientTest {
assertEquals(true, EpicClientSources.etagMatches(file, hex(md5(data))))
}
@Test fun appImageMagicIsRequired() {
val good = File(tmp.root, "a").apply { writeBytes(byteArrayOf(0x7f, 'E'.code.toByte(), 'L'.code.toByte(), 'F'.code.toByte(), 2, 1, 1, 0, 'A'.code.toByte(), 'I'.code.toByte(), 2, 0)) }
val bad = File(tmp.root, "b").apply { writeBytes(ByteArray(16)) }
assertTrue(EpicClientSources.isAppImage(good))
assertFalse(EpicClientSources.isAppImage(bad))
@Test fun debianPackageMagicIsRequired() {
val good = File(tmp.root, "a").apply { writeBytes("!<arch>\ndebian-binary/ 0 0 0 100644 4 `\n2.0\n".toByteArray()) }
val plainAr = File(tmp.root, "b").apply { writeBytes("!<arch>\ndata.tar.gz/".toByteArray()) }
val appImage = File(tmp.root, "c").apply { writeBytes(byteArrayOf(0x7f, 'E'.code.toByte(), 'L'.code.toByte(), 'F'.code.toByte(), 2, 1, 1, 0, 'A'.code.toByte(), 'I'.code.toByte(), 2, 0)) }
val short = File(tmp.root, "d").apply { writeBytes("!<arch>".toByteArray()) }
assertTrue(EpicClientSources.isDeb(good))
assertFalse(EpicClientSources.isDeb(plainAr))
assertFalse(EpicClientSources.isDeb(appImage))
assertFalse(EpicClientSources.isDeb(short))
assertFalse(EpicClientSources.isDeb(File(tmp.root, "missing")))
}
@Test fun desktopPackagesArePinnedWithAFallbackMirror() {
val packages = EpicClientSources.DESKTOP
assertTrue(packages.isNotEmpty())
assertEquals(packages.size, packages.map { it.file }.toSet().size)
assertTrue(packages.any { it.file.startsWith("libwebkit2gtk-4.1-0_") })
assertTrue(packages.any { it.file.startsWith("libjavascriptcoregtk-4.1-0_") })
assertTrue(packages.any { it.file.startsWith("libgtk-3-0t64_") })
packages.forEach { p ->
assertTrue(p.path, Regex("^pool/main/[a-z0-9]+/[^/]+/[^/]+_amd64\\.deb$").matches(p.path))
assertTrue(p.path, Regex("^[0-9a-f]{64}$").matches(p.sha256))
assertTrue(p.path, p.size > 0)
assertEquals(listOf(EpicClientSources.DEBIAN + p.path, EpicClientSources.SNAPSHOT + p.path), p.urls)
assertTrue(p.urls.all { it.startsWith("https://") && it.endsWith("/" + p.file) })
}
assertTrue(EpicClientSources.GLES_FILE !in packages.map { it.file })
}
@Test fun signInUrlsMustRedirectToLoopback() {
@@ -4,7 +4,6 @@ import collections
import fcntl
import filecmp
import http.client
import io
import json
import os
import re
@@ -72,6 +71,14 @@ APP_ID = "com.epicgames.eglv2"
DBUS_NAME = APP_ID + ".SingleInstance"
DBUS_PATH = "/" + APP_ID.replace(".", "/") + "/SingleInstance"
DBUS_METHOD = "org.SingleInstance.DBus.ExecuteCallback"
APP_BIN = "usr/bin/EpicGamesLauncher"
DEB_ICON = "usr/share/icons/hicolor/256x256@2/apps/EpicGamesLauncher.png"
ICON = "epic-games-launcher.png"
DESKTOP = "desktop"
DESKTOP_KEEP = ("usr/lib/x86_64-linux-gnu/", "usr/share/glib-2.0/schemas/")
DESKTOP_LIB = DESKTOP + "/usr/lib/x86_64-linux-gnu"
WEBKIT_DIR = "webkit2gtk-4.1"
WEBKIT_LIB = "libwebkit2gtk-4.1.so.0"
SKIPPED = ("lib/i386-linux-gnu", "lib32", "libx32", "i686-pc-linux-gnu", "share/doc", "include")
SETTINGS_SEED = {
"minimizeToTray": False,
@@ -254,6 +261,35 @@ def inside(root, path):
return real == root or real.startswith(root + os.sep)
def unpack_member(archive, member, staging, root, name, link):
target = os.path.join(staging, name)
if not inside(root, os.path.dirname(target)):
return False
if member.isdir():
os.makedirs(target, exist_ok=True)
return False
os.makedirs(os.path.dirname(target), exist_ok=True)
if not inside(root, os.path.dirname(target)):
return False
if member.issym():
remove(target)
os.symlink(link(target, member.linkname), target)
elif member.islnk():
source = safe_name(member.linkname)
source = os.path.join(staging, source) if source else None
if source and os.path.isfile(source) and inside(root, source):
remove(target)
shutil.copy2(source, target)
elif member.isfile():
remove(target)
with archive.extractfile(member) as src, open(target, "wb") as out:
shutil.copyfileobj(src, out, 1 << 20)
os.chmod(target, (member.mode & 0o777) | 0o600)
else:
return False
return True
def extract_runtime(tarball, dest):
staging = dest + ".staging"
remove(staging)
@@ -271,32 +307,12 @@ def extract_runtime(tarball, dest):
continue
if top == "files" and rest and skipped(rest):
continue
target = os.path.join(staging, name)
if not inside(root, os.path.dirname(target)):
continue
if member.isdir():
os.makedirs(target, exist_ok=True)
continue
os.makedirs(os.path.dirname(target), exist_ok=True)
if not inside(root, os.path.dirname(target)):
continue
if member.issym():
remove(target)
os.symlink(rooted_link(files_root, target, member.linkname) if top == "files" else member.linkname, target)
elif member.islnk():
source = safe_name(member.linkname)
source = os.path.join(staging, source) if source else None
if source and os.path.isfile(source) and inside(root, source):
remove(target)
shutil.copy2(source, target)
elif member.isfile():
remove(target)
with archive.extractfile(member) as src, open(target, "wb") as out:
shutil.copyfileobj(src, out, 1 << 20)
os.chmod(target, (member.mode & 0o777) | 0o600)
if top == "files":
link = lambda target, linkname: rooted_link(files_root, target, linkname)
else:
continue
count += 1
link = lambda target, linkname: linkname
if unpack_member(archive, member, staging, root, name, link):
count += 1
if not os.path.isfile(os.path.join(files_root, "lib", "x86_64-linux-gnu", "libc.so.6")) and \
not os.path.islink(os.path.join(files_root, "lib", "x86_64-linux-gnu", "libc.so.6")):
remove(staging)
@@ -306,63 +322,129 @@ def extract_runtime(tarball, dest):
return staging, count
def ar_members(path):
@contextlib.contextmanager
def deb_data(path, reason):
with open(path, "rb") as f:
if f.read(8) != b"!<arch>\n":
raise Failure("gles-format")
raise Failure(reason)
while True:
header = f.read(60)
if len(header) < 60:
return
raise Failure(reason)
name = header[:16].decode("ascii", "replace").strip().rstrip("/")
size = int(header[48:58].decode("ascii").strip())
data = f.read(size)
if size % 2:
f.read(1)
yield name, data
if name.startswith("data.tar"):
with tarfile.open(fileobj=f, mode="r|*") as archive:
yield archive
return
f.seek(size + size % 2, os.SEEK_CUR)
def is_deb(path):
try:
with open(path, "rb") as f:
return f.read(21) == b"!<arch>\ndebian-binary"
except OSError:
return False
def install_gles(deb, files_root):
libdir = os.path.join(files_root, "lib", "x86_64-linux-gnu")
os.makedirs(libdir, exist_ok=True)
for name, data in ar_members(deb):
if not name.startswith("data.tar"):
continue
with tarfile.open(fileobj=io.BytesIO(data), mode="r:*") as archive:
for member in archive:
base = os.path.basename(member.name)
if not base.startswith("libGLESv2.so"):
continue
target = os.path.join(libdir, base)
remove(target)
if member.issym():
os.symlink(os.path.basename(member.linkname), target)
elif member.isfile():
with archive.extractfile(member) as src, open(target, "wb") as out:
shutil.copyfileobj(src, out)
os.chmod(target, 0o644)
if os.path.exists(os.path.join(libdir, "libGLESv2.so.2")):
return
raise Failure("gles-missing")
with deb_data(deb, "gles-format") as archive:
for member in archive:
base = os.path.basename(member.name)
if not base.startswith("libGLESv2.so"):
continue
target = os.path.join(libdir, base)
remove(target)
if member.issym():
os.symlink(os.path.basename(member.linkname), target)
elif member.isfile():
with archive.extractfile(member) as src, open(target, "wb") as out:
shutil.copyfileobj(src, out)
os.chmod(target, 0o644)
if not os.path.exists(os.path.join(libdir, "libGLESv2.so.2")):
raise Failure("gles-missing")
def extract_app(image, dest):
def extract_deb(deb, dest, wanted=None):
root = os.path.realpath(dest)
def link(target, linkname):
if not linkname.startswith("/"):
return linkname
return os.path.relpath(os.path.join(dest, linkname.lstrip("/")), os.path.dirname(target))
count = 0
with deb_data(deb, "app-format") as archive:
for member in archive:
name = safe_name(member.name)
if name is None or (wanted is not None and not wanted(name)):
continue
if unpack_member(archive, member, dest, root, name, link):
count += 1
return count
def extract_app(image, dest, desktop=()):
staging = dest + ".staging"
remove(staging)
os.makedirs(staging)
status = subprocess.call([os.path.join(BIN_DIR, "droiddeck-fex"), "extract", os.path.abspath(image)],
cwd=staging, stdout=subprocess.DEVNULL)
root = os.path.realpath(os.path.join(staging, "squashfs-root"))
if status != 0 or not app_complete(root):
try:
if not is_deb(image):
raise Failure("app-format")
extract_deb(image, staging)
layer = os.path.join(staging, DESKTOP)
if not inside(os.path.realpath(staging), layer):
raise Failure("app-extract")
os.makedirs(layer, exist_ok=True)
for package in desktop:
if not is_deb(package):
raise Failure("desktop-format")
extract_deb(package, layer, lambda name: any(name.startswith(prefix) for prefix in DESKTOP_KEEP))
icon = os.path.join(staging, DEB_ICON)
if os.path.isfile(icon):
remove(os.path.join(staging, ICON))
shutil.copyfile(icon, os.path.join(staging, ICON))
if not app_complete(staging):
raise Failure("app-extract")
except Exception:
remove(staging)
raise Failure("app-extract")
raise
remove(dest)
os.rename(root, dest)
remove(staging)
os.rename(staging, dest)
def app_complete(root):
return os.path.isfile(os.path.join(root, "AppRun")) and os.path.isfile(os.path.join(root, "usr", "bin", "EpicGamesLauncher"))
if not os.path.isfile(os.path.join(root, APP_BIN)):
return False
return os.path.isfile(os.path.join(root, "AppRun")) or os.path.isfile(os.path.join(root, DESKTOP_LIB, WEBKIT_LIB))
def app_command(app_dir):
apprun = os.path.join(app_dir, "AppRun")
return apprun if os.path.isfile(apprun) else os.path.join(app_dir, APP_BIN)
def desktop_libs(app_dir):
path = os.path.join(app_dir, DESKTOP_LIB)
return path if os.path.isdir(path) else None
def link_webkit(files, libs):
target = os.path.join(files, "lib", "x86_64-linux-gnu", WEBKIT_DIR)
if os.path.isdir(target) and not os.path.islink(target):
return
source = os.path.join(libs, WEBKIT_DIR) if libs else None
if source is None or not os.path.isdir(source):
remove(target)
return
link = os.path.relpath(source, os.path.dirname(target))
if os.path.islink(target) and os.readlink(target) == link:
return
remove(target)
os.symlink(link, target)
def ready(path):
@@ -396,8 +478,11 @@ def install(options):
image = options.get("app")
if not image or not os.path.isfile(image):
raise Failure("no-app-image")
say("unpacking the Epic Games Launcher %s" % app)
extract_app(image, app_dir)
desktop = options.get("desktop") or []
if not all(os.path.isfile(package) for package in desktop):
raise Failure("no-desktop-package")
say("unpacking the Epic Games Launcher %s (%d desktop packages)" % (app, len(desktop)))
extract_app(image, app_dir, desktop)
mark_ready(app_dir)
if not ready(runtime_dir):
tarball, deb = options.get("runtime"), options.get("gles")
@@ -729,11 +814,16 @@ def fex_environment(fex, files, env):
return result
def client_environment(base, fex, files, display, bus, broker, a11y=None, hidden=False):
def client_environment(base, fex, files, display, bus, broker, a11y=None, hidden=False, libs=None):
env = {name: base[name] for name in KEPT_ENV if base.get(name)}
env.setdefault("HOME", HOME)
env.setdefault("LANG", "C.UTF-8")
env["PATH"] = SHIMS + ":/usr/bin:/bin"
if libs:
env["LD_LIBRARY_PATH"] = libs
data = os.path.normpath(os.path.join(os.path.dirname(libs), "..", "share"))
env["XDG_DATA_DIRS"] = data + ":/usr/local/share:/usr/share"
env["GSETTINGS_SCHEMA_DIR"] = os.path.join(data, "glib-2.0", "schemas")
env["DISPLAY"] = display
env["DBUS_SESSION_BUS_ADDRESS"] = bus
env[BROKER_ENV] = broker
@@ -1238,6 +1328,8 @@ class Session:
seed_settings()
install_shims()
install_preload(files)
libs = desktop_libs(app_dir)
link_webkit(files, libs)
fex_module()["install_fonts"](files)
clear_playing()
sync_installations()
@@ -1254,8 +1346,8 @@ class Session:
path = broker_path()
self.broker = Broker(path, self.mode, base)
write_json(instance_file(), {"pid": os.getpid(), "mode": self.mode, "bus": bus, "broker": path})
env = client_environment(base, fex, files, display, bus, path, self.a11y, hidden=self.mode == "hidden")
self.command = [fex["bin"], os.path.join(app_dir, "AppRun")]
env = client_environment(base, fex, files, display, bus, path, self.a11y, hidden=self.mode == "hidden", libs=libs)
self.command = [fex["bin"], app_command(app_dir)]
self.env = env
say("starting the Epic Games Launcher %s (%s, display %s)" % (current.get("app"), self.mode, display))
self.start_client()
@@ -1471,12 +1563,14 @@ def forward(bus, url):
return False
def parse_options(args, flags=()):
def parse_options(args, flags=(), lists=()):
options, rest = {}, []
while args:
arg = args.pop(0)
if arg.startswith("--") and arg[2:] in flags:
options[arg[2:]] = True
elif arg.startswith("--") and arg[2:] in lists and args:
options.setdefault(arg[2:], []).append(args.pop(0))
elif arg.startswith("--") and args:
options[arg[2:]] = args.pop(0)
else:
@@ -1830,7 +1924,7 @@ def main(argv):
if action == "xdg-open":
return shim_open(args)
if action == "install":
options, _ = parse_options(args)
options, _ = parse_options(args, lists=("desktop",))
try:
return install(options)
except (ValueError, tarfile.TarError, OSError) as error:
+156 -5
View File
@@ -175,17 +175,27 @@ class RuntimeExtractTest(EpicTestCase):
old = self.state / "app/0.1"
old.mkdir(parents=True)
def extract_app(image, dest):
os.makedirs(os.path.join(dest, "usr/bin"))
Path(dest, "AppRun").write_text("run")
Path(dest, "usr/bin/EpicGamesLauncher").write_text("bin")
layers = []
def extract_app(image, dest, desktop=()):
layers.append(list(desktop))
os.makedirs(os.path.join(dest, "usr/bin"))
os.makedirs(os.path.join(dest, "desktop/usr/lib/x86_64-linux-gnu"))
Path(dest, "usr/bin/EpicGamesLauncher").write_text("bin")
Path(dest, "desktop/usr/lib/x86_64-linux-gnu/libwebkit2gtk-4.1.so.0").write_text("webkit")
package = self.tmp / "libwebkit.deb"
package.write_bytes(b"x")
with mock.patch.dict(G, {"extract_app": extract_app, "fex_tool": lambda request=False: {"bin": "/fex", "server": "/s"}}), \
mock.patch("sys.stdout", new_callable=io.StringIO) as out:
image = self.tmp / "image"
image.write_bytes(b"x")
with self.assertRaises(G["Failure"]):
G["install"]({"app": str(image), "app-version": "0.95.2+g1", "runtime": str(tarball),
"runtime-version": "4.0.1", "gles": str(deb), "desktop": [str(self.tmp / "missing.deb")]})
code = G["install"]({"app": str(image), "app-version": "0.95.2+g1", "runtime": str(tarball),
"runtime-version": "4.0.1", "gles": str(deb)})
"runtime-version": "4.0.1", "gles": str(deb), "desktop": [str(package)]})
self.assertEqual([[str(package)]], layers)
self.assertEqual(0, code)
report = json.loads(out.getvalue())
self.assertTrue(report["installed"])
@@ -197,6 +207,147 @@ class RuntimeExtractTest(EpicTestCase):
self.assertTrue((self.state / "app/0.95.2+g1/.droiddeck-ready").is_file())
def deb(path, entries, compression="gz"):
data = io.BytesIO()
with tarfile.open(fileobj=data, mode="w:" + compression) as archive:
for entry in entries:
tar_add(archive, *entry[:1], **entry[1])
path.write_bytes(ar([("debian-binary", b"2.0\n"), ("control.tar.xz", b"c"), ("data.tar." + compression, data.getvalue())]))
return path
class LauncherDebTest(EpicTestCase):
def launcher(self, extra=()):
return deb(self.tmp / "EpicGamesLauncher-x86_64.deb", [
("./usr", {"kind": "dir"}),
("./usr/bin/EpicGamesLauncher", {"data": b"egl", "mode": 0o755}),
("./usr/lib/epic-games-launcher/libEOSSDK-Linux-Shipping.so", {"data": b"eos"}),
("./usr/share/icons/hicolor/256x256@2/apps/EpicGamesLauncher.png", {"data": b"png"}),
("./usr/share/applications/epic-games-launcher.desktop", {"data": b"[Desktop Entry]\n"}),
("./usr/bin/egl", {"link": "/usr/bin/EpicGamesLauncher"}),
("../escape", {"data": b"x"}),
*extra,
])
def webkit(self):
return deb(self.tmp / "libwebkit2gtk-4.1-0_amd64.deb", [
("./usr/lib/x86_64-linux-gnu/libwebkit2gtk-4.1.so.0.19.1", {"data": b"webkit"}),
("./usr/lib/x86_64-linux-gnu/libwebkit2gtk-4.1.so.0", {"link": "libwebkit2gtk-4.1.so.0.19.1"}),
("./usr/lib/x86_64-linux-gnu/webkit2gtk-4.1/WebKitNetworkProcess", {"data": b"net", "mode": 0o755}),
("./usr/lib/x86_64-linux-gnu/webkit2gtk-4.1/injected-bundle/libwebkit2gtkinjectedbundle.so", {"data": b"bundle"}),
("./usr/share/glib-2.0/schemas/org.gnome.GWeather4.gschema.xml", {"data": b"schema"}),
("./usr/share/doc/libwebkit2gtk-4.1-0/copyright", {"data": b"c"}),
("./usr/share/locale/fr/LC_MESSAGES/WebKitGTK-4.1.mo", {"data": b"fr"}),
], "xz")
def test_the_launcher_and_its_desktop_layer_come_out_of_debs(self):
dest = self.state / "app/0.113.0+g1"
G["extract_app"](str(self.launcher()), str(dest), [str(self.webkit())])
self.assertEqual(b"egl", (dest / "usr/bin/EpicGamesLauncher").read_bytes())
self.assertTrue(os.access(dest / "usr/bin/EpicGamesLauncher", os.X_OK))
self.assertEqual(b"eos", (dest / "usr/lib/epic-games-launcher/libEOSSDK-Linux-Shipping.so").read_bytes())
self.assertEqual("EpicGamesLauncher", os.readlink(dest / "usr/bin/egl"))
self.assertEqual(b"png", (dest / "epic-games-launcher.png").read_bytes())
libs = dest / "desktop/usr/lib/x86_64-linux-gnu"
self.assertEqual(b"webkit", (libs / "libwebkit2gtk-4.1.so.0").read_bytes())
self.assertEqual(b"net", (libs / "webkit2gtk-4.1/WebKitNetworkProcess").read_bytes())
self.assertEqual(b"schema", (dest / "desktop/usr/share/glib-2.0/schemas/org.gnome.GWeather4.gschema.xml").read_bytes())
self.assertFalse((dest / "desktop/usr/share/doc").exists())
self.assertFalse((self.state / "app/escape").exists())
self.assertFalse((self.state / "app/0.113.0+g1.staging").exists())
self.assertTrue(G["app_complete"](str(dest)))
self.assertEqual(str(dest / "usr/bin/EpicGamesLauncher"), G["app_command"](str(dest)))
self.assertEqual(str(libs), G["desktop_libs"](str(dest)))
def test_archive_symlinks_cannot_redirect_the_desktop_layer_or_icon(self):
outside = self.tmp / "outside"
outside.mkdir()
dest = self.state / "app/0.113.0+g1"
escape = os.path.relpath(outside, Path(str(dest) + ".staging"))
launcher = self.launcher([("./desktop", {"link": escape}),
("./epic-games-launcher.png", {"link": escape + "/target"})])
with self.assertRaises(G["Failure"]) as caught:
G["extract_app"](str(launcher), str(dest), [str(self.webkit())])
self.assertEqual("app-extract", str(caught.exception))
self.assertFalse((outside / "usr").exists())
self.assertFalse((outside / "target").exists())
icon_dest = self.state / "app/0.113.0+g2"
icon_escape = os.path.relpath(outside / "target", Path(str(icon_dest) + ".staging"))
G["extract_app"](str(self.launcher([("./epic-games-launcher.png", {"link": icon_escape})])),
str(icon_dest), [str(self.webkit())])
self.assertEqual(b"png", (icon_dest / "epic-games-launcher.png").read_bytes())
self.assertFalse((outside / "target").exists())
def test_a_launcher_without_its_desktop_layer_is_refused(self):
dest = self.state / "app/0.113.0+g1"
with self.assertRaises(G["Failure"]) as caught:
G["extract_app"](str(self.launcher()), str(dest))
self.assertEqual("app-extract", str(caught.exception))
self.assertFalse(dest.exists())
self.assertFalse(Path(str(dest) + ".staging").exists())
def test_anything_but_a_deb_is_refused_and_leaves_nothing_behind(self):
image = self.tmp / "EpicGamesLauncher-x86_64.AppImage"
image.write_bytes(b"\x7fELF\x02\x01\x01\x00AI\x02" + bytes(64))
dest = self.state / "app/0.95.2+g1"
with self.assertRaises(G["Failure"]) as caught:
G["extract_app"](str(image), str(dest), [str(self.webkit())])
self.assertEqual("app-format", str(caught.exception))
plain = self.tmp / "plain.deb"
plain.write_bytes(ar([("data.tar.gz", b"x")]))
with self.assertRaises(G["Failure"]) as caught:
G["extract_app"](str(self.launcher()), str(dest), [str(plain)])
self.assertEqual("desktop-format", str(caught.exception))
self.assertFalse(dest.exists())
self.assertFalse(Path(str(dest) + ".staging").exists())
def test_an_installed_appimage_launcher_still_runs_through_apprun(self):
app = self.state / "app/0.95.2+g1"
(app / "usr/bin").mkdir(parents=True)
(app / "AppRun").write_text("run")
(app / "usr/bin/EpicGamesLauncher").write_text("bin")
self.assertTrue(G["app_complete"](str(app)))
self.assertEqual(str(app / "AppRun"), G["app_command"](str(app)))
self.assertIsNone(G["desktop_libs"](str(app)))
(app / "usr/bin/EpicGamesLauncher").unlink()
self.assertFalse(G["app_complete"](str(app)))
def test_the_webkit_helpers_are_linked_into_the_runtime(self):
dest = self.state / "app/0.113.0+g1"
G["extract_app"](str(self.launcher()), str(dest), [str(self.webkit())])
files = self.state / "runtime/4.0.1/files"
(files / "lib/x86_64-linux-gnu").mkdir(parents=True)
link = files / "lib/x86_64-linux-gnu/webkit2gtk-4.1"
G["link_webkit"](str(files), G["desktop_libs"](str(dest)))
self.assertFalse(os.path.isabs(os.readlink(link)))
self.assertEqual(b"net", (link / "WebKitNetworkProcess").read_bytes())
G["link_webkit"](str(files), G["desktop_libs"](str(dest)))
self.assertEqual(b"net", (link / "WebKitNetworkProcess").read_bytes())
G["link_webkit"](str(files), None)
self.assertFalse(os.path.lexists(link))
link.mkdir()
(link / "own").write_text("x")
G["link_webkit"](str(files), G["desktop_libs"](str(dest)))
self.assertTrue((link / "own").is_file())
self.assertTrue((dest / "desktop/usr/lib/x86_64-linux-gnu/webkit2gtk-4.1/WebKitNetworkProcess").is_file())
def test_only_the_deb_launcher_gets_the_desktop_libraries(self):
with mock.patch.dict(G, {"fex_environment": lambda fex, files, base: {}}):
plain = G["client_environment"]({"LD_LIBRARY_PATH": "/host"}, None, None, ":0", "bus", "broker")
layered = G["client_environment"]({}, None, None, ":0", "bus", "broker", libs="/app/desktop/usr/lib/x86_64-linux-gnu")
self.assertNotIn("LD_LIBRARY_PATH", plain)
self.assertEqual("/app/desktop/usr/lib/x86_64-linux-gnu", layered["LD_LIBRARY_PATH"])
self.assertEqual("/app/desktop/usr/share:/usr/local/share:/usr/share", layered["XDG_DATA_DIRS"])
self.assertEqual("/app/desktop/usr/share/glib-2.0/schemas", layered["GSETTINGS_SCHEMA_DIR"])
def test_every_desktop_package_reaches_the_install(self):
options, rest = G["parse_options"](["--app", "a.deb", "--desktop", "one.deb", "--desktop", "two.deb", "x"], lists=("desktop",))
self.assertEqual({"app": "a.deb", "desktop": ["one.deb", "two.deb"]}, options)
self.assertEqual(["x"], rest)
self.assertEqual({"desktop": "two.deb"}, G["parse_options"](["--desktop", "one.deb", "--desktop", "two.deb"])[0])
class ArgumentsTest(EpicTestCase):
def test_client_arguments_win_and_paths_become_windows_paths(self):
ovt = self.tmp / "ovt"