Skip to content

Commit 0b43d3d

Browse files
authored
Merge pull request #530 from Scalingo/feat/STORY-2477/scalingo-24_blackfire
fix(blackfire): update to the latest version and URLs
2 parents 81abc91 + 9ffb1c4 commit 0b43d3d

File tree

4 files changed

+48
-52
lines changed

4 files changed

+48
-52
lines changed

support/ext/blackfire

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22

33
if [ -n "$DEBUG" ]; then
4-
set -x
4+
set -x
55
fi
66

77
# fail hard
@@ -10,50 +10,46 @@ set -o pipefail
1010
set -eu
1111

1212
php_version=${1:=8.2}
13-
php_series="$(echo $php_version | cut -d '.' -f1,2)"
14-
# https://blackfire.io/docs/up-and-running/installation?action=install&mode=full&location=local&os=manual&language=php#install-the-php-probe
15-
#
16-
# → Select "Linux Binary", 64 bits, the right PHP version and you'll see the last version of the probe
17-
blackfire_probe_version=1.86.3
18-
# https://blackfire.io/docs/up-and-running/installation?action=install&mode=full&location=local&os=manual&language=php#install-the-packages
19-
#
20-
# → Select "Linux Binary", 64 bits and you'll see the last version
21-
blackfire_agent_version=2.13.2
22-
bin_dir=${PREFIX}/bin
23-
24-
# Blackfire Probe
25-
curl --location --output blackfire.so \
26-
"https://packages.blackfire.io/binaries/blackfire-php/${blackfire_probe_version}/blackfire-php-linux_amd64-php-$(echo $php_series | tr -d '.').so"
13+
php_series="$(echo "$php_version" | cut -d '.' -f1,2)"
2714

28-
mkdir -p ${EXT_DIR}
29-
mv blackfire.so ${EXT_DIR}/blackfire.so
15+
# https://docs.blackfire.io/up-and-running/installation?action=install&mode=full&location=local&os=manual&language=php&version=latest&#install-the-php-probe
16+
#
17+
# → Under "Install the PHP Probe", select "Linux Binary", 64 bits and your PHP version. Open the network inspector to identify the request triggered when you click on "Download". It contains the last version.
18+
blackfire_probe_version=1.92.41
3019

31-
# AGENT
32-
curl --user-agent "Scalingo" --output agent.tar.gz \
33-
--dump-header - --location --silent \
34-
https://blackfire.io/api/v1/releases/agent/linux/amd64
20+
# https://docs.blackfire.io/up-and-running/installation?action=install&mode=full&location=local&os=manual&language=php&version=latest&#install-the-packages
21+
#
22+
# → Under "Install the Packages", select "Linux Binary" and 64 bits. Open the network inspector to identify the request triggered when you click on "Download". It contains the last version.
23+
blackfire_agent_version=2.29.0
3524

36-
echo "-----> Packaging bin/blackfire-agent ${blackfire_agent_version}..."
25+
mkdir --parents "${EXT_DIR}"
26+
bin_dir=${PREFIX}/bin
27+
mkdir --parents "${bin_dir}"
28+
mkdir --parents "${PREFIX}/var/blackfire/run"
29+
mkdir --parents "${PREFIX}/etc/blackfire"
3730

38-
mkdir -p ${PREFIX}/var/blackfire/run
39-
mkdir -p ${PREFIX}/etc/blackfire
40-
echo -e "[blackfire]\nserver-id=f1abf3a8-3f85-4743-99b2-97f066c099b9\nserver-token=5ecbc6486e9db6b780a0c0a9ef1e244709e632996fe9105cb9075ab2826944d5" > ${PREFIX}/etc/blackfire/agent.ini
41-
mkdir -p ${bin_dir}
31+
echo "-----> Packaging Blackfire Probe ${blackfire_probe_version}..."
32+
curl --location --silent --output blackfire.so \
33+
"https://packages.blackfire.io/binaries/blackfire-php/${blackfire_probe_version}/blackfire-php-linux_amd64-php-$(echo "$php_series" | tr -d '.').so"
34+
mv blackfire.so "${EXT_DIR}/blackfire.so"
4235

43-
tar -zxf agent.tar.gz
44-
chmod +x agent
45-
cp agent ${bin_dir}/blackfire-agent
46-
rm agent.tar.gz agent agent.sha1
36+
echo "-----> Packaging Blackfire Agent ${blackfire_agent_version}..."
37+
curl --location --silent --output blackfire-agent.tar.gz \
38+
"https://packages.blackfire.io/binaries/blackfire/${blackfire_agent_version}/blackfire-linux_amd64.tar.gz"
39+
tar -zxf blackfire-agent.tar.gz
40+
chmod +x blackfire
41+
# Both the agent and the CLI are actually the same binary. For legacy purpose it is expected that the CLI is named `blackfire` and the agent is named `blackfire-agent`.
42+
cp blackfire "${bin_dir}/blackfire-agent"
43+
cp blackfire "${bin_dir}/blackfire"
44+
chmod +x "${bin_dir}/blackfire-agent" "${bin_dir}/blackfire"
45+
rm blackfire-agent.tar.gz blackfire blackfire.sha1
4746

48-
# CLI
49-
echo "-----> Packaging bin/blackfire ${blackfire_agent_version}..."
50-
curl https://packages.blackfire.io/binaries/blackfire-agent/${blackfire_agent_version}/blackfire-cli-linux_amd64 > ${bin_dir}/blackfire
51-
chmod +x ${bin_dir}/blackfire
47+
echo -e "[blackfire]\nserver-id=f1abf3a8-3f85-4743-99b2-97f066c099b9\nserver-token=5ecbc6486e9db6b780a0c0a9ef1e244709e632996fe9105cb9075ab2826944d5" > "${PREFIX}/etc/blackfire/agent.ini"
5248

5349
find ${PREFIX} -type f \( -executable -o -name '*.a' \) -exec sh -c "file -i '{}' | grep -Eq 'application/x-(archive|executable|sharedlib); charset=binary'" \; -print | xargs strip --strip-unneeded
5450

5551
# gets sourced on container boot
56-
cat > ${PREFIX}/bin/profile.blackfire.sh <<'EOF'
52+
cat > "${PREFIX}/bin/profile.blackfire.sh" <<'EOF'
5753
if [[ -n "$BLACKFIRE_SERVER_TOKEN" && -n "$BLACKFIRE_SERVER_ID" ]]; then
5854
if [[ -f "/app/vendor/php/bin/blackfire-agent" ]]; then
5955
touch /app/vendor/php/var/blackfire/run/agent.sock
@@ -64,8 +60,8 @@ if [[ -n "$BLACKFIRE_SERVER_TOKEN" && -n "$BLACKFIRE_SERVER_ID" ]]; then
6460
fi
6561
EOF
6662

67-
mkdir -p ${PREFIX}/etc/php/conf.d
68-
cat > ${PREFIX}/etc/conf.d/blackfire.ini <<'EOF'
63+
mkdir -p "${PREFIX}/etc/php/conf.d"
64+
cat > "${PREFIX}/etc/conf.d/blackfire.ini" <<'EOF'
6965
extension = blackfire.so
7066
7167
blackfire.server_token = ${BLACKFIRE_SERVER_TOKEN}

support/lib/php_ext

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env bash
2+
13
function build_ext() {
24
local tempbuilddir=$1
35
local php_version=$2
@@ -27,11 +29,11 @@ function upload_ext() {
2729

2830
echo "-----> Uploading extension $ext_name"
2931

30-
mkdir -p package/ext/${zend_api_version}
31-
pushd $tempbuilddir > /dev/null
32-
tar zcvf $tempdir/package/ext/${zend_api_version}/php-${package_name}.tgz .
32+
mkdir -p "package/ext/${zend_api_version}"
33+
pushd "$tempbuilddir" > /dev/null
34+
tar zcvf "$tempdir/package/ext/${zend_api_version}/php-${package_name}.tgz" .
3335
popd
3436

35-
swift_upload package/ext/${zend_api_version}/php-${package_name}.tgz
37+
swift_upload "package/ext/${zend_api_version}/php-${package_name}.tgz"
3638
"$basedir/package-checksum" "ext/${zend_api_version}/php-${package_name}"
3739
}

support/package_all

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,18 @@ for e in ./ext-internal/*; do
2323
ext_name="$( basename "${e}" )"
2424

2525
./package_internal_ext "${ext_name}" "${php_version}"
26-
2726
if [[ $? -ne 0 ]]; then
28-
echo "Error packaging internal extension ${ext_name}"
29-
exit -1
27+
echo "Error packaging internal extension ${ext_name}" >&2
28+
exit 1
3029
fi
3130
done
3231

3332
for e in ./ext/*; do
3433
ext_name="$( basename "${e}" )"
3534

3635
./package_ext "${ext_name}" "${ext_name}" "${php_version}"
37-
3836
if [[ $? -ne 0 ]]; then
39-
echo "Error packaging extension ${ext_name}"
40-
exit -1
37+
echo "Error packaging extension ${ext_name}" >&2
38+
exit 1
4139
fi
4240
done

support/package_ext

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ package_ext() {
3131
local ext_package_name="$2"
3232
local php_series="$3"
3333

34-
local zend_api_version=$(zend_api_from_php_series $basedir $php_series)
34+
local zend_api_version=$(zend_api_from_php_series "$basedir" "$php_series")
3535
if [ -z "$zend_api_version" ] ; then
3636
echo "No compatible zend API found for $php_series"
3737
return
3838
fi
3939

40-
local php_version=$(php_series_last_version $php_series)
40+
local php_version=$(php_series_last_version "$php_series")
4141
echo "-----> Building $ext_name for PHP module API version ${zend_api_version} using PHP ${php_version}"
4242

43-
tempdir=$(mktmpdir php${ext_name})
44-
cd $tempdir
43+
tempdir=$(mktmpdir "php${ext_name}")
44+
cd "$tempdir"
4545

4646
install_php "${php_version}"
4747
cp "$basedir/ext/${ext_name}" "$tempdir/build.sh"
@@ -51,7 +51,7 @@ package_ext() {
5151
package_name="${ext_package_name}"
5252
fi
5353

54-
local tempbuilddir=$(mktmpdir php-build${ext_name})
54+
local tempbuilddir=$(mktmpdir "php-build${ext_name}")
5555
build_ext "${tempbuilddir}" "${php_version}" "${zend_api_version}" "${ext_name}"
5656
upload_ext "${tempbuilddir}" "${tempdir}" "${package_name}" "${zend_api_version}"
5757

0 commit comments

Comments
 (0)