-
Notifications
You must be signed in to change notification settings - Fork 29
/
MakeMacImage.sh
executable file
·91 lines (76 loc) · 3.42 KB
/
MakeMacImage.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
#!/bin/bash
TMPDIR=/tmp
RELEASE="12"
SETFILE=/Developer/Tools/SetFile
HDIUTIL=/usr/bin/hdiutil
SED=/usr/bin/sed
CUT=/usr/bin/cut
GREP=/usr/bin/grep
STRIP=/usr/bin/strip
OTOOL=/usr/bin/otool
#EXAMPLES="brusselator.cps YeastGlycolysis.gps CircadianClock.cps Metabolism-2000Poo.xml"
EXAMPLES=`find ./TestSuite/distribution/ -type f -maxdepth 1`
# check if the binary is there
if test -e ./copasi/CopasiUI/CopasiUI.app/Contents/MacOS/CopasiUI ; then
# test if the binary is statically linked agains libqt
if ${OTOOL} -L ./copasi/CopasiUI/CopasiUI.app/Contents/MacOS/CopasiUI | grep libqt 2>&1 > /dev/null ;then
echo ""
echo "CopasiUI is dynamicall linked against Qt."
echo "Please link the binary statically before making an image."
echo ""
exit 1
fi
# strip the binary
echo "Removing debugging symbols from the binary."
${STRIP} ./copasi/CopasiUI/CopasiUI.app/Contents/MacOS/CopasiUI
# make a temporary directory and copy the CopasiUI.app directory there.
echo "Creating temporary directory."
mkdir ${TMPDIR}/copasi;
echo "Copying application bundle."
cp -r copasi/CopasiUI/CopasiUI.app ${TMPDIR}/copasi/
# copy the icon into the Resources directory
echo "Creating Resources directory."
mkdir -p ${TMPDIR}/copasi/CopasiUI.app/Contents/Resources
echo "Copy the icon file to the bundle."
cp copasi.icns ${TMPDIR}/copasi/CopasiUI.app/Contents/Resources/
# set the icon in the Info.plist file in the Contents directory
# the icon file name is located between <string></string> tags in the line after
# <key>CFBundleIconFile</key>
# Maybe this would better be done with a dom parser.
echo "Set the icon in the Info.plist file."
LINE=`${GREP} -n "CFBundleIconFile" ${TMPDIR}/copasi/CopasiUI.app/Contents/Info.plist | cut -c1`
LINE=$((LINE+1))
${SED} -e "${LINE}s%<string>.*</string>%<string>copasi.icns</string>%" ${TMPDIR}/copasi/CopasiUI.app/Contents/Info.plist > ${TMPDIR}/tmp.plist
mv ${TMPDIR}/tmp.plist ${TMPDIR}/copasi/CopasiUI.app/Contents/Info.plist
# copy the examples into the Resources directory
echo "Make example directory."
mkdir -p ${TMPDIR}/copasi/examples
echo "Copy examples to example directory."
for EXAMPLE in $EXAMPLES;do
cp ${EXAMPLE} ${TMPDIR}/copasi/examples/
done
# copy the files for the wizard into the Resources directory
echo "Making directory for wizard."
mkdir -p ${TMPDIR}/copasi/CopasiUI.app/Contents/Resources/doc/html
echo "Copying files for wizard."
cp ./copasi/wizard/help_html/*.html ${TMPDIR}/copasi/CopasiUI.app/Contents/Resources/doc/html/
cp -r ./copasi/wizard/help_html/figures ${TMPDIR}/copasi/CopasiUI.app/Contents/Resources/doc/html/
# add the readme to the image
echo "Copying readme file."
cp README_MAC.rtf ${TMPDIR}/copasi/COPASI-README.rtf
# set the bundles flag with SetFile
echo "Setting the bundle flag."
${SETFILE} -a b ${TMPDIR}/copasi/CopasiUI.app
# make an image with hdiutil from the folder
echo "Creating compressed image."
${HDIUTIL} create -srcfolder ${TMPDIR}/copasi -uid 99 -gid 99 -scrub -volname Copasi-${RELEASE} ${TMPDIR}/Copasi-${RELEASE}-Darwin.dmg
# move the image to this directory and delete the temporary diretory
echo "Cleaning up in temporary directory."
mv ${TMPDIR}/Copasi-${RELEASE}-Darwin.dmg .
rm -rf ${TMPDIR}/copasi
else
echo ""
echo "Please build the copasi executable first."
echo ""
exit 1;
fi