Removed threadpool because somehow appimageoutput/MyApp.app/Contents/runtime/Contents/MacOS/libjli.dylib was not signed due to a "File not found" error.

This commit is contained in:
dom 2020-02-26 11:44:56 +01:00
parent e8028654ff
commit e43d26eef9

View file

@ -6,8 +6,6 @@ import org.apache.commons.cli.Option
import org.apache.commons.cli.Options import org.apache.commons.cli.Options
import org.zeroturnaround.zip.ZipUtil import org.zeroturnaround.zip.ZipUtil
import java.io.File import java.io.File
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit
import java.util.zip.ZipFile import java.util.zip.ZipFile
fun main(args: Array<String>) { fun main(args: Array<String>) {
@ -16,7 +14,6 @@ fun main(args: Array<String>) {
class SignPackage(val args: Array<String>) { class SignPackage(val args: Array<String>) {
val tmpDir = File("tmpdir${System.currentTimeMillis()}") val tmpDir = File("tmpdir${System.currentTimeMillis()}")
val threadPool = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors())
private val OPTION_DIR = "d" private val OPTION_DIR = "d"
private val OPTION_SIGN_KEY = "k" private val OPTION_SIGN_KEY = "k"
@ -54,8 +51,6 @@ class SignPackage(val args: Array<String>) {
// Start scanning and signing the jar files // Start scanning and signing the jar files
scanRecursive(File(cmd.getOptionValue(OPTION_DIR)), cmd) scanRecursive(File(cmd.getOptionValue(OPTION_DIR)), cmd)
threadPool.shutdown()
threadPool.awaitTermination(1, TimeUnit.DAYS)
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printStackTrace()
} finally { } finally {
@ -72,7 +67,6 @@ class SignPackage(val args: Array<String>) {
if (file.isDirectory) { if (file.isDirectory) {
scanRecursive(file, cmd) scanRecursive(file, cmd)
} else if (file.name.endsWith(".jar")) { } else if (file.name.endsWith(".jar")) {
threadPool.submit {
ZipFile(file).entries().asSequence().forEach { zipEntry -> ZipFile(file).entries().asSequence().forEach { zipEntry ->
if (zipEntry.name.endsWith(".dylib")) { if (zipEntry.name.endsWith(".dylib")) {
// Extract, sign and compress the dylib file. // Extract, sign and compress the dylib file.
@ -87,10 +81,9 @@ class SignPackage(val args: Array<String>) {
// Sign the jar file // Sign the jar file
println(file.absolutePath) println(file.absolutePath)
signFile(file, cmd) signFile(file, cmd)
}
} else if (file.name.endsWith(".dylib") || file.canExecute()) { } else if (file.name.endsWith(".dylib") || file.canExecute()) {
println(file.absolutePath) println(file.absolutePath)
threadPool.submit { signFile(file, cmd) } signFile(file, cmd)
} }
} }
} }
@ -112,14 +105,11 @@ class SignPackage(val args: Array<String>) {
println(command.joinToString(" ")) println(command.joinToString(" "))
val resultCode = ProcessBuilder() ProcessBuilder()
.directory(dylibFile.parentFile) .directory(dylibFile.parentFile)
.inheritIO() .inheritIO()
.command(command) .command(command)
.start() .start()
.waitFor() .waitFor()
if (resultCode != 0) {
throw Exception("Resultcode $resultCode when executing ${command.joinToString(" ")}")
}
} }
} }