8237966: Creating runtime pkg requires --mac-package-identifier

Reviewed-by: kizune, asemenyuk, almatvee
This commit is contained in:
Andy Herrick 2020-03-03 18:07:11 -05:00
parent aa54795965
commit ef4053ee41

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -362,6 +362,7 @@ public class MacPkgBundler extends MacBaseInstallerBundler {
String root = appLocation.getParent() == null ?
"." : appLocation.getParent();
File rootDir = new File(root);
File[] list = rootDir.listFiles();
if (list != null) { // Should not happend
// We should only have app image and/or .DS_Store
@ -378,11 +379,25 @@ public class MacPkgBundler extends MacBaseInstallerBundler {
// Copy to new root
Path newRoot = Files.createTempDirectory(
TEMP_ROOT.fetchFrom(params).toPath(),
"root-");
TEMP_ROOT.fetchFrom(params).toPath(), "root-");
IOUtils.copyRecursive(appLocation.toPath(),
newRoot.resolve(appLocation.getName()));
Path source, dest;
if (StandardBundlerParam.isRuntimeInstaller(params)) {
// firs, is this already a runtime with
// <runtime>/Contents/Home - if so we need the Home dir
Path original = appLocation.toPath();
Path home = original.resolve("Contents/Home");
source = (Files.exists(home)) ? home : original;
// Then we need to put back the <NAME>/Content/Home
dest = newRoot.resolve(
MAC_CF_BUNDLE_IDENTIFIER.fetchFrom(params) + "/Contents/Home");
} else {
source = appLocation.toPath();
dest = newRoot.resolve(appLocation.getName());
}
IOUtils.copyRecursive(source, dest);
return newRoot.toString();
}
@ -422,6 +437,8 @@ public class MacPkgBundler extends MacBaseInstallerBundler {
cpl.getAbsolutePath(),
"--scripts",
SCRIPTS_DIR.fetchFrom(params).getAbsolutePath(),
"--identifier",
MAC_CF_BUNDLE_IDENTIFIER.fetchFrom(params),
appPKG.getAbsolutePath());
IOUtils.exec(pb);