src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacDmgBundler.java
branchJDK-8200758-branch
changeset 57391 970f28090a06
parent 57390 1cb722a11ead
child 57396 3944e4c2f779
equal deleted inserted replaced
57390:1cb722a11ead 57391:970f28090a06
    74                 File configScript = getConfig_Script(params);
    74                 File configScript = getConfig_Script(params);
    75                 if (configScript.exists()) {
    75                 if (configScript.exists()) {
    76                     Log.verbose(MessageFormat.format(
    76                     Log.verbose(MessageFormat.format(
    77                             I18N.getString("message.running-script"),
    77                             I18N.getString("message.running-script"),
    78                             configScript.getAbsolutePath()));
    78                             configScript.getAbsolutePath()));
    79                     IOUtils.run("bash", configScript, false);
    79                     IOUtils.run("bash", configScript);
    80                 }
    80                 }
    81 
    81 
    82                 return buildDMG(params, outdir);
    82                 return buildDMG(params, outdir);
    83             }
    83             }
    84             return null;
    84             return null;
   289                 "-srcfolder", srcFolder.getAbsolutePath(),
   289                 "-srcfolder", srcFolder.getAbsolutePath(),
   290                 "-volname", APP_NAME.fetchFrom(p),
   290                 "-volname", APP_NAME.fetchFrom(p),
   291                 "-ov", protoDMG.getAbsolutePath(),
   291                 "-ov", protoDMG.getAbsolutePath(),
   292                 "-fs", "HFS+",
   292                 "-fs", "HFS+",
   293                 "-format", "UDRW");
   293                 "-format", "UDRW");
   294         IOUtils.exec(pb, false);
   294         IOUtils.exec(pb);
   295 
   295 
   296         // mount temp image
   296         // mount temp image
   297         pb = new ProcessBuilder(
   297         pb = new ProcessBuilder(
   298                 hdiutil,
   298                 hdiutil,
   299                 "attach",
   299                 "attach",
   300                 protoDMG.getAbsolutePath(),
   300                 protoDMG.getAbsolutePath(),
   301                 hdiUtilVerbosityFlag,
   301                 hdiUtilVerbosityFlag,
   302                 "-mountroot", imagesRoot.getAbsolutePath());
   302                 "-mountroot", imagesRoot.getAbsolutePath());
   303         IOUtils.exec(pb, false);
   303         IOUtils.exec(pb);
   304 
   304 
   305         File mountedRoot =
   305         File mountedRoot =
   306                 new File(imagesRoot.getAbsolutePath(), APP_NAME.fetchFrom(p));
   306                 new File(imagesRoot.getAbsolutePath(), APP_NAME.fetchFrom(p));
   307 
   307 
   308         // volume icon
   308         // volume icon
   310         IOUtils.copyFile(getConfig_VolumeIcon(p),
   310         IOUtils.copyFile(getConfig_VolumeIcon(p),
   311                 volumeIconFile);
   311                 volumeIconFile);
   312 
   312 
   313         pb = new ProcessBuilder("osascript",
   313         pb = new ProcessBuilder("osascript",
   314                 getConfig_VolumeScript(p).getAbsolutePath());
   314                 getConfig_VolumeScript(p).getAbsolutePath());
   315         IOUtils.exec(pb, false);
   315         IOUtils.exec(pb);
   316 
   316 
   317         // Indicate that we want a custom icon
   317         // Indicate that we want a custom icon
   318         // NB: attributes of the root directory are ignored
   318         // NB: attributes of the root directory are ignored
   319         // when creating the volume
   319         // when creating the volume
   320         // Therefore we have to do this after we mount image
   320         // Therefore we have to do this after we mount image
   330                 // (might not work on Mac 10.13 with old XCode)
   330                 // (might not work on Mac 10.13 with old XCode)
   331                 pb = new ProcessBuilder(
   331                 pb = new ProcessBuilder(
   332                         setFileUtility,
   332                         setFileUtility,
   333                         "-c", "icnC",
   333                         "-c", "icnC",
   334                         volumeIconFile.getAbsolutePath());
   334                         volumeIconFile.getAbsolutePath());
   335                 IOUtils.exec(pb, false);
   335                 IOUtils.exec(pb);
   336                 volumeIconFile.setReadOnly();
   336                 volumeIconFile.setReadOnly();
   337 
   337 
   338                 pb = new ProcessBuilder(
   338                 pb = new ProcessBuilder(
   339                         setFileUtility,
   339                         setFileUtility,
   340                         "-a", "C",
   340                         "-a", "C",
   341                         mountedRoot.getAbsolutePath());
   341                         mountedRoot.getAbsolutePath());
   342                 IOUtils.exec(pb, false);
   342                 IOUtils.exec(pb);
   343             } catch (IOException ex) {
   343             } catch (IOException ex) {
   344                 Log.error(ex.getMessage());
   344                 Log.error(ex.getMessage());
   345                 Log.verbose("Cannot enable custom icon using SetFile utility");
   345                 Log.verbose("Cannot enable custom icon using SetFile utility");
   346             }
   346             }
   347         } else {
   347         } else {
   353         pb = new ProcessBuilder(
   353         pb = new ProcessBuilder(
   354                 hdiutil,
   354                 hdiutil,
   355                 "detach",
   355                 "detach",
   356                 hdiUtilVerbosityFlag,
   356                 hdiUtilVerbosityFlag,
   357                 mountedRoot.getAbsolutePath());
   357                 mountedRoot.getAbsolutePath());
   358         IOUtils.exec(pb, false);
   358         IOUtils.exec(pb);
   359 
   359 
   360         // Compress it to a new image
   360         // Compress it to a new image
   361         pb = new ProcessBuilder(
   361         pb = new ProcessBuilder(
   362                 hdiutil,
   362                 hdiutil,
   363                 "convert",
   363                 "convert",
   364                 protoDMG.getAbsolutePath(),
   364                 protoDMG.getAbsolutePath(),
   365                 hdiUtilVerbosityFlag,
   365                 hdiUtilVerbosityFlag,
   366                 "-format", "UDZO",
   366                 "-format", "UDZO",
   367                 "-o", finalDMG.getAbsolutePath());
   367                 "-o", finalDMG.getAbsolutePath());
   368         IOUtils.exec(pb, false);
   368         IOUtils.exec(pb);
   369 
   369 
   370         //add license if needed
   370         //add license if needed
   371         if (getConfig_LicenseFile(p).exists()) {
   371         if (getConfig_LicenseFile(p).exists()) {
   372             //hdiutil unflatten your_image_file.dmg
   372             //hdiutil unflatten your_image_file.dmg
   373             pb = new ProcessBuilder(
   373             pb = new ProcessBuilder(
   374                     hdiutil,
   374                     hdiutil,
   375                     "unflatten",
   375                     "unflatten",
   376                     finalDMG.getAbsolutePath()
   376                     finalDMG.getAbsolutePath()
   377             );
   377             );
   378             IOUtils.exec(pb, false);
   378             IOUtils.exec(pb);
   379 
   379 
   380             //add license
   380             //add license
   381             pb = new ProcessBuilder(
   381             pb = new ProcessBuilder(
   382                     hdiutil,
   382                     hdiutil,
   383                     "udifrez",
   383                     "udifrez",
   384                     finalDMG.getAbsolutePath(),
   384                     finalDMG.getAbsolutePath(),
   385                     "-xml",
   385                     "-xml",
   386                     getConfig_LicenseFile(p).getAbsolutePath()
   386                     getConfig_LicenseFile(p).getAbsolutePath()
   387             );
   387             );
   388             IOUtils.exec(pb, false);
   388             IOUtils.exec(pb);
   389 
   389 
   390             //hdiutil flatten your_image_file.dmg
   390             //hdiutil flatten your_image_file.dmg
   391             pb = new ProcessBuilder(
   391             pb = new ProcessBuilder(
   392                     hdiutil,
   392                     hdiutil,
   393                     "flatten",
   393                     "flatten",
   394                     finalDMG.getAbsolutePath()
   394                     finalDMG.getAbsolutePath()
   395             );
   395             );
   396             IOUtils.exec(pb, false);
   396             IOUtils.exec(pb);
   397 
   397 
   398         }
   398         }
   399 
   399 
   400         //Delete the temporary image
   400         //Delete the temporary image
   401         protoDMG.delete();
   401         protoDMG.delete();