Skip to content

Commit b6f9768

Browse files
author
duke
committed
Automatic merge of jdk:master into master
2 parents 269d6c5 + 57210af commit b6f9768

File tree

55 files changed

+2107
-415
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2107
-415
lines changed

src/jdk.jpackage/linux/classes/jdk/jpackage/internal/DesktopIntegration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ void applyTo(Map<String, String> data) {
355355
* - installPath(): path where it should be installed by package manager;
356356
*/
357357
private InstallableFile createDesktopFile(String fileName) {
358-
var srcPath = pkg.asPackageApplicationLayout().orElseThrow().resolveAt(env.appImageDir()).desktopIntegrationDirectory().resolve(fileName);
358+
var srcPath = env.asApplicationLayout().orElseThrow().desktopIntegrationDirectory().resolve(fileName);
359359
var installPath = pkg.asInstalledPackageApplicationLayout().orElseThrow().desktopIntegrationDirectory().resolve(fileName);
360360
return new InstallableFile(srcPath, installPath);
361361
}

src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxApplicationLayout.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@
2424
*/
2525
package jdk.jpackage.internal;
2626

27-
import static jdk.jpackage.internal.util.PathUtils.resolveNullablePath;
27+
import static jdk.jpackage.internal.util.PathUtils.mapNullablePath;
2828

2929
import java.nio.file.Path;
30+
import java.util.function.UnaryOperator;
3031
import jdk.jpackage.internal.model.ApplicationLayout;
3132
import jdk.jpackage.internal.util.CompositeProxy;
3233

@@ -40,7 +41,25 @@ static LinuxApplicationLayout create(ApplicationLayout layout, Path libAppLaunch
4041

4142
@Override
4243
default LinuxApplicationLayout resolveAt(Path root) {
43-
return create(ApplicationLayout.super.resolveAt(root),
44-
resolveNullablePath(root, libAppLauncher()));
44+
return (LinuxApplicationLayout)ApplicationLayout.super.resolveAt(root);
45+
}
46+
47+
@Override
48+
default LinuxApplicationLayout unresolve() {
49+
return (LinuxApplicationLayout)ApplicationLayout.super.unresolve();
50+
}
51+
52+
@Override
53+
default LinuxApplicationLayout resetRootDirectory() {
54+
if (isResolved()) {
55+
return create(ApplicationLayout.super.resetRootDirectory(), libAppLauncher());
56+
} else {
57+
return this;
58+
}
59+
}
60+
61+
@Override
62+
default LinuxApplicationLayout map(UnaryOperator<Path> mapper) {
63+
return create(ApplicationLayout.super.map(mapper), mapNullablePath(mapper, libAppLauncher()));
4564
}
4665
}

src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxApplicationLayoutMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
import java.nio.file.Path;
2828

29-
// Must be publc to allow access from AppImageLayout.toPathGroup()
29+
// Must be public to allow access from AppImageLayout.toPathGroup()
3030
public interface LinuxApplicationLayoutMixin {
3131

3232
/**

src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxDebBundler.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,7 @@ protected Map<String, String> createReplacementData(BuildEnv env, LinuxPackage p
351351
data.put("APPLICATION_LICENSE_TEXT", licenseText);
352352
data.put("APPLICATION_ARCH", pkg.arch());
353353
data.put("APPLICATION_INSTALLED_SIZE", Long.toString(
354-
AppImageLayout.toPathGroup(pkg.packageLayout().resolveAt(
355-
env.appImageDir())).sizeInBytes() >> 10));
354+
AppImageLayout.toPathGroup(env.appImageLayout()).sizeInBytes() >> 10));
356355
data.put("APPLICATION_HOMEPAGE", pkg.aboutURL().map(
357356
value -> "Homepage: " + value).orElse(""));
358357
data.put("APPLICATION_VERSION_WITH_RELEASE", ((LinuxDebPackage) pkg).versionWithRelease());

src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxPackageBuilder.java

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333
import jdk.jpackage.internal.model.AppImageLayout;
3434
import jdk.jpackage.internal.model.ApplicationLayout;
3535
import jdk.jpackage.internal.model.ConfigException;
36+
import jdk.jpackage.internal.model.LinuxApplication;
3637
import jdk.jpackage.internal.model.LinuxPackage;
38+
import jdk.jpackage.internal.model.RuntimeLayout;
3739
import jdk.jpackage.internal.model.LinuxPackageMixin;
3840
import jdk.jpackage.internal.model.Package;
3941
import jdk.jpackage.internal.model.StandardPackageType;
@@ -52,24 +54,35 @@ LinuxPackage create() throws ConfigException {
5254
pkgBuilder.name(pkgBuilder.create().packageName().toLowerCase().replaceAll("[ _]", "-"));
5355
}
5456

55-
final var pkg = pkgBuilder.create();
57+
final var tmpPkg = pkgBuilder.create();
5658

57-
final var stdPkgType = pkg.asStandardPackageType();
59+
final var stdPkgType = tmpPkg.asStandardPackageType();
5860
if (stdPkgType.isPresent()) {
59-
validatePackageName(pkg.packageName(), stdPkgType.orElseThrow());
61+
validatePackageName(tmpPkg.packageName(), stdPkgType.orElseThrow());
6062
}
6163

62-
var reply = create(pkg, pkg.packageLayout());
63-
if (reply.isInstallDirInUsrTree()) {
64-
reply = create(pkg, usrTreePackageLayout(pkg.relativeInstallDir(), pkg.packageName()));
64+
final AppImageLayout relativeInstalledLayout;
65+
if (create(tmpPkg).isInstallDirInUsrTree()) {
66+
final var usrTreeLayout = usrTreePackageLayout(tmpPkg.relativeInstallDir(), tmpPkg.packageName());
67+
if (tmpPkg.isRuntimeInstaller()) {
68+
relativeInstalledLayout = RuntimeLayout.create(usrTreeLayout.runtimeDirectory());
69+
} else {
70+
relativeInstalledLayout = usrTreeLayout;
71+
}
72+
} else {
73+
relativeInstalledLayout = tmpPkg.appImageLayout().resolveAt(tmpPkg.relativeInstallDir()).resetRootDirectory();
6574
}
6675

67-
return reply;
76+
final var app = ApplicationBuilder.overrideAppImageLayout(pkgBuilder.app(), relativeInstalledLayout);
77+
78+
return create(pkgBuilder
79+
.app(LinuxApplication.create(app))
80+
.installedPackageLayout(relativeInstalledLayout.resolveAt(Path.of("/")).resetRootDirectory())
81+
.create());
6882
}
6983

70-
private LinuxPackage create(Package pkg, AppImageLayout pkgLayout) throws ConfigException {
84+
private LinuxPackage create(Package pkg) throws ConfigException {
7185
return LinuxPackage.create(pkg, new LinuxPackageMixin.Stub(
72-
pkgLayout,
7386
Optional.ofNullable(menuGroupName).orElseGet(DEFAULTS::menuGroupName),
7487
Optional.ofNullable(category),
7588
Optional.ofNullable(additionalDependencies),

src/jdk.jpackage/linux/classes/jdk/jpackage/internal/model/LinuxPackage.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ public interface LinuxPackage extends Package, LinuxPackageMixin {
3636

3737
LinuxApplication app();
3838

39-
@Override
40-
AppImageLayout packageLayout();
41-
4239
@Override
4340
default String packageFileName() {
4441
String packageFileNameTemlate = asStandardPackageType().map(stdType -> {

src/jdk.jpackage/linux/classes/jdk/jpackage/internal/model/LinuxPackageMixin.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@
3131
*/
3232
public interface LinuxPackageMixin {
3333

34-
/**
35-
* Overrides {@link Package#packageLayout()}.
36-
*/
37-
AppImageLayout packageLayout();
38-
3934
/**
4035
* Gets the name of the start menu group where to create shortcuts for
4136
* application launchers of this package.
@@ -88,7 +83,7 @@ public interface LinuxPackageMixin {
8883
/**
8984
* Default implementation of {@link LinuxPackageMixin} interface.
9085
*/
91-
record Stub(AppImageLayout packageLayout, String menuGroupName,
86+
record Stub(String menuGroupName,
9287
Optional<String> category, Optional<String> additionalDependencies,
9388
Optional<String> release, String arch) implements LinuxPackageMixin {
9489
}

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

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
package jdk.jpackage.internal;
2626

2727
import static java.util.stream.Collectors.joining;
28+
import static jdk.jpackage.internal.MacPackagingPipeline.APPLICATION_LAYOUT;
29+
import static jdk.jpackage.internal.model.MacPackage.RUNTIME_BUNDLE_LAYOUT;
2830
import static jdk.jpackage.internal.util.function.ThrowingConsumer.toConsumer;
2931

3032
import java.io.IOException;
@@ -44,13 +46,14 @@
4446
import jdk.jpackage.internal.model.ApplicationLayout;
4547
import jdk.jpackage.internal.model.Launcher;
4648
import jdk.jpackage.internal.model.MacApplication;
49+
import jdk.jpackage.internal.model.RuntimeLayout;
4750
import jdk.jpackage.internal.util.PathUtils;
4851
import jdk.jpackage.internal.util.function.ExceptionBox;
4952

5053

5154
final class AppImageSigner {
5255

53-
static Consumer<Path> createSigner(MacApplication app, CodesignConfig signingCfg) {
56+
static Consumer<MacBundle> createSigner(MacApplication app, CodesignConfig signingCfg) {
5457
return toConsumer(appImage -> {
5558
try {
5659
new AppImageSigner(Codesigners.create(signingCfg)).sign(app, appImage);
@@ -67,12 +70,12 @@ static Consumer<Path> createSigner(MacApplication app, CodesignConfig signingCfg
6770

6871
private static final class SignFilter implements Predicate<Path> {
6972

70-
SignFilter(Application app, Path appImage) {
73+
SignFilter(Application app, MacBundle appImage) {
7174
Objects.requireNonNull(appImage);
7275

7376
// Don't explicitly sign main launcher. It will be implicitly signed when the bundle is signed.
7477
otherExcludePaths = app.asApplicationLayout().map(appLayout -> {
75-
return appLayout.resolveAt(appImage);
78+
return appLayout.resolveAt(appImage.root());
7679
}).map(ApplicationLayout::launchersDirectory).flatMap(launchersDir -> {
7780
return app.mainLauncher().map(Launcher::executableNameWithSuffix).map(launchersDir::resolve);
7881
}).map(Set::of).orElseGet(Set::of);
@@ -98,11 +101,16 @@ public boolean test(Path path) {
98101
private final Set<Path> otherExcludePaths;
99102
}
100103

101-
private void sign(MacApplication app, Path appImage) throws CodesignException, IOException {
104+
private void sign(MacApplication app, MacBundle appImage) throws CodesignException, IOException {
105+
if (!appImage.isValid()) {
106+
throw new IllegalArgumentException();
107+
}
108+
109+
app = normalizeAppImageLayout(app);
102110

103111
final var fileFilter = new SignFilter(app, appImage);
104112

105-
try (var content = Files.walk(appImage)) {
113+
try (var content = Files.walk(appImage.root())) {
106114
content.filter(fileFilter).forEach(toConsumer(path -> {
107115
final var origPerms = ensureCanWrite(path);
108116
try {
@@ -118,10 +126,10 @@ private void sign(MacApplication app, Path appImage) throws CodesignException, I
118126

119127
// Sign runtime root directory if present
120128
app.asApplicationLayout().map(appLayout -> {
121-
return appLayout.resolveAt(appImage);
129+
return appLayout.resolveAt(appImage.root());
122130
}).map(MacApplicationLayout.class::cast).map(MacApplicationLayout::runtimeRootDirectory).ifPresent(codesigners);
123131

124-
final var frameworkPath = appImage.resolve("Contents/Frameworks");
132+
final var frameworkPath = appImage.contentsDir().resolve("Frameworks");
125133
if (Files.isDirectory(frameworkPath)) {
126134
try (var content = Files.list(frameworkPath)) {
127135
content.forEach(toConsumer(path -> {
@@ -131,7 +139,7 @@ private void sign(MacApplication app, Path appImage) throws CodesignException, I
131139
}
132140

133141
// Sign the app image itself
134-
codesigners.accept(appImage);
142+
codesigners.accept(appImage.root());
135143
}
136144

137145
private static Set<PosixFilePermission> ensureCanWrite(Path path) {
@@ -235,5 +243,19 @@ static Codesigners create(CodesignConfig signingCfg) {
235243
}
236244
}
237245

246+
private static MacApplication normalizeAppImageLayout(MacApplication app) {
247+
switch (app.imageLayout()) {
248+
case MacApplicationLayout macLayout -> {
249+
return MacApplicationBuilder.overrideAppImageLayout(app, APPLICATION_LAYOUT);
250+
}
251+
case RuntimeLayout macLayout -> {
252+
return MacApplicationBuilder.overrideAppImageLayout(app, RUNTIME_BUNDLE_LAYOUT);
253+
}
254+
default -> {
255+
throw new IllegalArgumentException();
256+
}
257+
}
258+
}
259+
238260
private final Codesigners codesigners;
239261
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ public MacAppBundler() {
4242
final BuildEnv env;
4343

4444
if (StandardBundlerParam.hasPredefinedAppImage(params)) {
45-
env = BuildEnvFromParams.BUILD_ENV.fetchFrom(params);
45+
env = MacBuildEnvFromParams.BUILD_ENV.fetchFrom(params);
4646
final var pkg = MacPackagingPipeline.createSignAppImagePackage(app, env);
4747
MacPackagingPipeline.build(Optional.of(pkg)).create().execute(env, pkg, output);
4848
} else {
49-
env = BuildEnv.withAppImageDir(BuildEnvFromParams.BUILD_ENV.fetchFrom(params), output);
49+
env = BuildEnv.withAppImageDir(MacBuildEnvFromParams.BUILD_ENV.fetchFrom(params), output);
5050
MacPackagingPipeline.build(Optional.empty())
5151
.excludeDirFromCopying(output.getParent())
5252
.excludeDirFromCopying(OUTPUT_DIR.fetchFrom(params)).create().execute(env, app);

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import jdk.jpackage.internal.model.Launcher;
3535
import jdk.jpackage.internal.model.MacApplication;
3636
import jdk.jpackage.internal.model.MacApplicationMixin;
37+
import jdk.jpackage.internal.model.AppImageLayout;
3738
import jdk.jpackage.internal.model.AppImageSigningConfig;
3839

3940
final class MacApplicationBuilder {
@@ -95,12 +96,28 @@ MacApplication create() throws ConfigException {
9596

9697
validateAppVersion(app);
9798

98-
final var mixin = new MacApplicationMixin.Stub(validatedIcon(), validatedBundleName(),
99-
validatedBundleIdentifier(), validatedCategory(), appStore, createSigningConfig());
99+
final var mixin = new MacApplicationMixin.Stub(
100+
validatedIcon(),
101+
validatedBundleName(),
102+
validatedBundleIdentifier(),
103+
validatedCategory(),
104+
appStore,
105+
createSigningConfig());
100106

101107
return MacApplication.create(app, mixin);
102108
}
103109

110+
static MacApplication overrideAppImageLayout(MacApplication app, AppImageLayout appImageLayout) {
111+
final var mixin = new MacApplicationMixin.Stub(
112+
app.icon(),
113+
app.bundleName(),
114+
app.bundleIdentifier(),
115+
app.category(),
116+
app.appStore(),
117+
app.signingConfig());
118+
return MacApplication.create(ApplicationBuilder.overrideAppImageLayout(app, appImageLayout), mixin);
119+
}
120+
104121
static boolean isValidBundleIdentifier(String id) {
105122
for (int i = 0; i < id.length(); i++) {
106123
char a = id.charAt(i);

0 commit comments

Comments
 (0)