The problem is that actually building such a DMG isn't too obvious. Notably, it's very difficult to get the DMG configured in such a way that it always opens to the right size, and showing its icons, not a list of files. There a number of methods on the web showing various ways of doing this, but most of them are very complex. This is my (fairly) simple way, without using any exotic tools:
- This assumes you have an application, and a background (in e.g., PNG form) that you want displayed when your DMG is mounted. I used InkScape to build this one, based on the FireFox one.
- Create a new image using Disk Utility, leaving all the options at their defaults, sized such that it will contain all your files.
- Create a folder inside the mounted DMG and name it “background”. Drop the background PNG into this.
- Hide the background folder (aka rename with a leading .) - I use X-Folders to this, but you can do it from the command line as well.
- Drop your app into the root of the DMG.
- From the View menu of Finder, choose Show View Options, and customize the view to show icons only, no sideview, etc. Also switch off the toolbar in the view menu.
- Set the window background to picture, and use Cmd-Shift-G in combination with the full path (e.g. /Volumes/MyDisk/.background) to set your background PNG as the background for the view.
- Move the app icon into the right place versus the background image, changing the font size and the dimensions of the icons.
- Now just add a shortcut to the Application Folder, place it inside the DMG, and then position the shortcut.
- Do a final resize on the Window such that it is the same size of your background. Your DMG should now look as you expect.
- Eject the DMG, then go to Disk Utilities, select the DMG and choose “convert“, then “compression” and save again. Now the DMG is compressed (as small as possible) and made unwritable. Note that's its a really good idea to save to a different name, so that you can use the uncompressed DMG as a template for future releases, and not have to go through this whole process again.
- That's it
NOTE: Unless the DMG is compressed, it will revert to the default format on opening. But in order to edit it, you have to convert it back to read/write, else changes won't stick. Keep track of what state its in, because there's no obvious way to tell.....
If you need to create a new DMG for a subsequent release, you can just delete the old application from the uncompressed DNG, and then copy the new version of the application to the DMG. Warning: you MUST use either command line, or something like X-Folders to delete the file, rather than move it to the trash as the Mac OS X finder will do. Using Finder will create a trash folder inside the DMG. Once you have a trash in a DMG, it's nearly impossible to get rid of, and you'll have to rebuild the whole DMG.
View comments