-
Notifications
You must be signed in to change notification settings - Fork 8
/
create_appbundle.sh
150 lines (124 loc) · 4.11 KB
/
create_appbundle.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
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/sh
# Force Bourne shell in case tcsh is default.
#
#
# Reads the bundle type
#
echo "========================================================"
echo " Bundle creation script"
echo "========================================================"
echo ""
echo " Please select which kind of bundle you would like to build:"
echo ""
echo " 1 > Debug bundle"
echo " 2 > Release bundle"
echo " 0 > Exit"
read command
case $command in
1) ;;
2) ;;
0) exit 0;;
*) echo "Invalid command"
exit 0;;
esac
#
# Creates the bundle
#
BASE=$(pwd)
BIN_DIR=$BASE/bin/darwin
PACKAGES_DIR=$BASE/packages
appname=OvoPlayer
appfolder=$PACKAGES_DIR/$appname.app
macosfolder=$appfolder/Contents/MacOS
plistfile=$appfolder/Contents/Info.plist
appfile=ovoplayer
PkgInfoContents="APPLMAG#"
#
if ! [ -e $appfile ]
then
echo "$appfile does not exist"
elif [ -e $appfolder ]
then
echo "$appfolder already exists"
else
echo "Creating $appfolder..."
mkdir $appfolder
mkdir $appfolder/Contents
mkdir $appfolder/Contents/MacOS
mkdir $appfolder/Contents/Resources
#
# For a debug bundle,
# Instead of copying executable into .app folder after each compile,
# simply create a symbolic link to executable.
#
if [ $command = 1 ]; then
ln -s ../../../$appname $macosfolder/$appname
else
cp $appname $macosfolder/$appname
fi
cp $BASE/images/logo.png $appfolder/Contents/Resources
cp $BASE/images/nocover.png $appfolder/Contents/Resources
cp $BASE/images/volume-slider.png $appfolder/Contents/Resources
cp $BASE/images/volume-slider-mask.png $appfolder/Contents/Resources
# Copy the resource files to the correct place
cp o$BASE/images/ovoplayer.icns $appfolder/Contents/Resources
# Create PkgInfo file.
echo $PkgInfoContents >$appfolder/Contents/PkgInfo
#
# Create information property list file (Info.plist).
echo '<?xml version="1.0" encoding="UTF-8"?>' >$plistfile
echo '<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">' >>$plistfile
echo '<plist version="1.0">' >>$plistfile
echo '<dict>' >>$plistfile
echo ' <key>CFBundleDevelopmentRegion</key>' >>$plistfile
echo ' <string>English</string>' >>$plistfile
echo ' <key>CFBundleExecutable</key>' >>$plistfile
echo ' <string>'$appname'</string>' >>$plistfile
echo ' <key>CFBundleIconFile</key>' >>$plistfile
echo ' <string>ovoplayer.icns</string>' >>$plistfile
echo ' <key>CFBundleIdentifier</key>' >>$plistfile
echo ' <string>org.ovoplayer.ovoplayer</string>' >>$plistfile
echo ' <key>CFBundleInfoDictionaryVersion</key>' >>$plistfile
echo ' <string>6.0</string>' >>$plistfile
echo ' <key>CFBundlePackageType</key>' >>$plistfile
echo ' <string>APPL</string>' >>$plistfile
echo ' <key>CFBundleSignature</key>' >>$plistfile
echo ' <string>MAG#</string>' >>$plistfile
echo ' <key>CFBundleVersion</key>' >>$plistfile
echo ' <string>1.0</string>' >>$plistfile
echo '</dict>' >>$plistfile
echo '</plist>' >>$plistfile
fi
hdiutil create -srcfolder "$appfolder" -volname "$appname" -fs HFS+ \
-fsargs "-c c=64,a=16,e=16" -format UDRW -size ${size}k pack.temp.dmg
device=$(hdiutil attach -readwrite -noverify -noautoopen "pack.temp.dmg" | \
egrep '^/dev/' | sed 1q | awk '{print $1}')
chmod -Rf go-w /Volumes/"$appname"
sync
sync
hdiutil detach $device
hdiutil convert "/pack.temp.dmg" -format UDZO -imagekey zlib-level=9 -o "${finalDMGName}"
rm -f /pack.temp.dmg
OUTPUT=$1
TITLE=$2
FILESIZE=$3
CONTENTDIR=$4
USER=`whoami`
TMPDIR="/tmp/dmgdir"
if [ ${USER} != "root" ]; then
echo "makedmg must be run as root!"
else
echo "Creating DMG File..."
dd if=/dev/zero of=${OUTPUT} bs=1M count=$FILESIZE
mkfs.hfsplus -v "${TITLE}" ${OUTPUT}
echo "Mounting DMG File..."
mkdir -p ${TMPDIR}
mount -t hfsplus -o loop ${OUTPUT} ${TMPDIR}
echo "Copying content to DMG File..."
cp -R ${CONTENTDIR}/* ${TMPDIR}
echo "Unmounting DMG File..."
umount ${TMPDIR}
rm -rf ${TMPDIR}
echo "All Done!"
fi
fi