source: orange/install-scripts/mac/bundle-daily-build-hg.sh @ 10788:54d1998fd646

Revision 10788:54d1998fd646, 2.1 KB checked in by Ales Erjavec <ales.erjavec@…>, 2 years ago (diff)

Check bundle image file integrity.

  • Property exe set to *
Line 
1#!/bin/bash -e
2#
3# ./bundle-daily-build-hg.sh
4#
5# $1 Force
6#
7
8FORCE=$1
9
10trap "echo \"Script failed\"" ERR
11
12# If possible get the orange tip revision number and check if the bundle already exists
13if [ -e /private/tmp/repos/orange ]; then
14    # Try to pull and update (pull returns 1 if no changesets)
15    hg pull --update -R /private/tmp/repos/orange || true
16    DAILY_REVISION=`hg log -r tip -R /private/tmp/repos/orange | grep 'changeset:' | cut -d ' ' -f 4 | cut -d ':' -f 1`
17else
18    DAILY_REVISION="tip"
19fi
20
21BUNDLE="/private/tmp/orange-bundle-hg-$DAILY_REVISION.dmg"
22       
23# Create the bundle if it does not yet exist
24if [[ ! -e /Volumes/download/orange-bundle-hg-0.0.$DAILY_REVISION.dmg || $DAILY_REVISION -eq "tip" || $FORCE ]]; then
25    echo "Building orange revision $DAILY_REVISION"
26    ./bundle-build-hg.sh /private/tmp tip $BUNDLE
27   
28    # Get the revision again in case it was "tip"
29    DAILY_REVISION=`hg log -r tip -R /private/tmp/repos/orange | grep 'changeset:' | cut -d ' ' -f 4 | cut -d ':' -f 1`
30
31    # TODO: Should be called only on a daily build server and not if building locally
32    /Users/ailabc/mount-dirs.sh
33
34    echo "Removing old versions of bundles."
35    # (Keeps last 5 versions.)
36    perl -e 'unlink ((reverse sort </Volumes/download/orange-bundle-hg-0*.dmg>)[5..10000])'
37
38    echo "Moving bundle to the download directory."
39    mv $BUNDLE /Volumes/download/orange-bundle-hg-0.0.$DAILY_REVISION.dmg
40
41    echo "Setting permissions."
42    chmod +r /Volumes/download/orange-bundle-hg-0.0.$DAILY_REVISION.dmg
43
44    # Check integrity
45    MD5=`md5 -q /Volumes/download/orange-bundle-hg-0.0.$DAILY_REVISION.dmg`
46    if [[ $MD5 != `md5 -q $BUNDLE` ]]; then
47        echo "Error moving the bundle in place"
48        rm /Volumes/download/orange-bundle-hg-0.0.$DAILY_REVISION.dmg
49        exit 1
50    fi
51   
52    echo "Registering new bundles."
53    egrep -v '^(MAC_DAILY)=' /Volumes/download/filenames_mac.set > /Volumes/download/filenames_mac.set.new
54    echo "MAC_DAILY=orange-bundle-hg-0.0.$DAILY_REVISION.dmg" >> /Volumes/download/filenames_mac.set.new
55    mv /Volumes/download/filenames_mac.set.new /Volumes/download/filenames_mac.set
56
57else
58    echo "The bundle with revision $DAILY_REVISION already exists."
59fi
Note: See TracBrowser for help on using the repository browser.