src/jdk.packager/windows/classes/jdk/packager/internal/windows/WinMsiBundler.java
branchJDK-8200758-branch
changeset 56989 0f19096663d1
parent 56982 e094d5483bd6
child 57015 5d2008115309
equal deleted inserted replaced
56988:3cb9af04c779 56989:0f19096663d1
   108                     Arguments.CLIOptions.WIN_PER_USER_INSTALLATION.getId(),
   108                     Arguments.CLIOptions.WIN_PER_USER_INSTALLATION.getId(),
   109                     Boolean.class,
   109                     Boolean.class,
   110                     params -> true, // MSIs default to system wide
   110                     params -> true, // MSIs default to system wide
   111                     // valueOf(null) is false,
   111                     // valueOf(null) is false,
   112                     // and we actually do want null
   112                     // and we actually do want null
   113                     (s, p) -> (s == null || "null".equalsIgnoreCase(s))? null 
   113                     (s, p) -> (s == null || "null".equalsIgnoreCase(s))? null
   114                             : Boolean.valueOf(s)
   114                             : Boolean.valueOf(s)
   115             );
   115             );
   116 
   116 
   117 
   117 
   118     public static final StandardBundlerParam<String> PRODUCT_VERSION =
   118     public static final StandardBundlerParam<String> PRODUCT_VERSION =
   183                     }
   183                     }
   184                 }
   184                 }
   185                 return null;
   185                 return null;
   186             },
   186             },
   187             null);
   187             null);
   188     
   188 
   189     public static final StandardBundlerParam<Boolean> MENU_HINT =
   189     public static final StandardBundlerParam<Boolean> MENU_HINT =
   190         new WindowsBundlerParam<>(
   190         new WindowsBundlerParam<>(
   191                 I18N.getString("param.menu-shortcut-hint.name"),
   191                 I18N.getString("param.menu-shortcut-hint.name"),
   192                 I18N.getString("param.menu-shortcut-hint.description"),
   192                 I18N.getString("param.menu-shortcut-hint.description"),
   193                 Arguments.CLIOptions.WIN_MENU_HINT.getId(),
   193                 Arguments.CLIOptions.WIN_MENU_HINT.getId(),
   580                     IOUtils.copyFile(configScriptSrc, configScript);
   580                     IOUtils.copyFile(configScriptSrc, configScript);
   581                     Log.info(MessageFormat.format(
   581                     Log.info(MessageFormat.format(
   582                             I18N.getString("message.running-wsh-script"),
   582                             I18N.getString("message.running-wsh-script"),
   583                             configScript.getAbsolutePath()));
   583                             configScript.getAbsolutePath()));
   584                     IOUtils.run("wscript",
   584                     IOUtils.run("wscript",
   585                              configScript, ECHO_MODE.fetchFrom(p));
   585                              configScript, false);
   586                 }
   586                 }
   587                 return buildMSI(p, outdir);
   587                 return buildMSI(p, outdir);
   588             }
   588             }
   589             return null;
   589             return null;
   590         } catch (IOException ex) {
   590         } catch (IOException ex) {
   593         } finally {
   593         } finally {
   594             try {
   594             try {
   595                 if (imageDir != null &&
   595                 if (imageDir != null &&
   596                         PREDEFINED_APP_IMAGE.fetchFrom(p) == null &&
   596                         PREDEFINED_APP_IMAGE.fetchFrom(p) == null &&
   597                         (PREDEFINED_RUNTIME_IMAGE.fetchFrom(p) == null ||
   597                         (PREDEFINED_RUNTIME_IMAGE.fetchFrom(p) == null ||
   598                         !Arguments.CREATE_JRE_INSTALLER.fetchFrom(p)) && 
   598                         !Arguments.CREATE_JRE_INSTALLER.fetchFrom(p)) &&
   599                         !Log.isDebug()) {
   599                         !Log.isDebug()) {
   600                     IOUtils.deleteRecursive(imageDir);
   600                     IOUtils.deleteRecursive(imageDir);
   601                 } else if (imageDir != null) {
   601                 } else if (imageDir != null) {
   602                     Log.info(MessageFormat.format(
   602                     Log.info(MessageFormat.format(
   603                             I18N.getString("message.debug-working-directory"),
   603                             I18N.getString("message.debug-working-directory"),
   604                             imageDir.getAbsolutePath()));
   604                             imageDir.getAbsolutePath()));
   605                 }
   605                 }
   606                 if (ECHO_MODE.fetchFrom(p)) {
   606 
   607                     Log.info(MessageFormat.format(
   607                 cleanupConfigFiles(p);
   608                             I18N.getString("message.config-save-location"),
       
   609                             CONFIG_ROOT.fetchFrom(p).getAbsolutePath()));
       
   610                 } else {
       
   611                     cleanupConfigFiles(p);
       
   612                 }
       
   613             } catch (IOException ex) {
   608             } catch (IOException ex) {
   614                 // noinspection ReturnInsideFinallyBlock
   609                 // noinspection ReturnInsideFinallyBlock
   615                 Log.debug(ex.getMessage());
   610                 Log.debug(ex.getMessage());
   616                 return null;
   611                 return null;
   617             }
   612             }
   618         }
   613         }
   619     }
   614     }
   620 
   615 
   621     protected void cleanupConfigFiles(Map<String, ? super Object> params) {
   616     protected void cleanupConfigFiles(Map<String, ? super Object> params) {
   622         if(!StandardBundlerParam.ECHO_MODE.fetchFrom(params)) {
   617         if (getConfig_ProjectFile(params) != null) {
   623             if (getConfig_ProjectFile(params) != null) {
   618             getConfig_ProjectFile(params).delete();
   624                 getConfig_ProjectFile(params).delete();
   619         }
   625             }
   620         if (getConfig_Script(params) != null) {
   626             if (getConfig_Script(params) != null) {
   621             getConfig_Script(params).delete();
   627                 getConfig_Script(params).delete();
       
   628             }
       
   629         }
   622         }
   630     }
   623     }
   631 
   624 
   632     // name of post-image script
   625     // name of post-image script
   633     private File getConfig_Script(Map<String, ? super Object> params) {
   626     private File getConfig_Script(Map<String, ? super Object> params) {
  1157                 "-nologo",
  1150                 "-nologo",
  1158                 getConfig_ProjectFile(params).getAbsolutePath(),
  1151                 getConfig_ProjectFile(params).getAbsolutePath(),
  1159                 "-ext", "WixUtilExtension",
  1152                 "-ext", "WixUtilExtension",
  1160                 "-out", candleOut.getAbsolutePath());
  1153                 "-out", candleOut.getAbsolutePath());
  1161         pb = pb.directory(WIN_APP_IMAGE.fetchFrom(params));
  1154         pb = pb.directory(WIN_APP_IMAGE.fetchFrom(params));
  1162         IOUtils.exec(pb, ECHO_MODE.fetchFrom(params));
  1155         IOUtils.exec(pb, false);
  1163 
  1156 
  1164         Log.verbose(MessageFormat.format(I18N.getString(
  1157         Log.verbose(MessageFormat.format(I18N.getString(
  1165                 "message.generating-msi"), msiOut.getAbsolutePath()));
  1158                 "message.generating-msi"), msiOut.getAbsolutePath()));
  1166 
  1159 
  1167         boolean enableLicenseUI = (getLicenseFile(params) != null);
  1160         boolean enableLicenseUI = (getLicenseFile(params) != null);
  1189 
  1182 
  1190         // create .msi
  1183         // create .msi
  1191         pb = new ProcessBuilder(commandLine);
  1184         pb = new ProcessBuilder(commandLine);
  1192 
  1185 
  1193         pb = pb.directory(WIN_APP_IMAGE.fetchFrom(params));
  1186         pb = pb.directory(WIN_APP_IMAGE.fetchFrom(params));
  1194         IOUtils.exec(pb, ECHO_MODE.fetchFrom(params));
  1187         IOUtils.exec(pb, false);
  1195 
  1188 
  1196         candleOut.delete();
  1189         candleOut.delete();
  1197         IOUtils.deleteRecursive(tmpDir);
  1190         IOUtils.deleteRecursive(tmpDir);
  1198 
  1191 
  1199         return msiOut;
  1192         return msiOut;