source: orange/install-scripts/mac/bundle-daily-build.sh @ 9774:95e6cdc3fe1e

Revision 9774:95e6cdc3fe1e, 14.1 KB checked in by ales_erjavec, 2 years ago (diff)

Using hg repos for daily addons.

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