source: orange/install-scripts/mac/bundle-build-hg.sh @ 11728:a71f53323935

Revision 11728:a71f53323935, 5.9 KB checked in by Ales Erjavec <ales.erjavec@…>, 6 months ago (diff)

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