< prev index next >

modules/jdk.packager/src/main/java/com/oracle/tools/packager/mac/MacPkgBundler.java

Print this page




  36 import java.io.BufferedWriter;
  37 import java.io.File;
  38 import java.io.FileNotFoundException;
  39 import java.io.FileWriter;
  40 import java.io.IOException;
  41 import java.io.PrintStream;
  42 import java.io.Writer;
  43 import java.net.URLEncoder;
  44 import java.text.MessageFormat;
  45 import java.util.ArrayList;
  46 import java.util.Arrays;
  47 import java.util.Collection;
  48 import java.util.HashMap;
  49 import java.util.LinkedHashSet;
  50 import java.util.List;
  51 import java.util.Map;
  52 import java.util.Optional;
  53 import java.util.ResourceBundle;
  54 
  55 import static com.oracle.tools.packager.StandardBundlerParam.*;



  56 
  57 public class MacPkgBundler extends MacBaseInstallerBundler {
  58 
  59     private static final ResourceBundle I18N =
  60             ResourceBundle.getBundle(MacPkgBundler.class.getName());
  61 
  62     public final static String MAC_BUNDLER_PREFIX =
  63             BUNDLER_PREFIX + "macosx" + File.separator;
  64 
  65     private static final String DEFAULT_BACKGROUND_IMAGE = "background_pkg.png";
  66 
  67     private static final String TEMPLATE_PREINSTALL_SCRIPT = "preinstall.template";
  68     private static final String TEMPLATE_POSTINSTALL_SCRIPT = "postinstall.template";
  69 
  70     private static final BundlerParamInfo<File> PACKAGES_ROOT = new StandardBundlerParam<>(
  71             I18N.getString("param.packages-root.name"),
  72             I18N.getString("param.packages-root.description"),
  73             "mac.pkg.packagesRoot",
  74             File.class,
  75             params -> {


  80             (s, p) -> new File(s));
  81 
  82 
  83     protected final BundlerParamInfo<File> SCRIPTS_DIR = new StandardBundlerParam<>(
  84             I18N.getString("param.scripts-dir.name"),
  85             I18N.getString("param.scripts-dir.description"),
  86             "mac.pkg.scriptsDir",
  87             File.class,
  88             params -> {
  89                 File scriptsDir = new File(CONFIG_ROOT.fetchFrom(params), "scripts");
  90                 scriptsDir.mkdirs();
  91                 return scriptsDir;
  92             },
  93             (s, p) -> new File(s));
  94 
  95     public static final BundlerParamInfo<String> DEVELOPER_ID_INSTALLER_SIGNING_KEY = new StandardBundlerParam<>(
  96             I18N.getString("param.signing-key-developer-id-installer.name"),
  97             I18N.getString("param.signing-key-developer-id-installer.description"),
  98             "mac.signing-key-developer-id-installer",
  99             String.class,
 100             params -> MacBaseInstallerBundler.findKey("Developer ID Installer: " + SIGNING_KEY_USER.fetchFrom(params), SIGNING_KEYCHAIN.fetchFrom(params), VERBOSE.fetchFrom(params)),













 101             (s, p) -> s);
 102 
 103     public static final BundlerParamInfo<String> INSTALLER_SUFFIX = new StandardBundlerParam<> (
 104             I18N.getString("param.installer-suffix.name"),
 105             I18N.getString("param.installer-suffix.description"),
 106             "mac.pkg.installerName.suffix",
 107             String.class,
 108             params -> "",
 109             (s, p) -> s);
 110 
 111     public MacPkgBundler() {
 112         super();
 113         baseResourceLoader = MacResources.class;
 114     }
 115 
 116     //@Override
 117     public File bundle(Map<String, ? super Object> params, File outdir) {
 118         Log.info(MessageFormat.format(I18N.getString("message.building-pkg"), APP_NAME.fetchFrom(params)));
 119         if (!outdir.isDirectory() && !outdir.mkdirs()) {
 120             throw new RuntimeException(MessageFormat.format(I18N.getString("error.cannot-create-output-dir"), outdir.getAbsolutePath()));




  36 import java.io.BufferedWriter;
  37 import java.io.File;
  38 import java.io.FileNotFoundException;
  39 import java.io.FileWriter;
  40 import java.io.IOException;
  41 import java.io.PrintStream;
  42 import java.io.Writer;
  43 import java.net.URLEncoder;
  44 import java.text.MessageFormat;
  45 import java.util.ArrayList;
  46 import java.util.Arrays;
  47 import java.util.Collection;
  48 import java.util.HashMap;
  49 import java.util.LinkedHashSet;
  50 import java.util.List;
  51 import java.util.Map;
  52 import java.util.Optional;
  53 import java.util.ResourceBundle;
  54 
  55 import static com.oracle.tools.packager.StandardBundlerParam.*;
  56 import static com.oracle.tools.packager.mac.MacBaseInstallerBundler.SIGNING_KEYCHAIN;
  57 import static com.oracle.tools.packager.mac.MacBaseInstallerBundler.SIGNING_KEY_USER;
  58 import jdk.packager.internal.mac.MacCertificate;
  59 
  60 public class MacPkgBundler extends MacBaseInstallerBundler {
  61 
  62     private static final ResourceBundle I18N =
  63             ResourceBundle.getBundle(MacPkgBundler.class.getName());
  64 
  65     public final static String MAC_BUNDLER_PREFIX =
  66             BUNDLER_PREFIX + "macosx" + File.separator;
  67 
  68     private static final String DEFAULT_BACKGROUND_IMAGE = "background_pkg.png";
  69 
  70     private static final String TEMPLATE_PREINSTALL_SCRIPT = "preinstall.template";
  71     private static final String TEMPLATE_POSTINSTALL_SCRIPT = "postinstall.template";
  72 
  73     private static final BundlerParamInfo<File> PACKAGES_ROOT = new StandardBundlerParam<>(
  74             I18N.getString("param.packages-root.name"),
  75             I18N.getString("param.packages-root.description"),
  76             "mac.pkg.packagesRoot",
  77             File.class,
  78             params -> {


  83             (s, p) -> new File(s));
  84 
  85 
  86     protected final BundlerParamInfo<File> SCRIPTS_DIR = new StandardBundlerParam<>(
  87             I18N.getString("param.scripts-dir.name"),
  88             I18N.getString("param.scripts-dir.description"),
  89             "mac.pkg.scriptsDir",
  90             File.class,
  91             params -> {
  92                 File scriptsDir = new File(CONFIG_ROOT.fetchFrom(params), "scripts");
  93                 scriptsDir.mkdirs();
  94                 return scriptsDir;
  95             },
  96             (s, p) -> new File(s));
  97 
  98     public static final BundlerParamInfo<String> DEVELOPER_ID_INSTALLER_SIGNING_KEY = new StandardBundlerParam<>(
  99             I18N.getString("param.signing-key-developer-id-installer.name"),
 100             I18N.getString("param.signing-key-developer-id-installer.description"),
 101             "mac.signing-key-developer-id-installer",
 102             String.class,
 103             params -> {
 104                     String result = MacBaseInstallerBundler.findKey("Developer ID Installer: " + SIGNING_KEY_USER.fetchFrom(params),
 105                                                                     SIGNING_KEYCHAIN.fetchFrom(params),
 106                                                                     VERBOSE.fetchFrom(params));
 107                     if (result != null) {
 108                         MacCertificate certificate = new MacCertificate(result, VERBOSE.fetchFrom(params));
 109 
 110                         if (!certificate.isValid()) {
 111                             Log.info(MessageFormat.format(I18N.getString("error.certificate.expired"), result));
 112                         }
 113                     }
 114 
 115                     return result;
 116                 },
 117             (s, p) -> s);
 118 
 119     public static final BundlerParamInfo<String> INSTALLER_SUFFIX = new StandardBundlerParam<> (
 120             I18N.getString("param.installer-suffix.name"),
 121             I18N.getString("param.installer-suffix.description"),
 122             "mac.pkg.installerName.suffix",
 123             String.class,
 124             params -> "",
 125             (s, p) -> s);
 126 
 127     public MacPkgBundler() {
 128         super();
 129         baseResourceLoader = MacResources.class;
 130     }
 131 
 132     //@Override
 133     public File bundle(Map<String, ? super Object> params, File outdir) {
 134         Log.info(MessageFormat.format(I18N.getString("message.building-pkg"), APP_NAME.fetchFrom(params)));
 135         if (!outdir.isDirectory() && !outdir.mkdirs()) {
 136             throw new RuntimeException(MessageFormat.format(I18N.getString("error.cannot-create-output-dir"), outdir.getAbsolutePath()));


< prev index next >