root/trunk/Release/CreateDiskImage.sh

Revision 29, 5.6 kB (checked in by durin42, 2 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).

Line 
1 #dmgSize=${DiskImageSizeInMB}
2 #dmgBasePath="${TARGET_BUILD_DIR}/${DiskImageVolumeName}"
3 dmgSize=8
4 BUILT_PRODUCTS_DIR=build/Deployment
5 DiskImageProduct=Perian.component
6 dmgBasePath=build/Perian
7 DiskImageVolumeName="Perian Codec"
8
9 if [ x${ACTION} = xclean ]; then
10         echo "Removing disk image ${dmgPath}.dmg"
11         rm -f "${dmgBasePath}.dmg"
12         exit 0
13 fi
14
15 echo "Creating ${dmgSize} MB disk image named '${DiskImageVolumeName}'..."
16 rm -f "${dmgBasePath}.dmg"
17 hdiutil create "${dmgBasePath}.dmg" -volname "${DiskImageVolumeName}" -megabytes ${dmgSize} -layout NONE -fs HFS+ -quiet
18 if [ $? != 0 ]; then
19         echo error:0: Failed to create disk image at ${dmgBasePath}.dmg
20         exit 1
21 fi
22 echo "...done"
23 echo
24
25 echo "Mounting newly created disk image..."
26 hdidOutput=`hdiutil mount "${dmgBasePath}.dmg" | grep '/dev/disk[0-9]*' | awk '{print $1}'`
27 mountedDmgPath="/Volumes/${DiskImageVolumeName}"
28 if [ $? != 0  -o  ! -x "${mountedDmgPath}" ]; then
29         echo error:0: Failed to mount newly created disk image at ${dmgBasePath}.dmg
30         exit 1
31 fi
32 sleep 2
33 echo "...done"
34 echo
35
36 echo "Copying contents to ${dmgPath}..."
37 #cp "${SOURCE_ROOT}/Fire-README.txt" "${mountedDmgPath}"
38 #cp "${SOURCE_ROOT}/GPL" "${mountedDmgPath}"
39 ditto -rsrc "${BUILT_PRODUCTS_DIR}/${DiskImageProduct}" "${mountedDmgPath}/${DiskImageProduct}"
40 strip -u -r "${mountedDmgPath}/${DiskImageProduct}/Contents/MacOS/Fire"
41 mkdir "${mountedDmgPath}/Pictures"
42 cp "${SOURCE_ROOT}/scripts/daily-img/camp_fire.jpg" "${mountedDmgPath}/Pictures"
43 cp "${SOURCE_ROOT}/scripts/daily-img/dsstore" "${mountedDmgPath}/.DS_Store"
44 echo "...done"
45 echo
46 echo "${mountedDmgPath}"
47
48 echo "Configuring folder properties..."
49 osascript -e "tell application \"Finder\"" \
50           -e "    set mountedDiskImage to disk \"${DiskImageVolumeName}\"" \
51           -e "    open mountedDiskImage" \
52           -e "    tell container window of mountedDiskImage" \
53           -e "        set toolbar visible to false" \
54           -e "        set current view to icon view" \
55           -e "        set bounds to {${DiskImageWindowMinX}, ${DiskImageWindowMinY}, ${DiskImageWindowMaxX}, ${DiskImageWindowMaxY}}" \
56           -e "        set position of file \"Fire-README.txt\" to {0, 64}" \
57           -e "        set position of folder \"Pictures\" to {0, 64}" \
58           -e "        set position of file \"${DiskImageProduct}\" to {(${DiskImageWindowMaxX} - ${DiskImageWindowMinX}) / 2 - 64, ${DiskImageWindowMaxY} - ${DiskImageWindowMinY} - 90}" \
59           -e "        set position of file \"GPL\" to {${DiskImageWindowMaxX} - ${DiskImageWindowMinX} - 155, 64}" \
60           -e "        set opts to icon view options of container window of mountedDiskImage" \
61           -e "        set background picture of opts to file \"camp_fire.jpg\" of folder \"Pictures\"" \
62           -e "    end tell" \
63           -e "end tell" \
64           > /dev/null
65 #          -e "    set icon size of icon view options of container window of mountedDiskImage to 128" \
66 #          -e "    set background color of icon view options of container window of mountedDiskImage to { ${DiskImageWindowBackgroundRed} * 65535, ${DiskImageWindowBackgroundGreen} * 65535, ${DiskImageWindowBackgroundBlue} * 65535 }" \
67 echo "...done"
68 echo
69
70 mv "${mountedDmgPath}/Pictures" "${mountedDmgPath}/.Pictures"
71
72 osascript -e 'tell application "Xcode" to display dialog "Eject the image through Finder to keep background image"'
73
74 #echo "Unmounting disk image..."
75 #hdiutil eject -quiet ${hdidOutput}
76 #echo "...done"
77 #echo
78
79 echo "Compressing disk image..."
80 mv "${dmgBasePath}.dmg" "${dmgBasePath}-orig.dmg"
81 hdiutil convert "${dmgBasePath}-orig.dmg" -format UDZO -o "${dmgBasePath}"
82 if [ $? != 0 ]; then
83         echo error:0: Failed to compress newly created disk image at ${dmgBasePath}.dmg
84         exit 1
85 fi
86 rm "${dmgBasePath}-orig.dmg"
87 echo "...done"
88 echo
89
90 osascript -e "tell application \"Finder\"" -e "select posix file \"${TARGET_BUILD_DIR}/${DiskImageVolumeName}.dmg\"" -e "end tell" > /dev/null
91
92 svnrev=`svn info "${SOURCE_ROOT}" | grep 'Revision' | awk '{print $2}'`
93 echo "Creating 1${dmgSize} MB disk image named '${DiskImageVolumeName}'..."
94 rm -f "${dmgBasePath}_${svnrev}.dmg"
95 hdiutil create "${dmgBasePath}_${svnrev}.dmg" -volname "${DiskImageVolumeName}" -megabytes 1${dmgSize} -layout NONE -fs HFS+ -quiet
96 if [ $? != 0 ]; then
97         echo error:0: Failed to create disk image at ${dmgBasePath}_${svnrev}.dmg
98         exit 1
99 fi
100 echo "...done"
101 echo
102
103 echo "Mounting newly created disk image..."
104 hdidOutput=`hdiutil mount "${dmgBasePath}_${svnrev}.dmg" | grep '/dev/disk[0-9]*' | awk '{print $1}'`
105 mountedDmgPath="/Volumes/${DiskImageVolumeName}"
106 if [ $? != 0  -o  ! -x "${mountedDmgPath}" ]; then
107         echo error:0: Failed to mount newly created disk image at ${dmgBasePath}_${svnrev}.dmg
108         exit 1
109 fi
110 sleep 2
111 echo "...done"
112 echo
113
114 echo "Copying contents to ${dmgPath}_${svnrev}..."
115 cd "${BUILT_PRODUCTS_DIR}/"
116 #tricky regex to reject those files within Fire.app/Contents/Resources and reject the mdimporter
117 find -E . -iregex "\./[^/]+[^r]/Contents/MacOS/[^/]*" -type f -perm +111 -exec cp {} "${mountedDmgPath}/" \;
118 #tricky regex to reject those frameworks within Fire.app/Contents/Frameworks
119 find -E . -iregex "\./[^/]+\.framework/.*" -type f -perm +111 -exec cp {} "${mountedDmgPath}/" \;
120 echo "...done"
121 echo
122 echo "${mountedDmgPath}"
123
124 echo "Unmounting disk image..."
125 hdiutil eject -quiet ${hdidOutput}
126 echo "...done"
127 echo
128
129 echo "Compressing disk image..."
130 mv "${dmgBasePath}_${svnrev}.dmg" "${dmgBasePath}_${svnrev}-orig.dmg"
131 hdiutil convert "${dmgBasePath}_${svnrev}-orig.dmg" -format UDZO -o "${dmgBasePath}_${svnrev}"
132 if [ $? != 0 ]; then
133         echo error:0: Failed to compress newly created disk image at ${dmgBasePath}_${svnrev}.dmg
134         exit 1
135 fi
136 rm "${dmgBasePath}_${svnrev}-orig.dmg"
137 echo "...done"
138 echo
139 exit 0
Note: See TracBrowser for help on using the browser.