summaryrefslogtreecommitdiffstats
path: root/test/setup_vendor.sh
blob: 7d47ff87bcca5e0b2dfbcc44cf2d02df422480b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash

set -ex

MODULE_HOME=${MODULE_HOME:="$(dirname "$(readlink -f $(dirname "$0"))")"}
PHP_VERSION="$(php -r 'echo phpversion();')"

# see also .travis.yml
ICINGAWEB_VERSION=${ICINGAWEB_VERSION:=2.5.1}
ICINGAWEB_GITREF=${ICINGAWEB_GITREF:=}

IPL_VERSION=${IPL_VERSION:=0.1.1}

PHPCS_VERSION=${PHPCS_VERSION:=2.9.1}

if [ "$PHP_VERSION" '<' 5.6.0 ]; then
  PHPUNIT_VERSION=${PHPUNIT_VERSION:=4.8}
else
  PHPUNIT_VERSION=${PHPUNIT_VERSION:=5.7}
fi

cd ${MODULE_HOME}

test -d vendor || mkdir vendor
cd vendor/

# icingaweb2
if [ -n "$ICINGAWEB_GITREF" ]; then
  icingaweb_path="icingaweb2"
  test ! -L "$icingaweb_path" || rm "$icingaweb_path"

  if [ ! -d "$icingaweb_path" ]; then
    git clone https://github.com/Icinga/icingaweb2.git "$icingaweb_path"
  fi

  (
    set -e
    cd "$icingaweb_path"
    git fetch -p
    git checkout -f "$ICINGAWEB_GITREF"
  )
else
  icingaweb_path="icingaweb2-${ICINGAWEB_VERSION}"
  if [ ! -e "${icingaweb_path}".tar.gz ]; then
    wget -O "${icingaweb_path}".tar.gz https://github.com/Icinga/icingaweb2/archive/v"${ICINGAWEB_VERSION}".tar.gz
  fi
  if [ ! -d "${icingaweb_path}" ]; then
    tar xf "${icingaweb_path}".tar.gz
  fi

  rm -f icingaweb2
  ln -svf "${icingaweb_path}" icingaweb2
fi
ln -svf "${icingaweb_path}"/library/Icinga
ln -svf "${icingaweb_path}"/library/vendor/Zend

# ipl
ipl_path="ipl"
if [ ! -d "$ipl_path" ]; then
  git clone https://github.com/Icinga/icingaweb2-module-ipl.git "$ipl_path"
fi
(
  set -e
  cd "$ipl_path"
  git fetch -p
  git checkout -f "stable/$IPL_VERSION"
)

# phpunit
phpunit_path="phpunit-${PHPUNIT_VERSION}"
if [ ! -e "${phpunit_path}".phar ]; then
  wget -O "${phpunit_path}".phar https://phar.phpunit.de/phpunit-${PHPUNIT_VERSION}.phar
fi
ln -svf "${phpunit_path}".phar phpunit.phar

# phpcs
phpcs_path="phpcs-${PHPCS_VERSION}"
if [ ! -e "${phpcs_path}".phar ]; then
  wget -O "${phpcs_path}".phar \
    https://github.com/squizlabs/PHP_CodeSniffer/releases/download/${PHPCS_VERSION}/phpcs.phar
fi
ln -svf "${phpcs_path}".phar phpcs.phar