source: orange/install-scripts/mac/bundle-daily-build.sh @ 9731:612bb5f19096

Revision 9731:612bb5f19096, 16.8 KB checked in by ales_erjavec, 2 years ago (diff)

Using hg repo in mac osx bundle building scripts.

  • Property exe set to *
Line 
1#!/bin/bash -e
2#
3# Should be run as: ./bundle-daily-build.sh [stable revision] [daily revision]
4#
5# If [stable revision] and/or [daily revision] is/are not specified it uses its latest revision
6#
7
8# Lists of add-ons to include
9STABLE_ADDONS=""
10DAILY_ADDONS="Bioinformatics Text"
11
12# Sets error handler
13trap "echo \"Script failed\"" ERR
14
15[ -e /Volumes/download/ ] || { echo "/Volumes/download/ not mounted."; exit 1; }
16
17if [ ! -x /usr/bin/xcodebuild ]; then
18    echo "It seems Xcode is not installed on a system."
19    exit 2
20fi
21
22# Clone hg repo if not yet local.
23if [ ! -e orange ]; then
24    hg clone https://bitbucket.org/biolab/orange
25fi
26
27cd orange
28hg pull --update
29
30if [ -e ../orange_archive ]; then
31    rm -rf ../orange_archive
32fi
33
34hg archive ../orange_archive
35cd ..
36
37ORANGE_REPO=`pwd`/orange
38ORANGE_ARCHIVE=`pwd`/orange_archive
39
40# Defaults are current latest revisions in stable branch and trunk
41STABLE_REVISION_1=${1:-`svn info --non-interactive http://orange.biolab.si/svn/orange/branches/ver1.0/ | grep 'Last Changed Rev:' | cut -d ' ' -f 4`}
42# svn info does not return proper exit status on an error so we check it this way
43[ "$STABLE_REVISION_1" ] || exit 3
44STABLE_REVISION_2=${1:-`svn info --non-interactive http://orange.biolab.si/svn/orange/externals/branches/ver1.0/ | grep 'Last Changed Rev:' | cut -d ' ' -f 4`}
45# svn info does not return proper exit status on an error so we check it this way
46[ "$STABLE_REVISION_2" ] || exit 3
47if [[ $STABLE_REVISION_1 -gt $STABLE_REVISION_2 ]]; then
48    STABLE_REVISION=$STABLE_REVISION_1
49else
50    STABLE_REVISION=$STABLE_REVISION_2
51fi
52
53DAILY_REVISION_1 = `hg log -l1 daily | grep 'changeset:' | cut -d ' ' -f 4 | cut -d ':' -f 1`
54
55#TODO: versions of hg and svn repos are no longer in sync
56
57#DAILY_REVISION_2=${2:-`svn info --non-interactive http://orange.biolab.si/svn/orange/externals/trunk/ | grep 'Last Changed Rev:' | cut -d ' ' -f 4`}
58## svn info does not return proper exit status on an error so we check it this way
59#[ "$DAILY_REVISION_2" ] || exit 4
60#if [[ $DAILY_REVISION_1 -gt $DAILY_REVISION_2 ]]; then
61#    DAILY_REVISION=$DAILY_REVISION_1
62#else
63#    DAILY_REVISION=$DAILY_REVISION_2
64#fi
65
66echo "Preparing temporary directory."
67rm -rf /private/tmp/bundle/
68   
69# Gives our Python executable to compile scripts later on
70export PATH=/private/tmp/bundle/Orange.app/Contents/MacOS/:$PATH
71
72# Enables compiling of Universal binaries
73export CFLAGS="-arch ppc -arch i386"
74export CXXFLAGS="-arch ppc -arch i386"
75export LDFLAGS="-arch ppc -arch i386"
76
77
78###########################
79# Stable orange-1.0  bundle
80###########################
81
82if [ ! -e /Volumes/download/orange-bundle-1.0b.$STABLE_REVISION.dmg ]; then
83    echo "Downloading bundle template."
84    svn export --non-interactive --revision $STABLE_REVISION http://orange.biolab.si/svn/orange/externals/branches/ver1.0/install-scripts/mac/bundle/ /private/tmp/bundle/
85   
86    echo "Downloading Orange stable source code revision $STABLE_REVISION."
87    svn export --non-interactive --revision $STABLE_REVISION http://orange.biolab.si/svn/orange/branches/ver1.0/orange/ /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/orange/
88    svn export --non-interactive --revision $STABLE_REVISION http://orange.biolab.si/svn/orange/branches/ver1.0/source/ /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/orange/source/
89    svn export --non-interactive --revision $STABLE_REVISION http://orange.biolab.si/svn/orange/branches/ver1.0/add-ons/orngCRS/src/ /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/orange/source/crs/
90   
91    [ -e /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/orange/doc/COPYING ] || svn export --non-interactive --revision $STABLE_REVISION http://orange.biolab.si/svn/orange/branches/ver1.0/COPYING /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/orange/doc/COPYING
92    [ -e /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/orange/doc/LICENSES ] || svn export --non-interactive --revision $STABLE_REVISION http://orange.biolab.si/svn/orange/branches/ver1.0/LICENSES /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/orange/doc/LICENSES
93   
94    ln -s ../Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/orange/ /private/tmp/bundle/Orange.app/Contents/Resources/orange
95    ln -s ../Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/orange/doc/ /private/tmp/bundle/Orange.app/Contents/Resources/doc
96   
97    echo "Compiling."
98    cd /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/orange/source/
99    make
100    cd /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/orange/source/crs/
101    make
102    mv _orngCRS.so ../../
103    cd /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/orange/
104   
105    echo "Correcting install names for modules."
106    for module in *.so ; do
107        [ -L $module ] && continue
108       
109        install_name_tool -id @executable_path/../Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/orange/$module $module
110       
111        perl -MFile::Spec::Functions=abs2rel -e '
112        for (`/usr/bin/otool -L -X $ARGV[0]`) {
113            next unless m|^\s+(/private/tmp/bundle/Orange.app/.*) \(.*\)$|;
114            system("/usr/bin/install_name_tool", "-change", $1, "\@loader_path/" . abs2rel($1), $ARGV[0]);
115        }
116        ' $module
117    done
118   
119    echo "Cleaning up."
120    rm -rf source/ c45.dll liborange_include.a updateOrange.py
121   
122    # Installation registration
123    echo "orange" > /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/orange.pth
124   
125    for addon in $STABLE_ADDONS ; do
126        echo "Downloading Orange add-on $addon stable source code revision $STABLE_REVISION."
127        svn export --non-interactive --revision $STABLE_REVISION http://orange.biolab.si/svn/orange/branches/ver1.0/add-ons/$addon/ /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/orange/add-ons/$addon/
128       
129        [ -e /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/orange/add-ons/$addon/doc/COPYING ] || svn export --non-interactive --revision $STABLE_REVISION http://orange.biolab.si/svn/orange/branches/ver1.0/COPYING /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/orange/add-ons/$addon/doc/COPYING
130        [ -e /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/orange/add-ons/$addon/doc/LICENSES ] || svn export --non-interactive --revision $STABLE_REVISION http://orange.biolab.si/svn/orange/branches/ver1.0/LICENSES /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/orange/add-ons/$addon/doc/LICENSES
131       
132        if [ -e /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/orange/add-ons/$addon/source/ ]; then
133            echo "Compiling add-on."
134            cd /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/orange/add-ons/$addon/source/
135            make
136            cd /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/orange/add-ons/$addon/
137           
138            echo "Correcting install names for modules."
139            for module in *.so ; do
140                [ -L $module ] && continue
141           
142                install_name_tool -id @executable_path/../Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/orange/add-ons/$addon/$module $module
143               
144                perl -MFile::Spec::Functions=abs2rel -e '
145                for (`/usr/bin/otool -L -X $ARGV[0]`) {
146                    next unless m|^\s+(/private/tmp/bundle/Orange.app/.*) \(.*\)$|;
147                    system("/usr/bin/install_name_tool", "-change", $1, "\@loader_path/" . abs2rel($1), $ARGV[0]);
148                }
149                ' $module
150            done
151        fi
152       
153        echo "Cleaning up."
154        rm -rf source/ setup.py
155       
156        # Installation registration
157        echo "orange/add-ons/$addon" > /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/orange-`echo $addon | tr "[:upper:]" "[:lower:]"`.pth
158    done
159   
160    echo "Removing unnecessary files."
161    find /private/tmp/bundle/ \( -name '*~' -or -name '*.bak' -or -name '*.pyc' -or -name '*.pyo' -or -name '*.pyd' \) -exec rm -rf {} ';'
162   
163    # Makes a link to Applications folder
164    ln -s /Applications/ /private/tmp/bundle/Applications
165   
166    echo "Fixing bundle permissions."
167    chown -Rh root:wheel /private/tmp/bundle/
168   
169    echo "Creating temporary image with the bundle."
170    rm -f /private/tmp/bundle.dmg
171    hdiutil detach /Volumes/Orange -force || true
172    hdiutil create -format UDRW -volname Orange -fs HFS+ -fsargs "-c c=64,a=16,e=16" -srcfolder /private/tmp/bundle/ /private/tmp/bundle.dmg
173    MOUNT_OUTPUT=`hdiutil attach -readwrite -noverify -noautoopen /private/tmp/bundle.dmg | egrep '^/dev/'`
174    DEV_NAME=`echo -n "$MOUNT_OUTPUT" | head -n 1 | awk '{print $1}'`
175    MOUNT_POINT=`echo -n "$MOUNT_OUTPUT" | tail -n 1 | awk '{print $3}'`
176   
177    # Makes the disk image window open automatically when mounted
178    bless -openfolder "$MOUNT_POINT"
179    # Hides background directory even more
180    /Developer/Tools/SetFile -a V "$MOUNT_POINT/.background/"
181    # Sets the custom icon volume flag so that volume has nice Orange icon after mount (.VolumeIcon.icns)
182    /Developer/Tools/SetFile -a C "$MOUNT_POINT"
183   
184    rm -rf "$MOUNT_POINT/.Trashes/"
185    rm -rf "$MOUNT_POINT/.fseventsd/"
186   
187    hdiutil detach "$DEV_NAME" -force
188   
189    echo "Converting temporary image to a compressed image."
190    rm -f /private/tmp/orange-bundle-1.0b.$STABLE_REVISION.dmg
191    hdiutil convert /private/tmp/bundle.dmg -format UDZO -imagekey zlib-level=9 -o /private/tmp/orange-bundle-1.0b.$STABLE_REVISION.dmg
192   
193    echo "Cleaning up."
194    rm -f /private/tmp/bundle.dmg
195    rm -rf /private/tmp/bundle/
196fi
197
198# TODO: Should be called only on a daily build server and not if building locally
199/Users/ailabc/mount-dirs.sh
200
201#########################
202# Daily orange 2.* bundle
203#########################
204
205if [ ! -e /Volumes/download/orange-bundle-hg-0.0.$DAILY_REVISION.dmg ]; then
206    echo "Downloading bundle template."
207    svn export --non-interactive --revision $DAILY_REVISION http://orange.biolab.si/svn/orange/externals/trunk/install-scripts/mac/bundle/ /private/tmp/bundle/
208   
209    echo "Building and installing orange into the bundle."
210    cd $ORANGE_ARCHIVE
211    /private/tmp/bundle/Orange.app/Contents/MacOS/python setup.py install
212       
213#   echo "Correcting install names for modules."
214#   for module in *.so ; do
215#       [ -L $module ] && continue
216#       
217#       install_name_tool -id @executable_path/../Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/orange/$module $module
218#       
219#       perl -MFile::Spec::Functions=abs2rel -e '
220#       for (`/usr/bin/otool -L -X $ARGV[0]`) {
221#           next unless m|^\s+(/private/tmp/bundle/Orange.app/.*) \(.*\)$|;
222#           system("/usr/bin/install_name_tool", "-change", $1, "\@loader_path/" . abs2rel($1), $ARGV[0]);
223#       }
224#       ' $module
225#   done
226   
227#   echo "Cleaning up."
228#   rm -rf source/ c45.dll liborange_include.a updateOrange.py
229   
230    # Installation registration
231#   echo "orange" > /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/orange.pth
232   
233    # TODO: hg repos for addons
234    for addon in $DAILY_ADDONS ; do
235        echo "Downloading Orange add-on $addon daily source code revision $DAILY_REVISION."
236        svn export --non-interactive --revision $DAILY_REVISION http://orange.biolab.si/svn/orange/trunk/add-ons/$addon/ /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/orange/add-ons/$addon/
237       
238        [ -e /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/orange/add-ons/$addon/doc/COPYING ] || svn export --non-interactive --revision $DAILY_REVISION http://orange.biolab.si/svn/orange/trunk/COPYING /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/orange/add-ons/$addon/doc/COPYING
239        [ -e /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/orange/add-ons/$addon/doc/LICENSES ] || svn export --non-interactive --revision $DAILY_REVISION http://orange.biolab.si/svn/orange/trunk/LICENSES /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/orange/add-ons/$addon/doc/LICENSES
240       
241        if [ -e /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/orange/add-ons/$addon/source/ ]; then
242            echo "Compiling add-on."
243            cd /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/orange/add-ons/$addon/source/
244            make
245            cd /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/orange/add-ons/$addon/
246           
247            echo "Correcting install names for modules."
248            for module in *.so ; do
249                [ -L $module ] && continue
250           
251                install_name_tool -id @executable_path/../Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/orange/add-ons/$addon/$module $module
252               
253                perl -MFile::Spec::Functions=abs2rel -e '
254                for (`/usr/bin/otool -L -X $ARGV[0]`) {
255                    next unless m|^\s+(/private/tmp/bundle/Orange.app/.*) \(.*\)$|;
256                    system("/usr/bin/install_name_tool", "-change", $1, "\@loader_path/" . abs2rel($1), $ARGV[0]);
257                }
258                ' $module
259            done
260        fi
261       
262#       echo "Cleaning up."
263#       rm -rf source/ setup.py
264       
265        # Installation registration
266        echo "orange/add-ons/$addon" > /private/tmp/bundle/Orange.app/Contents/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/orange-`echo $addon | tr "[:upper:]" "[:lower:]"`.pth
267    done
268   
269    echo "Removing unnecessary files."
270    find /private/tmp/bundle/ \( -name '*~' -or -name '*.bak' -or -name '*.pyc' -or -name '*.pyo' -or -name '*.pyd' \) -exec rm -rf {} ';'
271   
272    # Makes a link to Applications folder
273    ln -s /Applications/ /private/tmp/bundle/Applications
274
275    echo "Fixing bundle permissions."
276    chown -Rh root:wheel /private/tmp/bundle/
277   
278    echo "Creating temporary image with the bundle."
279    rm -f /private/tmp/bundle.dmg
280    hdiutil detach /Volumes/Orange -force || true
281    hdiutil create -format UDRW -volname Orange -fs HFS+ -fsargs "-c c=64,a=16,e=16" -srcfolder /private/tmp/bundle/ /private/tmp/bundle.dmg
282    MOUNT_OUTPUT=`hdiutil attach -readwrite -noverify -noautoopen /private/tmp/bundle.dmg | egrep '^/dev/'`
283    DEV_NAME=`echo -n "$MOUNT_OUTPUT" | head -n 1 | awk '{print $1}'`
284    MOUNT_POINT=`echo -n "$MOUNT_OUTPUT" | tail -n 1 | awk '{print $3}'`
285   
286    # Makes the disk image window open automatically when mounted
287    bless -openfolder "$MOUNT_POINT"
288    # Hides background directory even more
289    /Developer/Tools/SetFile -a V "$MOUNT_POINT/.background/"
290    # Sets the custom icon volume flag so that volume has nice Orange icon after mount (.VolumeIcon.icns)
291    /Developer/Tools/SetFile -a C "$MOUNT_POINT"
292   
293    rm -rf "$MOUNT_POINT/.Trashes/"
294    rm -rf "$MOUNT_POINT/.fseventsd/"
295   
296    hdiutil detach "$DEV_NAME" -force
297   
298    echo "Converting temporary image to a compressed image."
299    rm -f /private/tmp/orange-bundle-hg-0.0.$DAILY_REVISION.dmg
300    hdiutil convert /private/tmp/bundle.dmg -format UDZO -imagekey zlib-level=9 -o /private/tmp/orange-bundle-hg-0.0.$DAILY_REVISION.dmg
301   
302    echo "Cleaning up."
303    rm -f /private/tmp/bundle.dmg
304    rm -rf /private/tmp/bundle/
305fi
306
307# TODO: Should be called only on a daily build server and not if building locally
308/Users/ailabc/mount-dirs.sh
309
310echo "Removing old versions of bundles."
311# (Keeps last 5 versions.)
312perl -e 'unlink ((reverse sort </Volumes/download/orange-bundle-hg-0*.dmg>)[5..10000])'
313perl -e 'unlink ((reverse sort </Volumes/download/orange-bundle-1*.dmg>)[5..10000])'
314
315if [ -e /private/tmp/orange-bundle-hg-0.0.$DAILY_REVISION.dmg ] || [ -e /private/tmp/orange-bundle-hg-0.0.$DAILY_REVISION.dmg ]; then
316    echo "Moving bundles to the download directory."
317    [ -e /private/tmp/orange-bundle-1.0b.$STABLE_REVISION.dmg ] && mv /private/tmp/orange-bundle-1.0b.$STABLE_REVISION.dmg /Volumes/download/
318    [ -e /private/tmp/orange-bundle-hg-0.0.$DAILY_REVISION.dmg ] && mv /private/tmp/orange-bundle-hg-0.0.$DAILY_REVISION.dmg /Volumes/download/
319   
320    echo "Setting permissions."
321    chmod +r /Volumes/download/orange-bundle-1.0b.$STABLE_REVISION.dmg
322    chmod +r /Volumes/download/orange-bundle-hg-0.0.$DAILY_REVISION.dmg
323
324# Don't register the bundles until hg version stabilizes
325   
326#   echo "Registering new bundles."
327#   egrep -v '^(MAC_STABLE|MAC_DAILY)=' /Volumes/download/filenames_mac.set > /Volumes/download/filenames_mac.set.new
328#   echo "MAC_STABLE=orange-bundle-1.0b.$STABLE_REVISION.dmg" >> /Volumes/download/filenames_mac.set.new
329#   echo "MAC_DAILY=orange-bundle-svn-0.0.$DAILY_REVISION.dmg" >> /Volumes/download/filenames_mac.set.new
330#   mv /Volumes/download/filenames_mac.set.new /Volumes/download/filenames_mac.set
331fi
Note: See TracBrowser for help on using the repository browser.