Many applications in Mac OS X do not require a special installer. Often, they can be installed by simply dragging the application's folder or icon to a convenient location in the directory structure, usually the /Applications folder. Applications that are distributed this way are typically packaged as a disk image . A disk image is a file that, when double-clicked, creates a virtual volume that is mounted as shown in Figure 12-6.
Figure 12-6. A disk image and its mounted volume![]()
Disk images can be created by using Disk Utility ( /Applications/Utilities ) or via the command line (described later). There are two types of disk images. One is a dual fork disk image with an .img extension, and the other is a single fork disk image with a .dmg extension. A dual fork disk image requires additional (MacBinary) encoding in order for it to be transferred across networks. The single fork version is preferred for distributing software in Mac OS X, as it requires no additional encoding and, as we shall see later, can be "Internet-enabled." The Unix command df reveals a disk image as a mounted volume that will appear in the /Volumes directory. When you are done with the mounted volume, unmount it by clicking on the volume (in Figure 12-6, the mounted volume is named Fink 0.6.2 Installer) to select it and choose File
12.3.1 Creating a Disk Image with Disk UtilityTo create a disk image using Disk Utility, perform the following steps:
Figure 12-7. Creating a new blank image with Disk Utility![]()
Figure 12-8. A blank Disk Image, ready to be loaded up with files![]()
Figure 12-9. Copying the file to the Disk Image![]()
Figure 12-10. Choosing the image to convert in Disk Utility![]()
Figure 12-11. Converting an image![]()
12.3.2 Creating a Disk Image from the Command LineThe following example illustrates how to create a disk image at the command line:
Whenever you want to mount this volume again, double-click the file Ready4Dist.dmg in the finder. Note that the writable disk image Sample.dmg is not destroyed in this process. 12.3.3 Distributing Your Image Once you've created a disk image, you can share it with the world. Put the image up on a web server or FTP server for others to enjoy, share it on your iDisk, or burn it to a CD using Disk Utility (select File 12.3.3.1 Internet-enabled disk imagesAn Internet-enabled disk image is a read-only disk image that cleans up after itself, leaving only the software and no by-products of the download. If you distribute your software as an Internet-enabled disk image, the user just needs to perform these steps:
The disk image is mounted in a hidden location until its contents are copied to the user's default download folder, which is typically the Desktop folder. If the disk image contains a single file, only this file is copied. On the other hand, if the disk image contains more than one file, a new folder is created in the download folder bearing the root name of the .dmg file. Files contained in the disk image are then copied to this folder. For example, if the Internet-enabled disk image containing multiple files is named Sample.dmg , a folder named Sample will be created in the download folder and the files contained in the disk image will be copied to the Sample folder. In this scheme, the user does not deal directly with the .dmg file (other than initiating the download). This is in contrast to the situation before Internet-enabled disk images were supported, in which the user had to manually unmount the disk image and drag it to the Trash. To create an Internet-enabled disk image, first create a read-only .dmg formatted disk image as described earlier ( neither read-write disk images nor older .img / .smi formats can be Internet-enabled), then set the Internet-enabled flag with the hdiutil command: $ hdiutil internet-enable -yes Ready4Dist.dmg If you want to disable the Internet-enabled flag, enter this command: $ hdiutil internet-enable -no Ready4Dist.dmg If you are not sure how a disk image has its Internet-enabled flag set, the following command reveals this information: $ hdiutil internet-enable -query Ready4Dist.dmg As noted earlier, Internet-enabled disk images are moved to the Trash after they are downloaded and acted upon by Mac OS X. Although their Internet-enabled flags are set to No during the process, you can still rescue .dmg files from the Trash in case you want to reinstall the software later. ![]() |