Skip to content

Commit 4b6297c

Browse files
authored
Merge pull request #84 from glensc/install-ext-update
CI: Update install-extensions.sh to work with GHA
2 parents b0fd596 + 1c90bc0 commit 4b6297c

1 file changed

Lines changed: 28 additions & 13 deletions

File tree

install-extensions.sh

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
1-
#!/bin/sh
1+
#!/usr/bin/env bash
22

33
set -xeu
44

55
: "${TIDEWAYS_VERSION:=4.1.4}"
6-
: "${TIDEWAYS_XHPROF_VERSION:=5.0.2}"
6+
: "${TIDEWAYS_XHPROF_VERSION:=5.0.4}"
77
: "${PHP_VERSION:=7.4}"
88

99
die() {
1010
echo >&2 "ERROR: $*"
1111
exit 1
1212
}
1313

14+
has_extension() {
15+
local extension="$1"
16+
php -m | awk -vrc=1 -vextension="$extension" '$1 == extension { rc=0 } END { exit rc }'
17+
}
18+
1419
install_xhprof() {
1520
local version="${1:-stable}"
1621

22+
has_extension "xhprof" && return 0
1723
pecl install xhprof-$version
1824
}
1925

@@ -22,7 +28,7 @@ install_mongo() {
2228
}
2329

2430
install_mongodb() {
25-
php -m | grep -q mongodb || pecl install -f mongodb
31+
has_extension "mongodb" || pecl install -f mongodb
2632
composer require --dev alcaeus/mongo-php-adapter
2733
}
2834

@@ -32,31 +38,40 @@ install_tideways_xhprof() {
3238
local url="https://github.com/tideways/php-xhprof-extension/releases/download/v$version/tideways-xhprof-$version-$arch.tar.gz"
3339
local extension="tideways_xhprof"
3440
local tar="$extension.tgz"
35-
local config library
41+
local workdir="vendor/tideways_xhprof"
42+
local library
43+
local config
3644
local zts
3745

38-
curl -fL -o "$tar" "$url"
39-
tar -xvf "$tar"
40-
4146
zts=$(php --version | grep -q ZTS && echo -zts || :)
42-
library="$PWD/tideways_xhprof-$version/tideways_xhprof-$PHP_VERSION$zts.so"
43-
config="$HOME/.phpenv/versions/$PHP_VERSION/etc/conf.d/tideways_xhprof.ini"
47+
library="$PWD/$workdir/tideways_xhprof-$version/tideways_xhprof-$PHP_VERSION$zts.so"
48+
49+
if [ ! -f "$library" ]; then
50+
curl -fL -o "$tar" "$url"
51+
mkdir -p "$workdir"
52+
tar -xvf "$tar" -C "$workdir"
53+
fi
54+
4455
test -f "$library" || die "Extension not available: $library"
45-
echo "extension=$library" > "$config"
46-
php -m | grep -F "$extension"
56+
config="/etc/php/$PHP_VERSION/cli/conf.d/10-tideways_xhprof.ini"
57+
echo "extension=$library" | sudo tee "$config"
58+
has_extension "$extension"
4759
}
4860

61+
# Show php config paths
62+
php --ini
63+
4964
case "$(uname -s):$PHP_VERSION" in
5065
*:5.*)
5166
install_xhprof 0.9.4
5267
install_mongo
5368
;;
54-
Linux:7.*)
69+
Linux:7.*|Linux:8.*)
5570
install_xhprof
5671
install_mongodb
5772
install_tideways_xhprof
5873
;;
59-
*:7.*)
74+
*:7.*|*:8.*)
6075
install_xhprof
6176
install_mongodb
6277
;;

0 commit comments

Comments
 (0)