source: orange/install-scripts/mac/bundle-build-hg.sh @ 11621:18e7af983522

Revision 11621:18e7af983522, 5.7 KB checked in by Ales Erjavec <ales.erjavec@…>, 9 months ago (diff)

Removed no longer needed dependencies in OSX application bundle.

  • 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
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
76    #!/bin/bash
77
78    DIRNAME=$(dirname "$0")
79    source "$DIRNAME"/ENV
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
87    exec -a "$0" "$DIRNAME"/PythonAppStart -m Orange.OrangeCanvas.main "$@"
88EOF
89
90chmod +x ${APP}/Contents/MacOS/Orange
91
92
93echo "Checkouting and building orange"
94echo "==============================="
95./bundle-inject-hg.sh https://bitbucket.org/biolab/orange orange $REVISION $REPOS_DIR ${APP}
96
97echo "Specifically building orangeqt"
98echo "------------------------------"
99
100pushd $REPOS_DIR/orange/source/orangeqt
101echo "Fixing sip/pyqt configuration"
102
103sed -i.bak "s@/Users/.*/Orange.app/@$APP/@g" ${SITE_PACKAGES}/PyQt4/pyqtconfig.py
104sed -i.bak "s@/Users/.*/Orange.app/@$APP/@g" ${SITE_PACKAGES}/sipconfig.py
105export PATH=$APP/Contents/Resources/Qt4/bin:$PATH
106$PYTHON setup.py install
107
108popd
109
110echo "Fixing Qt plugins search path"
111echo "[Paths]
112Plugins = ../../../../../Resources/Qt4/plugins/" > $APP/Contents/Frameworks/Python.framework/Resources/Python.app/Contents/Resources/qt.conf
113
114echo "[Paths]
115Plugins = Resources/Qt4/plugins/" > $APP/Contents/Resources/qt.conf
116
117
118echo "Checkouting and building bioinformatics addon"
119echo "============================================="
120./bundle-inject-hg.sh https://bitbucket.org/biolab/orange-bioinformatics bioinformatics tip $REPOS_DIR ${APP}
121
122echo "Checkouting and building text addon"
123echo "==================================="
124./bundle-inject-hg.sh https://bitbucket.org/biolab/orange-text text tip $REPOS_DIR ${APP}
125
126echo "Instaling slumber library"
127echo "+++++++++++++++++++++++++"
128$EASY_INSTALL slumber
129
130echo "Removing unnecessary files."
131find $TMP_BUNDLE_DIR \( -name '*~' -or -name '*.bak' -or -name '*.pyc' -or -name '*.pyo' -or -name '*.pyd' \) -exec rm -rf {} ';'
132
133ln -s ../Frameworks/Python.framework/Versions/Current/lib/python${PY_VER}/site-packages/Orange ${APP}/Contents/Resources/Orange
134
135   
136echo "Preparing the .dmg image"
137echo "========================"
138
139# Makes a link to Applications folder
140ln -s /Applications/ $TMP_BUNDLE_DIR/Applications
141
142echo "Fixing bundle permissions."
143
144{ chown -Rh root:wheel $TMP_BUNDLE_DIR; } || { echo "Could not fix bundle permissions"; }
145
146echo "Creating temporary image with the bundle."
147
148TMP_BUNDLE=${WORK_DIR}/bundle.dmg
149rm -f $TMP_BUNDLE
150
151hdiutil detach /Volumes/Orange -force || true
152hdiutil create -format UDRW -volname Orange -fs HFS+ -fsargs "-c c=64,a=16,e=16" -srcfolder $TMP_BUNDLE_DIR $TMP_BUNDLE
153MOUNT_OUTPUT=`hdiutil attach -readwrite -noverify -noautoopen $TMP_BUNDLE | egrep '^/dev/'`
154DEV_NAME=`echo -n "$MOUNT_OUTPUT" | head -n 1 | awk '{print $1}'`
155MOUNT_POINT=`echo -n "$MOUNT_OUTPUT" | tail -n 1 | awk '{print $3}'`
156
157# Makes the disk image window open automatically when mounted
158bless -openfolder "$MOUNT_POINT"
159# Hides background directory even more
160/Developer/Tools/SetFile -a V "$MOUNT_POINT/.background/"
161# Sets the custom icon volume flag so that volume has nice Orange icon after mount (.VolumeIcon.icns)
162/Developer/Tools/SetFile -a C "$MOUNT_POINT"
163
164# Might mot have permissions to do this
165{ rm -rf "$MOUNT_POINT/.Trashes/"; } || { echo "Could not remove $MOUNT_POINT/.Trashes/"; }
166
167{ rm -rf "$MOUNT_POINT/.fseventsd/"; } || { echo "Could not remove $MOUNT_POINT/.fseventsd/"; }
168
169hdiutil detach "$DEV_NAME" -force
170
171echo "Converting temporary image to a compressed image."
172
173if [ -e $BUNDLE ]; then
174    rm -f $BUNDLE
175fi
176
177hdiutil convert $TMP_BUNDLE -format UDZO -imagekey zlib-level=9 -o $BUNDLE
178
179echo "Cleaning up."
180rm -f $TMP_BUNDLE
181rm -rf $TMP_BUNDLE_DIR
182
183true
Note: See TracBrowser for help on using the repository browser.