JarBundler - Creating a Disk Image

I'm writing to contribute a shell script which creates a disk image via terminal commands. I wrote it a few years ago so I can't quite explain how it works and likely needs some cleanup - but it basically does the job. It doesn't support a background image yet nor icon positioning.

Thanks,
Philip Weaver


<exec dir="." os="Mac OS X" executable="/bin/sh">
	<arg value="-c"/>
	<arg value="./scripts/mkdmg.sh /Users/Me/Development/ ./mac/ ./mac-image/ Project"/>
</exec>
<gzip zipfile="${dist}/mac-image/MyTool .dmg.gz" src="${dist}/mac-image/MyTool.dmg"/>

mkdmg.sh

#!/bin/sh

BASE="$1"
SRC="$2"
DEST="$3"
VOLUME="$4"

echo Base Directory $1
echo Source $2
echo Destination $3
echo Volume $4

TEMP="TEMPORARY"

cd BASE

hdiutil create -megabytes 5 $DEST$TEMP.dmg -layout NONE
MY_DISK=`hdid -nomount $DEST$TEMP.dmg`
newfs_hfs -v $VOLUME $MY_DISK
hdiutil eject $MY_DISK
hdid $DEST$TEMP.dmg
chflags -R nouchg,noschg "$SRC"
ditto -rsrcFork -v "$SRC" "/Volumes/$VOLUME"
#ditto -rsrcFork -v "./background/" "/Volumes/$VOLUME"
hdiutil eject $MY_DISK
hdiutil convert -format UDCO $DEST$TEMP.dmg -o $DEST$VOLUME.dmg
hdiutil internet-enable -yes $DEST$VOLUME.dmg