-
Notifications
You must be signed in to change notification settings - Fork 1
/
make-dmg-bundle.sh
executable file
·51 lines (34 loc) · 1.27 KB
/
make-dmg-bundle.sh
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
#!/bin/bash
pushd $(dirname $0) &>/dev/null
VOLUME_NAME="Password Chest"
DMG_APP=build/Release/$VOLUME_NAME.app
DMG_FILE=build/Release/$VOLUME_NAME.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 1MB
image_size=$(du -ck "$DMG_APP" dmg-data README.txt | tail -n1 | cut -f1)
image_size=$((($image_size + 1000) / 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
echo "Populating image..."
rsync -aq "$DMG_APP" "$MOUNT_POINT"
pushd "$MOUNT_POINT" &>/dev/null
ln -s /Applications
popd &>/dev/null
mkdir "$MOUNT_POINT"/.background
cp dmg-data/background.png "$MOUNT_POINT"/.background
cp dmg-data/DS_Store "$MOUNT_POINT"/.DS_Store
cp README.txt "$MOUNT_POINT"
echo "Detaching from disk image..."
hdiutil detach "$MOUNT_POINT" -quiet
mv "$DMG_FILE" "$DMG_FILE.master"
echo "Creating distributable image..."
hdiutil convert -quiet -format UDBZ -o "$DMG_FILE" "$DMG_FILE.master"
echo "Done: '$DMG_FILE'"
if [ ! "x$1" = "x-m" ]; then
rm "$DMG_FILE.master"
fi
popd &>/dev/null