Skip to content

Commit 2a8c0ba

Browse files
Got rid of params in DMG bundler. Enhanced PackagingPipeline to do native packaging. Changed Linux, Windows, and DMG bunders to work inside of the pipeline. All tests but PKG packaging pass. PKG bundler compiles but has not been tested.
1 parent 6edbf92 commit 2a8c0ba

File tree

15 files changed

+1078
-882
lines changed

15 files changed

+1078
-882
lines changed

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

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
import java.util.Objects;
3535
import java.util.function.Predicate;
3636
import java.util.stream.Stream;
37+
import jdk.jpackage.internal.PackagingPipeline.PackageBuildEnv;
38+
import jdk.jpackage.internal.model.AppImageLayout;
3739
import jdk.jpackage.internal.model.ConfigException;
3840
import jdk.jpackage.internal.model.LinuxPackage;
3941
import jdk.jpackage.internal.model.Package;
@@ -103,48 +105,41 @@ public final Path execute(Map<String, ? super Object> params,
103105
final LinuxPackage pkg = pkgParam.fetchFrom(params);
104106
final var env = BuildEnvFromParams.BUILD_ENV.fetchFrom(params);
105107

106-
final BuildEnv pkgEnv;
107-
108-
if (pkg.app().runtimeBuilder().isEmpty()) {
109-
// Packaging external app image
110-
pkgEnv = BuildEnv.withAppImageDir(env, BuildEnvBuilder.defaultAppImageDir(env.buildRoot()));
111-
} else {
112-
pkgEnv = env;
113-
}
114-
115108
LinuxPackagingPipeline.build()
116109
.excludeDirFromCopying(outputParentDir)
117-
.pkgBuildEnvFactory((e, p) -> pkgEnv)
110+
.task(PackagingPipeline.PackageTaskID.CREATE_PACKAGE_FILE)
111+
.packageAction(this::buildPackage)
112+
.add()
113+
.task(PackagingPipeline.PackageTaskID.RUN_POST_IMAGE_USER_SCRIPT)
114+
.noaction() // FIXME: implement post-app-image script execution on Linux
115+
.add()
118116
.create().execute(env, pkg, outputParentDir);
119117

120-
try {
121-
for (var ca : customActions) {
122-
ca.init(pkgEnv, pkg);
123-
}
118+
return outputParentDir.resolve(pkg.packageFileNameWithSuffix()).toAbsolutePath();
119+
}
124120

125-
Map<String, String> data = createDefaultReplacementData(pkgEnv, pkg);
121+
private void buildPackage(PackageBuildEnv<LinuxPackage, AppImageLayout> env) throws PackagerException, IOException {
122+
for (var ca : customActions) {
123+
ca.init(env.env(), env.pkg());
124+
}
126125

127-
for (var ca : customActions) {
128-
ShellCustomAction.mergeReplacementData(data, ca.instance.create());
129-
}
126+
Map<String, String> data = createDefaultReplacementData(env.env(), env.pkg());
130127

131-
data.putAll(createReplacementData(pkgEnv, pkg));
128+
for (var ca : customActions) {
129+
ShellCustomAction.mergeReplacementData(data, ca.instance.create());
130+
}
132131

133-
Path packageBundle = buildPackageBundle(Collections.unmodifiableMap(
134-
data), pkgEnv, pkg, outputParentDir);
132+
data.putAll(createReplacementData(env.env(), env.pkg()));
135133

136-
verifyOutputBundle(pkgEnv, pkg, packageBundle).stream()
137-
.filter(Objects::nonNull)
138-
.forEachOrdered(ex -> {
139-
Log.verbose(ex.getLocalizedMessage());
140-
Log.verbose(ex.getAdvice());
141-
});
134+
Path packageBundle = buildPackageBundle(Collections.unmodifiableMap(
135+
data), env.env(), env.pkg(), env.outputDir());
142136

143-
return packageBundle;
144-
} catch (IOException ex) {
145-
Log.verbose(ex);
146-
throw new PackagerException(ex);
147-
}
137+
verifyOutputBundle(env.env(), env.pkg(), packageBundle).stream()
138+
.filter(Objects::nonNull)
139+
.forEachOrdered(ex -> {
140+
Log.verbose(ex.getLocalizedMessage());
141+
Log.verbose(ex.getAdvice());
142+
});
148143
}
149144

150145
private List<String> getListOfNeededPackages(BuildEnv env) throws IOException {

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

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

2727
import static jdk.jpackage.internal.ApplicationImageUtils.createLauncherIconResource;
28+
import jdk.jpackage.internal.PackagingPipeline.AppImageBuildEnv;
2829

2930
import java.io.IOException;
3031
import java.io.UncheckedIOException;
3132
import java.nio.file.Files;
3233
import java.nio.file.Path;
33-
import jdk.jpackage.internal.PackagingPipeline.AppImageTaskID;
34+
import jdk.jpackage.internal.PackagingPipeline.BuildApplicationTaskID;
3435
import jdk.jpackage.internal.PackagingPipeline.PrimaryTaskID;
3536
import jdk.jpackage.internal.PackagingPipeline.TaskID;
3637
import jdk.jpackage.internal.model.Application;
@@ -48,27 +49,29 @@ static PackagingPipeline.Builder build() {
4849
return PackagingPipeline.buildStandard()
4950
.task(LinuxAppImageTaskID.LAUNCHER_LIB)
5051
.addDependent(PrimaryTaskID.BUILD_APPLICATION_IMAGE)
51-
.action(LinuxPackagingPipeline::writeLauncherLib).add()
52+
.applicationAction(LinuxPackagingPipeline::writeLauncherLib).add()
5253
.task(LinuxAppImageTaskID.LAUNCHER_ICONS)
53-
.addDependent(AppImageTaskID.CONTENT)
54-
.action(LinuxPackagingPipeline::writeLauncherIcons).add();
54+
.addDependent(BuildApplicationTaskID.CONTENT)
55+
.applicationAction(LinuxPackagingPipeline::writeLauncherIcons).add();
5556
}
5657

57-
private static void writeLauncherLib(BuildEnv env, Application app,
58-
ApplicationLayout appLayout) throws IOException {
59-
var launcherLib = ((LinuxApplicationLayout)appLayout).libAppLauncher();
58+
private static void writeLauncherLib(
59+
AppImageBuildEnv<Application, LinuxApplicationLayout> env) throws IOException {
60+
61+
final var launcherLib = env.resolvedLayout().libAppLauncher();
6062
try (var in = ResourceLocator.class.getResourceAsStream("libjpackageapplauncheraux.so")) {
6163
Files.createDirectories(launcherLib.getParent());
6264
Files.copy(in, launcherLib);
6365
}
6466
}
6567

66-
private static void writeLauncherIcons(BuildEnv env, Application app,
67-
ApplicationLayout appLayout) throws IOException {
68-
for (var launcher : app.launchers()) {
69-
createLauncherIconResource(app, launcher, env::createResource).ifPresent(iconResource -> {
68+
private static void writeLauncherIcons(
69+
AppImageBuildEnv<Application, ApplicationLayout> env) throws IOException {
70+
71+
for (var launcher : env.app().launchers()) {
72+
createLauncherIconResource(env.app(), launcher, env.env()::createResource).ifPresent(iconResource -> {
7073
String iconFileName = launcher.executableName() + ".png";
71-
Path iconTarget = appLayout.destktopIntegrationDirectory().resolve(iconFileName);
74+
Path iconTarget = env.resolvedLayout().destktopIntegrationDirectory().resolve(iconFileName);
7275
try {
7376
iconResource.saveToFile(iconTarget);
7477
} catch (IOException ex) {

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

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,9 @@ public MacAppBundler() {
4646
final var app = MacFromParams.APPLICATION.fetchFrom(params);
4747
final var env = BuildEnv.withAppImageDir(BuildEnvFromParams.BUILD_ENV.fetchFrom(params), output);
4848

49-
final var taskPipelineBuilder = MacPackagingPipeline.build()
49+
MacPackagingPipeline.build(Optional.empty())
5050
.excludeDirFromCopying(output.getParent())
51-
.excludeDirFromCopying(OUTPUT_DIR.fetchFrom(params))
52-
.inputApplicationLayoutForPackaging(pkg -> pkg.app().asApplicationLayout());
53-
54-
final var pkg = FromParams.getCurrentPackage(params);
55-
if (pkg.isPresent()) {
56-
taskPipelineBuilder.pkgBuildEnvFactory((e, p) -> {
57-
return BuildEnv.withAppImageDir(e, output);
58-
});
59-
taskPipelineBuilder.create().execute(env, pkg.orElseThrow(), output);
60-
} else {
61-
taskPipelineBuilder.create().execute(env, app);
62-
}
51+
.excludeDirFromCopying(OUTPUT_DIR.fetchFrom(params)).create().execute(env, app);
6352

6453
});
6554
setParamsValidator(MacAppBundler::doValidate);

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

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,16 @@
2626
package jdk.jpackage.internal;
2727

2828
import jdk.jpackage.internal.model.ConfigException;
29-
import jdk.jpackage.internal.model.PackagerException;
3029
import java.io.IOException;
3130
import java.nio.file.Files;
32-
import java.nio.file.LinkOption;
3331
import java.nio.file.Path;
3432
import java.text.MessageFormat;
3533
import java.util.Map;
3634
import java.util.Optional;
3735
import static jdk.jpackage.internal.StandardBundlerParam.APP_NAME;
3836
import static jdk.jpackage.internal.StandardBundlerParam.INSTALLER_NAME;
3937
import static jdk.jpackage.internal.StandardBundlerParam.INSTALL_DIR;
38+
import static jdk.jpackage.internal.StandardBundlerParam.OUTPUT_DIR;
4039
import static jdk.jpackage.internal.StandardBundlerParam.PREDEFINED_APP_IMAGE;
4140
import static jdk.jpackage.internal.StandardBundlerParam.PREDEFINED_APP_IMAGE_FILE;
4241
import static jdk.jpackage.internal.StandardBundlerParam.VERSION;
@@ -130,8 +129,7 @@ static String getInstallDir(
130129
}
131130

132131
public MacBaseInstallerBundler() {
133-
appImageBundler = new MacAppBundler()
134-
.setDependentTask(true);
132+
appImageBundler = new MacAppBundler();
135133
}
136134

137135
protected void validateAppImageAndBundeler(
@@ -177,36 +175,6 @@ protected void validateAppImageAndBundeler(
177175
}
178176
}
179177

180-
protected Path prepareAppBundle(Map<String, ? super Object> params)
181-
throws PackagerException, IOException {
182-
Path appDir;
183-
Path appImageRoot = APP_IMAGE_TEMP_ROOT.fetchFrom(params);
184-
Path predefinedImage =
185-
StandardBundlerParam.getPredefinedAppImage(params);
186-
if (predefinedImage != null) {
187-
appDir = appImageRoot.resolve(APP_NAME.fetchFrom(params) + ".app");
188-
FileUtils.copyRecursive(predefinedImage, appDir,
189-
LinkOption.NOFOLLOW_LINKS);
190-
191-
// Create PackageFile if predefined app image is not signed
192-
if (!StandardBundlerParam.isRuntimeInstaller(params) &&
193-
!new MacAppImageFileExtras(PREDEFINED_APP_IMAGE_FILE.fetchFrom(params)).signed()) {
194-
new PackageFile(APP_NAME.fetchFrom(params)).save(
195-
ApplicationLayoutUtils.PLATFORM_APPLICATION_LAYOUT.resolveAt(appDir));
196-
// We need to re-sign app image after adding ".package" to it.
197-
// We only do this if app image was not signed which means it is
198-
// signed with ad-hoc signature. App bundles with ad-hoc
199-
// signature are sealed, but without a signing identity, so we
200-
// need to re-sign it after modification.
201-
MacAppImageBuilder.signAppBundle(params, appDir, "-", null, null);
202-
}
203-
} else {
204-
appDir = appImageBundler.execute(params, appImageRoot);
205-
}
206-
207-
return appDir;
208-
}
209-
210178
@Override
211179
public String getBundleType() {
212180
return "INSTALLER";

0 commit comments

Comments
 (0)