changeset 59326:304e65936f8f

8237971: Package type for runtime image on macosx Reviewed-by: asemenyuk, almatvee
author herrick
date Mon, 18 May 2020 10:11:10 -0400
parents 1ba9a9a3f948
children f814dd59bfe9
files src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/MacBaseInstallerBundler.java src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/MacDmgBundler.java src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/MacPkgBundler.java src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/resources/DMGsetup.scpt
diffstat 4 files changed, 47 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/MacBaseInstallerBundler.java	Mon May 18 12:32:11 2020 +0200
+++ b/src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/MacBaseInstallerBundler.java	Mon May 18 10:11:10 2020 -0400
@@ -83,17 +83,6 @@
             params -> "",
             null);
 
-    public static final BundlerParamInfo<String> MAC_INSTALL_DIR =
-            new StandardBundlerParam<>(
-            "mac-install-dir",
-            String.class,
-             params -> {
-                 String dir = INSTALL_DIR.fetchFrom(params);
-                 return (dir != null) ? dir : "/Applications";
-             },
-            (s, p) -> s
-    );
-
     public static final BundlerParamInfo<String> INSTALLER_NAME =
             new StandardBundlerParam<> (
             "mac.installerName",
@@ -111,6 +100,19 @@
             },
             (s, p) -> s);
 
+    protected static String getInstallDir(
+            Map<String, ? super Object>  params) {
+        String returnValue = INSTALL_DIR.fetchFrom(params);
+        if (returnValue == null) {
+            if (StandardBundlerParam.isRuntimeInstaller(params)) {
+                returnValue = "/Library/Java/JavaVirtualMachines";
+            } else {
+               returnValue = "/Applications";
+            }
+        }
+        return returnValue;
+    }
+
     protected void validateAppImageAndBundeler(
             Map<String, ? super Object> params) throws ConfigException {
         if (PREDEFINED_APP_IMAGE.fetchFrom(params) != null) {
--- a/src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/MacDmgBundler.java	Mon May 18 12:32:11 2020 +0200
+++ b/src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/MacDmgBundler.java	Mon May 18 10:11:10 2020 -0400
@@ -68,9 +68,9 @@
         File appImageDir = APP_IMAGE_TEMP_ROOT.fetchFrom(params);
         try {
             appImageDir.mkdirs();
+            File appLocation = prepareAppBundle(params);
 
-            if (prepareAppBundle(params) != null &&
-                    prepareConfigFiles(params)) {
+            if (appLocation != null && prepareConfigFiles(params)) {
                 File configScript = getConfig_Script(params);
                 if (configScript.exists()) {
                     Log.verbose(MessageFormat.format(
@@ -79,7 +79,7 @@
                     IOUtils.run("bash", configScript);
                 }
 
-                return buildDMG(params, outdir);
+                return buildDMG(params, appLocation, outdir);
             }
             return null;
         } catch (IOException ex) {
@@ -117,8 +117,7 @@
         data.put("DEPLOY_VOLUME_PATH", volumePath.toString());
         data.put("DEPLOY_APPLICATION_NAME", APP_NAME.fetchFrom(params));
 
-        data.put("DEPLOY_INSTALL_LOCATION", MAC_INSTALL_DIR.fetchFrom(params));
-        data.put("DEPLOY_INSTALL_NAME", MAC_INSTALL_DIR.fetchFrom(params));
+        data.put("DEPLOY_INSTALL_LOCATION", getInstallDir(params));
 
         createResource(DEFAULT_DMG_SETUP_SCRIPT, params)
                 .setCategory(I18N.getString("resource.dmg-setup-script"))
@@ -253,9 +252,8 @@
         return null;
     }
 
-    private File buildDMG(
-            Map<String, ? super Object> params, File outdir)
-            throws IOException {
+    private File buildDMG( Map<String, ? super Object> params,
+            File appLocation, File outdir) throws IOException {
         File imagesRoot = IMAGES_ROOT.fetchFrom(params);
         if (!imagesRoot.exists()) imagesRoot.mkdirs();
 
@@ -269,6 +267,24 @@
                 StandardBundlerParam.getPredefinedAppImage(params);
         if (predefinedImage != null) {
             srcFolder = predefinedImage;
+        } else if (StandardBundlerParam.isRuntimeInstaller(params)) {
+            Path newRoot = Files.createTempDirectory(
+                TEMP_ROOT.fetchFrom(params).toPath(), "root-");
+
+            // first, 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");
+            Path source = (Files.exists(home)) ? home : original;
+
+            // Then we need to put back the <NAME>/Content/Home
+            Path root = newRoot.resolve(
+                    MAC_CF_BUNDLE_IDENTIFIER.fetchFrom(params));
+            Path dest = root.resolve("Contents/Home");
+
+            IOUtils.copyRecursive(source, dest);
+
+            srcFolder = newRoot.toFile();
         }
 
         Log.verbose(MessageFormat.format(I18N.getString(
--- a/src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/MacPkgBundler.java	Mon May 18 12:32:11 2020 +0200
+++ b/src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/MacPkgBundler.java	Mon May 18 10:11:10 2020 -0400
@@ -176,10 +176,10 @@
 
         Map<String, String> data = new HashMap<>();
 
-        Path appLocation = Path.of(MAC_INSTALL_DIR.fetchFrom(params),
+        Path appLocation = Path.of(getInstallDir(params),
                          APP_NAME.fetchFrom(params) + ".app", "Contents", "app");
 
-        data.put("INSTALL_LOCATION", MAC_INSTALL_DIR.fetchFrom(params));
+        data.put("INSTALL_LOCATION", getInstallDir(params));
         data.put("APP_LOCATION", appLocation.toString());
 
         createResource(TEMPLATE_PREINSTALL_SCRIPT, params)
@@ -406,7 +406,7 @@
                     "--root",
                     root,
                     "--install-location",
-                    MAC_INSTALL_DIR.fetchFrom(params),
+                    getInstallDir(params),
                     "--analyze",
                     cpl.getAbsolutePath());
 
@@ -421,7 +421,7 @@
                     "--root",
                     root,
                     "--install-location",
-                    MAC_INSTALL_DIR.fetchFrom(params),
+                    getInstallDir(params),
                     "--component-plist",
                     cpl.getAbsolutePath(),
                     "--scripts",
--- a/src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/resources/DMGsetup.scpt	Mon May 18 12:32:11 2020 +0200
+++ b/src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/resources/DMGsetup.scpt	Mon May 18 10:11:10 2020 -0400
@@ -8,8 +8,8 @@
   set toolbar visible of theWindow to false
   set statusbar visible of theWindow to false
 
-  -- size of window should match size of background
-  set the bounds of theWindow to {400, 100, 917, 380}
+  -- size of window should fit the size of background
+  set the bounds of theWindow to {400, 100, 920, 440}
 
   set theViewOptions to a reference to the icon view options of theWindow
   set arrangement of theViewOptions to not arranged
@@ -17,20 +17,17 @@
   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_NAME"}
+  make new alias file at POSIX file "DEPLOY_VOLUME_PATH" to POSIX file "DEPLOY_INSTALL_LOCATION" with properties {name:"DEPLOY_INSTALL_LOCATION"}
 
   set allTheFiles to the name of every item of theWindow
   repeat with theFile in allTheFiles
     set theFilePath to POSIX path of theFile
-    if theFilePath is "/DEPLOY_APPLICATION_NAME.app" then
-      -- Position application location
-      set position of item theFile of theWindow to {120, 130}
-    else if theFilePath is "DEPLOY_INSTALL_NAME" then
+    if theFilePath is "DEPLOY_INSTALL_LOCATION" then
       -- Position install location
       set position of item theFile of theWindow to {390, 130}
     else
-      -- Move all other files far enough to be not visible if user has "show hidden files" option set
-      set position of item theFile of theWindow to {1000, 130}
+      -- Position application or runtime
+      set position of item theFile of theWindow to {120, 130}
     end if
   end repeat