MacOS – .dmg files organization

dmgmacospkg

Today I needed to view the contents of OS X's SDKs, which are published as .dmg's.

To my surprise, I discovered that the structure is as follows :

  • The .dmg contains a hidden .pkg files
  • The .pkg files contain a Payload file, which is a .gz or a .bz2, depends
  • The .gz contains a single cpio-compressed file
  • This cpio archive contains all the files.

Can anybody provide technical and/or historical reasons why this is done this way ?

Just to be clear : I don't have any technical problem, I'm just curious.

Best Answer

  • The .dmg is the disk image which is mountable like an external file. The value it provides here is that .dmgs are checked for consistency/correctness upon mount, so if the download went wrong you will get notified
  • The .pkg is the standard format for installable software and usually contains not only the application itself but all the other stuff displayed during installation: ReadMe, legal/license information, optional packages etc.
  • The .gz is to compress the data and keep the packages smaller on disk (and for download)
  • .cpio is an archive format similar to tar etc.