[PATCH]: jpackage fails to add DMG volume icon on macOS
Johan Kaving
johan at kaving.se
Mon Mar 16 21:48:55 UTC 2020
Hi,
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:
https://github.com/andreyvit/create-dmg/issues/57
It was fixed in this commit:
https://github.com/andreyvit/create-dmg/commit/bb4651bc1bc8c9e3571ca17fe43e51cf6979e0d2
and according to this comment the fix works for at least macOS 10.9-10.13:
https://github.com/andreyvit/create-dmg/issues/57#issuecomment-425031425
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":
https://books.google.se/books?id=t0snCgAAQBAJ&pg=PA33&lpg=PA33&dq=applescript+%22registering+applications%22&source=bl&ots=ffSt6a-J8E&sig=ACfU3U3jG6p0CSqAGr2nQ-TjAwF097Fw7g&hl=en&sa=X&ved=2ahUKEwiIgd_y5JboAhVP-yoKHegLBccQ6AEwAXoECAoQAQ#v=onepage&q=applescript%20%22registering%20applications%22&f=false
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
either."
The description of the update command is:
"Update the display of the specified object(s) to match their on-disk
representation"
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
approach.
- 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