8210505: Unable to create an installer from an app-image on linux JDK-8200758-branch
authorherrick
Mon, 17 Sep 2018 19:14:56 -0400
branchJDK-8200758-branch
changeset 56888 628a283daa6c
parent 56887 93db8a13c4c5
child 56889 6658178cefe6
8210505: Unable to create an installer from an app-image on linux Reviewed-by: almatvee
src/jdk.packager/linux/classes/jdk/packager/internal/linux/LinuxDebBundler.java
src/jdk.packager/linux/classes/jdk/packager/internal/linux/LinuxRpmBundler.java
src/jdk.packager/macosx/classes/jdk/packager/internal/resources/mac/MacBaseInstallerBundler.properties
src/jdk.packager/share/classes/jdk/packager/internal/DeployParams.java
src/jdk.packager/share/classes/jdk/packager/internal/bundlers/BundleParams.java
--- a/src/jdk.packager/linux/classes/jdk/packager/internal/linux/LinuxDebBundler.java	Mon Sep 17 16:22:44 2018 -0400
+++ b/src/jdk.packager/linux/classes/jdk/packager/internal/linux/LinuxDebBundler.java	Mon Sep 17 19:14:56 2018 -0400
@@ -347,9 +347,18 @@
         }
     }
 
-    private boolean prepareProto(Map<String, ? super Object> p) {
-        File appDir = StandardBundlerParam.getPredefinedAppImage(p);
-        if (appDir == null) {
+    private boolean prepareProto(Map<String, ? super Object> p) 
+            throws IOException {
+        File appImage = StandardBundlerParam.getPredefinedAppImage(p);
+        File appDir = null;
+
+        // we either have an application image or need to build one
+        if (appImage != null) {
+            appDir = new File(APP_IMAGE_ROOT.fetchFrom(p),
+                APP_NAME.fetchFrom(p));
+            // copy everything from appImage dir into appDir/name
+            IOUtils.copyRecursive(appImage.toPath(), appDir.toPath());
+        } else {
             appDir = APP_BUNDLER.fetchFrom(p).doBundle(p,
                     APP_IMAGE_ROOT.fetchFrom(p), true);
         }
--- a/src/jdk.packager/linux/classes/jdk/packager/internal/linux/LinuxRpmBundler.java	Mon Sep 17 16:22:44 2018 -0400
+++ b/src/jdk.packager/linux/classes/jdk/packager/internal/linux/LinuxRpmBundler.java	Mon Sep 17 19:14:56 2018 -0400
@@ -273,11 +273,20 @@
         }
     }
 
-    private boolean prepareProto(Map<String, ? super Object> params) {
-        File appDir = StandardBundlerParam.getPredefinedAppImage(params);
-        if (appDir == null) {
-            appDir = APP_BUNDLER.fetchFrom(params).doBundle(
-                    params, RPM_IMAGE_DIR.fetchFrom(params), true);
+    private boolean prepareProto(Map<String, ? super Object> p) 
+            throws IOException {
+        File appImage = StandardBundlerParam.getPredefinedAppImage(p);
+        File appDir = null;
+
+        // we either have an application image or need to build one
+        if (appImage != null) {
+            appDir = new File(RPM_IMAGE_DIR.fetchFrom(p),
+                APP_NAME.fetchFrom(p));
+            // copy everything from appImage dir into appDir/name
+            IOUtils.copyRecursive(appImage.toPath(), appDir.toPath());
+        } else {
+            appDir = APP_BUNDLER.fetchFrom(p).doBundle(p,
+                    RPM_IMAGE_DIR.fetchFrom(p), true);
         }
         return appDir != null;
     }
--- a/src/jdk.packager/macosx/classes/jdk/packager/internal/resources/mac/MacBaseInstallerBundler.properties	Mon Sep 17 16:22:44 2018 -0400
+++ b/src/jdk.packager/macosx/classes/jdk/packager/internal/resources/mac/MacBaseInstallerBundler.properties	Mon Sep 17 19:14:56 2018 -0400
@@ -28,6 +28,9 @@
 error.parameters-null=Parameters map is null.
 error.parameters-null.advice=Pass in a non-null parameters map.
 
+message.app-image-dir-does-not-exist=Specified application image directory {0}\: {1} does not exists
+message.app-image-dir-does-not-exist.advice=Confirm that the value for {0} exists
+
 message.could-not-retrieve-name=Could not retrieve gecos name
 message.app-image-requires-app-name=When using an external app image you must specify the app name.
 message.app-image-requires-app-name.advice=Set the app name via the -name CLI flag, the fx:application/@name ANT attribute, or via the 'appName' bundler argument.
--- a/src/jdk.packager/share/classes/jdk/packager/internal/DeployParams.java	Mon Sep 17 16:22:44 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/DeployParams.java	Mon Sep 17 19:14:56 2018 -0400
@@ -41,9 +41,6 @@
 import java.util.TreeSet;
 
 public class DeployParams extends CommonParams {
-    public enum RunMode {
-        EMBEDDED, STANDALONE, ALL
-    }
 
     final List<RelativeFileSet> resources = new ArrayList<>();
 
@@ -470,6 +467,29 @@
         if (outdir == null) {
             throw new PackagerException("ERR_MissingArgument", "--output");
         }
+
+        boolean hasModule = (bundlerArguments.get(
+                Arguments.CLIOptions.MODULE.getId()) != null);
+        boolean hasImage = (bundlerArguments.get(
+                Arguments.CLIOptions.PREDEFINED_APP_IMAGE.getId()) != null);
+        boolean hasClass = (bundlerArguments.get(
+                Arguments.CLIOptions.APPCLASS.getId()) != null);
+        boolean hasMain = (bundlerArguments.get(
+                Arguments.CLIOptions.MAIN_JAR.getId()) != null);
+
+        // if bundling non-modular image, or installer without app-image
+        // then we need some resources and a main class
+        if (!hasModule && !hasImage && !jreInstaller) {
+            if (resources.isEmpty()) {
+                throw new PackagerException("ERR_MissingAppResources");
+            }
+            if (!hasClass) {
+                throw new PackagerException("ERR_MissingArgument", "--class");
+            }
+            if (!hasMain) {
+                throw new PackagerException("ERR_MissingArgument", "--main-jar");
+            }
+        }
     }
 
     public boolean validateForBundle() {
@@ -484,41 +504,6 @@
         return result;
     }
 
-    // could be icon or splash
-    // TODO: do we still need this class?
-    static class Icon {
-        final static int UNDEFINED = -1;
-
-        String href;
-        String kind;
-        int width = UNDEFINED;
-        int height = UNDEFINED;
-        int depth = UNDEFINED;
-        RunMode mode = RunMode.ALL;
-
-        Icon(String href, String kind, int w, int h, int d, RunMode m) {
-            mode = m;
-            this.href = href;
-            this.kind = kind;
-            if (w > 0) {
-                width = w;
-            }
-            if (h > 0) {
-                height = h;
-            }
-            if (d > 0) {
-                depth = d;
-            }
-        }
-    }
-
-    List<Icon> icons = new LinkedList<>();
-
-    public void addIcon(
-            String href, String kind, int w, int h, int d, RunMode m) {
-        icons.add(new Icon(href, kind, w, h, d, m));
-    }
-
     BundleType bundleType = BundleType.NONE;
     String targetFormat = null; //means any
 
@@ -668,43 +653,6 @@
             bundleParams.setDetectMods(detectmods);
         }
 
-        File appIcon = null;
-        List<Map<String, ? super Object>> bundlerIcons = new ArrayList<>();
-        for (Icon ic: icons) {
-            // NB: in theory we should be paying attention to RunMode but
-            // currently everything is marked as webstart internally and
-            // runmode is not publicly documented property
-            if (/* (ic.mode == RunMode.ALL ||
-                    ic.mode == RunMode.STANDALONE) && */
-                (ic.kind == null || ic.kind.equals("default")))
-            {
-                //could be full path or something relative to the output folder
-                appIcon = new File(ic.href);
-                if (!appIcon.exists()) {
-                    jdk.packager.internal.Log.debug(
-                        "Icon [" + ic.href + "] is not valid absolute path. "
-                        + "Assume it is relative to the output dir.");
-                    appIcon = new File(outdir, ic.href);
-                }
-            }
-
-            Map<String, ? super Object> iconInfo = new TreeMap<>();
-/*
-            if (ic.href != null) iconInfo.put(ICONS_HREF.getID(), ic.href);
-            if (ic.kind != null) iconInfo.put(ICONS_KIND.getID(), ic.kind);
-            if (ic.width > 0)    iconInfo.put(ICONS_WIDTH.getID(),
-                    Integer.toString(ic.width));
-            if (ic.height > 0)   iconInfo.put(ICONS_HEIGHT.getID(),
-                    Integer.toString(ic.height));
-            if (ic.depth > 0)    iconInfo.put(ICONS_DEPTH.getID(),
-                    Integer.toString(ic.depth));
-*/
-            if (!iconInfo.isEmpty()) bundlerIcons.add(iconInfo);
-        }
-        // putUnlessNullOrEmpty(ICONS.getID(), bundlerIcons);
-
-        bundleParams.setIcon(appIcon);
-
         Map<String, String> paramsMap = new TreeMap<>();
         if (params != null) {
             for (Param p : params) {
@@ -715,37 +663,6 @@
         Map<String, String> unescapedHtmlParams = new TreeMap<>();
         Map<String, String> escapedHtmlParams = new TreeMap<>();
         
-        // putUnlessNullOrEmpty(JNLPBundler.APPLET_PARAMS.getID(),
-        //         unescapedHtmlParams);
-        // putUnlessNullOrEmpty(ESCAPED_APPLET_PARAMS.getID(),
-        //          escapedHtmlParams);
-
-/*
-        putUnlessNull(WIDTH.getID(), width);
-        putUnlessNull(HEIGHT.getID(), height);
-        putUnlessNull(EMBEDDED_WIDTH.getID(), embeddedWidth);
-        putUnlessNull(EMBEDDED_HEIGHT.getID(), embeddedHeight);
-
-        putUnlessNull(CODEBASE.getID(), codebase);
-        putUnlessNull(EMBED_JNLP.getID(), embedJNLP);
-        // embedCertificates
-        putUnlessNull(ALL_PERMISSIONS.getID(), allPermissions);
-        putUnlessNull(UPDATE_MODE.getID(), updateMode);
-        putUnlessNull(EXTENSION.getID(), isExtension);
-        putUnlessNull(SWING_APP.getID(), isSwingApp);
-
-        putUnlessNull(OUT_FILE.getID(), outfile);
-        putUnlessNull(INCLUDE_DT.getID(), includeDT);
-        putUnlessNull(PLACEHOLDER.getID(), placeholder);
-        putUnlessNull(OFFLINE_ALLOWED.getID(), offlineAllowed);
-
-        putUnlessNull(TEMPLATES.getID(), templatesMap);
-
-        putUnlessNull(FX_PLATFORM.getID(), fxPlatform);
-        putUnlessNull(JRE_PLATFORM.getID(), jrePlatform);
-
-        putUnlessNull(FALLBACK_APP.getID(), fallbackApp);
-*/
         // check for collisions
         TreeSet<String> keys = new TreeSet<>(bundlerArguments.keySet());
         keys.retainAll(bundleParams.getBundleParamsAsMap().keySet());
--- a/src/jdk.packager/share/classes/jdk/packager/internal/bundlers/BundleParams.java	Mon Sep 17 16:22:44 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/bundlers/BundleParams.java	Mon Sep 17 19:14:56 2018 -0400
@@ -436,14 +436,6 @@
         putUnlessNull(APP_RESOURCES_LIST.getID(), rfs);
     }
 
-    public File getIcon() {
-        return fetchParam(ICON);
-    }
-
-    public void setIcon(File icon) {
-        putUnlessNull(PARAM_ICON, icon);
-    }
-
     public String getApplicationCategory() {
         return fetchParam(CATEGORY);
     }