File: make-dmg

package info (click to toggle)
gitg 41-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 18,876 kB
  • sloc: ansic: 1,636; ruby: 1,445; sh: 314; python: 261; xml: 57; makefile: 15
file content (73 lines) | stat: -rwxr-xr-x 1,845 bytes parent folder | download | duplicates (4)
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
#!/bin/bash

pushd $(dirname "$0")/.. > /dev/null
D=$(pwd -P)
popd > /dev/null

ME="$0"
BUNDLE_NAME="Gitg"
BUNDLE="$D/$BUNDLE_NAME.app"

# Copied and modified from gedit
if [ ! -d "$BUNDLE" ]; then
	echo "Bundle $BUNDLE_NAME.app could not befound"
	exit 1
fi

VOLUME_NAME="$BUNDLE_NAME"

if [ ! -z "$1" ]; then
	DMG_FILE="$1.dmg"
else
	DMG_FILE="$D/$BUNDLE_NAME.dmg"
fi

DMG_APP="$BUNDLE"
TMP_MOUNT_POINT="$TMPDIR/$VOLUME_NAME.mounted"
FINAL_MOUNT_POINT="/Volumes/$VOLUME_NAME"

rm -f $DMG_FILE
rm -f $DMG_FILE.master

# Compute an approximated image size in MB, and bloat by 1%
image_size=$(du -ck "$DMG_APP" | tail -n1 | cut -f1)
image_size=$((($image_size * 11) / 10000))

echo "Creating disk image (${image_size}MB)..."

TMPNAME="$TMPDIR/$(basename ${DMG_FILE%.dmg}_tmp.dmg)"
rm -f "$TMPNAME"

#hdiutil create -volname "$BUNDLE_NAME" -srcfolder "$DMG_APP" -ov -format UDZO "$TMPNAME" || exit 1
#hdiutil create -volname "$BUNDLE_NAME" -srcfolder "$DMG_APP" -ov -format UDRW "$TMPNAME" || exit 1

cp "$D/data/Gitg-template.dmg.xz" "$TMPNAME.xz"
unxz "$TMPNAME.xz"

hdiutil resize -size ${image_size}m "$TMPNAME" || exit 1

echo "Attaching to disk image..."
hdiutil attach "$TMPNAME" -readwrite -noautoopen -mountpoint "$TMP_MOUNT_POINT" -quiet || exit 1

echo "Populating image..."
rsync -az "$DMG_APP" "$TMP_MOUNT_POINT/" || exit 1

echo "Ensuring permissions"
chmod -Rf go-w "$TMP_MOUNT_POINT" 2>/dev/null

echo "Blessing image..."
bless --folder "$TMP_MOUNT_POINT" --openfolder "$TMP_MOUNT_POINT" || exit 1

echo "Detaching from disk image..."
hdiutil detach "$TMP_MOUNT_POINT" -quiet || exit 1

echo "Converting to final image..."
hdiutil convert -quiet -format UDBZ -o "$DMG_FILE" "$TMPNAME" || exit 1

# Make internet-enable
hdiutil internet-enable -yes "$DMG_FILE" || exit 1

rm -f "$TMPNAME"

n=$(basename "$DMG_FILE")
echo "Done $n."