source: orange/install-scripts/mac/bundle-build-hg.sh @ 11594:4472f0f29bce

Revision 11594:4472f0f29bce, 6.3 KB checked in by Ales Erjavec <ales.erjavec@…>, 10 months ago (diff)

Changed Orange Canvas OSX application startup script.

Start the application through a symlink in the top level application
directory so the correct Info.plist is considered by OSX (otherwise the one
in the contained Python.app is used).

  • Property exe set to *
RevLine 
[10788]1#!/bin/bash -e
[10270]2#
3# Build the orange Mac OSX bundle
4#
5# ./bundle-build-hg.sh work_dir revision bundle_output_file
6# ./bundle-build-hg.sh /private/tmp tip /private/tmp/orange-bundle-hg-tip.dmg
7#
8
9WORK_DIR=$1
10REVISION=$2
11BUNDLE=$3
12
13TMP_BUNDLE_DIR=${WORK_DIR}/bundle
14REPOS_DIR=${WORK_DIR}/repos
15
16# Remove leftovers if any
17if [ -e $TMP_BUNDLE_DIR ]; then
18    rm -rf $TMP_BUNDLE_DIR
19fi
20
[10277]21echo "Preaparing the bundle template"
[11594]22TEMPLATE_VERSION=$(curl --silent http://orange.biolab.si/download/bundle-templates/CURRENT.txt)
[10504]23curl --silent http://orange.biolab.si/download/bundle-templates/Orange-template-${TEMPLATE_VERSION}.tar.gz | tar -xz -C $WORK_DIR
[10270]24
25# Make repos dir if it does not yet exist
26if [ ! -e $REPOS_DIR ]; then
27    mkdir $REPOS_DIR
28fi
29
[11594]30APP=${TMP_BUNDLE_DIR}/Orange.app
31
32# Python interpreter in the bundle
33PYTHON=${APP}/Contents/MacOS/python
34
35# Python version
36PY_VER=`$PYTHON -c "import sys; print sys.version[:3]"`
37
38SITE_PACKAGES=${APP}/Contents/Frameworks/Python.framework/Versions/${PY_VER}/lib/python${PY_VER}/site-packages/
39
40# easy_install script in the bundle
41EASY_INSTALL=${APP}/Contents/MacOS/easy_install
42
43# Link Python.app startup script to top bundle
44ln -fs ../Frameworks/Python.framework/Versions/Current/Resources/Python.app/Contents/MacOS/Python ${APP}/Contents/MacOS/PythonAppStart
45
46echo "Preparing startup scripts"
47
48# Create an enironment startup script
49cat <<-'EOF' > $APP/Contents/MacOS/ENV
50    # Create an environment for running python from the bundle
51    # Should be run as "source ENV"
52
53    BUNDLE_DIR=`dirname "$0"`/../
54    BUNDLE_DIR=`perl -MCwd=realpath -e 'print realpath($ARGV[0])' "$BUNDLE_DIR"`/
55    FRAMEWORKS_DIR="$BUNDLE_DIR"Frameworks/
56    RESOURCES_DIR="$BUNDLE_DIR"Resources/
57
58    PYVERSION="2.7"
59
60    PYTHONEXECUTABLE="$FRAMEWORKS_DIR"Python.framework/Resources/Python.app/Contents/MacOS/Python
61    PYTHONHOME="$FRAMEWORKS_DIR"Python.framework/Versions/"$PYVERSION"/
62
63    DYLD_FRAMEWORK_PATH="$FRAMEWORKS_DIR"${DYLD_FRAMEWORK_PATH:+:$DYLD_FRAMEWORK_PATH}
64
65    export PYTHONEXECUTABLE
66    export PYTHONHOME
67
68    export DYLD_FRAMEWORK_PATH
69
70    # Some non framework libraries are put in $FRAMEWORKS_DIR by macho_standalone
71    export DYLD_LIBRARY_PATH="$FRAMEWORKS_DIR"${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}
72EOF
73
74# Create Orange application startup script
75cat <<-'EOF' > ${APP}/Contents/MacOS/Orange
[11533]76    #!/bin/bash
77
[11594]78    DIRNAME=$(dirname "$0")
79    source "$DIRNAME"/ENV
[11533]80
81    # LaunchServices passes the Carbon process identifier to the application with
82    # -psn parameter - we do not want it
83    if [[ $1 == -psn_* ]]; then
84        shift 1
85    fi
86
[11594]87    exec -a "$0" "$DIRNAME"/PythonAppStart -m Orange.OrangeCanvas.main "$@"
[11533]88EOF
89
[11594]90chmod +x ${APP}/Contents/MacOS/Orange
[10488]91
[11074]92# First install/upgrade distrubute. The setup.py scripts might
93# need it
94echo "Installing/upgrading distribute in the bundle"
95echo "============================================="
96$EASY_INSTALL -U distribute
97
98
[10270]99echo "Checkouting and building orange"
[10277]100echo "==============================="
[11594]101./bundle-inject-hg.sh https://bitbucket.org/biolab/orange orange $REVISION $REPOS_DIR ${APP}
[10270]102
[10782]103echo "Specifically building orangeqt"
[11074]104echo "------------------------------"
105
[11594]106pushd $REPOS_DIR/orange/source/orangeqt
[10782]107echo "Fixing sip/pyqt configuration"
108
[11594]109sed -i.bak "s@/Users/.*/Orange.app/@$APP/@g" ${SITE_PACKAGES}/PyQt4/pyqtconfig.py
110sed -i.bak "s@/Users/.*/Orange.app/@$APP/@g" ${SITE_PACKAGES}/sipconfig.py
[10782]111export PATH=$APP/Contents/Resources/Qt4/bin:$PATH
112$PYTHON setup.py install
[11594]113
114popd
[10782]115
[10946]116echo "Fixing Qt plugins search path"
117echo "[Paths]
118Plugins = ../../../../../Resources/Qt4/plugins/" > $APP/Contents/Frameworks/Python.framework/Resources/Python.app/Contents/Resources/qt.conf
119
[11594]120echo "[Paths]
121Plugins = Resources/Qt4/plugins/" > $APP/Contents/Resources/qt.conf
122
[11074]123
[10270]124echo "Checkouting and building bioinformatics addon"
[10277]125echo "============================================="
[11594]126./bundle-inject-hg.sh https://bitbucket.org/biolab/orange-bioinformatics bioinformatics tip $REPOS_DIR ${APP}
[10270]127
128echo "Checkouting and building text addon"
[10277]129echo "==================================="
[11594]130./bundle-inject-hg.sh https://bitbucket.org/biolab/orange-text text tip $REPOS_DIR ${APP}
[10270]131
[10487]132echo "Installing networkx"
[11074]133echo "+++++++++++++++++++"
[11594]134./bundle-inject-pypi.sh networkx-1.6 http://pypi.python.org/packages/source/n/networkx/networkx-1.6.tar.gz $REPOS_DIR ${APP}
[10487]135
[10336]136echo "Installing suds library"
137echo "+++++++++++++++++++++++"
[11594]138./bundle-inject-pypi.sh suds-0.4 http://pypi.python.org/packages/source/s/suds/suds-0.4.tar.gz $REPOS_DIR ${APP}
[10336]139
[11460]140echo "Instaling slumber library"
141echo "+++++++++++++++++++++++++"
142$EASY_INSTALL slumber
143
[10270]144echo "Removing unnecessary files."
145find $TMP_BUNDLE_DIR \( -name '*~' -or -name '*.bak' -or -name '*.pyc' -or -name '*.pyo' -or -name '*.pyd' \) -exec rm -rf {} ';'
146
[11594]147ln -s ../Frameworks/Python.framework/Versions/Current/lib/python${PY_VER}/site-packages/Orange ${APP}/Contents/Resources/Orange
[10488]148
[10270]149   
[10277]150echo "Preparing the .dmg image"
151echo "========================"
[10270]152
153# Makes a link to Applications folder
154ln -s /Applications/ $TMP_BUNDLE_DIR/Applications
155
156echo "Fixing bundle permissions."
157
158{ chown -Rh root:wheel $TMP_BUNDLE_DIR; } || { echo "Could not fix bundle permissions"; }
159
160echo "Creating temporary image with the bundle."
161
162TMP_BUNDLE=${WORK_DIR}/bundle.dmg
163rm -f $TMP_BUNDLE
164
165hdiutil detach /Volumes/Orange -force || true
166hdiutil create -format UDRW -volname Orange -fs HFS+ -fsargs "-c c=64,a=16,e=16" -srcfolder $TMP_BUNDLE_DIR $TMP_BUNDLE
167MOUNT_OUTPUT=`hdiutil attach -readwrite -noverify -noautoopen $TMP_BUNDLE | egrep '^/dev/'`
168DEV_NAME=`echo -n "$MOUNT_OUTPUT" | head -n 1 | awk '{print $1}'`
169MOUNT_POINT=`echo -n "$MOUNT_OUTPUT" | tail -n 1 | awk '{print $3}'`
170
171# Makes the disk image window open automatically when mounted
172bless -openfolder "$MOUNT_POINT"
173# Hides background directory even more
174/Developer/Tools/SetFile -a V "$MOUNT_POINT/.background/"
175# Sets the custom icon volume flag so that volume has nice Orange icon after mount (.VolumeIcon.icns)
176/Developer/Tools/SetFile -a C "$MOUNT_POINT"
177
178# Might mot have permissions to do this
179{ rm -rf "$MOUNT_POINT/.Trashes/"; } || { echo "Could not remove $MOUNT_POINT/.Trashes/"; }
180
181{ rm -rf "$MOUNT_POINT/.fseventsd/"; } || { echo "Could not remove $MOUNT_POINT/.fseventsd/"; }
182
183hdiutil detach "$DEV_NAME" -force
184
185echo "Converting temporary image to a compressed image."
186
187if [ -e $BUNDLE ]; then
188    rm -f $BUNDLE
189fi
190
191hdiutil convert $TMP_BUNDLE -format UDZO -imagekey zlib-level=9 -o $BUNDLE
192
193echo "Cleaning up."
194rm -f $TMP_BUNDLE
195rm -rf $TMP_BUNDLE_DIR
196
197true
Note: See TracBrowser for help on using the repository browser.