8248059: [macos] EmptyFolderPackageTest.java failed "hdiutil: create failed - No child processes"

Reviewed-by: herrick, asemenyuk
This commit is contained in:
Alexander Matveev 2020-07-01 14:52:09 -04:00
parent 83a8c4acc7
commit 55e7003fd5
2 changed files with 45 additions and 8 deletions
src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal
test/jdk

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

@ -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
############################################################################