mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-16 02:12:58 +08:00
chore: detection installation type
This commit is contained in:
@@ -449,6 +449,9 @@ tasks.register<Exec>("jpackage") {
|
|||||||
|
|
||||||
if (os.isLinux) {
|
if (os.isLinux) {
|
||||||
options.add("-Dsun.java2d.opengl=true")
|
options.add("-Dsun.java2d.opengl=true")
|
||||||
|
if (isDeb) {
|
||||||
|
options.add("-Djpackage.app-layout=deb")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val arguments = mutableListOf("${Jvm.current().javaHome}/bin/jpackage")
|
val arguments = mutableListOf("${Jvm.current().javaHome}/bin/jpackage")
|
||||||
@@ -601,20 +604,26 @@ fun pack() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建 zip、7z、msi
|
* 创建 zip、msi
|
||||||
*/
|
*/
|
||||||
fun packOnWindows(distributionDir: Directory, finalFilenameWithoutExtension: String, projectName: String) {
|
fun packOnWindows(distributionDir: Directory, finalFilenameWithoutExtension: String, projectName: String) {
|
||||||
|
val dir = layout.buildDirectory.dir("jpackage/images/win-msi.image/").get().asFile
|
||||||
|
val cfg = FileUtils.getFile(dir, projectName, "app", "${projectName}.cfg")
|
||||||
|
val configText = cfg.readText()
|
||||||
|
|
||||||
// zip
|
// zip
|
||||||
|
cfg.writeText(StringBuilder(configText).appendLine("java-options=-Djpackage.app-layout=zip").toString())
|
||||||
exec {
|
exec {
|
||||||
commandLine(
|
commandLine(
|
||||||
"tar", "-vacf",
|
"tar", "-vacf",
|
||||||
distributionDir.file("${finalFilenameWithoutExtension}.zip").asFile.absolutePath,
|
distributionDir.file("${finalFilenameWithoutExtension}.zip").asFile.absolutePath,
|
||||||
projectName
|
projectName
|
||||||
)
|
)
|
||||||
workingDir = layout.buildDirectory.dir("jpackage/images/win-msi.image/").get().asFile
|
workingDir = dir
|
||||||
}
|
}
|
||||||
|
|
||||||
// exe
|
// exe
|
||||||
|
cfg.writeText(StringBuilder(configText).appendLine("java-options=-Djpackage.app-layout=exe").toString())
|
||||||
exec {
|
exec {
|
||||||
commandLine(
|
commandLine(
|
||||||
"iscc",
|
"iscc",
|
||||||
@@ -718,7 +727,11 @@ fun packOnLinux(distributionDir: Directory, finalFilenameWithoutExtension: Strin
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val cfg = FileUtils.getFile(distributionDir.asFile, projectName, "lib", "app", "${projectName}.cfg")
|
||||||
|
val configText = cfg.readText()
|
||||||
|
|
||||||
// tar.gz
|
// tar.gz
|
||||||
|
cfg.writeText(StringBuilder(configText).appendLine("java-options=-Djpackage.app-layout=tar.gz").toString())
|
||||||
exec {
|
exec {
|
||||||
commandLine(
|
commandLine(
|
||||||
"tar", "-czvf",
|
"tar", "-czvf",
|
||||||
@@ -773,6 +786,7 @@ Terminal=false
|
|||||||
appRun.setExecutable(true)
|
appRun.setExecutable(true)
|
||||||
|
|
||||||
// AppImage
|
// AppImage
|
||||||
|
cfg.writeText(StringBuilder(configText).appendLine("java-options=-Djpackage.app-layout=AppImage").toString())
|
||||||
exec {
|
exec {
|
||||||
commandLine(appimagetool.absolutePath, termoraName, "${finalFilenameWithoutExtension}.AppImage")
|
commandLine(appimagetool.absolutePath, termoraName, "${finalFilenameWithoutExtension}.AppImage")
|
||||||
workingDir = distributionDir.asFile
|
workingDir = distributionDir.asFile
|
||||||
|
|||||||
21
src/main/kotlin/app/termora/AppLayout.kt
Normal file
21
src/main/kotlin/app/termora/AppLayout.kt
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
package app.termora
|
||||||
|
|
||||||
|
enum class AppLayout {
|
||||||
|
/**
|
||||||
|
* Windows
|
||||||
|
*/
|
||||||
|
Zip,
|
||||||
|
Exe,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* macOS
|
||||||
|
*/
|
||||||
|
App,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Linux
|
||||||
|
*/
|
||||||
|
TarGz,
|
||||||
|
AppImage,
|
||||||
|
Deb,
|
||||||
|
}
|
||||||
@@ -121,6 +121,30 @@ object Application {
|
|||||||
return version
|
return version
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getLayout(): AppLayout {
|
||||||
|
if (SystemInfo.isMacOS) return AppLayout.App
|
||||||
|
|
||||||
|
val layout = System.getProperty("jpackage.app-layout")
|
||||||
|
if (SystemInfo.isLinux) {
|
||||||
|
if ("deb" == layout) {
|
||||||
|
return AppLayout.Deb
|
||||||
|
} else if ("tar.gz" == layout) {
|
||||||
|
return AppLayout.TarGz
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SystemInfo.isWindows) {
|
||||||
|
if ("exe" == layout) {
|
||||||
|
return AppLayout.Exe
|
||||||
|
} else if ("zip" == layout) {
|
||||||
|
return AppLayout.Zip
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return if (SystemInfo.isWindows) AppLayout.Exe else AppLayout.AppImage
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 未知版本通常是开发版本
|
* 未知版本通常是开发版本
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user