From 3167d8aa15cc5c7b7064a61eccb0e28336808241 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Sun, 6 Apr 2025 21:09:56 +0200 Subject: [PATCH] Fix/startup jvm error after installation update via msi (#1229) * Remove existing installations with msi installer * Remove unused x86 wxs file * Uninstall old msi versions with different upgrade code * Progress but error 2721 happens on install * Remove added uninstall previous version wxs stuff * Use revision as patch number MSI only uninstalls previous versions in case the version number changed (it only checks the first three numbers (major, minor, patch)). Thus, to prevent each preview install to result in it getting registered as a new "app" and for it to uninstall the old versions, we have to change the version on each release. * Deprecate "BuildConfig.REVISION" * Remove outdated env vars --------- Co-authored-by: Syer10 --- buildSrc/src/main/kotlin/Constants.kt | 16 ++--- scripts/bundler.sh | 18 +++--- scripts/resources/msi/suwayomi-server-x64.wxs | 8 ++- scripts/resources/msi/suwayomi-server-x86.wxs | 60 ------------------- server/build.gradle.kts | 8 +-- .../kotlin/eu/kanade/tachiyomi/AppInfo.kt | 7 ++- .../suwayomi/tachidesk/global/impl/About.kt | 1 + .../tachidesk/graphql/queries/InfoQuery.kt | 2 + .../mangaupdates/MangaUpdatesInterceptor.kt | 2 +- .../suwayomi/tachidesk/server/ServerSetup.kt | 2 +- .../server/util/WebInterfaceManager.kt | 8 ++- 11 files changed, 46 insertions(+), 86 deletions(-) delete mode 100644 scripts/resources/msi/suwayomi-server-x86.wxs diff --git a/buildSrc/src/main/kotlin/Constants.kt b/buildSrc/src/main/kotlin/Constants.kt index 125a1422..236616a0 100644 --- a/buildSrc/src/main/kotlin/Constants.kt +++ b/buildSrc/src/main/kotlin/Constants.kt @@ -10,14 +10,13 @@ import java.io.BufferedReader const val MainClass = "suwayomi.tachidesk.MainKt" // should be bumped with each stable release -val tachideskVersion = System.getenv("ProductVersion") ?: "v1.1.1" +val getTachideskVersion = { "v1.1.${getCommitCount()}" } -val webUIRevisionTag = System.getenv("WebUIRevision") ?: "r1689" +val webUIRevisionTag = "r1689" -// counts commits on the current checked out branch -val getTachideskRevision = { +private val getCommitCount = { runCatching { - System.getenv("ProductRevision") ?: ProcessBuilder() + ProcessBuilder() .command("git", "rev-list", "HEAD", "--count") .start() .let { process -> @@ -26,8 +25,11 @@ val getTachideskRevision = { it.bufferedReader().use(BufferedReader::readText) } process.destroy() - "r" + output.trim() + output.trim() } - }.getOrDefault("r0") + }.getOrDefault("0") } +// counts commits on the current checked out branch +val getTachideskRevision = { "r${getCommitCount()}" } + diff --git a/scripts/bundler.sh b/scripts/bundler.sh index 4e4047df..4f452796 100755 --- a/scripts/bundler.sh +++ b/scripts/bundler.sh @@ -151,16 +151,16 @@ setup_jre() { mv "jre" "$RELEASE_NAME/jre" else if [ ! -f "$JRE" ]; then - curl -L "$JRE_URL" -o "$JRE" - fi + curl -L "$JRE_URL" -o "$JRE" + fi - local ext="${JRE##*.}" - if [ "$ext" = "zip" ]; then - unzip "$JRE" - else - tar xvf "$JRE" - fi - mv "$JRE_DIR" "$RELEASE_NAME/jre" + local ext="${JRE##*.}" + if [ "$ext" = "zip" ]; then + unzip "$JRE" + else + tar xvf "$JRE" + fi + mv "$JRE_DIR" "$RELEASE_NAME/jre" fi } diff --git a/scripts/resources/msi/suwayomi-server-x64.wxs b/scripts/resources/msi/suwayomi-server-x64.wxs index dcfd3e0e..3fe4f788 100644 --- a/scripts/resources/msi/suwayomi-server-x64.wxs +++ b/scripts/resources/msi/suwayomi-server-x64.wxs @@ -1,6 +1,6 @@  - @@ -9,6 +9,8 @@ VersionNT64 + + @@ -48,6 +50,10 @@ + + + + diff --git a/scripts/resources/msi/suwayomi-server-x86.wxs b/scripts/resources/msi/suwayomi-server-x86.wxs deleted file mode 100644 index b5ea57ab..00000000 --- a/scripts/resources/msi/suwayomi-server-x86.wxs +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/server/build.gradle.kts b/server/build.gradle.kts index 10f968d9..fb734e0d 100644 --- a/server/build.gradle.kts +++ b/server/build.gradle.kts @@ -121,7 +121,7 @@ buildConfig { fun quoteWrap(obj: Any): String = """"$obj"""" buildConfigField("String", "NAME", quoteWrap(rootProject.name)) - buildConfigField("String", "VERSION", quoteWrap(tachideskVersion)) + buildConfigField("String", "VERSION", quoteWrap(getTachideskVersion())) buildConfigField("String", "REVISION", quoteWrap(getTachideskRevision())) buildConfigField("String", "BUILD_TYPE", quoteWrap(if (System.getenv("ProductBuildType") == "Stable") "Stable" else "Preview")) buildConfigField("long", "BUILD_TIME", Instant.now().epochSecond.toString()) @@ -140,13 +140,13 @@ tasks { "Main-Class" to MainClass, "Implementation-Title" to rootProject.name, "Implementation-Vendor" to "The Suwayomi Project", - "Specification-Version" to tachideskVersion, + "Specification-Version" to getTachideskVersion(), "Implementation-Version" to getTachideskRevision(), ) } archiveBaseName.set(rootProject.name) - archiveVersion.set(tachideskVersion) - archiveClassifier.set(getTachideskRevision()) + archiveVersion.set(getTachideskVersion()) + archiveClassifier.set("") destinationDirectory.set(File("$rootDir/server/build")) mergeServiceFiles() } diff --git a/server/src/main/kotlin/eu/kanade/tachiyomi/AppInfo.kt b/server/src/main/kotlin/eu/kanade/tachiyomi/AppInfo.kt index 50368787..2d1d49a0 100644 --- a/server/src/main/kotlin/eu/kanade/tachiyomi/AppInfo.kt +++ b/server/src/main/kotlin/eu/kanade/tachiyomi/AppInfo.kt @@ -15,7 +15,12 @@ object AppInfo { * * @since extension-lib 1.3 */ - fun getVersionCode() = BuildConfig.REVISION.substring(1).toInt() + fun getVersionCode() = + BuildConfig.VERSION + .replace("v", "") + .split('.') + .joinToString("") + .toInt() /** * should be something like "0.13.1" diff --git a/server/src/main/kotlin/suwayomi/tachidesk/global/impl/About.kt b/server/src/main/kotlin/suwayomi/tachidesk/global/impl/About.kt index e0b5b1bc..b8b651aa 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/global/impl/About.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/global/impl/About.kt @@ -12,6 +12,7 @@ import suwayomi.tachidesk.server.generated.BuildConfig data class AboutDataClass( val name: String, val version: String, + @Deprecated("The version includes the revision as the patch number") val revision: String, val buildType: String, val buildTime: Long, diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/InfoQuery.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/InfoQuery.kt index 9aa68d07..ed584323 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/InfoQuery.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/InfoQuery.kt @@ -1,5 +1,6 @@ package suwayomi.tachidesk.graphql.queries +import com.expediagroup.graphql.generator.annotations.GraphQLDeprecated import suwayomi.tachidesk.global.impl.AppUpdate import suwayomi.tachidesk.graphql.types.AboutWebUI import suwayomi.tachidesk.graphql.types.WebUIUpdateCheck @@ -15,6 +16,7 @@ class InfoQuery { data class AboutServerPayload( val name: String, val version: String, + @GraphQLDeprecated("The version includes the revision as the patch number") val revision: String, val buildType: String, val buildTime: Long, diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/track/tracker/mangaupdates/MangaUpdatesInterceptor.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/track/tracker/mangaupdates/MangaUpdatesInterceptor.kt index ba9f5e20..d4ea5c29 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/track/tracker/mangaupdates/MangaUpdatesInterceptor.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/track/tracker/mangaupdates/MangaUpdatesInterceptor.kt @@ -20,7 +20,7 @@ class MangaUpdatesInterceptor( originalRequest .newBuilder() .addHeader("Authorization", "Bearer $token") - .header("User-Agent", "Suwayomi ${BuildConfig.VERSION} (${BuildConfig.REVISION})") + .header("User-Agent", "Suwayomi ${BuildConfig.VERSION}") .build() return chain.proceed(authRequest) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/server/ServerSetup.kt b/server/src/main/kotlin/suwayomi/tachidesk/server/ServerSetup.kt index eb739806..e7fc56f7 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/server/ServerSetup.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/server/ServerSetup.kt @@ -137,7 +137,7 @@ fun applicationSetup() { setupLogLevelUpdating(serverConfig.debugLogsEnabled, listOf(BASE_LOGGER_NAME)) - logger.info { "Running Suwayomi-Server ${BuildConfig.VERSION} revision ${BuildConfig.REVISION}" } + logger.info { "Running Suwayomi-Server ${BuildConfig.VERSION}" } logger.debug { "Loaded config:\n" + diff --git a/server/src/main/kotlin/suwayomi/tachidesk/server/util/WebInterfaceManager.kt b/server/src/main/kotlin/suwayomi/tachidesk/server/util/WebInterfaceManager.kt index 75282fff..311583ec 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/server/util/WebInterfaceManager.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/server/util/WebInterfaceManager.kt @@ -591,14 +591,18 @@ object WebInterfaceManager { return BuildConfig.WEBUI_TAG } - val currentServerVersionNumber = extractVersion(BuildConfig.REVISION) + val currentServerVersionNumber = + BuildConfig.VERSION + .split(".") + .last() + .toInt() val webUIToServerVersionMappings = fetchServerMappingFile(flavor) logger.debug { "getLatestCompatibleVersion: " + "flavor= ${flavor.uiName}, " + "webUIChannel= ${serverConfig.webUIChannel.value}, " + - "currentServerVersion= ${BuildConfig.REVISION}, " + + "currentServerVersion= ${BuildConfig.VERSION}, " + "mappingFile= $webUIToServerVersionMappings" }