[PATCH]: jpackage fails to add DMG volume icon on macOS
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/bb4651bc1bc8c9e3571ca17fe43e5... 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=applescrip... 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
participants (1)
-
Johan Kaving