Skip to content

Commit 78f52a3

Browse files
Don HardmanDon Hardman
authored andcommitted
Update PHP to 8.2.8 and use ubuntu:22.04 to build manticore-executor-dev
1 parent 46b67b8 commit 78f52a3

8 files changed

Lines changed: 137 additions & 92 deletions

File tree

.github/workflows/release.yml

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
env:
99
APP_NAME: 'manticore-executor'
1010
DOCKER_TAG: 'manticoresearch/manticore-executor'
11-
PHP_VERSION: '8.2.4'
11+
PHP_VERSION: '8.2.8'
1212
MAINTAINER: 'Manticore'
1313
DESC: 'Custom built PHP executor for Manticore.'
1414
EXTRA_NAME: 'manticore-extra'
@@ -74,6 +74,32 @@ jobs:
7474
path: |
7575
*${{ matrix.arch }}.tar.gz
7676
77+
build-artifact-dev:
78+
runs-on: ubuntu-22.04
79+
steps:
80+
- name: Checkout
81+
uses: actions/checkout@v3
82+
- id: vars
83+
run: |
84+
echo "app_version=$(echo ${{ github.ref_name }} | cut -dv -f2)" >> $GITHUB_OUTPUT
85+
- name: Build manticore-executor-dev
86+
run: ./build-linux 8.2.8 0 1
87+
shell: bash
88+
- name: Create artifact
89+
run: |
90+
APP_ARCH=amd64 \
91+
APP_VERSION=${{ steps.vars.outputs.app_version }} \
92+
APP_NAME=${{ env.APP_NAME }} \
93+
RUNNER_OS="${{ runner.os }}" \
94+
ASSET_SUFFIX=-dev \
95+
./collect-assets
96+
shell: bash
97+
- uses: actions/upload-artifact@v3
98+
with:
99+
name: artifact-dev-ubuntu-22.04-amd64
100+
path: |
101+
*.tar.gz
102+
77103
build-linux-packages:
78104
needs:
79105
- build-artifact
@@ -372,6 +398,7 @@ jobs:
372398
runs-on: ubuntu-22.04
373399
needs:
374400
- build-artifact
401+
- build-artifact-dev
375402
- build-linux-packages
376403
- build-linux-packages-arm64
377404
- build-extra-packages
@@ -411,22 +438,22 @@ jobs:
411438
strategy:
412439
matrix:
413440
include:
414-
- os: ubuntu-22.04
415-
arch: amd64
441+
- artifact_suffix: ubuntu-22.04-amd64
416442
asset_name_suffix: linux_amd64.tar.gz
417443
asset_content_type: application/gzip
418-
- os: ubuntu-22.04
419-
arch: arm64
444+
- artifact_suffix: ubuntu-22.04-arm64
420445
asset_name_suffix: linux_arm64.tar.gz
421446
asset_content_type: application/gzip
422-
- os: macos-12
423-
arch: amd64
447+
- artifact_suffix: macos-12-amd64
424448
asset_name_suffix: macos_amd64.tar.gz
425449
asset_content_type: application/gzip
450+
- artifact_suffix: dev-ubuntu-22.04-amd64
451+
asset_name_suffix: linux_amd64-dev.tar.gz
452+
asset_content_type: application/gzip
426453
steps:
427454
- uses: actions/download-artifact@v3
428455
with:
429-
name: artifact-${{ matrix.os }}-${{ matrix.arch }}
456+
name: artifact-${{ matrix.artifact_suffix }}
430457

431458
- uses: actions/download-artifact@v3
432459
with:

.github/workflows/test.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77

88
env:
99
APP_NAME: 'manticore-executor'
10-
PHP_VERSION: '8.2.4'
10+
PHP_VERSION: '8.2.8'
1111
MAINTAINER: 'Manticore'
1212
DESC: 'Custom built PHP executor for Manticore.'
1313

@@ -20,10 +20,16 @@ jobs:
2020
- ubuntu-22.04
2121
- macos-12
2222
include:
23-
- os: ubuntu-22.04
23+
- job_name: 'Build static in Alpine'
24+
os: ubuntu-22.04
2425
use_docker: true
2526
script_name: ./build-alpine
26-
- os: macos-12
27+
- job_name: 'Build dev version in Jammy'
28+
os: ubuntu-22.04
29+
use_docker: false
30+
script_name: ./build-linux
31+
- job_name: 'Build static on OSX'
32+
os: macos-12
2733
use_docker: false
2834
script_name: ./build-osx
2935
steps:

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ARG BUILD_DEV=0
55
COPY . /src
66
RUN apk add bash && \
77
cd /src && \
8-
./build-alpine 8.2.4 0 $BUILD_DEV && \
8+
./build-alpine 8.2.8 0 $BUILD_DEV && \
99
mv build/dist/bin/php /usr/bin/manticore-executor && \
1010
ln -s /usr/bin/manticore-executor /usr/bin/php && \
1111
cd ../..

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Manticore Executor is a custom built PHP binary which:
2828

2929
By default, we disable all extensions and enable only those required to run our scripts.
3030

31-
We build executor from `PHP 8.2.4` with the following extensions enabled and compiled into the executable statically:
31+
We build executor from `PHP 8.2.8` with the following extensions enabled and compiled into the executable statically:
3232

3333
* pcntl
3434
* posix
@@ -83,13 +83,13 @@ Several scripts used to build the final package:
8383
* `build-linux`
8484
* `build-osx`
8585

86-
The scripts accept a version of PHP as a parameter. The current version is `8.2.4`. To build the binary, you should run the following example:
86+
The scripts accept a version of PHP as a parameter. The current version is `8.2.8`. To build the binary, you should run the following example:
8787

8888
```bash
89-
./build-linux "8.2.4"
89+
./build-linux "8.2.8"
9090
```
9191

92-
The command above will build the package on Linux with **PHP** `8.2.4`. Once it's done, you can find your binary in folder `dist/bin`.
92+
The command above will build the package on Linux with **PHP** `8.2.8`. Once it's done, you can find your binary in folder `dist/bin`.
9393

9494
### Build for MacOS arm64
9595

build-alpine

Lines changed: 8 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
# received a copy of the license along with this program; if you did not,
77
# you can find it at https://www.php.net/license/3_01.txt
88

9-
set -e
9+
set -xe
10+
. helper.sh
11+
1012
install_deps() {
1113
arch=$(arch)
1214
# Do basic configuration of the system, and install build tools
@@ -22,59 +24,22 @@ install_deps() {
2224

2325
apk add curl git autoconf bison re2c pkgconf zlib-dev zstd-dev openssl-libs-static openssl-dev zlib-static zlib-dev
2426

25-
# Build curl
26-
test -d curl-8.0.0 && rm -f $_
27-
curl -sSL https://github.com/curl/curl/releases/download/curl-8_0_0/curl-8.0.0.tar.gz | tar -xzf -
28-
cd curl-8.0.0
29-
./configure --disable-shared --with-ssl --without-libidn2
30-
make -j8
31-
make install
32-
cd ..
27+
install_curl
3328

34-
test -d libzip-1.9.2 && rm -f $_
35-
curl -sSL https://github.com/nih-at/libzip/releases/download/v1.9.2/libzip-1.9.2.tar.gz | tar -xzf -
36-
cd libzip-1.9.2 && mkdir -p build && cd build
37-
cmake -DBUILD_SHARED_LIBS=OFF -DENABLE_LZMA=OFF -DENABLE_BZIP2=OFF ..
38-
make -j4 && make install
39-
cd ../..
40-
rm -fr libzip-1.9.2
29+
install_libzip
4130
}
4231

4332
install_dev_deps() {
4433
apk add gmp-dev judy-dev bsd-compat-headers m4
4534

46-
test -d libxml2-2.10.3 && rm -f libxml2-2.10.3
47-
curl -sSL https://github.com/GNOME/libxml2/archive/refs/tags/v2.10.3.tar.gz | tar -xzf -
48-
cd libxml2-2.10.3 && mkdir -p build && cd build
49-
cmake -DBUILD_SHARED_LIBS=OFF -DLIBXML2_WITH_LZMA=OFF -DLIBXML2_WITH_PYTHON=OFF -DLIBXML2_WITH_ICONV=OFF -DCMAKE_BUILD_TYPE=Release ..
50-
make -j4 && make install
51-
cd ../..
52-
rm -fr libxml2-2.10.3
35+
install_libxml2
5336
}
5437

5538
export -f install_deps install_dev_deps
5639
. build-bash-base.sh "$@"
5740

5841
if [ "$BUILD_DEV" -eq 1 ]; then
59-
cd ext
60-
61-
git clone https://github.com/donhardman/php-memory-profiler.git memprof && cd "$_"
62-
git checkout 68eb143bd5700a6fe041826118aeb9a13a3fcef3
63-
cd ..
64-
65-
git clone https://github.com/tideways/php-xhprof-extension.git tideways_xhprof && cd "$_"
66-
git checkout 6ee298f910a3661960f454bd6a787686657c7570
67-
cd ..
68-
69-
# Still not working due to zend
70-
# git clone https://github.com/donhardman/xdebug.git xdebug && cd "$_"
71-
# git checkout xdebug_3_2
72-
# cd ..
73-
74-
cd ..
75-
76-
# We need to rebuild because we modify extensions in PHP core code
77-
./buildconf --force
42+
build_dev_conf
7843
fi
7944

8045
MAKE_LDFLAGS=-ldl
@@ -94,9 +59,7 @@ ENABLE_STATIC=yes
9459
--enable-mbstring \
9560
"${BUILD_EXTRA[@]}"
9661

97-
sed -ie 's/PHP_INI_ENTRY("openssl.cafile", NULL, PHP_INI_PERDIR, NULL)/PHP_INI_ENTRY("openssl.cafile", "\/etc\/ssl\/cert.pem", PHP_INI_PERDIR, NULL)/g' ext/openssl/openssl.c
98-
sed -ie 's/-export-dynamic//g' Makefile
99-
sed -ie 's/-o $(SAPI_CLI_PATH)/-all-static -o $(SAPI_CLI_PATH)/g' Makefile
62+
fix_static_linking
10063

10164
make LDFLAGS=$MAKE_LDFLAGS -j8
10265
make install-cli

build-linux

Lines changed: 19 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,37 @@
66
# received a copy of the license along with this program; if you did not,
77
# you can find it at https://www.php.net/license/3_01.txt
88

9-
# ! This script is deprecated and we use muslc build on alpine.
10-
# See: build-alpine
11-
set -e
9+
# We use this script exclusively to build dev version, because static linking is hard
10+
# For static linking we keep using the alpine docker image and buildx
11+
12+
# To make it work on fresh ubuntu jammy, run the following command:
13+
# apt-get install -y libxml2 libcurl4 libonig5 libzip4
14+
15+
set -xe
16+
. helper.sh
17+
1218
install_deps() {
1319
sudo apt-get update -y
14-
sudo apt-get install -y curl build-essential autoconf automake bison re2c libzstd-dev pkg-config git libssl-dev zlib1g-dev libzip-dev libonig-dev cmake
15-
16-
# Build curl
17-
curl -sSL https://github.com/curl/curl/releases/download/curl-8_0_0/curl-8.0.0.tar.gz | tar -xzf -
18-
cd curl-8.0.0
19-
./configure --disable-shared --with-ssl --without-libidn2
20-
make -j8
21-
sudo make install
22-
cd ..
20+
sudo apt-get install -y curl build-essential autoconf automake bison re2c libzstd-dev pkg-config git libssl-dev zlib1g-dev libzip-dev libonig-dev cmake libcurl4-openssl-dev libzip-dev
2321
}
2422

2523
install_dev_deps() {
26-
sudo apt-get install -y libonig-dev libgmp-dev
24+
sudo apt-get install -y libonig-dev libgmp-dev libxml2-dev
2725
}
2826

2927
export -f install_deps install_dev_deps
3028
. build-bash-base.sh "$@"
3129

32-
CONFIGURE_LDFLAGS=
33-
MAKE_LDFLAGS=
34-
ENABLE_SHARED=yes
35-
ENABLE_STATIC=no
36-
if [[ "$BUILD_STATIC" == 1 ]]; then
37-
CONFIGURE_LDFLAGS=-static
38-
MAKE_LDFLAGS=-ldl
39-
ENABLE_SHARED=no
40-
ENABLE_STATIC=yes
30+
31+
if [ "$BUILD_DEV" -eq 1 ]; then
32+
build_dev_conf
4133
fi
4234

4335

44-
./configure LDFLAGS=$CONFIGURE_LDFLAGS CFLAGS="-O3" --prefix="$BUILD_PREFIX" --disable-all \
36+
ENABLE_SHARED=yes
37+
ENABLE_STATIC=yes
38+
39+
./configure CFLAGS="-O3" --prefix="$BUILD_PREFIX" --disable-all \
4540
--enable-shared=$ENABLE_SHARED --enable-static=$ENABLE_STATIC --with-layout=GNU \
4641
--with-pear=no --disable-cgi --disable-phpdbg \
4742
--with-pcre-jit --enable-zstd --with-libzstd \
@@ -54,11 +49,5 @@ fi
5449
--enable-mbstring \
5550
"${BUILD_EXTRA[@]}"
5651

57-
if [[ "$BUILD_STATIC" == 1 ]]; then
58-
sed -ie 's/-export-dynamic//g' Makefile
59-
sed -ie 's/-o $(SAPI_CLI_PATH)/-all-static -o $(SAPI_CLI_PATH)/g' Makefile
60-
fi
61-
62-
make LDFLAGS=$MAKE_LDFLAGS -j8
52+
make -j8
6353
make install-cli
64-
strip --strip-all dist/bin/php

collect-assets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# ! Must be defined: APP_ARCH, APP_NAME, APP_VERSION, GITHUB_SHA, RUNNER_OS
99
# This script is part of tools to use in GitHub workflow
1010

11-
assets="${APP_NAME}_${APP_VERSION}-$( date +%y%m%d )-${GITHUB_SHA:0:7}_$(echo "${RUNNER_OS}" | tr '[:upper:]' '[:lower:]')_${APP_ARCH}"
11+
assets="${APP_NAME}_${APP_VERSION}-$( date +%y%m%d )-${GITHUB_SHA:0:7}_$(echo "${RUNNER_OS}" | tr '[:upper:]' '[:lower:]')_${APP_ARCH}${ASSET_SUFFIX}"
1212

1313
pwd
1414
echo "$assets"

helper.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/usr/bin/env bash
2+
set -ex
3+
4+
install_curl() {
5+
test -d curl-8.0.0 && rm -fr "$_"
6+
curl -sSL https://github.com/curl/curl/releases/download/curl-8_0_0/curl-8.0.0.tar.gz | tar -xzf -
7+
cd curl-8.0.0
8+
./configure --disable-shared --with-ssl --without-libidn2
9+
make -j8
10+
make install
11+
cd ..
12+
}
13+
14+
install_libzip() {
15+
test -d libzip-1.9.2 && rm -fr "$_"
16+
curl -sSL https://github.com/nih-at/libzip/releases/download/v1.9.2/libzip-1.9.2.tar.gz | tar -xzf -
17+
cd libzip-1.9.2 && mkdir -p build && cd build
18+
cmake -DBUILD_SHARED_LIBS=OFF -DENABLE_LZMA=OFF -DENABLE_BZIP2=OFF ..
19+
make -j4 && make install
20+
cd ../..
21+
rm -fr libzip-1.9.2
22+
}
23+
24+
install_libxml2() {
25+
test -d libxml2-2.10.3 && rm -fr libxml2-2.10.3
26+
curl -sSL https://github.com/GNOME/libxml2/archive/refs/tags/v2.10.3.tar.gz | tar -xzf -
27+
cd libxml2-2.10.3 && mkdir -p build && cd build
28+
cmake -DBUILD_SHARED_LIBS=OFF -DLIBXML2_WITH_LZMA=OFF -DLIBXML2_WITH_PYTHON=OFF -DLIBXML2_WITH_ICONV=OFF -DCMAKE_BUILD_TYPE=Release ..
29+
make -j4 && make install
30+
cd ../..
31+
rm -fr libxml2-2.10.3
32+
}
33+
34+
build_dev_conf() {
35+
cd ext
36+
37+
git clone https://github.com/donhardman/php-memory-profiler.git memprof && cd "$_"
38+
git checkout 68eb143bd5700a6fe041826118aeb9a13a3fcef3
39+
cd ..
40+
41+
git clone https://github.com/tideways/php-xhprof-extension.git tideways_xhprof && cd "$_"
42+
git checkout 6ee298f910a3661960f454bd6a787686657c7570
43+
cd ..
44+
45+
# Still not working due to zend
46+
# git clone https://github.com/donhardman/xdebug.git xdebug && cd "$_"
47+
# git checkout xdebug_3_2
48+
# cd ..
49+
50+
cd ..
51+
52+
# We need to rebuild because we modify extensions in PHP core code
53+
./buildconf --force
54+
}
55+
56+
fix_static_linking() {
57+
sed -ie 's/PHP_INI_ENTRY("openssl.cafile", NULL, PHP_INI_PERDIR, NULL)/PHP_INI_ENTRY("openssl.cafile", "\/etc\/ssl\/cert.pem", PHP_INI_PERDIR, NULL)/g' ext/openssl/openssl.c
58+
sed -ie 's/-export-dynamic//g' Makefile
59+
sed -ie 's/-o $(SAPI_CLI_PATH)/-all-static -o $(SAPI_CLI_PATH)/g' Makefile
60+
}

0 commit comments

Comments
 (0)