From e98b076734b861db17daf3fae26fa0f5d1650f96 Mon Sep 17 00:00:00 2001 From: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com> Date: Wed, 11 Nov 2026 20:23:02 +0000 Subject: [PATCH] fix(gog): keep innoextract output in the log and leave the install failure message unchanged --- .../stores/gog/GogDownloadManager.java | 6 +-- .../launcher/stores/gog/GogInnoextract.kt | 33 ++------------- .../launcher/stores/gog/GogOffline.kt | 4 +- .../launcher/stores/gog/GogInnoextractTest.kt | 41 ------------------- 4 files changed, 8 insertions(+), 76 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/stores/gog/GogDownloadManager.java b/app/src/main/java/com/droiddeck/launcher/stores/gog/GogDownloadManager.java index 54e4a0ff55..5ec4d811ff 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/gog/GogDownloadManager.java +++ b/app/src/main/java/com/droiddeck/launcher/stores/gog/GogDownloadManager.java @@ -323,15 +323,15 @@ public final class GogDownloadManager { } String guestSetup = guestDir + "/" + setupName; cb.onProgress("Extracting installer…", 95); - GogInnoextract.Result result; + int rc; try { - result = GogInnoextract.extract(ctx, guestSetup, guestDir, "gog-innoextract", cancelled, + rc = GogInnoextract.extract(ctx, guestSetup, guestDir, "gog-innoextract", cancelled, line -> { cb.onLog("gog innoextract: " + line); return kotlin.Unit.INSTANCE; }); } catch (Exception e) { throw new InstallException("The installer could not be extracted: " + e.getClass().getSimpleName()); } if (cancelled.get()) return; - if (result.getExit() != 0) throw new InstallException(result.failure("The installer could not be extracted (innoextract exit " + result.getExit() + ")")); + if (rc != 0) throw new InstallException("The installer could not be extracted (innoextract exit " + rc + ")"); } static long installerBytesNeeded(long downloadBytes, long installedBytes) { diff --git a/app/src/main/java/com/droiddeck/launcher/stores/gog/GogInnoextract.kt b/app/src/main/java/com/droiddeck/launcher/stores/gog/GogInnoextract.kt index c9f1999a28..3f3f507ff8 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/gog/GogInnoextract.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/gog/GogInnoextract.kt @@ -7,38 +7,11 @@ import java.util.concurrent.atomic.AtomicBoolean internal object GogInnoextract { private const val PROGRAM = "/usr/local/bin/droiddeck-innoextract" - private const val REASON_LINES = 3 - private const val REASON_CHARS = 400 - private val TREE = Regex("""^[\s├└│─]+""") - private val BOILERPLATE = Regex( - """^(\S+ )?warning:|^If you are sure the setup file is not corrupted|^filing a bug report at |^Done with \d+ (errors?|warnings?)""", - RegexOption.IGNORE_CASE, - ) - - class Result(val exit: Int, val reason: String) { - fun failure(message: String): String = if (reason.isEmpty()) message else "$message: $reason" - } @JvmStatic - fun extract(context: Context, setup: String, target: String, logName: String, cancelled: AtomicBoolean, onLine: (String) -> Unit): Result { - val details = ArrayDeque() - val exit = GuestCommand.run(context, argv(setup, target), logName = logName, - extraBinds = StoreInstallRoot.guestBinds(context), cancelled = cancelled) { line -> - onLine(line) - val kept = detail(line) - if (kept != null) { - details.addLast(kept) - if (details.size > REASON_LINES) details.removeFirst() - } - } - return Result(exit, if (exit == 0) "" else reason(details)) - } + fun extract(context: Context, setup: String, target: String, logName: String, cancelled: AtomicBoolean, onLine: (String) -> Unit): Int = + GuestCommand.run(context, argv(setup, target), logName = logName, + extraBinds = StoreInstallRoot.guestBinds(context), cancelled = cancelled, onLine = onLine) internal fun argv(setup: String, target: String): List = listOf(PROGRAM, "--gog", "--silent", "-d", target, setup) - - internal fun reason(lines: Iterable): String = - lines.mapNotNull(::detail).takeLast(REASON_LINES).joinToString(" ").take(REASON_CHARS) - - private fun detail(raw: String): String? = - raw.replace(TREE, "").trim().takeUnless { it.isEmpty() || BOILERPLATE.containsMatchIn(it) } } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/gog/GogOffline.kt b/app/src/main/java/com/droiddeck/launcher/stores/gog/GogOffline.kt index e7d5510bdd..fafd185e5f 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/gog/GogOffline.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/gog/GogOffline.kt @@ -69,9 +69,9 @@ internal object GogOffline { val source = AddedGames.guestPath(context, installer) ?: error("The GOG installer is not visible to Linux") val target = AddedGames.guestPath(context, extracted) ?: error("The GOG staging folder is not visible to Linux") handle.stage(DownloadStage.INSTALL, "Extracting the full offline installer") - val result = GogInnoextract.extract(context, source, target, "gog-refresh", stop, handle::log) + val rc = GogInnoextract.extract(context, source, target, "gog-refresh", stop, handle::log) if (stop.get()) return - check(result.exit == 0) { result.failure("GOG installer extraction failed (exit ${result.exit})") } + check(rc == 0) { "GOG installer extraction failed (exit $rc)" } applyRefresh(proposal, extracted, handle, stop) } diff --git a/app/src/test/java/com/droiddeck/launcher/stores/gog/GogInnoextractTest.kt b/app/src/test/java/com/droiddeck/launcher/stores/gog/GogInnoextractTest.kt index 127d6eb5a4..f1c333eb85 100644 --- a/app/src/test/java/com/droiddeck/launcher/stores/gog/GogInnoextractTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/stores/gog/GogInnoextractTest.kt @@ -90,45 +90,4 @@ class GogInnoextractTest { assertTrue(internalGuest.startsWith(StoreInstallRoot.INTERNAL_GUEST + "/GOG/")) assertNull(hostOf("$internalGuest/setup_1207658935.exe", StoreInstallRoot.guestBinds(app))) } - - @Test fun aFailedExtractionReportsTheExtractorsOwnError() { - val result = GogInnoextract.Result(2, GogInnoextract.reason(listOf( - "Warning: Unexpected setup data version: Inno Setup Setup Data (6.4.0)", - "Stream error while parsing setup headers!", - " ├─ detected setup version: 6.4.0", - " └─ error reason: iostream error", - "", - ))) - assertEquals( - "The installer could not be extracted (innoextract exit 2): Stream error while parsing setup headers! detected setup version: 6.4.0 error reason: iostream error", - result.failure("The installer could not be extracted (innoextract exit 2)"), - ) - } - - @Test fun aStreamErrorDuringExtractionReportsItsReasonWithoutTheExtractorsBoilerplate() { - val result = GogInnoextract.Result(2, GogInnoextract.reason(listOf( - "proot warning: can't sanitize binding \"/proc/self/fd/0\": No such file or directory", - "proot warning: can't sanitize binding \"/proc/self/fd/1\": No such file or directory", - "Stream error while extracting files!", - " └─ error reason: zlib error: iostream error", - "If you are sure the setup file is not corrupted, consider ", - "filing a bug report at https://innoextract.constexpr.org/issues", - "Done with 1 error.", - ))) - assertEquals( - "The installer could not be extracted (innoextract exit 2): Stream error while extracting files! error reason: zlib error: iostream error", - result.failure("The installer could not be extracted (innoextract exit 2)"), - ) - } - - @Test fun theReasonKeepsTheLastErrorLinesAndStaysShort() { - val lines = (1..10).map { "Could not open file \"/mnt/droiddeck-stores/card/setup_$it.exe\"" } - assertEquals(lines.takeLast(3).joinToString(" "), GogInnoextract.reason(lines)) - assertEquals(400, GogInnoextract.reason(listOf("x".repeat(1000))).length) - } - - @Test fun anExtractionWithoutOutputKeepsTheExitMessage() { - val result = GogInnoextract.Result(2, GogInnoextract.reason(listOf("", "Warning: Unexpected setup data version"))) - assertEquals("GOG installer extraction failed (exit 2)", result.failure("GOG installer extraction failed (exit 2)")) - } }