source: orange/install-scripts/mac/bundle-build-hg.sh @ 11774:c75652222fa2

Revision 11774:c75652222fa2, 6.0 KB checked in by Ales Erjavec <ales.erjavec@…>, 5 months ago (diff)

Install PIL inside OSX application bundle, disable user site packages.

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