8296154: [macos] Change "/Applications" to "Applications" in DMG image

Reviewed-by: asemenyuk
This commit is contained in:
Alexander Matveev 2022-11-07 20:52:57 +00:00
parent 60db5f2ba2
commit 7e85b41d37
3 changed files with 19 additions and 4 deletions
src/jdk.jpackage/macosx/classes/jdk/jpackage/internal

@ -96,7 +96,8 @@ public abstract class MacBaseInstallerBundler extends AbstractBundler {
},
(s, p) -> s);
static String getInstallDir(
// Returns full path to installation directory
static String getInstallDir(
Map<String, ? super Object> params, boolean defaultOnly) {
String returnValue = INSTALL_DIR.fetchFrom(params);
if (defaultOnly && returnValue != null) {
@ -113,6 +114,18 @@ public abstract class MacBaseInstallerBundler extends AbstractBundler {
return returnValue;
}
// Returns display name of installation directory. Display name is used to
// show user installation location and for well known (default only) we will
// use "Applications" or "JavaVirtualMachines".
static String getInstallDirDisplayName(
Map<String, ? super Object> params) {
if (StandardBundlerParam.isRuntimeInstaller(params)) {
return "JavaVirtualMachines";
} else {
return "Applications";
}
}
public MacBaseInstallerBundler() {
appImageBundler = new MacAppBundler()
.setDependentTask(true);

@ -121,7 +121,7 @@ public class MacDmgBundler extends MacBaseInstallerBundler {
Path bgFile = Path.of(rootPath.toString(), APP_NAME.fetchFrom(params),
BACKGROUND_IMAGE_FOLDER, BACKGROUND_IMAGE);
//prepare config for exe
// Prepare DMG setup script
Map<String, String> data = new HashMap<>();
data.put("DEPLOY_VOLUME_URL", volumeUrl);
data.put("DEPLOY_BG_FILE", bgFile.toString());
@ -131,6 +131,8 @@ public class MacDmgBundler extends MacBaseInstallerBundler {
APP_NAME.fetchFrom(params) : appLocation.getFileName().toString();
data.put("DEPLOY_TARGET", targetItem);
data.put("DEPLOY_INSTALL_LOCATION", getInstallDir(params, true));
data.put("DEPLOY_INSTALL_LOCATION_DISPLAY_NAME",
getInstallDirDisplayName(params));
createResource(DEFAULT_DMG_SETUP_SCRIPT, params)
.setCategory(I18N.getString("resource.dmg-setup-script"))

@ -17,14 +17,14 @@ tell application "Finder"
set background picture of theViewOptions to POSIX file "DEPLOY_BG_FILE"
-- Create alias for install location
make new alias file at POSIX file "DEPLOY_VOLUME_PATH" to POSIX file "DEPLOY_INSTALL_LOCATION" with properties {name:"DEPLOY_INSTALL_LOCATION"}
make new alias file at POSIX file "DEPLOY_VOLUME_PATH" to POSIX file "DEPLOY_INSTALL_LOCATION" with properties {name:"DEPLOY_INSTALL_LOCATION_DISPLAY_NAME"}
set allTheFiles to the name of every item of theWindow
set xpos to 120
repeat with theFile in allTheFiles
set theFilePath to POSIX path of theFile
set appFilePath to POSIX path of "/DEPLOY_TARGET"
if theFilePath is "DEPLOY_INSTALL_LOCATION" then
if theFilePath ends with "DEPLOY_INSTALL_LOCATION_DISPLAY_NAME" then
-- Position install location
set position of item theFile of theWindow to {390, 130}
else if theFilePath ends with appFilePath then