41
41
import java .util .stream .Stream ;
42
42
import jdk .jpackage .internal .Codesign .CodesignException ;
43
43
import jdk .jpackage .internal .model .Application ;
44
+ import jdk .jpackage .internal .model .ApplicationLayout ;
45
+ import jdk .jpackage .internal .model .Launcher ;
44
46
import jdk .jpackage .internal .model .MacApplication ;
45
47
import jdk .jpackage .internal .util .PathUtils ;
46
48
import jdk .jpackage .internal .util .function .ExceptionBox ;
@@ -63,21 +65,22 @@ static Consumer<Path> createSigner(MacApplication app, CodesignConfig signingCfg
63
65
});
64
66
}
65
67
66
- static Consumer <Path > createUnsigner (MacApplication app ) {
67
- return toConsumer (appImage -> {
68
- new AppImageSigner (Codesigners .nop ()).sign (app , appImage );
69
- });
70
- }
71
-
72
- static final class SignFilter implements Predicate <Path > {
68
+ private static final class SignFilter implements Predicate <Path > {
73
69
74
70
SignFilter (Application app , Path appImage ) {
75
71
Objects .requireNonNull (appImage );
72
+
73
+ // Don't explicitly sign main launcher. It will be implicitly signed when the bundle is signed.
74
+ otherExcludePaths = app .asApplicationLayout ().map (appLayout -> {
75
+ return appLayout .resolveAt (appImage );
76
+ }).map (ApplicationLayout ::launchersDirectory ).flatMap (launchersDir -> {
77
+ return app .mainLauncher ().map (Launcher ::executableNameWithSuffix ).map (launchersDir ::resolve );
78
+ }).map (Set ::of ).orElseGet (Set ::of );
76
79
}
77
80
78
81
@ Override
79
82
public boolean test (Path path ) {
80
- if (!Files .isRegularFile (path )) {
83
+ if (!Files .isRegularFile (path ) || otherExcludePaths . contains ( path ) ) {
81
84
return false ;
82
85
}
83
86
@@ -91,6 +94,8 @@ public boolean test(Path path) {
91
94
92
95
return false ;
93
96
}
97
+
98
+ private final Set <Path > otherExcludePaths ;
94
99
}
95
100
96
101
private void sign (MacApplication app , Path appImage ) throws CodesignException , IOException {
@@ -219,11 +224,6 @@ private Optional<Consumer<Path>> findCodesigner(Path path) {
219
224
return Optional .empty ();
220
225
}
221
226
222
- static Codesigners nop () {
223
- Consumer <Path > nop = path -> {};
224
- return new Codesigners (nop , nop , nop );
225
- }
226
-
227
227
static Codesigners create (CodesignConfig signingCfg ) {
228
228
final var signingCfgWithoutEntitlements = CodesignConfig .build ().from (signingCfg ).entitlements (null ).create ();
229
229
0 commit comments