Skip to content

Commit fe8f5f5

Browse files
Fix AppImageSigner to not sign only the main launcher and sign additional launchers
1 parent 591c783 commit fe8f5f5

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/AppImageSigner.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
import java.util.stream.Stream;
4242
import jdk.jpackage.internal.Codesign.CodesignException;
4343
import jdk.jpackage.internal.model.Application;
44+
import jdk.jpackage.internal.model.ApplicationLayout;
45+
import jdk.jpackage.internal.model.Launcher;
4446
import jdk.jpackage.internal.model.MacApplication;
4547
import jdk.jpackage.internal.util.PathUtils;
4648
import jdk.jpackage.internal.util.function.ExceptionBox;
@@ -63,21 +65,22 @@ static Consumer<Path> createSigner(MacApplication app, CodesignConfig signingCfg
6365
});
6466
}
6567

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> {
7369

7470
SignFilter(Application app, Path appImage) {
7571
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);
7679
}
7780

7881
@Override
7982
public boolean test(Path path) {
80-
if (!Files.isRegularFile(path)) {
83+
if (!Files.isRegularFile(path) || otherExcludePaths.contains(path)) {
8184
return false;
8285
}
8386

@@ -91,6 +94,8 @@ public boolean test(Path path) {
9194

9295
return false;
9396
}
97+
98+
private final Set<Path> otherExcludePaths;
9499
}
95100

96101
private void sign(MacApplication app, Path appImage) throws CodesignException, IOException {
@@ -219,11 +224,6 @@ private Optional<Consumer<Path>> findCodesigner(Path path) {
219224
return Optional.empty();
220225
}
221226

222-
static Codesigners nop() {
223-
Consumer<Path> nop = path -> {};
224-
return new Codesigners(nop, nop, nop);
225-
}
226-
227227
static Codesigners create(CodesignConfig signingCfg) {
228228
final var signingCfgWithoutEntitlements = CodesignConfig.build().from(signingCfg).entitlements(null).create();
229229

0 commit comments

Comments
 (0)