Skip to content

Commit 4c2e115

Browse files
committed
Fix installation of blackfire (more regular way)
1 parent 334ba4a commit 4c2e115

File tree

1 file changed

+23
-29
lines changed

1 file changed

+23
-29
lines changed

extensions/core/blackfire/install.sh

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ set -e
44
set -ex
55

66
# Install Blackfire
7-
version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;")
8-
97
if [[ -z "${BLACKFIRE_VERSION}" ]]; then
108
echo "Blackfire version is not set in the environment variables. Exiting!"
119
exit 1
@@ -14,36 +12,32 @@ fi
1412
# Let's make it flexible: for those who want to be safe, the image will be built with v1
1513
# Now if you build the image yourself, you can build it with v2, this way everyone gets happy :)
1614

17-
mkdir /tmp/blackfire
15+
version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;")
16+
# Probe is the same for v1 and v2
17+
curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/${TARGETOS}/${TARGETARCH}/$version
18+
mkdir -p /tmp/blackfire
19+
tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire
20+
mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get ('extension_dir');")/blackfire.so
21+
printf "extension=blackfire.so" > "/etc/php/${PHP_VERSION}/mods-available/blackfire.ini"
22+
rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz
1823

1924
if [ $BLACKFIRE_VERSION == "1" ]; then
20-
echo "Installing Blackfire version 1"
21-
# curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v2/releases/probe/php/linux/amd64/$version
22-
curl -o /tmp/blackfire/blackfire.so "https://packages.blackfire.io/binaries/blackfire-php/1.78.0/blackfire-php-${TARGETOS}"_"${TARGETARCH}-php-${version}.so"
23-
mv /tmp/blackfire/blackfire.so $(php -r "echo ini_get('extension_dir');")/blackfire.so
24-
echo "extension=blackfire" > /etc/php/${PHP_VERSION}/mods-available/blackfire.ini
25-
26-
# Adding this in the list of Ubuntu extensions because we use that list as a base for the modules list.
27-
# TODO: question: cannot we use /etc/php/mods-available instead???
28-
touch /var/lib/php/modules/${PHP_VERSION}/registry/blackfire
29-
# curl -A "Docker" -L https://blackfire.io/api/v1/releases/client/linux_static/amd64 | tar zxp -C /tmp/blackfire
30-
curl -o /tmp/blackfire/blackfire "https://packages.blackfire.io/binaries/blackfire-agent/1.50.0/blackfire-cli-${TARGETOS}"_"${TARGETARCH}"
31-
chmod +x /tmp/blackfire/blackfire
32-
mv /tmp/blackfire/blackfire /usr/bin/blackfire
33-
rm -Rf /tmp/blackfire
34-
25+
# Cli for v1 require specific version
26+
curl -A "Docker" "https://packages.blackfire.io/binaries/blackfire-agent/1.50.0/blackfire-cli-${TARGETOS}"_"${TARGETARCH}" -o /tmp/blackfire
27+
chmod +x /tmp/blackfire
28+
mv /tmp/blackfire /usr/bin/blackfire
29+
rm -Rf /tmp/blackfire
3530
elif [ $BLACKFIRE_VERSION == "2" ]; then
36-
echo "Installing Blackfire version 2..."
37-
38-
curl -o /tmp/blackfire/blackfire.so "https://packages.blackfire.io/binaries/blackfire-php/1.78.0/blackfire-php-${TARGETOS}"_"${TARGETARCH}-php-${version}.so"
39-
mv /tmp/blackfire/blackfire.so $(php -r "echo ini_get('extension_dir');")/blackfire.so
40-
echo "extension=blackfire.so" > /etc/php/${PHP_VERSION}/mods-available/blackfire.ini
41-
touch /var/lib/php/modules/${PHP_VERSION}/registry/blackfire
42-
curl -o /tmp/blackfire-cli.tar.gz "https://packages.blackfire.io/binaries/blackfire/2.10.0/blackfire-"${TARGETOS}"_"${TARGETARCH}".tar.gz"
43-
tar zxpf /tmp/blackfire-cli.tar.gz -C /tmp/blackfire
44-
mv /tmp/blackfire/blackfire /usr/bin/blackfire
45-
46-
rm -Rf /tmp/blackfire
31+
# Cli for v2 is latest version
32+
echo "Installing Blackfire version 2..."
33+
mkdir -p /tmp/blackfire
34+
curl -A "Docker" -L https://blackfire.io/api/v1/releases/cli/linux/${TARGETARCH} | tar zxp -C /tmp/blackfire
35+
if ! /tmp/blackfire/blackfire self:version --no-ansi | grep -qE "version 2\.[0-9]+\.[0-9]+"; then
36+
echo "Blackfire installed is not version 2 : $(/tmp/blackfire/blackfire self:version --no-ansi)"
37+
exit 1
38+
fi
39+
mv /tmp/blackfire/blackfire /usr/bin/blackfire
40+
rm -Rf /tmp/blackfire
4741
else
4842
echo "Blackfire version in environment variable is either empty or the value is invalid"
4943
echo "Value: '$BLACKFIRE_VERSION'"

0 commit comments

Comments
 (0)