< prev index next >

src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacPkgBundler.java

Print this page




 194 
 195     private File getScripts_PostinstallFile(
 196             Map<String, ? super Object> params) {
 197         return new File(SCRIPTS_DIR.fetchFrom(params), "postinstall");
 198     }
 199 
 200     private String getAppIdentifier(Map<String, ? super Object> params) {
 201         return IDENTIFIER.fetchFrom(params);
 202     }
 203 
 204     private String getDaemonIdentifier(Map<String, ? super Object> params) {
 205         return IDENTIFIER.fetchFrom(params) + ".daemon";
 206     }
 207 
 208     private void preparePackageScripts(Map<String, ? super Object> params)
 209             throws IOException {
 210         Log.verbose(I18N.getString("message.preparing-scripts"));
 211 
 212         Map<String, String> data = new HashMap<>();
 213 
 214         data.put("DEPLOY_DAEMON_IDENTIFIER", getDaemonIdentifier(params));
 215         data.put("DEPLOY_LAUNCHD_PLIST_FILE",
 216                 IDENTIFIER.fetchFrom(params).toLowerCase() + ".launchd.plist");
 217 
 218         Writer w = new BufferedWriter(
 219                 new FileWriter(getScripts_PreinstallFile(params)));
 220         String content = preprocessTextResource(
 221                 getScripts_PreinstallFile(params).getName(),
 222                 I18N.getString("resource.pkg-preinstall-script"),
 223                 TEMPLATE_PREINSTALL_SCRIPT,
 224                 data,
 225                 VERBOSE.fetchFrom(params),
 226                 RESOURCE_DIR.fetchFrom(params));
 227         w.write(content);
 228         w.close();
 229         getScripts_PreinstallFile(params).setExecutable(true, false);
 230 
 231         w = new BufferedWriter(
 232                 new FileWriter(getScripts_PostinstallFile(params)));
 233         content = preprocessTextResource(
 234                 getScripts_PostinstallFile(params).getName(),
 235                 I18N.getString("resource.pkg-postinstall-script"),
 236                 TEMPLATE_POSTINSTALL_SCRIPT,


 361             File outdir, File appLocation) {
 362         // generic find attempt
 363         try {
 364             File appPKG = getPackages_AppPackage(params);
 365 
 366             // Generate default CPL file
 367             File cpl = new File(CONFIG_ROOT.fetchFrom(params).getAbsolutePath()
 368                     + File.separator + "cpl.plist");
 369             ProcessBuilder pb = new ProcessBuilder("pkgbuild",
 370                     "--root",
 371                     appLocation.getParent(),
 372                     "--install-location",
 373                     MAC_INSTALL_DIR.fetchFrom(params),
 374                     "--analyze",
 375                     cpl.getAbsolutePath());
 376 
 377             IOUtils.exec(pb, false);
 378 
 379             patchCPLFile(cpl);
 380 


 381             // build application package
 382             pb = new ProcessBuilder("pkgbuild",
 383                     "--root",
 384                     appLocation.getParent(),
 385                     "--install-location",
 386                     MAC_INSTALL_DIR.fetchFrom(params),
 387                     "--component-plist",
 388                     cpl.getAbsolutePath(),


 389                     appPKG.getAbsolutePath());
 390             IOUtils.exec(pb, false);
 391 
 392             // build final package
 393             File finalPKG = new File(outdir, INSTALLER_NAME.fetchFrom(params)
 394                     + INSTALLER_SUFFIX.fetchFrom(params)
 395                     + ".pkg");
 396             outdir.mkdirs();
 397 
 398             List<String> commandLine = new ArrayList<>();
 399             commandLine.add("productbuild");
 400 
 401             commandLine.add("--resources");
 402             commandLine.add(CONFIG_ROOT.fetchFrom(params).getAbsolutePath());
 403 
 404             // maybe sign
 405             if (Optional.ofNullable(MacAppImageBuilder.
 406                     SIGN_BUNDLE.fetchFrom(params)).orElse(Boolean.TRUE)) {
 407                 if (Platform.getMajorVersion() > 10 ||
 408                     (Platform.getMajorVersion() == 10 &&




 194 
 195     private File getScripts_PostinstallFile(
 196             Map<String, ? super Object> params) {
 197         return new File(SCRIPTS_DIR.fetchFrom(params), "postinstall");
 198     }
 199 
 200     private String getAppIdentifier(Map<String, ? super Object> params) {
 201         return IDENTIFIER.fetchFrom(params);
 202     }
 203 
 204     private String getDaemonIdentifier(Map<String, ? super Object> params) {
 205         return IDENTIFIER.fetchFrom(params) + ".daemon";
 206     }
 207 
 208     private void preparePackageScripts(Map<String, ? super Object> params)
 209             throws IOException {
 210         Log.verbose(I18N.getString("message.preparing-scripts"));
 211 
 212         Map<String, String> data = new HashMap<>();
 213 
 214         data.put("INSTALL_LOCATION", MAC_INSTALL_DIR.fetchFrom(params));


 215 
 216         Writer w = new BufferedWriter(
 217                 new FileWriter(getScripts_PreinstallFile(params)));
 218         String content = preprocessTextResource(
 219                 getScripts_PreinstallFile(params).getName(),
 220                 I18N.getString("resource.pkg-preinstall-script"),
 221                 TEMPLATE_PREINSTALL_SCRIPT,
 222                 data,
 223                 VERBOSE.fetchFrom(params),
 224                 RESOURCE_DIR.fetchFrom(params));
 225         w.write(content);
 226         w.close();
 227         getScripts_PreinstallFile(params).setExecutable(true, false);
 228 
 229         w = new BufferedWriter(
 230                 new FileWriter(getScripts_PostinstallFile(params)));
 231         content = preprocessTextResource(
 232                 getScripts_PostinstallFile(params).getName(),
 233                 I18N.getString("resource.pkg-postinstall-script"),
 234                 TEMPLATE_POSTINSTALL_SCRIPT,


 359             File outdir, File appLocation) {
 360         // generic find attempt
 361         try {
 362             File appPKG = getPackages_AppPackage(params);
 363 
 364             // Generate default CPL file
 365             File cpl = new File(CONFIG_ROOT.fetchFrom(params).getAbsolutePath()
 366                     + File.separator + "cpl.plist");
 367             ProcessBuilder pb = new ProcessBuilder("pkgbuild",
 368                     "--root",
 369                     appLocation.getParent(),
 370                     "--install-location",
 371                     MAC_INSTALL_DIR.fetchFrom(params),
 372                     "--analyze",
 373                     cpl.getAbsolutePath());
 374 
 375             IOUtils.exec(pb, false);
 376 
 377             patchCPLFile(cpl);
 378 
 379             preparePackageScripts(params);
 380 
 381             // build application package
 382             pb = new ProcessBuilder("pkgbuild",
 383                     "--root",
 384                     appLocation.getParent(),
 385                     "--install-location",
 386                     MAC_INSTALL_DIR.fetchFrom(params),
 387                     "--component-plist",
 388                     cpl.getAbsolutePath(),
 389                     "--scripts",
 390                     SCRIPTS_DIR.fetchFrom(params).getAbsolutePath(),
 391                     appPKG.getAbsolutePath());
 392             IOUtils.exec(pb, false);
 393 
 394             // build final package
 395             File finalPKG = new File(outdir, INSTALLER_NAME.fetchFrom(params)
 396                     + INSTALLER_SUFFIX.fetchFrom(params)
 397                     + ".pkg");
 398             outdir.mkdirs();
 399 
 400             List<String> commandLine = new ArrayList<>();
 401             commandLine.add("productbuild");
 402 
 403             commandLine.add("--resources");
 404             commandLine.add(CONFIG_ROOT.fetchFrom(params).getAbsolutePath());
 405 
 406             // maybe sign
 407             if (Optional.ofNullable(MacAppImageBuilder.
 408                     SIGN_BUNDLE.fetchFrom(params)).orElse(Boolean.TRUE)) {
 409                 if (Platform.getMajorVersion() > 10 ||
 410                     (Platform.getMajorVersion() == 10 &&


< prev index next >