Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I've noticed that many downloads are a dmg (disk image) that contains a single pkg file (installation package). Usually the pkg seems to be already compressed since the dmg doesn't reduce the file size much if any.

Example:

A savings of 737,658 bytes, or 0.6% of the original file size.

Is there a reason not to just distribute the pkg? Is the 0.6% compression savings that important? Or is it just the way things have always been done on the Mac?

(Yes, I realize that 737,658 bytes times all the millions of downloads that dmg gets does add up, but it just always seems annoying to have that extra steps in there to mount a dmg, run the installer and then unmount the dmg. Maybe a better question is "why doesn't Mac OS X recognize a dmg with a single pkg inside it as just a pkg and simply install it without requiring all that mounting and unmounting?")

share|improve this question
    
Actually modern packages are flat files, not folders. So putting them in a dmg just to provide a flat file is no longer necessary. –  mlaster Nov 9 '11 at 17:48
    
@mlaster That doesn't appear to be true. Do you have an example? –  Gerry Nov 11 '11 at 17:24
1  
radiosilenceapp.com/downloads/Private%20Eye.pkg is one example, as is JavaForMacOSX10.7.pkg (although Apple still has it as a .dmg when it is ready for download). I have several others in my Downloads archive, but it's definitely not universal yet. file lists them as "xar archive - version 1" But then there's the issue of making sure that the web server is setup to force .pkg files to download rather than display. (I expect some devs use .zip instead of .dmg for the same reason - even the worst configured web servers and browsers know to download .zip files). –  TJ Luoma Nov 16 '11 at 16:56
    
However, even once we got flat files, lots of developers put .pkg files inside a .zip because they can count on servers to have their MIME type set correctly for .zip files but not necessarily for .pkg (or .dmg for that matter). –  TJ Luoma Dec 11 '13 at 18:33

3 Answers 3

up vote 18 down vote accepted

Technically, a .pkg is not a file, but a folder. So maybe collecting it into a single file is essential for downloading.

share|improve this answer
    
I didn't even realize this, but you hit the nail on the head. –  Gerry Nov 9 '11 at 16:33
    
Didn't know that about a .pkg either. Knowing that it all makes sense. Thanks! –  Jim McKeeth Nov 14 '11 at 17:41
    
Packing it into a dmg means any OS X extended file attributes and/or resource forks are preserved and you can serve it from a non-OS X webserver. It is also why the package format was updated to include flat files in recent versions of OS X. –  Joe Block Feb 17 at 0:02

Data on DMG image can be checked for integrity with Disk utility. You can make it mandatory for the user to agree to license before mounting dmg. It could be locked from modification. You can easily add hidden files and folders on DMG. You can make background image. You can make it safe from stripping during transit through non-metadata aware file systems like FAT.

Plenty of reasons actually.

share|improve this answer
    
All cool features of a DMG, but they don't add anything to a PKG unless they seriously cannot verify their own integrity. –  Jim McKeeth Nov 9 '11 at 13:23

One possible reason could be that Safari by default automatically mounts DMG files, and that a Finder window would pop up with the contents. In turn the DMG folder could be styled with for example a background image. I assume that could be considered more user-friendly than having to look in your Downloads folder for an installer, but I agree it's pretty moot.

Another reason would be the ability to group together other supporting files as well, for example documentation files or even secondary installers.

However, it's not such a common distribution to start with. The majority of apps are distributed as self-contained .app folders inside a DMG file (if not via the App Store now). Your example seems to be rather an exception to me, though maybe it is more common with some particular distribution channels? Personally, I wouldn't dwell on it much further.

share|improve this answer
    
+ 1 for the last paragraph - I thought due to som trojans .dmg s are not (definitely should not) be automatically mounted –  Mark Nov 9 '11 at 15:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.