blob: eac33e3cec2c731248e7299516bd8d3133f54c70 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
#!/usr/bin/env bash
# Shamelessly lifted from Banshee's build process
pushd $(dirname $0) &>/dev/null
DMG_APP=$1
RENDER_OP=$2
if [ -z "$DMG_APP" ]; then
DMG_APP=MonoDevelop.app
fi
if test ! -e "$DMG_APP" ; then
echo "Missing $DMG_APP"
exit 1
fi
NAME=`grep -A1 CFBundleDisplayName "$DMG_APP/Contents/Info.plist" | grep string | sed -e 's/.*<string>//' -e 's,</string>,,'`
VERSION=`grep -A1 CFBundleVersion "$DMG_APP/Contents/Info.plist" | grep string | sed -e 's/.*<string>//' -e 's,</string>,,'`
#if we use the version in the volume name, Finder can't find the background image
#because the DS_Store depends on the volume name, and we aren't currently able
#to alter it programmatically
VOLUME_NAME="$NAME"
echo "Building bundle for $NAME $VERSION..."
DMG_FILE="$NAME-$VERSION.dmg"
MOUNT_POINT="$VOLUME_NAME.mounted"
rm -f "$DMG_FILE"
rm -f "$DMG_FILE.master"
# Compute an approximated image size in MB, and bloat by double
# codesign adds a unknown amount of extra size requirements and there are some
# files where the additional size required is even more "unknown". doubling
# is a brute force approach, but doesn't really impact final distribution size
# because the empty space is compressed to nothing.
image_size=$(du -ck "$DMG_APP" | tail -n1 | cut -f1)
image_size=$((($image_size *2) / 1000))
echo "Creating disk image (${image_size}MB)..."
hdiutil create "$DMG_FILE" -megabytes $image_size -volname "$VOLUME_NAME" -fs HFS+ -quiet || exit $?
echo "Attaching to disk image..."
hdiutil attach "$DMG_FILE" -readwrite -noautoopen -mountpoint "$MOUNT_POINT" -quiet || exit $?
echo "Populating image..."
# this used to be mv, but we need to preserve the bundle directory to do more checks on the contents
# such as compatibility-check
ditto "$DMG_APP" "$MOUNT_POINT/$DMG_APP"
# This won't result in any deletions
#find "$MOUNT_POINT" -type d -iregex '.*\.svn$' &>/dev/null | xargs rm -rf
pushd "$MOUNT_POINT" &>/dev/null
ln -s /Applications Applications
popd &>/dev/null
mkdir -p "$MOUNT_POINT/.background"
if [ "$RENDER_OP" == "norender" ]; then
cp dmg-bg.png "$MOUNT_POINT/.background/dmg-bg.png"
else
DYLD_FALLBACK_LIBRARY_PATH="/Library/Frameworks/Mono.framework/Versions/Current/lib:/lib:/usr/lib" mono render.exe "$NAME $VERSION"
mv dmg-bg-with-version.png "$MOUNT_POINT/.background/dmg-bg.png"
fi
cp DS_Store "$MOUNT_POINT/.DS_Store"
if [ -e VolumeIcon.icns ] ; then
cp VolumeIcon.icns "$MOUNT_POINT/.VolumeIcon.icns"
SetFile -c icnC "$MOUNT_POINT/.VolumeIcon.icns"
fi
SetFile -a C "$MOUNT_POINT"
echo "Detaching from disk image..."
for n in `seq 1 5`
do
hdiutil detach "$MOUNT_POINT" && break
if [ $n = 5 ]; then
hdiutil detach -force "$MOUNT_POINT"
exit $?
fi
done
mv "$DMG_FILE" "$DMG_FILE.master"
echo "Creating distributable image..."
hdiutil convert -quiet -format UDBZ -o "$DMG_FILE" "$DMG_FILE.master" || exit $?
echo "Built disk image $DMG_FILE"
if [ ! "x$1" = "x-m" ]; then
rm "$DMG_FILE.master"
fi
rm -rf "$MOUNT_POINT"
echo "Done."
popd &>/dev/null
|