Fix unbound variable
[openjpeg.git] / tools / travis-ci / install.sh
1 #!/bin/bash
2
3 # This script executes the install step when running under travis-ci
4
5 # Set-up some error handling
6 set -o nounset   ## set -u : exit the script if you try to use an uninitialised variable
7 set -o errexit   ## set -e : exit the script if any statement returns a non-true return value
8 set -o pipefail  ## Fail on error in pipe
9
10 function exit_handler ()
11 {
12         local exit_code="$?"
13         
14         test ${exit_code} == 0 && return;
15
16         echo -e "\nInstall failed !!!\nLast command at line ${BASH_LINENO}: ${BASH_COMMAND}";
17         exit "${exit_code}"
18 }
19 trap exit_handler EXIT
20 trap exit ERR 
21
22 # travis-ci doesn't dump cmake version in system info, let's print it 
23 cmake --version
24
25 OPJ_SOURCE_DIR=$(cd $(dirname $0)/../.. && pwd)
26
27 # We need test data
28 if [ "${TRAVIS_BRANCH:-}" == "" ]; then
29         TRAVIS_BRANCH=$(git -C ${OPJ_SOURCE_DIR} branch | grep '*' | tr -d '*[[:blank:]]') #default to same branch as we're setting up
30 fi
31 OPJ_DATA_HAS_BRANCH=$(git ls-remote --heads git://github.com/uclouvain/openjpeg-data.git ${TRAVIS_BRANCH} | wc -l)
32 if [ ${OPJ_DATA_HAS_BRANCH} -ne 0 ]; then
33         OPJ_DATA_BRANCH=${TRAVIS_BRANCH}
34 else
35         OPJ_DATA_BRANCH=master #default to master
36 fi
37 echo "Cloning openjpeg-data from ${OPJ_DATA_BRANCH} branch"
38 git clone --depth=1 --branch=${OPJ_DATA_BRANCH} git://github.com/uclouvain/openjpeg-data.git data
39
40 # We need jpylyzer for the test suite
41 echo "Retrieving jpylyzer"
42 wget -qO - https://github.com/openpreserve/jpylyzer/archive/1.14.2.tar.gz | tar -xz
43 mv jpylyzer-1.14.2 jpylyzer
44 chmod +x jpylyzer/jpylyzer/jpylyzer.py
45
46 # When OPJ_NONCOMMERCIAL=1, kakadu trial binaries are used for testing. Here's the copyright notice from kakadu:
47 # Copyright is owned by NewSouth Innovations Pty Limited, commercial arm of the UNSW Australia in Sydney.
48 # You are free to trial these executables and even to re-distribute them, 
49 # so long as such use or re-distribution is accompanied with this copyright notice and is not for commercial gain.
50 # Note: Binaries can only be used for non-commercial purposes.
51 if [ "${OPJ_NONCOMMERCIAL:-}" == "1" ]; then
52         if [ "${TRAVIS_OS_NAME:-}" == "linux" ] || uname -s | grep -i Linux &> /dev/null; then
53                 echo "Retrieving Kakadu"
54                 wget -q http://kakadusoftware.com/wp-content/uploads/2014/06/KDU77_Demo_Apps_for_Linux-x86-64_150710.zip
55                 cmake -E tar -xf KDU77_Demo_Apps_for_Linux-x86-64_150710.zip
56                 mv KDU77_Demo_Apps_for_Linux-x86-64_150710 kdu
57         fi
58 fi