1 # Create a read-only disk image of the contents of a folder
3 # Usage: make-diskimage <image_file>
12 DMG_DIRNAME
=`dirname $1`
13 DMG_DIR
=`cd $DMG_DIRNAME > /dev/null; pwd`
14 DMG_NAME
=`basename $1`
15 DMG_TEMP_NAME
=${DMG_DIR}/rw.
${DMG_NAME}
16 SRC_FOLDER
=`cd $2 > /dev/null; pwd`
25 echo "Creating disk image..."
26 rm -f "${DMG_TEMP_NAME}"
27 hdiutil create
-srcfolder "${SRC_FOLDER}" -volname "${VOLUME_NAME}" -fs HFS+ -fsargs "-c c=64,a=16,e=16" -format UDRW "${DMG_TEMP_NAME}"
30 echo "Mounting disk image..."
31 MOUNT_DIR
="/Volumes/${VOLUME_NAME}"
32 DEV_NAME
=`hdiutil attach -readwrite -noverify -noautoopen "${DMG_TEMP_NAME}" | egrep '^/dev/' | sed 1q | awk '{print $1}'`
34 cp RightDS_Store
"/Volumes/${VOLUME_NAME}/.DS_Store"
37 if [ ! -z "${APPLESCRIPT}" -a "${APPLESCRIPT}" != "-null-" ]; then
38 # osascript "${APPLESCRIPT}"
39 # pass the applescript our volume name and our artwork path, to its process_disk_image function
40 echo "Running Applescript: ./AdiumApplescriptRunner \"${APPLESCRIPT}\" process_disk_image \"${VOLUME_NAME}\""
41 .
/AdiumApplescriptRunner
"${APPLESCRIPT}" process_disk_image "${VOLUME_NAME}" "${ART_PATH}" || true
42 echo "Done running the applescript..."
47 # if [ ! -z "${SHELLSCRIPT}" -a "${SHELLSCRIPT}" != "-null-" ]; then
48 # ./${SHELLSCRIPT} \"${VOLUME_NAME}\"
51 # make sure it's not world writeable
52 echo "Fixing permissions..."
53 chmod -Rf go-w
"${MOUNT_DIR}" || true
55 # make the top window open itself on mount:
56 if [ -x /usr
/local
/bin
/openUp
]; then
57 /usr
/local
/bin
/openUp
"${MOUNT_DIR}"
61 echo "Unmounting disk image..."
62 hdiutil detach
"${DEV_NAME}"
65 echo "Compressing disk image..."
66 hdiutil convert
"${DMG_TEMP_NAME}" -format UDZO -imagekey zlib-level=9 -o "${DMG_DIR}/${DMG_NAME}"
67 rm -f "${DMG_TEMP_NAME}"
69 # adding EULA resources
70 if [ ! -z "${EULA_RSRC}" -a "${EULA_RSRC}" != "-null-" ]; then
71 echo "adding EULA resources"
72 hdiutil unflatten
"${DMG_DIR}/${DMG_NAME}"
73 /Developer
/Tools
/ResMerger
-a "${EULA_RSRC}" -o "${DMG_DIR}/${DMG_NAME}"
74 hdiutil flatten
"${DMG_DIR}/${DMG_NAME}"
77 echo "Disk image done"