Commit 0e15f39a authored by Adrien's avatar Adrien

add a goToFileFolder method to avoid difficulties while signing

parent 2848a2ad
...@@ -31,10 +31,12 @@ class MacCodeSign { ...@@ -31,10 +31,12 @@ class MacCodeSign {
throw Throwable() throw Throwable()
} }
goToFileFolder(file)
logger.info("Signing osx application...") logger.info("Signing osx application...")
val signResult = ProcessBuilder() val signResult = ProcessBuilder()
.inheritIO() .inheritIO()
.command("codesign", "--deep", "-s", "Bonitasoft", file.canonicalPath) .command("codesign", "--deep", "-s", "Bonitasoft", file.name)
.start() .start()
.waitFor() .waitFor()
if (signResult != 0) { if (signResult != 0) {
...@@ -42,11 +44,8 @@ class MacCodeSign { ...@@ -42,11 +44,8 @@ class MacCodeSign {
} }
var newZipFile = zip(file); var newZipFile = zip(file);
deleteApplication(file) deleteApplication(file)
logger.info("Osx application has been signed successfully") logger.info("Osx application has been signed successfully")
return newZipFile return newZipFile
} }
...@@ -56,10 +55,12 @@ class MacCodeSign { ...@@ -56,10 +55,12 @@ class MacCodeSign {
throw Throwable("Failed to delete temp file $zipFile") throw Throwable("Failed to delete temp file $zipFile")
} }
goToFileFolder(file)
logger.info("Signing macOS installer...") logger.info("Signing macOS installer...")
var signResult = ProcessBuilder() var signResult = ProcessBuilder()
.inheritIO() .inheritIO()
.command("codesign", "--deep", "-s", "Bonitasoft", file.canonicalPath) .command("codesign", "--deep", "-s", "Bonitasoft", file.name)
.start() .start()
.waitFor() .waitFor()
if (signResult != 0) { if (signResult != 0) {
...@@ -126,23 +127,30 @@ class MacCodeSign { ...@@ -126,23 +127,30 @@ class MacCodeSign {
} }
fun zip(file: File): File { fun zip(file: File): File {
val zipPath: String = file.parentFile.canonicalPath + separator + file.nameWithoutExtension + ".zip"
ProcessBuilder() ProcessBuilder()
.inheritIO() .inheritIO()
.command("zip", zipPath, "-r", file.canonicalPath) .command("zip", file.nameWithoutExtension + ".zip", "-r", file.name)
.start() .start()
.waitFor() .waitFor()
var zipFile = File(zipPath) var zipFile = File(file.parentFile.canonicalPath + separator + file.nameWithoutExtension + ".zip")
if (!zipFile.exists()) { if (!zipFile.exists()) {
throw Throwable("failed to zip $file") throw Throwable("failed to zip $file")
} }
return zipFile return zipFile
} }
fun goToFileFolder(file: File) {
ProcessBuilder()
.inheritIO()
.command("cd", file.parentFile.canonicalPath)
.start()
.waitFor()
}
fun deleteApplication(application: File) { fun deleteApplication(application: File) {
ProcessBuilder() ProcessBuilder()
.inheritIO() .inheritIO()
.command("rm", "-r", application.canonicalPath) .command("rm", "-r", application.name)
.start() .start()
.waitFor() .waitFor()
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment