Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build a dmg Mac OS X file (on a non-Mac platform)?

Is it possible to build a .dmg file (for distributing apps) from a non-Mac platform? And if yes, how?

like image 493
michelemarcon Avatar asked Nov 13 '08 07:11

michelemarcon


People also ask

Is DMG only for Mac?

DMG files are for Mac and EXE files are for Windows, so the only way to use a DMG program on Windows is to download its equivalent from the developer (if one exists); there aren't any DMG file to EXE file converters.

Can I install OSX from DMG file?

Double-click the DMG file to make its content available (the name will show up in the Finder sidebar), and a window generally opens also showing the content. Drag the application from the DMG window into the Applications directory to install (you may need an administrator password). Wait for the copy process to finish.


2 Answers

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.

like image 108
jstck Avatar answered Sep 21 '22 15:09

jstck


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 
like image 31
uckelman Avatar answered Sep 18 '22 15:09

uckelman