#!/bin/sh -x # invoke this script like: create_dmg image_name "Volume Name" # it will produce image_name.dmg if [ $# -ne 2 ] then echo "Please specify an image name and a volume name. I'm no good at this sort of thing." exit fi # if a previous copy of the image exists, remove it rm -f build/$1.dmg # remove those .DS_Store files find . -name ".DS_Store" | xargs rm # create the image. My software fits on a 5MB image hdiutil create build/$1.dmg -size 05m -fs HFS+ -volname "$2" # mount the image and store the device name into dev_handle dev_handle=`hdid build/$1.dmg | grep Apple_HFS | perl -e '\$_=<>; /^\\/dev\\/(disk.)/; print \$1'` # copy the software onto the disk cp -R "build/Release/Hex Fiend.app" "/Volumes/$2/" # unmount the volume hdiutil detach $dev_handle # compress the image hdiutil convert build/$1.dmg -format UDZO -o build/$1.udzo.dmg # remove the uncompressed image rm -f build/$1.dmg # move the compressed image to take its place mv build/$1.udzo.dmg build/$1.dmg # Internet-enable it hdiutil internet-enable -yes build/$1.dmg