Skip to content

Commit d528fb9

Browse files
committed
Add support for arm builds [skip ci]
1 parent 0d4c934 commit d528fb9

8 files changed

+97
-35
lines changed

.github/workflows/cache-nightly.yml

+53-16
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,61 @@
11
name: Cache PHP for nightly versions
22
on:
33
push:
4-
workflow_dispatch:
54
schedule:
65
- cron: '0 4 1-31/2 * *'
6+
workflow_dispatch:
7+
inputs:
8+
php-versions:
9+
description: 'PHP version to build'
10+
default: '8.5'
11+
required: false
12+
builds:
13+
description: 'Build type'
14+
default: 'debug release'
15+
required: false
16+
ts:
17+
description: 'Type safety'
18+
default: 'nts zts'
19+
required: false
20+
containers:
21+
description: 'OS containers'
22+
default: 'ubuntu:24.04 ubuntu:22.04 ubuntu:20.04 arm64v8/ubuntu:22.04 arm64v8/ubuntu:24.04'
23+
required: false
24+
25+
env:
26+
PHP_VERSIONS: '8.5'
27+
BUILDS: 'debug release'
28+
TS: 'nts zts'
29+
CONTAINERS: 'ubuntu:24.04 ubuntu:22.04 ubuntu:20.04 arm64v8/ubuntu:22.04 arm64v8/ubuntu:24.04'
30+
BASE_OS: ubuntu-24.04
31+
BASE_OS_ARM: ubuntu-24.04-arm
32+
733
jobs:
8-
cache:
9-
container: ubuntu:${{ matrix.container }}
34+
get-matrix:
1035
runs-on: ubuntu-latest
36+
outputs:
37+
matrix: ${{ steps.get-matrix.outputs.matrix }}
38+
steps:
39+
- name: Checkout
40+
uses: actions/checkout@v4
41+
42+
- name: Get Matrix
43+
id: get-matrix
44+
run: bash scripts/get-matrix.sh
45+
env:
46+
PHP_VERSIONS: ${{ inputs.php-versions || env.PHP_VERSIONS }}
47+
BUILDS: ${{ inputs.builds || env.BUILDS }}
48+
TS: ${{ inputs.ts || env.TS }}
49+
CONTAINERS: ${{ inputs.containers || env.CONTAINERS }}
50+
BASE_OS: ${{ env.BASE_OS }}
51+
BASE_OS_ARM: ${{ env.BASE_OS_ARM }}
52+
cache:
53+
needs: get-matrix
54+
container: ${{ matrix.container }}
55+
runs-on: ${{ matrix.container-base }}
1156
strategy:
1257
fail-fast: false
13-
matrix:
14-
container: [24.04, 22.04, 20.04]
15-
php-versions: ['8.5']
16-
builds: ['debug', 'release']
17-
ts: [zts, nts]
58+
matrix: ${{fromJson(needs.get-matrix.outputs.matrix)}}
1859
if: "!contains(github.event.head_commit.message, 'skip-nightly-cache')"
1960
steps:
2061
- name: Checkout
@@ -63,18 +104,14 @@ jobs:
63104
- name: Upload Artifact
64105
uses: actions/upload-artifact@v4
65106
with:
66-
name: ubuntu-${{ matrix.container }}-${{ matrix.php-versions }}-${{ matrix.builds }}-${{ matrix.ts }}
107+
name: ${{ matrix.os }}-${{ matrix.php-versions }}-${{ matrix.builds }}-${{ matrix.ts }}
67108
path: builds
68109
tests:
69110
runs-on: ${{ matrix.os }}
70-
needs: cache
111+
needs: [get-matrix, cache]
71112
strategy:
72113
fail-fast: false
73-
matrix:
74-
os: [ubuntu-24.04, ubuntu-22.04, ubuntu-20.04]
75-
php-versions: ['8.5']
76-
builds: ['debug', 'release']
77-
ts: [nts, zts]
114+
matrix: ${{fromJson(needs.get-matrix.outputs.matrix)}}
78115
if: "!contains(github.event.head_commit.message, 'skip-tests')"
79116
steps:
80117
- name: Checkout
@@ -121,7 +158,7 @@ jobs:
121158
run: sudo apt-get check
122159
release:
123160
runs-on: ubuntu-latest
124-
needs: [cache, tests]
161+
needs: [get-matrix, cache, tests]
125162
if: "!contains(github.event.head_commit.message, 'skip-release')"
126163
steps:
127164
- name: Checkout

.github/workflows/cache-stable.yml

+10-6
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@ on:
1717
required: false
1818
containers:
1919
description: 'OS containers'
20-
default: '24.04 22.04 20.04'
20+
default: 'ubuntu:24.04 ubuntu:22.04 ubuntu:20.04 arm64v8/ubuntu:22.04 arm64v8/ubuntu:24.04'
2121
required: false
2222

2323
env:
2424
PHP_VERSIONS: '5.6 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3 8.4'
2525
BUILDS: 'debug release'
2626
TS: 'nts zts'
27-
CONTAINERS: '24.04 22.04 20.04'
27+
CONTAINERS: 'ubuntu:24.04 ubuntu:22.04 ubuntu:20.04 arm64v8/ubuntu:22.04 arm64v8/ubuntu:24.04'
28+
BASE_OS: ubuntu-24.04
29+
BASE_OS_ARM: ubuntu-24.04-arm
2830

2931
jobs:
3032
get-matrix:
@@ -43,10 +45,12 @@ jobs:
4345
BUILDS: ${{ inputs.builds || env.BUILDS }}
4446
TS: ${{ inputs.ts || env.TS }}
4547
CONTAINERS: ${{ inputs.containers || env.CONTAINERS }}
48+
BASE_OS: ${{ env.BASE_OS }}
49+
BASE_OS_ARM: ${{ env.BASE_OS_ARM }}
4650
cache:
4751
needs: get-matrix
48-
container: ubuntu:${{ matrix.container }}
49-
runs-on: ubuntu-latest
52+
container: ${{ matrix.container }}
53+
runs-on: ${{ matrix.container-base }}
5054
strategy:
5155
fail-fast: false
5256
matrix: ${{fromJson(needs.get-matrix.outputs.matrix)}}
@@ -61,7 +65,7 @@ jobs:
6165
PHP_VERSION: ${{ matrix.php-versions }}
6266
BUILDS: ${{ matrix.builds }}
6367
NIGHTLY: 'false'
64-
TS: ${{ matrix.ts }}
68+
TS: ${{ matrix.ts }}
6569

6670
- name: Get ZSTD_DIR
6771
id: zstd
@@ -98,7 +102,7 @@ jobs:
98102
- name: Upload Artifact
99103
uses: actions/upload-artifact@v4
100104
with:
101-
name: ubuntu-${{ matrix.container }}-${{ matrix.php-versions }}-${{ matrix.builds }}-${{ matrix.ts }}
105+
name: ${{ matrix.os }}-${{ matrix.php-versions }}-${{ matrix.builds }}-${{ matrix.ts }}
102106
path: builds
103107
tests:
104108
runs-on: ${{ matrix.os }}

scripts/configure-git.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ touch /run/php/.gitkeep
44

55
git config --global user.email "[email protected]"
66
git init
7-
git add /bin /lib /lib64 /sbin /usr /var /run/php
7+
for dir_path in /bin /lib /lib64 /sbin /usr /var /run/php; do
8+
[ -d "$dir_path" ] && git add "$dir_path"
9+
done
810
find /etc -maxdepth 1 -mindepth 1 -type d -exec git add {} \;
911
git commit -m "init"

scripts/get-matrix.sh

+12-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,21 @@ IFS=' ' read -r -a build_array <<<"${BUILDS:?}"
77
IFS=' ' read -r -a ts_array <<<"${TS:?}"
88
IFS=' ' read -r -a container_array <<<"${CONTAINERS:?}"
99

10+
get_container_base() {
11+
[[ $1 = *arm64v8* ]] && echo "${BASE_OS_ARM:?}" || echo "${BASE_OS:?}"
12+
}
13+
14+
get_os_version() {
15+
[[ $1 = *arm64v8* ]] && echo "${1##*:}-arm" || echo "${1##*:}"
16+
}
17+
1018
for php in "${php_version_array[@]}"; do
1119
for build in "${build_array[@]}"; do
1220
for ts in "${ts_array[@]}"; do
13-
for container in "${container_array[@]}"; do
14-
json_array+=("{\"php-versions\": \"$php\", \"builds\": \"$build\", \"ts\": \"$ts\", \"container\": \"$container\", \"os\": \"ubuntu-${container}\" }")
21+
for os in "${container_array[@]}"; do
22+
os_base="$(get_container_base "$os")"
23+
os_version="ubuntu-$(get_os_version "$os")"
24+
json_array+=("{\"php-versions\": \"$php\", \"builds\": \"$build\", \"ts\": \"$ts\", \"container\": \"$os\", \"container-base\": \"$os_base\", \"os\": \"$os_version\" }")
1525
done
1626
done
1727
done

scripts/install-requirements-packages.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
. ./scripts/packages.sh
44
add_ppa
55

6-
DEBIAN_FRONTEND=noninteractive apt-get install -y apache2 apt-fast automake gcc g++ git jq make pkg-config shtool libtool sudo systemd unzip
6+
DEBIAN_FRONTEND=noninteractive apt-get install -y apache2 apt-fast automake gcc g++ git jq make pkg-config shtool libtool sudo systemd unzip
77
purge_packages libfile-fcntllock-perl libalgorithm-merge-perl libalgorithm-diff-xs-perl unattended-upgrades libalgorithm-diff-perl manpages-dev
88
DEBIAN_FRONTEND=noninteractive apt-get install -y php"${PHP_VERSION:?}"-common php"${PHP_VERSION:?}"-imagick
99
purge_packages php"${PHP_VERSION:?}"-imagick php"${PHP_VERSION:?}"-common php-common

scripts/install-requirements-php-builder.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
add_ppa
66

77
DEBIAN_FRONTEND=noninteractive apt-get install -y apache2 apt-fast automake gcc g++ git jq make pkg-config shtool libtool sudo systemd unzip
8-
DEBIAN_FRONTEND=noninteractive apt-get install -y autoconf firebird-dev freetds-dev libacl1-dev libapparmor-dev libargon2-dev libaspell-dev libc-client2007e-dev libcurl4-openssl-dev libdb-dev libedit-dev libgomp1 libicu-dev libkrb5-dev libldap-dev liblmdb-dev liblz4-dev libmemcached-dev libonig-dev libpq-dev libqdbm-dev librabbitmq-dev libsodium-dev libsnmp-dev libsqlite3-dev libtidy-dev libtool libwrap0-dev libxml2-dev libxslt1-dev libyaml-dev libzip-dev libzmq3-dev libzstd-dev make php-common snmp shtool systemd tzdata
8+
DEBIAN_FRONTEND=noninteractive apt-get install -y autoconf firebird-dev freetds-dev libacl1-dev libapparmor-dev libargon2-dev libaspell-dev libc-client2007e-dev libcurl4-openssl-dev libdb-dev libedit-dev libgomp1 libicu-dev libkrb5-dev libldap-dev liblmdb-dev liblz4-dev libmemcached-dev libonig-dev libpq-dev libqdbm-dev librabbitmq-dev libsodium-dev libsnmp-dev libsqlite3-dev libtidy-dev libtool libwrap0-dev libxml2-dev libxslt1-dev libyaml-dev libzip-dev libzmq3-dev make php-common snmp shtool systemd tzdata
99
purge_packages libfile-fcntllock-perl libalgorithm-merge-perl libalgorithm-diff-xs-perl unattended-upgrades libalgorithm-diff-perl manpages-dev
1010
purge_packages libgd-dev uuid-dev libfreetype-dev libfribidi-dev libharfbuzz-dev libgd3 libavif13 libavif16 libimagequant0 libraqm0 libyuv0 libaom3 libdav1d5 libgav1-0 libabsl20210324 libdav1d7 libgav1-1 librav1e0 libsvtav1enc1d1 libabsl20220623t64 || true
11-
if [ "$VERSION_ID" != '24.04' ]; then
11+
arch="$(arch)"
12+
if [[ "$VERSION_ID" != '24.04' && "$arch" != "aarch64" && "$arch" != "arm64" ]]; then
1213
DEBIAN_FRONTEND=noninteractive apt-get install -y unixodbc
1314
fi

scripts/install.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ version=$1
7373
builds=${2:-release}
7474
ts=${3:-nts}
7575
[ "${builds:?}" = "debug" ] && PHP_PKG_SUFFIX=-dbgsym
76-
tar_file=php_"$version-$ts$PHP_PKG_SUFFIX"+ubuntu"$VERSION_ID".tar.zst
76+
arch="$(arch)"
77+
[[ "$arch" = "aarch64" || "$arch" = "arm64" ]] && ARCH_SUFFIX='_arm64' || ARCH_SUFFIX=''
78+
tar_file=php_"$version-$ts$PHP_PKG_SUFFIX"+ubuntu"$VERSION_ID$ARCH_SUFFIX".tar.zst
7779
check_reload
7880
install
7981
fix_alternatives

scripts/package-php.sh

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
cd / || exit 1
22
[ "${BUILDS:?}" = "debug" ] && PHP_PKG_SUFFIX=-dbgsym
3-
git add /bin /lib /lib64 /sbin /usr /var /run/php
3+
ls -la /
4+
for dir_path in /bin /lib /lib64 /sbin /usr /var /run/php; do
5+
[ -d "$dir_path" ] && git add "$dir_path"
6+
done
47
find /etc -maxdepth 1 -mindepth 1 -type d -exec git add {} \;
58
git commit -m "installed php"
69
mkdir -p /tmp/php/etc/apt/sources.list.d /tmp/php/etc/apt/trusted.gpg.d /tmp/php/var/lib/apt/lists
@@ -9,25 +12,28 @@ for file in $(git log -p -n 1 --name-only | sed 's/^.*\(\s\).*$/\1/' | xargs -L1
912
sudo cp -r -p --parents "$file" /tmp/php || true
1013
fi
1114
done
15+
lib_subdir="$(uname -m)-linux-gnu"
1216
sudo touch /var/lib/dpkg/status-diff
1317
sudo cp "$GITHUB_WORKSPACE"/scripts/required /tmp/required
1418
sudo LC_ALL=C.UTF-8 python3 "$GITHUB_WORKSPACE"/scripts/create_status.py
19+
sudo mkdir -p /tmp/php/usr/sbin /tmp/php/var/lib/dpkg/
1520
sudo cp /var/lib/dpkg/status-diff /tmp/php/var/lib/dpkg/
16-
sudo mkdir -p /tmp/php/usr/sbin
1721
sudo cp "$GITHUB_WORKSPACE"/scripts/merge_status.py /tmp/php/usr/sbin/merge_status
1822
cat /tmp/php/var/lib/dpkg/status-diff
1923
sudo cp /etc/apt/sources.list.d/ondrej* /tmp/php/etc/apt/sources.list.d/
2024
sudo cp /etc/apt/trusted.gpg.d/ondrej* /tmp/php/etc/apt/trusted.gpg.d/
2125
sudo cp /var/lib/apt/lists/*ondrej* /tmp/php/var/lib/apt/lists/
22-
sudo cp -a /usr/lib/x86_64-linux-gnu/libpcre* /tmp/php/usr/lib/x86_64-linux-gnu/
23-
sudo cp -a /lib/x86_64-linux-gnu/libpcre* /tmp/php/usr/lib/x86_64-linux-gnu/
26+
sudo cp -a /usr/lib/"$lib_subdir"/libpcre* /tmp/php/usr/lib/"$lib_subdir"/
27+
sudo cp -a /lib/"$lib_subdir"/libpcre* /tmp/php/usr/lib/"$lib_subdir"/
2428
sudo rm -rf /tmp/php/var/lib/dpkg/alternatives/* /tmp/php/var/lib/dpkg/status-old /tmp/php/var/lib/dpkg/status-orig
2529
. /etc/os-release
2630
SEMVER="$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-')"
2731
(
2832
cd /tmp/php || exit 1
29-
sudo tar cf - ./* | zstd -22 -T0 --ultra > ../php_"$PHP_VERSION-$TS$PHP_PKG_SUFFIX"+ubuntu"$VERSION_ID".tar.zst
30-
cp ../php_"$PHP_VERSION-$TS$PHP_PKG_SUFFIX"+ubuntu"$VERSION_ID".tar.zst ../php_"$SEMVER-$TS$PHP_PKG_SUFFIX"+ubuntu"$VERSION_ID".tar.zst
33+
arch="$(arch)"
34+
[[ "$arch" = "aarch64" || "$arch" = "arm64" ]] && ARCH_SUFFIX='_arm64' || ARCH_SUFFIX=''
35+
sudo tar cf - ./* | zstd -22 -T0 --ultra > ../php_"$PHP_VERSION-$TS$PHP_PKG_SUFFIX"+ubuntu"$VERSION_ID$ARCH_SUFFIX".tar.zst
36+
cp ../php_"$PHP_VERSION-$TS$PHP_PKG_SUFFIX"+ubuntu"$VERSION_ID$ARCH_SUFFIX".tar.zst ../php_"$SEMVER-$TS$PHP_PKG_SUFFIX"+ubuntu"$VERSION_ID$ARCH_SUFFIX".tar.zst
3137
)
3238
cd "$GITHUB_WORKSPACE" || exit 1
3339
mkdir builds

0 commit comments

Comments
 (0)