-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathosx_pack.sh
executable file
·105 lines (85 loc) · 2.19 KB
/
osx_pack.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
#!/bin/bash
cd "$(dirname "$0")"
distribdir="$(pwd)"
source functions.sh
olxdir="$(guess_olx_dir)"
if ! is_olx_dir "$olxdir"; then
echo "Cannot find openlierox dir. Fix functions.sh."
exit 1
fi
"${distribdir}"/osx_build.sh || {
echo "Error while building."
exit 1
}
olxbin="$(get_olx_macosx_bin)"
#"${distribdir}"/osx_test_binary.sh "$olxbin" || {
# echo "Error while testing binary."
# exit 1
#}
# builds a DMG for OpenLieroX
# Creates a disk image (dmg) on Mac OS X from the command line.
# usage:
# mkdmg <volname> <dmgname> <srcdir>
#
# Where <volname> is the name to use for the mounted image, <vers> is the version
# number of the volume and <srcdir> is where the contents to put on the dmg are.
#
# The result will be a file called <dmgname>.dmg
mkdmg() {
if [ $# != 3 ]; then
echo "usage: mkdmg volname dmgname srcdir"
exit 1
fi
VOL="$1"
DMG="$2"
FILES="$3"
DMGTMP="tmp-$DMG"
if [ "$(echo "$DMG" | grep ".dmg")" == "" ]; then
echo "mkdmg: dmg-filename $DMG is invalid, must have .dmg ending"
exit 1
fi
# create temporary disk image and format, ejecting when done
SIZE=$(du -sk ${FILES} | cut -f 1)
SIZE=$((${SIZE}/1000+5))
echo "mkdmg: estimated size: $SIZE mb"
hdiutil create "$DMGTMP" -megabytes ${SIZE} -ov -type UDIF -fs HFS+ -volname "$VOL" || {
echo "mkdmg: could not create temp dmg"
exit 1
}
# mount and copy files onto volume
hdid "$DMGTMP" || {
echo "mkdmg: could not mount temp dmg"
exit 1
}
echo -n "copying files ... "
cp -R "${FILES}"/* "/Volumes/$VOL/" || {
echo "mkdmg: error while copying files"
exit 1
}
echo "ready"
hdiutil eject "/Volumes/$VOL"
# convert to compressed image, delete temp image
rm -f "$DMG"
hdiutil convert "$DMGTMP" -format UDZO -o "$DMG" || {
echo "mkdmg: error while creating compressed dmg"
exit 1
}
rm -f "$DMGTMP"
}
rm -rf dmg # cleanup old if there...
mkdir -p dmg || {
echo "Cannot create temporary dmg directory."
exit 1
}
olxtargetname="$(get_olx_targetname)"
echo "** preparing release DMG"
mv "$olxbin" dmg/ || {
echo "osx_pack: error while copying binary"
exit 1
}
mkdmg "$olxtargetname" "$(get_olx_osx_fn)" dmg || {
echo "osx_pack: error while creating DMG"
exit 1
}
rm -rf dmg
echo "** ready"