root/branches/perian-1.0/Release/make-diskimage.sh

Revision 29, 2.1 kB (checked in by durin42, 3 years ago)

Release scripts. As the name of one of the scripts suggests, these are borrowed from Adium with some slight mods for this project (including stripping symbols when building the dmg).

  • Property svn:executable set to *
Line 
1 # Create a read-only disk image of the contents of a folder
2 #
3 # Usage: make-diskimage <image_file>
4 #                       <src_folder>
5 #                       <volume_name>
6 #                       <applescript>
7 #                       <eula_resource_file>
8
9 set -e;
10
11 DMG_DIRNAME=`dirname $1`
12 DMG_DIR=`cd $DMG_DIRNAME > /dev/null; pwd`
13 DMG_NAME=`basename $1`
14 DMG_TEMP_NAME=${DMG_DIR}/rw.${DMG_NAME}
15 SRC_FOLDER=`cd $2 > /dev/null; pwd`
16 VOLUME_NAME=$3
17
18 # optional arguments
19 APPLESCRIPT=$4
20 EULA_RSRC=$5
21
22 # Create the image
23 echo "Creating disk image..."
24 rm -f "${DMG_TEMP_NAME}"
25 hdiutil create -srcfolder "${SRC_FOLDER}" -volname "${VOLUME_NAME}" -fs HFS+ -fsargs "-c c=64,a=16,e=16" -format UDRW "${DMG_TEMP_NAME}"
26
27 # mount it
28 echo "Mounting disk image..."
29 MOUNT_DIR="/Volumes/${VOLUME_NAME}"
30 DEV_NAME=`hdiutil attach -readwrite -noverify -noautoopen "${DMG_TEMP_NAME}" | egrep '^/dev/' | sed 1q | awk '{print $1}'`
31
32 # run applescript
33 if [ ! -z "${APPLESCRIPT}" -a "${APPLESCRIPT}" != "-null-" ]; then
34 #       osascript "${APPLESCRIPT}"
35     #   pass the applescript a single parameter, our volume name, to its process_disk_image function
36     echo "Running Applescript: ./AdiumApplescriptRunner \"${APPLESCRIPT}\" process_disk_image \"${VOLUME_NAME}\""
37     ./AdiumApplescriptRunner "${APPLESCRIPT}" process_disk_image "${VOLUME_NAME}" || true
38     echo "Done running the applescript..."
39 fi
40
41 # make sure it's not world writeable
42 echo "Fixing permissions..."
43 chmod -Rf go-w "${MOUNT_DIR}" || true
44
45 # make the top window open itself on mount:
46 if [ -x /usr/local/bin/openUp ]; then
47     /usr/local/bin/openUp "${MOUNT_DIR}"
48 fi
49
50 # unmount
51 echo "Unmounting disk image..."
52 hdiutil detach "${DEV_NAME}"
53
54 # compress image
55 echo "Compressing disk image..."
56 hdiutil convert "${DMG_TEMP_NAME}" -format UDBZ -o "${DMG_DIR}/${DMG_NAME}"
57 rm -f "${DMG_TEMP_NAME}"
58
59 # adding EULA resources
60 if [ ! -z "${EULA_RSRC}" -a "${EULA_RSRC}" != "-null-" ]; then
61         echo "adding EULA resources"
62         hdiutil unflatten "${DMG_DIR}/${DMG_NAME}"
63         /Developer/Tools/ResMerger -a "${EULA_RSRC}" -o "${DMG_DIR}/${DMG_NAME}"
64         hdiutil flatten "${DMG_DIR}/${DMG_NAME}"
65 fi
66
67 echo "Disk image done"
68 exit 0
Note: See TracBrowser for help on using the browser.