Add appveyor support
[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 #if cygwin, check path
6 case ${MACHTYPE} in
7         *cygwin*) OPJ_CI_IS_CYGWIN=1;;
8         *) ;;
9 esac
10
11 if [ "${OPJ_CI_IS_CYGWIN:-}" == "1" ]; then
12         if ! which which; then
13                 # PATH is not yet set up
14                 export PATH=$PATH:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
15         fi
16 fi
17
18 # Set-up some error handling
19 set -o nounset   ## set -u : exit the script if you try to use an uninitialised variable
20 set -o errexit   ## set -e : exit the script if any statement returns a non-true return value
21 set -o pipefail  ## Fail on error in pipe
22
23 function exit_handler ()
24 {
25         local exit_code="$?"
26         
27         test ${exit_code} == 0 && return;
28
29         echo -e "\nInstall failed !!!\nLast command at line ${BASH_LINENO}: ${BASH_COMMAND}";
30         exit "${exit_code}"
31 }
32 trap exit_handler EXIT
33 trap exit ERR
34
35 # We don't need anything for coverity scan builds. ABI check is managed in abi-check.sh
36 if [ "${COVERITY_SCAN_BRANCH:-}" == "1" ] || [ "${OPJ_CI_ABI_CHECK:-}" == "1" ]; then
37         exit 0
38 fi
39
40 if [ "${OPJ_CI_ASAN:-}" == "1" ]; then
41         # We need a new version of cmake than travis-ci provides
42         wget -qO - http://www.cmake.org/files/v3.3/cmake-3.3.1-Linux-x86_64.tar.gz | tar -xz
43         # copy to a directory that will not changed every version
44         mv cmake-3.3.1-Linux-x86_64 cmake-install
45 fi
46
47 if [ "${OPJ_CI_SKIP_TESTS:-}" != "1" ]; then
48
49         OPJ_SOURCE_DIR=$(cd $(dirname $0)/../.. && pwd)
50
51         # We need test data
52         if [ "${TRAVIS_BRANCH:-}" != "" ]; then
53                 OPJ_DATA_BRANCH=${TRAVIS_BRANCH}
54         elif [ "${APPVEYOR_REPO_BRANCH:-}" != "" ]; then
55                 OPJ_DATA_BRANCH=${APPVEYOR_REPO_BRANCH}
56         else
57                 OPJ_DATA_BRANCH=$(git -C ${OPJ_SOURCE_DIR} branch | grep '*' | tr -d '*[[:blank:]]') #default to same branch as we're setting up
58         fi
59         OPJ_DATA_HAS_BRANCH=$(git ls-remote --heads git://github.com/uclouvain/openjpeg-data.git ${OPJ_DATA_BRANCH} | wc -l)
60         if [ ${OPJ_DATA_HAS_BRANCH} -ne 0 ]; then
61                 OPJ_DATA_BRANCH=${TRAVIS_BRANCH}
62         else
63                 OPJ_DATA_BRANCH=master #default to master
64         fi
65         echo "Cloning openjpeg-data from ${OPJ_DATA_BRANCH} branch"
66         git clone --depth=1 --branch=${OPJ_DATA_BRANCH} git://github.com/uclouvain/openjpeg-data.git data
67
68         # We need jpylyzer for the test suite
69         echo "Retrieving jpylyzer"
70         wget -qO - https://github.com/openpreserve/jpylyzer/archive/1.14.2.tar.gz | tar -xz
71         mv jpylyzer-1.14.2 jpylyzer
72         chmod +x jpylyzer/jpylyzer/jpylyzer.py
73
74         # When OPJ_NONCOMMERCIAL=1, kakadu trial binaries are used for testing. Here's the copyright notice from kakadu:
75         # Copyright is owned by NewSouth Innovations Pty Limited, commercial arm of the UNSW Australia in Sydney.
76         # You are free to trial these executables and even to re-distribute them, 
77         # so long as such use or re-distribution is accompanied with this copyright notice and is not for commercial gain.
78         # Note: Binaries can only be used for non-commercial purposes.
79         if [ "${OPJ_NONCOMMERCIAL:-}" == "1" ]; then
80                 if [ "${TRAVIS_OS_NAME:-}" == "linux" ] || uname -s | grep -i Linux &> /dev/null; then
81                         echo "Retrieving Kakadu"
82                         wget -q http://kakadusoftware.com/wp-content/uploads/2014/06/KDU77_Demo_Apps_for_Linux-x86-64_150710.zip
83                         cmake -E tar -xf KDU77_Demo_Apps_for_Linux-x86-64_150710.zip
84                         mv KDU77_Demo_Apps_for_Linux-x86-64_150710 kdu
85                 elif [ "${TRAVIS_OS_NAME:-}" == "osx" ] || uname -s | grep -i Darwin &> /dev/null; then
86                         echo "Retrieving Kakadu"
87                         wget -q http://kakadusoftware.com/wp-content/uploads/2014/06/KDU77_Demo_Apps_for_OSX109_150710.dmg_.zip
88                         cmake -E tar -xf KDU77_Demo_Apps_for_OSX109_150710.dmg_.zip
89                         wget -q http://downloads.sourceforge.net/project/catacombae/HFSExplorer/0.23/hfsexplorer-0.23-bin.zip
90                         mkdir hfsexplorer && cmake -E chdir hfsexplorer tar -xf ../hfsexplorer-0.23-bin.zip
91                         ./hfsexplorer/bin/unhfs.sh -o ./ -fsroot Kakadu-demo-apps.pkg  KDU77_Demo_Apps_for_OSX109_150710.dmg
92                         pkgutil --expand Kakadu-demo-apps.pkg ./kdu
93                         cd kdu
94                         cat libkduv77r.pkg/Payload | gzip -d | cpio -id
95                         cat kduexpand.pkg/Payload | gzip -d | cpio -id
96                         cat kducompress.pkg/Payload | gzip -d | cpio -id
97                         install_name_tool -id ${PWD}/libkdu_v77R.dylib libkdu_v77R.dylib 
98                         install_name_tool -change /usr/local/lib/libkdu_v77R.dylib ${PWD}/libkdu_v77R.dylib kdu_compress
99                         install_name_tool -change /usr/local/lib/libkdu_v77R.dylib ${PWD}/libkdu_v77R.dylib kdu_expand
100                 elif [ "${APPVEYOR:-}" == "True" ]; then
101                         wget -q http://kakadusoftware.com/wp-content/uploads/2014/06/KDU77_Demo_Apps_for_Win32_150710.msi_.zip
102                         cmake -E tar -xf KDU77_Demo_Apps_for_Win32_150710.msi_.zip
103                         msiexec /i KDU77_Demo_Apps_for_Win32_150710.msi /quiet /qn /norestart
104                 fi
105         fi
106 fi