mirror of
https://github.com/sparrowwallet/signpackage.git
synced 2024-12-26 13:56:44 +00:00
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:
parent
e8028654ff
commit
e43d26eef9
1 changed files with 15 additions and 25 deletions
|
@ -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"
|
||||||
|
@ -24,7 +21,7 @@ class SignPackage(val args: Array<String>) {
|
||||||
private val OPTION_RUNTIME = "r"
|
private val OPTION_RUNTIME = "r"
|
||||||
private val OPTION_TIMESTAMP = "t"
|
private val OPTION_TIMESTAMP = "t"
|
||||||
private val OPTION_EXCLUDE = "x"
|
private val OPTION_EXCLUDE = "x"
|
||||||
private var excludedFiles: Array<String> = emptyArray()
|
private var excludedFiles : Array<String> = emptyArray()
|
||||||
|
|
||||||
fun run() {
|
fun run() {
|
||||||
val options = Options()
|
val options = Options()
|
||||||
|
@ -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,25 +67,23 @@ 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.
|
println("${file.absolutePath}: ${zipEntry.name}")
|
||||||
println("${file.absolutePath}: ${zipEntry.name}")
|
val dylibFile = File(tmpDir, File(zipEntry.name).name)
|
||||||
val dylibFile = File(tmpDir, File(zipEntry.name).name)
|
ZipUtil.unpackEntry(file, zipEntry.name, dylibFile)
|
||||||
ZipUtil.unpackEntry(file, zipEntry.name, dylibFile)
|
signFile(dylibFile, cmd)
|
||||||
signFile(dylibFile, cmd)
|
ZipUtil.replaceEntry(file, zipEntry.name, dylibFile)
|
||||||
ZipUtil.replaceEntry(file, zipEntry.name, dylibFile)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sign the jar file
|
|
||||||
println(file.absolutePath)
|
|
||||||
signFile(file, cmd)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sign the jar file
|
||||||
|
println(file.absolutePath)
|
||||||
|
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(" ")}")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue