3
# Package script for Diamond.
5
# Thanks: http://stackoverflow.com/questions/1596945/building-osx-app-bundle
8
# bzr co lp:spud mac_bundle
13
# *make a coffee or tea*
18
# Also fix $INSTALLDIR/MacOS/diamond in case this number changes
21
INSTALLDIR=$APP/Contents
22
LIBDIR=$INSTALLDIR/lib
23
APPDIR=/Applications/$INSTALLDIR
26
# set up our virtual python environment
27
virtualenv --python=python$PYVER --no-site-packages $INSTALLDIR
30
# install diamond in it
31
sed -i .bak 's/packaging=False/packaging=True/' setup.py
32
macosx/$INSTALLDIR/bin/python setup.py install
36
../diamond/macosx/$INSTALLDIR/bin/python setup.py install
40
mkdir $INSTALLDIR/MacOS
41
mkdir $INSTALLDIR/Resources
43
# Sort out the Resources
44
cp PkgInfo $INSTALLDIR/
45
cp Info.plist $INSTALLDIR/
46
cp pango_rc $INSTALLDIR/Resources/
47
cp diamond.icns $INSTALLDIR/Resources/
48
cp diamond $INSTALLDIR/MacOS
50
# Now we have to play silly buggers with some bits of the diamond file
51
# as the Mac app packages adds a command line argument, which we want to ignore
52
sed -i .bak 's/sys.argv\[1:\]/sys.argv\[2:\]/' $INSTALLDIR/bin/diamond
56
# Let's get the latest fluidity release schema
57
# NOTE: UPDATE URL AFTER A RELEASE
58
if [ ! -d fluidity ]; then
59
bzr branch lp:fluidity/4.1 fluidity
65
# Make the schemata description
66
rm -rf $INSTALLDIR/Resources/schemata/fluidity
67
mkdir -p $INSTALLDIR/Resources/schemata/fluidity
68
cat > $INSTALLDIR/Resources/schemata/flml << EOF
69
Fluidity Markup Language
70
/Applications/Diamond.app/Contents/Resources/schemata/fluidity/fluidity_options.rng
72
cp fluidity/schemas/*.rng $INSTALLDIR/Resources/schemata/fluidity/
73
cp ../../schema/*.rng $INSTALLDIR/Resources/schemata/fluidity/
77
# Do the above for any other schema we want to distribute
78
# Don't forget the spud-base!
82
# Let's get lxml installed
83
$INSTALLDIR/bin/easy_install --allow-hosts=lxml.de,*.python.org lxml
85
# Temp. solution - Just manually copy stuff we know we need
86
SITEPACKAGES=$LIBDIR/python$PYVER/site-packages
88
mkdir -p $SITEPACKAGES
90
# This locates pygtk.pyc. We want the source file
91
pygtk=`python -c "import pygtk; print pygtk.__file__[:-1]"`
92
oldsite=`dirname $pygtk`
93
gobject=`python -c "import gobject; print gobject.__file__[:-1]"`
94
glib=`python -c "import glib; print glib.__file__[:-1]"`
96
# Copy PyGtk and related libraries
97
cp $pygtk $SITEPACKAGES
98
cp -r `dirname $gobject` $SITEPACKAGES
99
cp -r `dirname $glib` $SITEPACKAGES
100
cp -r $oldsite/cairo $SITEPACKAGES
101
cp -r $oldsite/gtk-2.0 $SITEPACKAGES
102
cp $oldsite/pygtk.pth $SITEPACKAGES
105
# Modules, config, etc.
106
for dir in lib etc/pango etc/gtk-2.0 share/themes; do
107
mkdir -p $INSTALLDIR/$dir
108
cp -r $LOCALDIR/$dir/* $INSTALLDIR/$dir
111
# Resources, are processed on startup
112
for dir in etc/gtk-2.0 etc/pango lib/gdk-pixbuf-2.0/2.10.0; do
113
mkdir -p $INSTALLDIR/Resources/$dir
114
cp $LOCALDIR/$dir/* $INSTALLDIR/Resources/$dir
117
# Somehow files are writen with mode 444
118
find $INSTALLDIR -type f -exec chmod u+w {} \;
124
function resolve_deps() {
127
otool -L $lib | grep -e "^.$LOCALDIR/" |\
133
function fix_paths() {
136
for dep in `resolve_deps $lib`; do
137
log Fixing `basename $lib`
139
install_name_tool -change $dep @executable_path/../lib/`basename $dep` $lib
143
binlibs=`find $INSTALLDIR -type f -name '*.so'`
145
for lib in $binlibs; do
149
done | sort -u | while read lib; do
152
chmod u+w $LIBDIR/`basename $lib`
153
fix_paths $LIBDIR/`basename $lib`
156
for lib in $dylibs; do
160
done | sort -u | while read lib; do
163
chmod u+w $LIBDIR/`basename $lib`
164
fix_paths $LIBDIR/`basename $lib`
169
sed -i .bak 's#/opt/gtk/#'$APPDIR'/#' $INSTALLDIR/etc/pango/pango.modules
170
sed -i .bak 's#/opt/gtk/#'$APPDIR'/#' $INSTALLDIR/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache
171
sed -i .bak 's#/opt/gtk/#'$APPDIR'/#' $INSTALLDIR/Resources/etc/pango/pango.modules
172
sed -i .bak 's#/opt/gtk/#'$APPDIR'/#' $INSTALLDIR/Resources/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache
178
# we now need to fiddle with the Python run path on the diamond script
179
# COMMENT THESE OUT IF YOU WANT TO TEST YOUR APP WITHOUT INSTALLING
181
sed -i .bak 's|/Users/amcg/Software/spud/mac_port/diamond|/Applications|' $INSTALLDIR/bin/diamond
182
sed -i .bak 's|/Users/amcg/Software/spud/mac_port/diamond|/Applications|' $INSTALLDIR/MacOS/diamond
184
zip -rq Diamond-$VERSION-osx.zip $APP
185
hdiutil create -srcfolder $APP Diamond-$VERSION.dmg
188
# To test, temporarily move your /opt/gtk folder
189
# Move the Diamond.app folder to /Applications and go
b'\\ No newline at end of file'