michelemarcon
michelemarcon

Reputation: 24767

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?

Upvotes: 65

Views: 72272

Answers (7)

uckelman
uckelman

Reputation: 26224

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

Note: The libdmg-hfsplus repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Upvotes: 37

name
name

Reputation: 101

git clone https://github.com/hamstergene/libdmg-hfsplus
cd libdmg-hfsplus && cmake . && make && cd dmg
./dmg --help

Makefile:

dmg:
    genisoimage -D -V "$(PROJECT) $(VERSION)" -no-pad -r -apple -o project-$(VERSION)-uncompressed.dmg $(DARWIN_DIR)
    ./dmg dmg project-$(VERSION)-uncompressed.dmg project-$(VERSION).dmg

uncompressed works out of the box, compression may cause problems - the origin/master at least produces a 'checksum' error on snow-leopard

Upvotes: 10

MattWeiler
MattWeiler

Reputation: 790

I'm not sure if anyone is still watching this thread, but I tried TransMac as recommended by Nik Reiman.

Using this tool I was able to, running on Windows 7, create dmg files which were mountable on OSX 10.8.3.


Downside

The only downside for us is that this tool doesn't appear to be command-line friendly; for us that's a deal-breaker as we need to be able to have an automated tool which our build server (Windows based) can use to build dmg files on-the-fly.

Upvotes: 4

jstck
jstck

Reputation: 501

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.

Upvotes: 39

Josh
Josh

Reputation: 29

See mkfs.hfsplus

Upvotes: 2

Nik Reiman
Nik Reiman

Reputation: 40390

It does seem possible to create DMG files with some third party tools. A quick google search reveals at least a few commercial tools:

Not sure about any OSS/freeware options, but it does at least seem possible if you are so inclined.

Edit: I also forgot about MacDrive, which is another great tool for working with HFS+ filesystems under windows. Since a DMG is basically just a HFS+ filesystem snapshot, it is probably possible with MacDrive to create DMG's as well.

Upvotes: 8

Sherm Pendley
Sherm Pendley

Reputation: 13612

If you're distributing Mac apps, then surely you have a Mac to write and test them. Why not simply use that same Mac to create the disk image?

[Edit] Alternatively, if you're distributing a portable app, for example a Java .jar file, why bother with a disk image? Macs understand .zip and .tar.gz archives just fine.

I guess what I'm getting at is, I don't understand how one might need a DMG disk image, but not have a Mac with which to create it.

Upvotes: -39

Related Questions