How to build a dmg Mac OS X file (on a non-Mac platform)?
Yep, mkfs.hfsplus does it.
dd if=/dev/zero of=/tmp/foo.dmg bs=1M count=64
mkfs.hfsplus -v ThisIsFoo /tmp/foo.dmg
This creates a dmg file (in this case 64M) that can be mounted on a mac. It can also be mounted on linux, with something like
mount -o loop /tmp/foo.dmg /mnt/foo
after wich you just copy the content you want to it (in /mnt/foo). Unmount it, and the dmg can be copied over to a mac and mounted there.
A project I work on creates DMG files on Linux using genisoimage:
mkdir -p dmgdir/progname.app/Contents/{MacOS,Resources}
...copy your PkgInfo, Info.plist to Contents...
...copy your .icns to Resources...
...copy your other things to where you expect them to go...
genisoimage -V progname -D -R -apple -no-pad -o progname.dmg dmgdir
If you want to be really fancy, you can steal the .DS_Store
file from a DMG made on a Mac with a volume name progname
and app bundle called progname.app
(i.e., matching what you want to create off the Mac) where you've put a background in .background/background.png
and a symbolic link to /Applications in the root dir, and put that in dmgdir
along with your own a symbolic link to /Applications
.
Finally, if you want to create a compressed DMG, get the dmg tool from libdmg-hfsplus:
dmg uncompressed.dmg compressed.dmg