Prevent dragging groups into groups. Fixes #8706
[adiumx.git] / Release / make-diskimage.sh
blob2d16cbb42a97a2e8ec5556216d2536f93e132e99
1 # Create a read-only disk image of the contents of a folder
3 # Usage: make-diskimage <image_file>
4 # <src_folder>
5 # <volume_name>
6 # <applescript>
7 # <artpath>
8 # <eula_resource_file>
10 set -e;
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`
17 VOLUME_NAME=$3
19 # optional arguments
20 APPLESCRIPT=$4
21 ART_PATH=$5
22 EULA_RSRC=$6
24 # Create the image
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}"
29 # mount it
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"
36 # run applescript
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..."
46 # run shell script
47 # if [ ! -z "${SHELLSCRIPT}" -a "${SHELLSCRIPT}" != "-null-" ]; then
48 # ./${SHELLSCRIPT} \"${VOLUME_NAME}\"
49 # fi
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}"
60 # unmount
61 echo "Unmounting disk image..."
62 hdiutil detach "${DEV_NAME}"
64 # compress image
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"
78 exit 0