Question

My company ships a package containing several Qt-based MacOS/X GUI applications; the package ships as a .dmg file, and "installation" consists of double-clicking the .dmg icon, then dragging one or more application icons to where he wants to keep them (e.g. to his own Applications folder).

This works fine, but the .dmg file is rather large (e.g. 40+MB) and I'd like to reduce its size if possible, in order to reduce the time it takes to download it. One thing I notice is that the applications in the package all have a significant number of large files in common (Qt libraries, graphic resource files, etc), and that currently we are including a separate copy of each of these files inside the blah.app/Contents folder of each included application -- presumably this is what makes the .dmg file so large.

So my question is, is there any way to modify the .dmg so that it doesn't need to include several copies of these files, and thus isn't so big? Ideally I'd like to do this without requiring the user to run a special installer program, and without causing any of the applications to break if the user moves them to different (or unexpected) folders, or deletes any of them.

It seems like this would be an ideal application for hard-links -- i.e. prepare the input to the .dmg file such that one application contains the actual files, and the other applications contain hard-links to those files, so that after the user unpacks the applications from the .dmg file the files remain logically independent of each other (and in particular application B won't stop working if the user moves or deletes application A). But AFAICT MacOS/X doesn't support hard-links [edit: to directories] for applications that aren't named Time Machine. :^(

Was it helpful?

Solution

(it feels vaguely immoral to answer my own question, but since I came to a solution I'll do it anyway, rather than leave the question hanging open)

The solution is to replace the duplicate files with hard-links to the first-encountered file, before running hdiutil to create the .dmg file. I did this using a simple C++ program that I wrote for the purpose (just because I'm stubborn that way), but there are also a number of freeware programs such as freedup that will do this for you. I didn't try them, but I imagine they all work fine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top