Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
JesperIRL committed Jul 1, 2020
2 parents 03d47d5 + 55e7003 commit 292a3d5
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 8 deletions.
Expand Up @@ -91,7 +91,7 @@ public File bundle(Map<String, ? super Object> params,
return buildDMG(params, appLocation, outdir);
}
return null;
} catch (IOException ex) {
} catch (IOException | PackagerException ex) {
Log.verbose(ex);
throw new PackagerException(ex);
}
Expand Down Expand Up @@ -262,7 +262,8 @@ private String findSetFileUtility() {
}

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();

Expand Down Expand Up @@ -322,7 +323,31 @@ private File buildDMG( Map<String, ? super Object> params,
"-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(
Expand All @@ -335,6 +360,23 @@ private File buildDMG( Map<String, ? super Object> params,

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);
Expand Down
5 changes: 0 additions & 5 deletions test/jdk/ProblemList.txt
Expand Up @@ -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

############################################################################

0 comments on commit 292a3d5

Please sign in to comment.