-
Notifications
You must be signed in to change notification settings - Fork 89
Expand file tree
/
Copy pathPackageSigner.java
More file actions
49 lines (44 loc) · 1.71 KB
/
PackageSigner.java
File metadata and controls
49 lines (44 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Inspired by https://github.com/dg76/signpackage
package nodebox;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Objects;
public class PackageSigner {
public static void main(String[] args) {
File projectDir = new File(".");
scanRecursive(new File("dist/mac"), projectDir);
signFile(new File("dist/mac/NodeBox.app"), projectDir);
}
public static void scanRecursive(File dir, File projectDir) {
for (File f : Objects.requireNonNull(dir.listFiles())) {
if (f.isDirectory()) {
scanRecursive(f, projectDir);
} else if (f.getName().endsWith(".dylib") || f.canExecute()) {
System.out.println(f.getAbsolutePath());
signFile(f, projectDir);
}
}
}
private static void signFile(File f, File projectDir) {
ArrayList<String> command = new ArrayList<>();
command.add("codesign");
command.add("--sign");
command.add("Developer ID Application: Frederik De Bleser (5X78EYG9RH)");
command.add("--timestamp");
command.add("--deep");
command.add("-vvvv");
command.add("-f");
command.add("--entitlements");
command.add(new File(projectDir, "platform/mac/NodeBox.entitlements").getAbsolutePath());
command.add("--options");
command.add("runtime");
command.add(f.getAbsolutePath());
System.out.println("command = " + command);
try {
new ProcessBuilder().directory(f.getParentFile()).inheritIO().command(command).start().waitFor();
} catch (InterruptedException | IOException e) {
e.printStackTrace();
}
}
}