aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/MacDmgBundler.java48
-rw-r--r--test/jdk/ProblemList.txt5
2 files changed, 45 insertions, 8 deletions
diff --git a/src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/MacDmgBundler.java b/src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/MacDmgBundler.java
index 8787e345168..ac26b8a3262 100644
--- a/src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/MacDmgBundler.java
+++ b/src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/MacDmgBundler.java
@@ -91,7 +91,7 @@ public class MacDmgBundler extends MacBaseInstallerBundler {
return buildDMG(params, appLocation, outdir);
}
return null;
- } catch (IOException ex) {
+ } catch (IOException | PackagerException ex) {
Log.verbose(ex);
throw new PackagerException(ex);
}
@@ -262,7 +262,8 @@ public class MacDmgBundler extends MacBaseInstallerBundler {
}
private File buildDMG( Map<String, ? super Object> params,
- File appLocation, File outdir) throws IOException {
+ File appLocation, File outdir) throws IOException, PackagerException {
+ boolean copyAppImage = false;
File imagesRoot = IMAGES_ROOT.fetchFrom(params);
if (!imagesRoot.exists()) imagesRoot.mkdirs();
@@ -322,7 +323,31 @@ public class MacDmgBundler extends MacBaseInstallerBundler {
"-ov", protoDMG.getAbsolutePath(),
"-fs", "HFS+",
"-format", "UDRW");
- IOUtils.exec(pb);
+ try {
+ IOUtils.exec(pb);
+ } catch (IOException ex) {
+ Log.verbose(ex); // Log exception
+
+ // Creating DMG from entire app image failed, so lets try to create empty
+ // DMG and copy files manually. See JDK-8248059.
+ copyAppImage = true;
+
+ long size = new PathGroup(Map.of(new Object(), srcFolder.toPath()))
+ .sizeInBytes();
+ size += 50 * 1024 * 1024; // Add extra 50 megabytes. Actually DMG size will
+ // not be bigger, but it will able to hold additional 50 megabytes of data.
+ // We need extra room for icons and background image. When we providing
+ // actual files to hdiutil, it will create DMG with ~50 megabytes extra room.
+ pb = new ProcessBuilder(
+ hdiutil,
+ "create",
+ hdiUtilVerbosityFlag,
+ "-size", String.valueOf(size),
+ "-volname", APP_NAME.fetchFrom(params),
+ "-ov", protoDMG.getAbsolutePath(),
+ "-fs", "HFS+");
+ IOUtils.exec(pb);
+ }
// mount temp image
pb = new ProcessBuilder(
@@ -335,6 +360,23 @@ public class MacDmgBundler extends MacBaseInstallerBundler {
File mountedRoot = new File(imagesRoot.getAbsolutePath(),
APP_NAME.fetchFrom(params));
+
+ // Copy app image, since we did not create DMG with it, but instead we created
+ // empty one.
+ if (copyAppImage) {
+ // In case of predefine app image srcFolder will point to app bundle, so if
+ // we use it as is we will copy content of app bundle, but we need app bundle
+ // folder as well.
+ if (srcFolder.toPath().toString().toLowerCase().endsWith(".app")) {
+ Path destPath = mountedRoot.toPath()
+ .resolve(srcFolder.toPath().getFileName());
+ Files.createDirectory(destPath);
+ IOUtils.copyRecursive(srcFolder.toPath(), destPath);
+ } else {
+ IOUtils.copyRecursive(srcFolder.toPath(), mountedRoot.toPath());
+ }
+ }
+
try {
// background image
File bgdir = new File(mountedRoot, BACKGROUND_IMAGE_FOLDER);
diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt
index d1dc3124aaa..dcfff091deb 100644
--- a/test/jdk/ProblemList.txt
+++ b/test/jdk/ProblemList.txt
@@ -924,11 +924,6 @@ jdk/jfr/event/os/TestThreadContextSwitches.java 8247776 windows-
# jdk_jpackage
-tools/jpackage/share/EmptyFolderPackageTest.java 8248059 macosx-all
-tools/jpackage/share/IconTest.java 8248059 macosx-all
-tools/jpackage/share/AppImagePackageTest.java 8248059 macosx-all
-tools/jpackage/share/SimplePackageTest.java 8248059 macosx-all
-tools/jpackage/share/jdk/jpackage/tests/BasicTest.java 8248059 macosx-all
tools/jpackage/share/jdk/jpackage/tests/ModulePathTest3.java#id0 8248418 generic-all
############################################################################