Merge branch 'master' into travis-matrix
[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 # We don't need anything for coverity scan builds
23
24 if [ "${COVERITY_SCAN_BRANCH:-}" != "1" ]; then
25
26         if [ "${OPJ_CI_ASAN:-}" == "1" ]; then
27                 # We need a new version of cmake than travis-ci provides
28                 wget -qO - http://www.cmake.org/files/v3.3/cmake-3.3.1-Linux-x86_64.tar.gz | tar -xz
29                 # copy to a directory that will not changed every version
30                 mv cmake-3.3.1-Linux-x86_64 cmake-install
31         fi
32
33         if [ "${OPJ_CI_SKIP_TESTS:-}" != "1" ]; then
34
35                 OPJ_SOURCE_DIR=$(cd $(dirname $0)/../.. && pwd)
36
37                 # We need test data
38                 if [ "${TRAVIS_BRANCH:-}" == "" ]; then
39                         TRAVIS_BRANCH=$(git -C ${OPJ_SOURCE_DIR} branch | grep '*' | tr -d '*[[:blank:]]') #default to same branch as we're setting up
40                 fi
41                 OPJ_DATA_HAS_BRANCH=$(git ls-remote --heads git://github.com/uclouvain/openjpeg-data.git ${TRAVIS_BRANCH} | wc -l)
42                 if [ ${OPJ_DATA_HAS_BRANCH} -ne 0 ]; then
43                         OPJ_DATA_BRANCH=${TRAVIS_BRANCH}
44                 else
45                         OPJ_DATA_BRANCH=master #default to master
46                 fi
47                 echo "Cloning openjpeg-data from ${OPJ_DATA_BRANCH} branch"
48                 git clone --depth=1 --branch=${OPJ_DATA_BRANCH} git://github.com/uclouvain/openjpeg-data.git data
49
50                 # We need jpylyzer for the test suite
51                 echo "Retrieving jpylyzer"
52                 wget -qO - https://github.com/openpreserve/jpylyzer/archive/1.14.2.tar.gz | tar -xz
53                 mv jpylyzer-1.14.2 jpylyzer
54                 chmod +x jpylyzer/jpylyzer/jpylyzer.py
55
56                 # When OPJ_NONCOMMERCIAL=1, kakadu trial binaries are used for testing. Here's the copyright notice from kakadu:
57                 # Copyright is owned by NewSouth Innovations Pty Limited, commercial arm of the UNSW Australia in Sydney.
58                 # You are free to trial these executables and even to re-distribute them, 
59                 # so long as such use or re-distribution is accompanied with this copyright notice and is not for commercial gain.
60                 # Note: Binaries can only be used for non-commercial purposes.
61                 if [ "${OPJ_NONCOMMERCIAL:-}" == "1" ]; then
62                         if [ "${TRAVIS_OS_NAME:-}" == "linux" ] || uname -s | grep -i Linux &> /dev/null; then
63                                 echo "Retrieving Kakadu"
64                                 wget -q http://kakadusoftware.com/wp-content/uploads/2014/06/KDU77_Demo_Apps_for_Linux-x86-64_150710.zip
65                                 cmake -E tar -xf KDU77_Demo_Apps_for_Linux-x86-64_150710.zip
66                                 mv KDU77_Demo_Apps_for_Linux-x86-64_150710 kdu
67                         elif [ "${TRAVIS_OS_NAME:-}" == "osx" ] || uname -s | grep -i Darwin &> /dev/null; then
68                                 echo "Retrieving Kakadu"
69                                 wget -q http://kakadusoftware.com/wp-content/uploads/2014/06/KDU77_Demo_Apps_for_OSX109_150710.dmg_.zip
70                                 cmake -E tar -xf KDU77_Demo_Apps_for_OSX109_150710.dmg_.zip
71                                 wget -q http://downloads.sourceforge.net/project/catacombae/HFSExplorer/0.23/hfsexplorer-0.23-bin.zip
72                                 mkdir hfsexplorer && cmake -E chdir hfsexplorer tar -xf ../hfsexplorer-0.23-bin.zip
73                                 ./hfsexplorer/bin/unhfs.sh -o ./ -fsroot Kakadu-demo-apps.pkg  KDU77_Demo_Apps_for_OSX109_150710.dmg
74                                 pkgutil --expand Kakadu-demo-apps.pkg ./kdu
75                                 cd kdu
76                                 cat libkduv77r.pkg/Payload | gzip -d | cpio -id
77                                 cat kduexpand.pkg/Payload | gzip -d | cpio -id
78                                 cat kducompress.pkg/Payload | gzip -d | cpio -id
79                                 install_name_tool -id ${PWD}/libkdu_v77R.dylib libkdu_v77R.dylib 
80                                 install_name_tool -change /usr/local/lib/libkdu_v77R.dylib ${PWD}/libkdu_v77R.dylib kdu_compress
81                                 install_name_tool -change /usr/local/lib/libkdu_v77R.dylib ${PWD}/libkdu_v77R.dylib kdu_expand
82                         fi
83                 fi
84         fi
85 fi