[PATCH]: jpackage fails to add DMG volume icon on macOS

Johan Kaving johan at kaving.se
Mon Mar 16 21:48:55 UTC 2020


The jpackage tool on macOS supports adding a custom volume icon to DMGs
that it produces, but this functionality is currently broken.

** Analysis
A custom volume icon added as "*-volume.icns" in the resource directory
gets copied to the temporary DMG when building but is removed when the
DMGsetup.scpt script is run.
Specifically it is the line:

    update without registering applications

at the end of the script that seems to remove it.
It is unclear what this line is for. Many DMG creation scripts found by
googling includes it, but not all.

The same problem is reported here:
It was fixed in this commit:

and according to this comment the fix works for at least macOS 10.9-10.13:
I have verified the fix, and an alternative (see below), on macOS 10.15.

A Google search for "update without registering applications" turns up the
book "AppleScript: A Comprehensive Guide to Scripting and Automation on Mac
OS X":

The book uses the "update" command as an example of the AppleScript
dictionary and includes this section:

    "The optional parameters are _necessity_, which is explained well, and
_registering applications_,
     which I have no idea what it's good for or what it does.
     The dictionary author either got a bit lazy, or simply didn't know

The description of the update command is:

    "Update the display of the specified object(s) to match their on-disk

Since the jpackage DMGsetup.scpt script closes the window just after using
the update command there doesn't seem to be much point in updating the
display of the window.

** Patches
I have tried two alternative ways to fix this problem and both are attached
as patches to this email.
Both of these fixes work, but I guess the first one is the simpler

- macos_dmg_volume_icon_fix_1.patch
This patch simply removes the "update without registering applications"
line from DMGsetup.scpt.

- macos_dmg_volume_icon_fix_2.patch
This patch changes the order of the code in MacDmgBundler.java so that the
volume icon is added after running the DMGsetup.scpt script.
This also fixes the problem.

** Unit test
- macos_dmg_volume_icon_test.patch
I am attaching a jtreg unit test showing the problem as a separate patch.

** OCA
I have previously signed an OCA for the OpenJFX project, and if I
understand the contribution document correctly that should be enough for
OpenJDK as well.

/Johan Kaving

More information about the core-libs-dev mailing list