-
Notifications
You must be signed in to change notification settings - Fork 2
/
mkdmg.sh
executable file
·77 lines (58 loc) · 2.2 KB
/
mkdmg.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
#!/bin/sh
if [ $# != 2 ]; then
echo
echo "Usage: mkdmg.sh appname version"
echo
exit 1
fi
APPNAME="$1"
VERSION="$2"
KIND="CLI"
APPNAME_lower=`echo ${APPNAME} |awk '{print tolower($0)}'`
KIND_lower=`echo ${KIND} |awk '{print tolower($0)}'`
SIGNATURE="MediaArea.net"
FILES="tmp-${APPNAME}_${KIND}"
TEMPDMG="tmp-${APPNAME}_${KIND}.dmg"
FINALDMG="${APPNAME/ /}_${KIND}_${VERSION}_Mac.dmg"
# Clean up
rm -fr "${FILES}-Root"
rm -fr "${FILES}"
rm -f "${APPNAME}.pkg"
rm -f "${TEMPDMG}"
rm -f "${FINALDMG}"
echo
echo ========== Create the package ==========
echo
mkdir -p "${FILES}/.background"
mkdir -p "${FILES}-Root/usr/local/lib"
cp Logo_White.icns "${FILES}/.background"
cp -Ra MacOS/* "${FILES}-Root/usr/local/lib"
codesign -f --deep --options=runtime -s "Developer ID Application: ${SIGNATURE}" --verbose ${FILES}-Root/usr/local/lib/*.dylib ${FILES}-Root/usr/local/lib/graphviz/*.dylib
pkgbuild --root "${FILES}-Root" --identifier "net.mediaarea.${APPNAME_lower}.mac-${KIND_lower}" --sign "Developer ID Installer: ${SIGNATURE}" --version "${VERSION}" "${FILES}/${APPNAME_lower}.pkg"
codesign -f --deep --options=runtime -s "Developer ID Application: ${SIGNATURE}" --verbose "${FILES}/${APPNAME_lower}.pkg"
echo
echo ========== Create the disk image ==========
echo
# Check if an old image isn't already attached
DEVICE=$(hdiutil info |grep -B 1 "/Volumes/${APPNAME}" |egrep '^/dev/' | sed 1q | awk '{print $1}')
test -e "$DEVICE" && hdiutil detach -force "${DEVICE}"
hdiutil create "${TEMPDMG}" -ov -fs HFS+ -format UDRW -volname "${APPNAME}" -srcfolder "${FILES}"
DEVICE=$(hdiutil attach -readwrite -noverify "${TEMPDMG}" | egrep '^/dev/' | sed 1q | awk '{print $1}')
sleep 2
cd "/Volumes/${APPNAME}"
if [ "$KIND" = "GUI" ]; then
ln -s /Applications
fi
test -e .DS_Store && rm -fr .DS_Store
cd - >/dev/null
. Osascript_${KIND}.sh
osascript_Function
hdiutil detach "${DEVICE}"
sleep 2
echo
echo ========== Convert to compressed image ==========
echo
hdiutil convert "${TEMPDMG}" -format UDBZ -o "${FINALDMG}"
codesign -f --deep --options=runtime -s "Developer ID Application: ${SIGNATURE}" --verbose "${FINALDMG}"
unset -v APPNAME APPNAME_lower KIND KIND_lower VERSION SIGNATURE
unset -v TEMPDMG FINALDMG FILES DEVICE