JDK-8165630 Independent Background Images cannot be specified for Mac DMG and PKG bundlers

This is a workaround for JDK-8165630 reported in September 2016 using AEM Toolbox as example.
Details can be found in issue #37 (Doesn't appear to be a way to specify different backgrounds for a Mac Disk Image and a Mac Installer Package) for javafx-gradle-plugin.

Problem

Only one background image can be provided for both DMG and PKG bundles when using javafxpackager, but DMG and PKG bundles should have different backgrounds:

background image for DMG
(AEM Toolbox-background_dmg.png)
background image for PKG
(AEM Toolbox-background_pkg.png)

Solution

  1. Create background images for each bundle
    (AEM Toolbox-background_dmg.png and AEM Toolbox-background_pkg.png)
  2. cat both images into one mosaic file:
    cat "AEM Toolbox-background_dmg.png" "AEM Toolbox-background_pkg.png" > "AEM Toolbox-background.png"
  3. hook shell script (AEM Toolbox-post-image.sh) into build, detect context and write out one or the other into AEM Toolbox-background.png

AEM Toolbox-post-image.sh:


BACKGROUND="AEM Toolbox-background.png"
BYTES_DMG_PNG=969
BYTES_PKG_PNG=2505
BUILD_MARKER=distribution.dist

mv "$BACKGROUND" mosaic

if [ -f "$BUILD_MARKER" ]
then
    echo "pkg build"
    dd if=mosaic of="$BACKGROUND" bs=$BYTES_DMG_PNG skip=1
else
    echo "dmg build"
    dd if=mosaic of="$BACKGROUND" bs=$BYTES_DMG_PNG count=1
fi

rm -f mosaic

Files in src/main/deploy/package/macosx/:


AEM Toolbox-background.png
AEM Toolbox-background_dmg.png
AEM Toolbox-background_pkg.png
AEM Toolbox-dmg-setup.scpt
AEM Toolbox-post-image.sh
AEM Toolbox-volume.icns
AEM Toolbox.icns

Result

DMG (AEM Toolbox-0.0.1.dmg)
PKG (AEM Toolbox-0.0.1.pkg)

Tagged with: