Skip to content

Commit fcbe414

Browse files
committed
Add script to determine required xDebug version.
1 parent 87f41ec commit fcbe414

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

docker/xdebug.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit # Exit script when a command exits with non-zero status.
4+
#set -o errtrace # Exit on error inside any functions or sub-shells.
5+
set -o nounset # Exit script on use of an undefined variable.
6+
#set -o pipefail # Return exit status of the last command in the pipe that exited with a non-zero exit code
7+
8+
if [ -z "${NEXTCLOUD_VERSION}" ]; then
9+
echo >&2 'The "NEXTCLOUD_VERSION" variable MUST be set during build: docker build --build-arg "NEXTCLOUD_VERSION=..."'
10+
exit 65
11+
else
12+
echo "NEXTCLOUD_VERSION is set to '${NEXTCLOUD_VERSION}'"
13+
fi
14+
15+
PHP_VERSION="${PHP_VERSION:-$(php -r 'echo PHP_VERSION;')}"
16+
PHP_MAJOR="${PHP_VERSION%%.*}"
17+
PHP_MINOR="$(echo "${PHP_VERSION}" | awk -F. '{print $2}')"
18+
19+
if [ -z "${XDEBUG_VERSION:-}" ]; then
20+
if [ "$PHP_MAJOR" -eq 8 ]; then
21+
XDEBUG_VERSION=3.4.3
22+
elif [ "$PHP_MAJOR" -eq 7 ]; then
23+
if [ "$PHP_MINOR" -ge 2 ] && [ "$PHP_MINOR" -le 4 ]; then
24+
XDEBUG_VERSION=3.1.6
25+
elif [ "$PHP_MINOR" -eq 1 ]; then
26+
XDEBUG_VERSION=2.9.8
27+
elif [ "$PHP_MINOR" -eq 0 ]; then
28+
XDEBUG_VERSION=2.7.2
29+
else
30+
echo >&2 "Unsupported PHP 7 minor version: $PHP_MINOR"
31+
exit 66
32+
fi
33+
elif [ "$PHP_MAJOR" -eq 5 ]; then
34+
if [ "$PHP_MINOR" -ge 5 ] && [ "$PHP_MINOR" -le 6 ]; then
35+
XDEBUG_VERSION=2.5.5
36+
elif [ "$PHP_MINOR" -eq 4 ]; then
37+
XDEBUG_VERSION=2.4.1
38+
else
39+
echo >&2 "Unsupported PHP 5 minor version: $PHP_MINOR"
40+
exit 67
41+
fi
42+
else
43+
echo >&2 "Unsupported PHP version: ${PHP_VERSION}"
44+
exit 68
45+
fi
46+
fi
47+
48+
echo "${XDEBUG_VERSION}" > /xdebug.version

0 commit comments

Comments
 (0)