diff --git a/.github/workflows/linux-aarch64.yml b/.github/workflows/linux-aarch64.yml index d3e557a9db..821725261a 100644 --- a/.github/workflows/linux-aarch64.yml +++ b/.github/workflows/linux-aarch64.yml @@ -129,7 +129,7 @@ jobs: composer install --no-interaction --no-autoloader --no-scripts --profile composer dump-autoload --optimize --profile - php prepare.php +inotify +apcu +ds +xlswriter +ssh2 --with-swoole-pgsql=1 --with-libavif=1 + php prepare.php bash make.sh all-library diff --git a/.github/workflows/linux-x86_64.yml b/.github/workflows/linux-x86_64.yml index 8548afe854..c6e1f41e7b 100644 --- a/.github/workflows/linux-x86_64.yml +++ b/.github/workflows/linux-x86_64.yml @@ -115,7 +115,7 @@ jobs: composer install --no-interaction --no-autoloader --no-scripts --profile composer dump-autoload --optimize --profile - php prepare.php +inotify +apcu +ds +xlswriter +ssh2 --with-swoole-pgsql=1 + php prepare.php bash ./make.sh all-library diff --git a/.github/workflows/macos-aarch64.yml b/.github/workflows/macos-aarch64.yml index bdeff078c5..70c63570b3 100644 --- a/.github/workflows/macos-aarch64.yml +++ b/.github/workflows/macos-aarch64.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Prepare build environment + - name: Show Environment Info run: | set -x uname -s @@ -24,8 +24,6 @@ jobs: echo $HOME brew config - bash sapi/quickstart/macos/macos-init.sh - # sudo rm -rf /Library/Developer/CommandLineTools # xcode-select --install @@ -49,6 +47,10 @@ jobs: echo "X_IPV6=${IPV6}" >> $GITHUB_ENV echo "X_IPV4=${IPV4}" >> $GITHUB_ENV + - name: Prepare Build Environment + run: | + bash sapi/quickstart/macos/macos-init.sh + export PATH="/opt/homebrew/opt/libtool/bin:$PATH" ls -lha /opt/homebrew/opt/libtool/bin/ libtoolize --version @@ -60,6 +62,7 @@ jobs: echo ${CURRENT_USER} sudo mkdir -p /usr/local/swoole-cli CURRENT_USER=$(whoami) && sudo chown -R ${CURRENT_USER}:staff /usr/local/swoole-cli + git submodule update --init - name: Cache PHP Runtime @@ -97,7 +100,7 @@ jobs: mkdir -p pool/ext mkdir -p bin/runtime if [ ! -f bin/runtime/php ] ; then - bash sapi/quickstart/setup-php-runtime.sh --mirror china + bash sapi/quickstart/setup-php-runtime.sh fi bash sapi/download-box/download-box-get-archive-from-server.sh ls -A pool/lib/ @@ -111,7 +114,7 @@ jobs: composer install --no-interaction --no-autoloader --no-scripts --profile composer dump-autoload --optimize --profile - php prepare.php --without-docker=1 +ds +apcu +xlswriter +ssh2 --with-build-type=release --with-swoole-pgsql=1 + php prepare.php --without-docker=1 - name: Build run: | diff --git a/.github/workflows/macos-x86_64.yml b/.github/workflows/macos-x86_64.yml index 4d8dfb4493..12183de78b 100644 --- a/.github/workflows/macos-x86_64.yml +++ b/.github/workflows/macos-x86_64.yml @@ -14,16 +14,15 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Prepare build environment + - name: Show Environment Info run: | + set -x uname -s uname -m uname -r env echo $HOME brew config - set -x - bash sapi/quickstart/macos/macos-init.sh # sudo rm -rf /Library/Developer/CommandLineTools # xcode-select --install @@ -48,6 +47,10 @@ jobs: echo "X_IPV6=${IPV6}" >> $GITHUB_ENV echo "X_IPV4=${IPV4}" >> $GITHUB_ENV + - name: Prepare Build Environment + run: | + bash sapi/quickstart/macos/macos-init.sh + export PATH=/usr/local/opt/libtool/bin:$PATH ls -lha /usr/local/opt/libtool/bin/ @@ -59,6 +62,7 @@ jobs: echo ${CURRENT_USER} sudo mkdir -p /usr/local/swoole-cli CURRENT_USER=$(whoami) && sudo chown -R ${CURRENT_USER}:staff /usr/local/swoole-cli + git submodule update --init - name: Cache PHP Runtime @@ -110,7 +114,7 @@ jobs: composer install --no-interaction --no-autoloader --no-scripts --profile composer dump-autoload --optimize --profile - php prepare.php --without-docker=1 +ds +apcu +xlswriter +ssh2 --with-build-type=release + php prepare.php --without-docker=1 - name: Build run: | diff --git a/.gitignore b/.gitignore index 87d383f0cf..ccb8de0e7f 100644 --- a/.gitignore +++ b/.gitignore @@ -312,6 +312,7 @@ tmp-php.ini /ext/loader8 /ext/ds /ext/xlswriter +/ext/uuid /.phpunit.result.cache /samples/sfx/*.phar .php-cs-fixer.cache diff --git a/docs/extensions.md b/docs/extensions.md index ef7d55e87a..65ce208b91 100644 --- a/docs/extensions.md +++ b/docs/extensions.md @@ -50,6 +50,7 @@ | protobuf | ❌ | ❌ | ❌ | ❌ | | uuid | ✅ | ✅ | ❌ | ❌ | | mailparse | ✅ | ✅ | ❌ | ❌ | +| gettext | ✅ | ✅ | ❌ | ❌ | ## 查看 新增的扩展 和 移除的扩展 diff --git a/sapi/download-box/download-box-get-archive-from-server.sh b/sapi/download-box/download-box-get-archive-from-server.sh index 4ba5c8487e..4554b8ee50 100644 --- a/sapi/download-box/download-box-get-archive-from-server.sh +++ b/sapi/download-box/download-box-get-archive-from-server.sh @@ -18,9 +18,9 @@ test -d ${__PROJECT__}/var/download-box/ || mkdir -p ${__PROJECT__}/var/download cd ${__PROJECT__}/var/download-box/ -ALL_DEPS_HASH="5fa1485c2408f05cbc548712917e6dbb8ecd5a631b558d6d512d4a6671f071e5" +ALL_DEPS_HASH="ed854e2116ff663404250152af16d850ed69253079c65ee790538c51a09166dd" -DOMAIN='https://github.com/swoole/swoole-cli/releases/download/v5.1.3.0/' +DOMAIN='https://github.com/swoole/swoole-cli/releases/download/v5.1.4.0/' while [ $# -gt 0 ]; do case "$1" in --mirror) diff --git a/sapi/multistage-build-dependencies-container/Dockerfile-all-dependencies-alpine b/sapi/multistage-build-dependencies-container/Dockerfile-all-dependencies-alpine deleted file mode 100644 index e6e695f76e..0000000000 --- a/sapi/multistage-build-dependencies-container/Dockerfile-all-dependencies-alpine +++ /dev/null @@ -1,109 +0,0 @@ -FROM alpine:3.18 as builder-all-library - -RUN uname -a - -RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone -ENV TZ=Etc/UTC - -ARG COMPOSER_MIRROR="" -ARG MIRROR="" - - -RUN test -f /etc/apk/repositories.save || cp /etc/apk/repositories /etc/apk/repositories.save - -# setup source repo, install dependencies -RUN if [ "${MIRROR}" = "ustc" -o "${MIRROR}" = "china" ]; then { sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories ; } fi -RUN if [ "${MIRROR}" = "tuna" ]; then { sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories ; } fi - - -WORKDIR /work - -RUN mkdir -p /usr/local/swoole-cli/etc/ - -ADD ./bin/runtime/php /usr/local/bin/ -ADD ./bin/runtime/composer /usr/local/bin/ -ADD ./bin/runtime/cacert.pem /etc/ssl/certs/ - - -ADD ./php.ini /usr/local/swoole-cli/etc/ - -ADD ./ /work - -RUN chmod a+x /usr/local/bin/php -RUN chmod a+x /usr/local/bin/composer - - -ENV CERT_FILE=/etc/ssl/certs/cacert.pem -# ENV CERT_FILE=/etc/ssl/certs/ca-certificates.crt -ENV PHP_INI=/usr/local/swoole-cli/etc/php.ini - -RUN alias php='php -d curl.cainfo="${CERT_FILE}" -d openssl.cafile="${CERT_FILE}"' - -RUN echo "alias php='php -d curl.cainfo=\"\${CERT_FILE}\" -d openssl.cafile=\"\${CERT_FILE}\"'" >>/root/.bashrc - -RUN sh sapi/quickstart/linux/alpine-init.sh --mirror ${MIRROR} - - -WORKDIR /work - -ENV COMPOSER_ALLOW_SUPERUSER=1 - -RUN if [ "${COMPOSER_MIRROR}" = "aliyun" ]; then { composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ ; } fi -RUN if [ "${COMPOSER_MIRROR}" = "tencent" -o "${COMPOSER_MIRROR}" = "china" ]; then { composer config -g repos.packagist composer https://mirrors.cloud.tencent.com/composer/ ; } fi - -RUN composer update --optimize-autoloader -RUN composer config -g --unset repos.packagist - - -RUN php prepare.php +apcu +ds +xlswriter +ssh2 +uuid - -RUN bash make.sh all-library - - - -FROM alpine:3.18 - -RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone -ENV TZ=Etc/UTC - -ARG COMPOSER_MIRROR="" -ARG MIRROR="" - -# setup source repo, install dependencies -RUN cp /etc/apk/repositories /etc/apk/repositories.save - -RUN if [ "${MIRROR}" = "ustc" -o "${MIRROR}" = "china" ]; then { sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories ; } fi -RUN if [ "${MIRROR}" = "tuna" ]; then { sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories ; } fi - -RUN apk update && apk add --no-cache tini - -WORKDIR /work - - -COPY --from=builder-all-library /usr/local/bin/php /usr/local/bin/php -COPY --from=builder-all-library /usr/local/bin/composer /usr/local/bin/composer -COPY --from=builder-all-library /etc/ssl/certs/cacert.pem /etc/ssl/certs/cacert.pem - -COPY --from=builder-all-library /usr/local/swoole-cli /usr/local/swoole-cli - - -RUN chmod a+x /usr/local/bin/php -RUN chmod a+x /usr/local/bin/composer - -ENV CERT_FILE=/etc/ssl/certs/cacert.pem -# ENV CERT_FILE=/etc/ssl/certs/ca-certificates.crt -ENV PHP_INI=/usr/local/swoole-cli/etc/php.ini - - -RUN alias php='php -d curl.cainfo="${CERT_FILE}" -d openssl.cafile="${CERT_FILE}"' - -RUN echo "alias php='php -d curl.cainfo=\"\${CERT_FILE}\" -d openssl.cafile=\"\${CERT_FILE}\"'" >>/root/.bashrc - -ENV COMPOSER_ALLOW_SUPERUSER=1 - -RUN test -f /etc/apk/repositories.save && cp -f /etc/apk/repositories.save /etc/apk/repositories - -RUN rm -rf /var/cache/apk/* /tmp/* /var/tmp/* - -ENTRYPOINT ["tini", "--"] - diff --git a/sapi/multistage-build-dependencies-container/README.md b/sapi/multistage-build-dependencies-container/README.md deleted file mode 100644 index fcb3e30ee0..0000000000 --- a/sapi/multistage-build-dependencies-container/README.md +++ /dev/null @@ -1,75 +0,0 @@ -# 构建依赖库容器镜像 - -> 目的: 提前构建好依赖库,使用时直接跳过依赖库构建步骤 - -> 借助容器的多阶段构建功能,提前构建好依赖库 -> 工作目录位于 `var` 目录 - -## 构建依赖库容器镜像的2种方式说明 - -> 通过 docker commit 生成 比如 `phpswoole/swoole-cli-builder:1.6` - -> 通过 Dockerfile 多阶段构建生成 - -> 比如 `docker.io/jingjingxyk/build-swoole-cli:all-dependencies-alpine` - -> 二者容器镜像是一样的 - - - -## 执行构建依赖库容器 - -```bash - -bash sapi/multistage-build-dependencies-container/all-dependencies-build-container.sh - -## composer 使用腾讯镜像源 , 系统源使用 ustc 源 - -bash sapi/multistage-build-dependencies-container/all-dependencies-build-container.sh --composer_mirror tencent --mirror ustc - -``` - -## 验证构建好的依赖库 - -```bash - -bash sapi/multistage-build-dependencies-container/all-dependencies-run-container-test.sh - -# 新开终端进入容器 -docker exec -it swoole-cli-alpine-dev sh - - -# 执行构建测试 -sh build-release-example.sh --mirror china - -``` - -## 为了方便分发,把容器镜像导出为文件 -> 目的:节省网络传输流量 (容器镜像不压缩情况下,大小超过 1GB) - -> 构建加速建议: 使用 抢占式高配置云服务器 加速构建 - -```bash - -cd var - -docker save -o "all-dependencies-container-image-$(uname -m).tar" $(cat all-dependencies-container.txt) - -# xz 并行压缩 -T cpu核数 -k 保持源文件 -xz -9 -T$(nproc) -k "all-dependencies-container-image-$(uname -m).tar" - -# xz 解压 -xz -d -T$(nproc) -k "all-dependencies-container-image-$(uname -m).tar.xz" - -# 从文件导入容器镜像 - -docker load -i "all-dependencies-container-image-$(uname -m).tar" - - -``` - -## 容器多阶段构建镜像参考文档 - -- [multistage-build](https://docs.docker.com/develop/develop-images/multistage-build/) -- [dockerfile mount type 挂载目录](https://docs.docker.com/engine/reference/builder/#run---mount) -- [dockerfiles-now-support-multiple-build-contexts](https://www.docker.com/blog/dockerfiles-now-support-multiple-build-contexts/) diff --git a/sapi/multistage-build-dependencies-container/all-dependencies-build-container.sh b/sapi/multistage-build-dependencies-container/all-dependencies-build-container.sh deleted file mode 100644 index 808149914d..0000000000 --- a/sapi/multistage-build-dependencies-container/all-dependencies-build-container.sh +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/bash - -set -exu -__DIR__=$( - cd "$(dirname "$0")" - pwd -) -__PROJECT__=$( - cd ${__DIR__}/../../ - pwd -) - -if [[ -f /.dockerenv ]]; then - echo 'not support in docker' - exit 0 -fi - - -cd ${__PROJECT__} - - -mkdir -p ${__PROJECT__}/var - - -# export DOCKER_BUILDKIT=1 - -ARCH=$(uname -m) - -TIME=$(date -u '+%Y%m%dT%H%M%SZ') - -VERSION="1.0.0" -TAG="all-dependencies-alpine-3.18-php8-v${VERSION}-${ARCH}-${TIME}" -IMAGE="docker.io/jingjingxyk/build-swoole-cli:${TAG}" -IMAGE="docker.io/phpswoole/swoole-cli-builder:${TAG}" - - -COMPOSER_MIRROR="" -MIRROR="" -PLATFORM='' - -ARCH=$(uname -m) -case $ARCH in -'x86_64') - PLATFORM='linux/amd64' - ;; -'aarch64') - PLATFORM='linux/arm64' - ;; -esac - - -while [ $# -gt 0 ]; do - case "$1" in - --composer_mirror) - COMPOSER_MIRROR="$2" # "aliyun" "tencent" "china" - ;; - --mirror) - MIRROR="$2" # "ustc" "tuna" "china" - ;; - --platform) - PLATFORM="$2" - ;; - --*) - echo "Illegal option $1" - ;; - esac - shift $(($# > 0 ? 1 : 0)) -done - -cd ${__PROJECT__}/ - -if [ ! -f make.sh ] ;then - echo 'please run script:' - echo 'php prepare.php' - exit 0 -fi - -cp -f ${__DIR__}/Dockerfile-all-dependencies-alpine . -cp -f ${__DIR__}/php.ini . - -docker buildx build -t ${IMAGE} -f ./Dockerfile-all-dependencies-alpine . \ ---progress=plain \ ---build-arg="COMPOSER_MIRROR=${COMPOSER_MIRROR}" \ ---build-arg="MIRROR=${MIRROR}" \ ---platform "${PLATFORM}" - - -cd ${__PROJECT__}/ - -echo ${IMAGE} > ${__PROJECT__}/var/all-dependencies-container.txt - - -# docker push ${IMAGE} - - -# 例子: -# php prepare.php -# bash sapi/multistage-build-dependencies-container/all-dependencies-build-container.sh --composer_mirror tencent --mirror ustc --platform 'linux/amd64' -# 验证构建结果 -# bash sapi/multistage-build-dependencies-container/all-dependencies-run-container-test.sh - diff --git a/sapi/multistage-build-dependencies-container/all-dependencies-run-container-test.sh b/sapi/multistage-build-dependencies-container/all-dependencies-run-container-test.sh deleted file mode 100644 index ff75b72eb6..0000000000 --- a/sapi/multistage-build-dependencies-container/all-dependencies-run-container-test.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -set -exu -__DIR__=$( - cd "$(dirname "$0")" - pwd -) -__PROJECT__=$( - cd ${__DIR__}/../../ - pwd -) - -cd ${__PROJECT__}/ -ARCH=$(uname -m) - -IMAGE_FILE="${__PROJECT__}/var/all-dependencies-container.txt" -if test -f $IMAGE_FILE; then - { - docker stop swoole-cli-alpine-dev - sleep 5 - } || { - echo $? - } - IMAGE=$(cat ${IMAGE_FILE}) - docker run --rm --name swoole-cli-alpine-dev -d -v ${__PROJECT__}:/work -w /work ${IMAGE} tail -f /dev/null -else - echo 'no container image' -fi diff --git a/sapi/multistage-build-dependencies-container/php.ini b/sapi/multistage-build-dependencies-container/php.ini deleted file mode 100644 index 421cd39829..0000000000 --- a/sapi/multistage-build-dependencies-container/php.ini +++ /dev/null @@ -1,3 +0,0 @@ -curl.cainfo="/etc/ssl/certs/cacert.pem" -openssl.cafile="/etc/ssl/certs/cacert.pem" -# swoole.use_shortname=off diff --git a/sapi/quickstart/README.md b/sapi/quickstart/README.md index 2fc0790db6..c288cfda1b 100644 --- a/sapi/quickstart/README.md +++ b/sapi/quickstart/README.md @@ -1,12 +1,12 @@ # 快速初始化构建环境 -## 一个脚本执行整个流程 +## 一个脚本执行整个构建流程 > 定制 build-release.sh 即可开始构建 ```bash - cp build-release-example.sh build-release.sh + cp build-release-example.sh build-release.sh bash build-release.sh @@ -19,7 +19,7 @@ # 准备 PHP 运行时 bash sapi/quickstart/setup-php-runtime.sh -# 准备PHP 运行时 使用代理 (需提前准备好代理) +# 准备PHP 运行时 使用代理 bash sapi/quickstart/setup-php-runtime.sh --proxy http://192.168.3.26:8015 # 准备PHP 运行时 使用镜像 (镜像源 https://www.swoole.com/download) @@ -34,12 +34,10 @@ composer -v ``` -## 准备依赖库源码,来自镜像 - -> 可能部分源码包没有及时更新 ,请提 issues -> 缺失的部分,下一步执行时会自动到源站下载 +## 准备依赖库源码 ```bash +# 源码来源 https://github.com/swoole/swoole-cli/releases/download/${TAG}/all-deps.zip bash sapi/download-box/download-box-get-archive-from-server.sh @@ -51,35 +49,7 @@ bash sapi/download-box/download-box-get-archive-from-server.sh ```bash -git submodule update --init - -``` - -## 准备构建脚本(会自动下载依赖库源码包) - -> [ 构建参数选项 ](../../docs/options.md) - -```bash - -# 准备 php 运行环境 -# macos -alias php='php -d curl.cainfo=/etc/ssl/cert.pem -d openssl.cafile=/etc/ssl/cert.pem' -# linux -alias php='php -d curl.cainfo=/etc/ssl/certs/ca-certificates.crt -d openssl.cafile=/etc/ssl/certs/ca-certificates.crt' - - -composer update --optimize-autoloader - -php prepare.php +inotify +apcu +ds +xlswriter +ssh2 --with-swoole-pgsql=1 - -# 使用镜像下载依赖库源码 -php prepare.php +inotify +apcu +ds +xlswriter +ssh2 --with-swoole-pgsql=1 --with-download-mirror-url=https://swoole-cli.jingjingxyk.com/ - -# 不启用用 mysqli soap -# php prepare.php +inotify +apcu +ds -mysqli -soap - -# macos -# php prepare.php +inotify +apcu +ds --without-docker=1 +git submodule update --init -f ``` @@ -88,6 +58,7 @@ php prepare.php +inotify +apcu +ds +xlswriter +ssh2 --with-swoole-pgsql=1 --wit 1. [ linux 快速启动 容器 构建环环境 ](linux/README.md) 1. [ windows cygwin 快速启动 构建环环境 ](windows/README.md) 1. [ macos 快速启动 构建环环境 ](macos/README.md) +1. [ 构建选项 ](../../docs/options.md) ## 构建依赖库 、构建swoole 、打包 diff --git a/sapi/quickstart/linux/alpine-init-minimal.sh b/sapi/quickstart/linux/alpine-init-minimal.sh index 8a6c8d189a..9c6b6bdc88 100644 --- a/sapi/quickstart/linux/alpine-init-minimal.sh +++ b/sapi/quickstart/linux/alpine-init-minimal.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env sh set -exu __DIR__=$( @@ -10,7 +10,6 @@ cd ${__DIR__} # use china mirror # sh sapi/quickstart/linux/alpine-init-mini.sh --mirror [ china | ustc | tuna | tencentyun | huaweicloud ] - MIRROR='' while [ $# -gt 0 ]; do case "$1" in @@ -28,8 +27,8 @@ case "$MIRROR" in china | tuna | ustc) test -f /etc/apk/repositories.save || cp /etc/apk/repositories /etc/apk/repositories.save test "$MIRROR" = "china" && sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories - test "$MIRROR" = "tuna" && sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories - test "$MIRROR" = "ustc" && sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories + test "$MIRROR" = "tuna" && sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories + test "$MIRROR" = "ustc" && sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories ;; tencentyun | huaweicloud) # 云服务的内网镜像源 test -f /etc/apk/repositories.save || cp /etc/apk/repositories /etc/apk/repositories.save @@ -41,4 +40,4 @@ esac apk update -apk add bash git curl wget xz zip unzip ca-certificates +apk add bash git curl wget xz zip unzip ca-certificates diff --git a/sapi/quickstart/linux/alpine-init.sh b/sapi/quickstart/linux/alpine-init.sh index 2f50393af0..3d20c8ab5f 100644 --- a/sapi/quickstart/linux/alpine-init.sh +++ b/sapi/quickstart/linux/alpine-init.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env sh set -exu __DIR__=$( @@ -10,7 +10,6 @@ cd ${__DIR__} # use china mirror # sh sapi/quickstart/linux/alpine-init.sh --mirror [ china | ustc | tuna | tencentyun | huaweicloud ] - MIRROR='' while [ $# -gt 0 ]; do case "$1" in @@ -28,8 +27,8 @@ case "$MIRROR" in china | tuna | ustc) test -f /etc/apk/repositories.save || cp /etc/apk/repositories /etc/apk/repositories.save test "$MIRROR" = "china" && sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories - test "$MIRROR" = "tuna" && sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories - test "$MIRROR" = "ustc" && sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories + test "$MIRROR" = "tuna" && sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories + test "$MIRROR" = "ustc" && sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories ;; tencentyun | huaweicloud) # 云服务的内网镜像源 test -f /etc/apk/repositories.save || cp /etc/apk/repositories /etc/apk/repositories.save @@ -66,10 +65,8 @@ china | tuna | ustc) tencentyun | huaweicloud) test "$MIRROR" = "tencentyun" && pip3 config set global.index-url https://mirrors.tencentyun.com/pypi/simple/ test "$MIRROR" = "huaweicloud" && pip3 config set global.index-url https://repo.huaweicloud.com/pypi/simple/ + ;; esac - # pip3 install meson apk add meson - - diff --git a/sapi/quickstart/linux/connection-swoole-cli-alpine.sh b/sapi/quickstart/linux/connection-swoole-cli-alpine.sh index db089a711c..f39d9b749f 100644 --- a/sapi/quickstart/linux/connection-swoole-cli-alpine.sh +++ b/sapi/quickstart/linux/connection-swoole-cli-alpine.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -exu __DIR__=$( diff --git a/sapi/quickstart/linux/connection-swoole-cli-builder.sh b/sapi/quickstart/linux/connection-swoole-cli-builder.sh new file mode 100644 index 0000000000..236b7b52b1 --- /dev/null +++ b/sapi/quickstart/linux/connection-swoole-cli-builder.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) + +cd ${__DIR__} + +docker exec -it swoole-cli-builder sh + diff --git a/sapi/quickstart/linux/connection-swoole-cli-debian.sh b/sapi/quickstart/linux/connection-swoole-cli-debian.sh index 95d88604d4..a6a0301aa6 100644 --- a/sapi/quickstart/linux/connection-swoole-cli-debian.sh +++ b/sapi/quickstart/linux/connection-swoole-cli-debian.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -exu __DIR__=$( diff --git a/sapi/quickstart/linux/debian-init-minimal.sh b/sapi/quickstart/linux/debian-init-minimal.sh index 81dbe41442..093d2af330 100644 --- a/sapi/quickstart/linux/debian-init-minimal.sh +++ b/sapi/quickstart/linux/debian-init-minimal.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -exu __DIR__=$( @@ -14,7 +14,7 @@ while [ $# -gt 0 ]; do case "$1" in --mirror) case "$2" in - china | ustc | tuna | aliyuncs | tencentyun | huaweicloud ) + china | ustc | tuna | aliyuncs | tencentyun | huaweicloud) MIRROR="$2" ;; esac @@ -26,63 +26,66 @@ while [ $# -gt 0 ]; do shift $(($# > 0 ? 1 : 0)) done - - -if test -n "$MIRROR" ; then -{ - OS_ID=$(cat /etc/os-release | grep '^ID=' | awk -F '=' '{print $2}') - VERSION_ID=$(cat /etc/os-release | grep '^VERSION_ID=' | awk -F '=' '{print $2}' | sed "s/\"//g") - case $OS_ID in - debian) - case $VERSION_ID in - 11 | 12 ) - # debian 容器内和容器外 镜像源配置不一样 - if [ -f /.dockerenv ] && [ "$VERSION_ID" = 12 ]; then - test -f /etc/apt/sources.list.d/debian.sources.save || cp -f /etc/apt/sources.list.d/debian.sources /etc/apt/sources.list.d/debian.sources.save - sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list.d/debian.sources - sed -i 's/security.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list.d/debian.sources - test "$MIRROR" = "tuna" && sed -i "s@mirrors.ustc.edu.cn@mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list.d/debian.sources - # 云服务内网镜像源 - test "$MIRROR" = "aliyuncs" && sed -i "s@mirrors.ustc.edu.cn@mirrors.cloud.aliyuncs.com@g" /etc/apt/sources.list.d/debian.sources - test "$MIRROR" = "tencentyun" && sed -i "s@mirrors.ustc.edu.cn@mirrors.tencentyun.com@g" /etc/apt/sources.list.d/debian.sources - test "$MIRROR" = "huaweicloud" && sed -i "s@mirrors.ustc.edu.cn@repo.huaweicloud.com@g" /etc/apt/sources.list.d/debian.sources - else +if test -n "$MIRROR"; then + { + OS_ID=$(cat /etc/os-release | grep '^ID=' | awk -F '=' '{print $2}') + VERSION_ID=$(cat /etc/os-release | grep '^VERSION_ID=' | awk -F '=' '{print $2}' | sed "s/\"//g") + case $OS_ID in + debian) + case $VERSION_ID in + 11 | 12) + # debian 容器内和容器外 镜像源配置不一样 + if [ -f /.dockerenv ] && [ "$VERSION_ID" = 12 ]; then + test -f /etc/apt/sources.list.d/debian.sources.save || cp -f /etc/apt/sources.list.d/debian.sources /etc/apt/sources.list.d/debian.sources.save + sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list.d/debian.sources + sed -i 's/security.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list.d/debian.sources + test "$MIRROR" = "tuna" && sed -i "s@mirrors.ustc.edu.cn@mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list.d/debian.sources + # 云服务内网镜像源 + test "$MIRROR" = "aliyuncs" && sed -i "s@mirrors.ustc.edu.cn@mirrors.cloud.aliyuncs.com@g" /etc/apt/sources.list.d/debian.sources + test "$MIRROR" = "tencentyun" && sed -i "s@mirrors.ustc.edu.cn@mirrors.tencentyun.com@g" /etc/apt/sources.list.d/debian.sources + test "$MIRROR" = "huaweicloud" && sed -i "s@mirrors.ustc.edu.cn@repo.huaweicloud.com@g" /etc/apt/sources.list.d/debian.sources + else + test -f /etc/apt/sources.list.save || cp /etc/apt/sources.list /etc/apt/sources.list.save + sed -i "s@deb.debian.org@mirrors.ustc.edu.cn@g" /etc/apt/sources.list + sed -i "s@security.debian.org@mirrors.ustc.edu.cn@g" /etc/apt/sources.list + test "$MIRROR" = "tuna" && sed -i "s@mirrors.ustc.edu.cn@mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list + test "$MIRROR" = "aliyuncs" && sed -i "s@mirrors.ustc.edu.cn@mirrors.cloud.aliyuncs.com@g" /etc/apt/sources.list + test "$MIRROR" = "tencentyun" && sed -i "s@mirrors.ustc.edu.cn@mirrors.tencentyun.com@g" /etc/apt/sources.list + test "$MIRROR" = "huaweicloud" && sed -i "s@mirrors.ustc.edu.cn@repo.huaweicloud.com@g" /etc/apt/sources.list + fi + ;; + *) + echo 'no match debian OS version' . $VERSION_ID + ;; + esac + ;; + ubuntu) + case $VERSION_ID in + 20.04 | 22.04 | 22.10 | 23.04 | 23.10) test -f /etc/apt/sources.list.save || cp /etc/apt/sources.list /etc/apt/sources.list.save - sed -i "s@deb.debian.org@mirrors.ustc.edu.cn@g" /etc/apt/sources.list - sed -i "s@security.debian.org@mirrors.ustc.edu.cn@g" /etc/apt/sources.list + sed -i "s@security.ubuntu.com@mirrors.ustc.edu.cn@g" /etc/apt/sources.list + sed -i "s@archive.ubuntu.com@mirrors.ustc.edu.cn@g" /etc/apt/sources.list test "$MIRROR" = "tuna" && sed -i "s@mirrors.ustc.edu.cn@mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list test "$MIRROR" = "aliyuncs" && sed -i "s@mirrors.ustc.edu.cn@mirrors.cloud.aliyuncs.com@g" /etc/apt/sources.list test "$MIRROR" = "tencentyun" && sed -i "s@mirrors.ustc.edu.cn@mirrors.tencentyun.com@g" /etc/apt/sources.list test "$MIRROR" = "huaweicloud" && sed -i "s@mirrors.ustc.edu.cn@repo.huaweicloud.com@g" /etc/apt/sources.list - fi + ;; + 24.04) + test -f /etc/apt/sources.list.d/ubuntu.sources.save || cp /etc/apt/sources.list.d/ubuntu.sources /etc/apt/sources.list.d/ubuntu.sources.save + sed -i "s@security.ubuntu.com@mirrors.ustc.edu.cn@g" /etc/apt/sources.list.d/ubuntu.sources + sed -i "s@archive.ubuntu.com@mirrors.ustc.edu.cn@g" /etc/apt/sources.list.d/ubuntu.sources + ;; + *) + echo 'no match ubuntu OS version' . $VERSION_ID + ;; + esac ;; *) - echo 'no match debian OS version' . $VERSION_ID + echo 'NO SUPPORT LINUX OS' + exit 0 ;; esac - ;; - ubuntu) - case $VERSION_ID in - 20.04 | 22.04 | 22.10 | 23.04 | 23.10) - test -f /etc/apt/sources.list.save || cp /etc/apt/sources.list /etc/apt/sources.list.save - sed -i "s@security.ubuntu.com@mirrors.ustc.edu.cn@g" /etc/apt/sources.list - sed -i "s@archive.ubuntu.com@mirrors.ustc.edu.cn@g" /etc/apt/sources.list - test "$MIRROR" = "tuna" && sed -i "s@mirrors.ustc.edu.cn@mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list - test "$MIRROR" = "aliyuncs" && sed -i "s@mirrors.ustc.edu.cn@mirrors.cloud.aliyuncs.com@g" /etc/apt/sources.list - test "$MIRROR" = "tencentyun" && sed -i "s@mirrors.ustc.edu.cn@mirrors.tencentyun.com@g" /etc/apt/sources.list - test "$MIRROR" = "huaweicloud" && sed -i "s@mirrors.ustc.edu.cn@repo.huaweicloud.com@g" /etc/apt/sources.list - ;; - *) - echo 'no match ubuntu OS version' . $VERSION_ID - ;; - esac - ;; - *) - echo 'NO SUPPORT LINUX OS' - exit 0 - ;; - esac -} + } fi test -f /etc/apt/apt.conf.d/proxy.conf && rm -rf /etc/apt/apt.conf.d/proxy.conf diff --git a/sapi/quickstart/linux/debian-init.sh b/sapi/quickstart/linux/debian-init.sh index caf55d326b..505ef342d5 100644 --- a/sapi/quickstart/linux/debian-init.sh +++ b/sapi/quickstart/linux/debian-init.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -exu __DIR__=$( @@ -14,7 +14,7 @@ while [ $# -gt 0 ]; do case "$1" in --mirror) case "$2" in - china | ustc | tuna | aliyuncs | tencentyun | huaweicloud ) + china | ustc | tuna | aliyuncs | tencentyun | huaweicloud) MIRROR="$2" ;; esac @@ -26,87 +26,91 @@ while [ $# -gt 0 ]; do shift $(($# > 0 ? 1 : 0)) done - - -if test -n "$MIRROR" ; then -{ - OS_ID=$(cat /etc/os-release | grep '^ID=' | awk -F '=' '{print $2}') - VERSION_ID=$(cat /etc/os-release | grep '^VERSION_ID=' | awk -F '=' '{print $2}' | sed "s/\"//g") - case $OS_ID in - debian) - case $VERSION_ID in - 11 | 12 ) - # 容器内和容器外 镜像源配置不一样 - if [ -f /.dockerenv ] && [ "$VERSION_ID" = 12 ]; then - test -f /etc/apt/sources.list.d/debian.sources.save || cp -f /etc/apt/sources.list.d/debian.sources /etc/apt/sources.list.d/debian.sources.save - sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list.d/debian.sources - sed -i 's/security.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list.d/debian.sources - test "$MIRROR" = "tuna" && sed -i "s@mirrors.ustc.edu.cn@mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list.d/debian.sources - # 云服务内网镜像源 - test "$MIRROR" = "aliyuncs" && sed -i "s@mirrors.ustc.edu.cn@mirrors.cloud.aliyuncs.com@g" /etc/apt/sources.list.d/debian.sources - test "$MIRROR" = "tencentyun" && sed -i "s@mirrors.ustc.edu.cn@mirrors.tencentyun.com@g" /etc/apt/sources.list.d/debian.sources - test "$MIRROR" = "huaweicloud" && sed -i "s@mirrors.ustc.edu.cn@repo.huaweicloud.com@g" /etc/apt/sources.list.d/debian.sources - else +if test -n "$MIRROR"; then + { + OS_ID=$(cat /etc/os-release | grep '^ID=' | awk -F '=' '{print $2}') + VERSION_ID=$(cat /etc/os-release | grep '^VERSION_ID=' | awk -F '=' '{print $2}' | sed "s/\"//g") + case $OS_ID in + debian) + case $VERSION_ID in + 11 | 12) + # 容器内和容器外 镜像源配置不一样 + if [ -f /.dockerenv ] && [ "$VERSION_ID" = 12 ]; then + test -f /etc/apt/sources.list.d/debian.sources.save || cp -f /etc/apt/sources.list.d/debian.sources /etc/apt/sources.list.d/debian.sources.save + sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list.d/debian.sources + sed -i 's/security.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list.d/debian.sources + test "$MIRROR" = "tuna" && sed -i "s@mirrors.ustc.edu.cn@mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list.d/debian.sources + # 云服务内网镜像源 + test "$MIRROR" = "aliyuncs" && sed -i "s@mirrors.ustc.edu.cn@mirrors.cloud.aliyuncs.com@g" /etc/apt/sources.list.d/debian.sources + test "$MIRROR" = "tencentyun" && sed -i "s@mirrors.ustc.edu.cn@mirrors.tencentyun.com@g" /etc/apt/sources.list.d/debian.sources + test "$MIRROR" = "huaweicloud" && sed -i "s@mirrors.ustc.edu.cn@repo.huaweicloud.com@g" /etc/apt/sources.list.d/debian.sources + else + test -f /etc/apt/sources.list.save || cp /etc/apt/sources.list /etc/apt/sources.list.save + sed -i "s@deb.debian.org@mirrors.ustc.edu.cn@g" /etc/apt/sources.list + sed -i "s@security.debian.org@mirrors.ustc.edu.cn@g" /etc/apt/sources.list + test "$MIRROR" = "tuna" && sed -i "s@mirrors.ustc.edu.cn@mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list + test "$MIRROR" = "aliyuncs" && sed -i "s@mirrors.ustc.edu.cn@mirrors.cloud.aliyuncs.com@g" /etc/apt/sources.list + test "$MIRROR" = "tencentyun" && sed -i "s@mirrors.ustc.edu.cn@mirrors.tencentyun.com@g" /etc/apt/sources.list + test "$MIRROR" = "huaweicloud" && sed -i "s@mirrors.ustc.edu.cn@repo.huaweicloud.com@g" /etc/apt/sources.list + fi + ;; + *) + echo 'no match debian OS version' . $VERSION_ID + ;; + esac + ;; + ubuntu) + case $VERSION_ID in + 20.04 | 22.04 | 22.10 | 23.04 | 23.10) test -f /etc/apt/sources.list.save || cp /etc/apt/sources.list /etc/apt/sources.list.save - sed -i "s@deb.debian.org@mirrors.ustc.edu.cn@g" /etc/apt/sources.list - sed -i "s@security.debian.org@mirrors.ustc.edu.cn@g" /etc/apt/sources.list + sed -i "s@security.ubuntu.com@mirrors.ustc.edu.cn@g" /etc/apt/sources.list + sed -i "s@archive.ubuntu.com@mirrors.ustc.edu.cn@g" /etc/apt/sources.list test "$MIRROR" = "tuna" && sed -i "s@mirrors.ustc.edu.cn@mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list test "$MIRROR" = "aliyuncs" && sed -i "s@mirrors.ustc.edu.cn@mirrors.cloud.aliyuncs.com@g" /etc/apt/sources.list test "$MIRROR" = "tencentyun" && sed -i "s@mirrors.ustc.edu.cn@mirrors.tencentyun.com@g" /etc/apt/sources.list test "$MIRROR" = "huaweicloud" && sed -i "s@mirrors.ustc.edu.cn@repo.huaweicloud.com@g" /etc/apt/sources.list - fi - ;; - *) - echo 'no match debian OS version' . $VERSION_ID - ;; - esac - ;; - ubuntu) - case $VERSION_ID in - 20.04 | 22.04 | 22.10 | 23.04 | 23.10) - test -f /etc/apt/sources.list.save || cp /etc/apt/sources.list /etc/apt/sources.list.save - sed -i "s@security.ubuntu.com@mirrors.ustc.edu.cn@g" /etc/apt/sources.list - sed -i "s@archive.ubuntu.com@mirrors.ustc.edu.cn@g" /etc/apt/sources.list - test "$MIRROR" = "tuna" && sed -i "s@mirrors.ustc.edu.cn@mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list - test "$MIRROR" = "aliyuncs" && sed -i "s@mirrors.ustc.edu.cn@mirrors.cloud.aliyuncs.com@g" /etc/apt/sources.list - test "$MIRROR" = "tencentyun" && sed -i "s@mirrors.ustc.edu.cn@mirrors.tencentyun.com@g" /etc/apt/sources.list - test "$MIRROR" = "huaweicloud" && sed -i "s@mirrors.ustc.edu.cn@repo.huaweicloud.com@g" /etc/apt/sources.list + ;; + 24.04) + test -f /etc/apt/sources.list.d/ubuntu.sources.save || cp /etc/apt/sources.list.d/ubuntu.sources /etc/apt/sources.list.d/ubuntu.sources.save + sed -i "s@security.ubuntu.com@mirrors.ustc.edu.cn@g" /etc/apt/sources.list.d/ubuntu.sources + sed -i "s@archive.ubuntu.com@mirrors.ustc.edu.cn@g" /etc/apt/sources.list.d/ubuntu.sources + ;; + *) + echo 'no match ubuntu OS version' . $VERSION_ID + ;; + esac ;; *) - echo 'no match ubuntu OS version' . $VERSION_ID + echo 'NO SUPPORT LINUX OS' + exit 0 ;; esac - ;; - *) - echo 'NO SUPPORT LINUX OS' - exit 0 - ;; - esac -} + } fi test -f /etc/apt/apt.conf.d/proxy.conf && rm -rf /etc/apt/apt.conf.d/proxy.conf - -export LANG="en_US.UTF-8" -export LC_ALL="en_US.UTF-8" -export LC_CTYPE="en_US.UTF-8" export DEBIAN_FRONTEND=noninteractive export TZ="UTC" export TZ="Etc/UTC" -ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone - +ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ >/etc/timezone apt update -y +apt install -y locales +locale-gen en_US.UTF-8 +export LANGUAGE="en_US.UTF-8" +export LC_ALL="en_US.UTF-8" +export LC_CTYPE="en_US.UTF-8" +export LANG="en_US.UTF-8" + apt install -y git curl wget ca-certificates apt install -y xz-utils autoconf automake clang-tools clang lld libtool cmake bison re2c gettext coreutils lzip zip unzip apt install -y pkg-config bzip2 flex p7zip apt install -y gcc g++ musl-tools libtool-bin autopoint - # apt install build-essential linux-headers-$(uname -r) -apt install -y python3 python3-pip ninja-build diffutils +apt install -y python3 python3-pip ninja-build diffutils apt install -y yasm nasm apt install -y meson apt install -y netcat-openbsd @@ -120,5 +124,5 @@ aliyuncs | tencentyun | huaweicloud) test "$MIRROR" = "aliyuncs" && pip3 config set global.index-url https://mirrors.cloud.aliyuncs.com/pypi/simple/ test "$MIRROR" = "tencentyun" && pip3 config set global.index-url https://mirrors.tencentyun.com/pypi/simple/ test "$MIRROR" = "huaweicloud" && pip3 config set global.index-url https://repo.huaweicloud.com/pypi/simple/ + ;; esac - diff --git a/sapi/quickstart/linux/extra/alpine-php-init.sh b/sapi/quickstart/linux/extra/alpine-php-init.sh index bac0fa6b94..c00d49f09b 100644 --- a/sapi/quickstart/linux/extra/alpine-php-init.sh +++ b/sapi/quickstart/linux/extra/alpine-php-init.sh @@ -1,2 +1,14 @@ +apk add php82-cli php82-dev +apk add php82-iconv php82-mbstring php82-phar php82-openssl +apk add php82-posix php82-tokenizer php82-intl +apk add php82-dom php82-xmlwriter php82-xml php82-simplexml +apk add php82-pdo php82-sockets php82-curl php82-mysqlnd php82-pgsql php82-sqlite3 +apk add php82-redis php82-mongodb -apk add php-cli php-iconv php-mbstring php-phar php-openssl php-posix php-curl php-tokenizer php-dom php-xmlwriter php-xml php-simplexml +php82 -v +php82 --ini +php82 --ini | grep ".ini files" + +ln -sf /usr/bin/php82 /usr/bin/php +ln -sf /usr/bin/phpize82 /usr/bin/phpize +ln -sf /usr/bin/php-config82 /usr/bin/php-config diff --git a/sapi/quickstart/linux/extra/debian-php-init.sh b/sapi/quickstart/linux/extra/debian-php-init.sh index 9ec4ce99c7..463b2dd8dd 100644 --- a/sapi/quickstart/linux/extra/debian-php-init.sh +++ b/sapi/quickstart/linux/extra/debian-php-init.sh @@ -1,4 +1,6 @@ - -apt install -y php-cli php-pear php-dev php-curl php-intl - -# apt install -y php-mysqlnd php-pgsql php-sqlite3 php-redis php-mongodb +export TZ="Etc/UTC" +ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ >/etc/timezone +apt update -y +apt install -y php-cli php-pear php-dev php-curl php-intl +apt install -y php-mbstring php-tokenizer php-xml +apt install -y php-mysqlnd php-pgsql php-sqlite3 php-redis php-mongodb diff --git a/sapi/quickstart/linux/install-docker.sh b/sapi/quickstart/linux/install-docker.sh index 46c4b77ce7..ebdcf2a8ef 100644 --- a/sapi/quickstart/linux/install-docker.sh +++ b/sapi/quickstart/linux/install-docker.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -ex __DIR__=$( @@ -15,18 +15,6 @@ mkdir -p ${__PROJECT__}/var cd ${__PROJECT__}/var -# https://github.com/docker/docker-install.git - - -# test -f get-docker.sh || curl -fsSL https://get.docker.com -o get-docker.sh -test -f get-docker.sh || curl -fsSL https://github.com/docker/docker-install/blob/master/install.sh?raw=true -o get-docker.sh - -if [ -n "$http_proxy" ] || [ -n "$https_proxy" ] || [ -n "$HTTP_PROXY" ] || [ -n "$HTTPS_PROXY" ]; then - echo 'Please delete proxy settings !' - echo 'Execute this script again !' - exit 0 -fi - MIRROR='' while [ $# -gt 0 ]; do case "$1" in @@ -40,8 +28,29 @@ while [ $# -gt 0 ]; do shift $(($# > 0 ? 1 : 0)) done + +# https://github.com/docker/docker-install.git +# test -f get-docker.sh || curl -fsSL https://get.docker.com -o get-docker.sh + +case "$MIRROR" in +china | ustc | tuna) + test -f get-docker.sh || curl -fsSL https://gitee.com/jingjingxyk/docker-install/raw/master/install.sh -o get-docker.sh + ;; +*) + test -f get-docker.sh || curl -fsSL https://github.com/docker/docker-install/blob/master/install.sh?raw=true -o get-docker.sh + ;; +esac + + +if [ -n "$http_proxy" ] || [ -n "$https_proxy" ] || [ -n "$HTTP_PROXY" ] || [ -n "$HTTPS_PROXY" ]; then + echo 'Please delete proxy settings !' + echo 'Execute this script again !' + exit 0 +fi + + case "$MIRROR" in -china|ustc) +china | ustc) sed -i "s@https://mirrors.aliyun.com/docker-ce@https://mirrors.ustc.edu.cn/docker-ce@g" get-docker.sh sed -i "s@Aliyun)@china)@g" get-docker.sh sh get-docker.sh --mirror china diff --git a/sapi/quickstart/linux/run-alpine-container-full.sh b/sapi/quickstart/linux/run-alpine-container-full.sh index 6d7b41eee0..d9042de1f4 100644 --- a/sapi/quickstart/linux/run-alpine-container-full.sh +++ b/sapi/quickstart/linux/run-alpine-container-full.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -exu __DIR__=$( @@ -40,7 +40,7 @@ while [ $# -gt 0 ]; do --mirror) MIRROR="$2" ;; - --dev-shm) + --dev-shm) #使用 /dev/shm 目录加快构建速度 DEV_SHM=1 ;; esac @@ -49,7 +49,7 @@ done case $ARCH in 'x86_64') - TAG=all-dependencies-alpine-3.17-php8-v1.0.0-x86_64-20231113T100559Z + TAG=all-dependencies-alpine-3.18-php8-v1.0.0-x86_64-20240715T132512Z IMAGE=docker.io/jingjingxyk/build-swoole-cli:${TAG} if [ "$MIRROR" = 'china' ] ; then IMAGE=registry.cn-beijing.aliyuncs.com/jingjingxyk-public/app:${TAG} @@ -74,8 +74,8 @@ cd ${__DIR__} if [ $DEV_SHM -eq 1 ] ; then mkdir -p /dev/shm/swoole-cli/thirdparty/ mkdir -p /dev/shm/swoole-cli/ext/ - docker run --rm --name swoole-cli-alpine-dev -d -v ${__PROJECT__}:/work -v /dev/shm/swoole-cli/thirdparty/:/work/thirdparty/ -v /dev/shm/swoole-cli/ext/:/work/ext/ -w /work $IMAGE tail -f /dev/null + docker run --rm --name swoole-cli-alpine-dev -d -v ${__PROJECT__}:/work -v /dev/shm/swoole-cli/thirdparty/:/work/thirdparty/ -v /dev/shm/swoole-cli/ext/:/work/ext/ -w /work --init $IMAGE tail -f /dev/null else - docker run --rm --name swoole-cli-alpine-dev -d -v ${__PROJECT__}:/work -w /work $IMAGE tail -f /dev/null + docker run --rm --name swoole-cli-alpine-dev -d -v ${__PROJECT__}:/work -w /work --init $IMAGE tail -f /dev/null fi diff --git a/sapi/scripts/download-php-src-archive.php b/sapi/scripts/download-php-src-archive.php index 1aed3ac924..0644a48a67 100644 --- a/sapi/scripts/download-php-src-archive.php +++ b/sapi/scripts/download-php-src-archive.php @@ -2,8 +2,8 @@ $poject_dir = realpath(__DIR__ . '/../../'); $php_version_tag = trim(file_get_contents($poject_dir . '/sapi/PHP-VERSION.conf')); -$php_source_folder = $poject_dir . "/pool/php-src/php-{$php_version_tag}"; -$php_archive_file = $poject_dir . "/pool/php-tar/php-{$php_version_tag}.tar.gz"; +$php_source_folder = $poject_dir . "/var/php-{$php_version_tag}"; +$php_archive_file = $poject_dir . "/pool/php/php-{$php_version_tag}.tar.gz"; $download_dir = dirname($php_archive_file); # 下载 PHP 源码 diff --git a/sapi/src/Library.php b/sapi/src/Library.php index 8339fba5b8..a91b8ee74b 100644 --- a/sapi/src/Library.php +++ b/sapi/src/Library.php @@ -22,7 +22,7 @@ class Library extends Project public string $prefix = '/usr'; - public string $binPath = ''; + public string|array $binPath = ''; public bool $cleanBuildDirectory = false; @@ -117,7 +117,7 @@ public function withPkgName(string $pkgName): static return $this; } - public function withBinPath(string $path): static + public function withBinPath(string|array $path): static { $this->binPath = $path; return $this; diff --git a/sapi/src/Preprocessor.php b/sapi/src/Preprocessor.php index c7d9320975..955b831743 100644 --- a/sapi/src/Preprocessor.php +++ b/sapi/src/Preprocessor.php @@ -84,46 +84,7 @@ class Preprocessor * Extensions enabled by default * @var array|string[] */ - protected array $extEnabled = [ - 'opcache', - 'curl', - 'iconv', - 'bz2', - 'bcmath', - 'pcntl', - 'filter', - 'session', - 'tokenizer', - 'mbstring', - 'ctype', - 'zlib', - 'zip', - 'posix', - 'sockets', - 'pdo', - 'sqlite3', - 'phar', - 'mysqlnd', - 'mysqli', - 'intl', - 'fileinfo', - 'pdo_mysql', - //'pdo_sqlite', - 'soap', - 'xsl', - 'gmp', - 'exif', - 'sodium', - 'openssl', - 'readline', - 'xml', - 'gd', - 'redis', - 'swoole', - 'yaml', - 'imagick', - 'mongodb', - ]; + protected array $extEnabled; protected array $endCallbacks = []; protected array $extCallbacks = []; @@ -135,6 +96,7 @@ class Preprocessor protected function __construct() { $this->setOsType($this->getRealOsType()); + $this->extEnabled = require __DIR__ . '/builder/enabled_extensions.php'; } public function setLinker(string $ld): static @@ -193,17 +155,6 @@ public function getBaseImageTag(): string return 'base' . '-' . $arch; } } - - public function getBaseImageDockerFile(): string - { - $arch = $this->getSystemArch(); - if ($arch == 'x64') { - return 'Dockerfile'; - } else { - return 'Dockerfile' . '-' . $arch; - } - } - public function setPhpSrcDir(string $phpSrcDir) { $this->phpSrcDir = $phpSrcDir; @@ -408,7 +359,11 @@ public function addLibrary(Library $lib): void $this->pkgConfigPaths[] = $lib->pkgConfig; } if (!empty($lib->binPath)) { - $this->binPaths[] = $lib->binPath; + if (is_array($lib->binPath)) { + $this->binPaths = array_merge($this->binPaths, $lib->binPath); + } else { + $this->binPaths[] = $lib->binPath; + } } if (empty($lib->license)) { throw new Exception("require license"); diff --git a/sapi/src/builder/enabled_extensions.php b/sapi/src/builder/enabled_extensions.php new file mode 100644 index 0000000000..fdce760596 --- /dev/null +++ b/sapi/src/builder/enabled_extensions.php @@ -0,0 +1,40 @@ +addExtension( + (new Extension('gettext')) + ->withHomePage('https://www.php.net/gettext') + ->withOptions('--with-gettext=' . GETTEXT_PREFIX) + ->withDependentLibraries('gettext') + ); +}; diff --git a/sapi/src/builder/extension/imagick.php b/sapi/src/builder/extension/imagick.php index 47d60aef0d..e8a850c865 100644 --- a/sapi/src/builder/extension/imagick.php +++ b/sapi/src/builder/extension/imagick.php @@ -16,3 +16,5 @@ ->withDependentLibraries('imagemagick') ); }; + +# 构建 imagick 扩展时 会自动下载 https://github.com/nikic/PHP-Parser 源码 diff --git a/sapi/src/builder/extension/mongodb.php b/sapi/src/builder/extension/mongodb.php index 451d376f21..54f04ba37b 100644 --- a/sapi/src/builder/extension/mongodb.php +++ b/sapi/src/builder/extension/mongodb.php @@ -25,15 +25,14 @@ $options .= ' --with-mongodb-system-libs=no '; $options .= ' --with-mongodb-ssl=openssl '; $options .= ' --with-mongodb-sasl=no '; - $options .= ' --with-mongodb-icu=yes '; $ext = new Extension('mongodb'); $ext->withHomePage('https://www.php.net/mongodb') ->withHomePage('https://www.mongodb.com/docs/drivers/php/') ->withOptions($options) - ->withPeclVersion('1.14.2') - ->withFileHash('md5', 'b6de193d467f77d8fd7b27845c19e476') + ->withPeclVersion('1.19.4') + ->withFileHash('md5', '91f96b24df7ed5651731671f55cb68a1') ; $depends = ['icu', 'openssl', 'zlib', 'libzstd']; diff --git a/sapi/src/builder/extension/uuid.php b/sapi/src/builder/extension/uuid.php index 0e23cfa538..de1896bb29 100644 --- a/sapi/src/builder/extension/uuid.php +++ b/sapi/src/builder/extension/uuid.php @@ -5,8 +5,14 @@ use SwooleCli\Extension; return function (Preprocessor $p) { - $depends = ['libuuid', 'libintl']; - $options = '--with-uuid=' . LIBUUID_PREFIX; + + // uuid 扩展 依赖 libuuid 库 libintl 库 + + // libuuid 库 存在于 Util-linux (util_linux.php) + // libintl 库 存在于 gettext (gettext.php) + + $depends = ['util_linux']; + $options = '--with-uuid=' . UTIL_LINUX_PREFIX; $ext = (new Extension('uuid')) ->withLicense('https://github.com/php/pecl-networking-uuid#LGPL-2.1-1-ov-file', Extension::LICENSE_LGPL) diff --git a/sapi/src/builder/library/libintl.php b/sapi/src/builder/library/gettext.php similarity index 81% rename from sapi/src/builder/library/libintl.php rename to sapi/src/builder/library/gettext.php index 3e5f50d9d2..cbd2e5e728 100644 --- a/sapi/src/builder/library/libintl.php +++ b/sapi/src/builder/library/gettext.php @@ -5,28 +5,28 @@ return function (Preprocessor $p) { - //(gettext库包含libintl 、coreutils库包含libunistring + // gettext 包含 libintl 库 - $libintl_prefix = LIBINTL_PREFIX; + $gettext_prefix = GETTEXT_PREFIX; $libunistring_prefix = LIBUNISTRING_PREFIX; $iconv_prefix = ICONV_PREFIX; $libxml2_prefix = LIBXML2_PREFIX; $ncurses_prefix = NCURSES_PREFIX; $p->addLibrary( - (new Library('libintl')) + (new Library('gettext')) ->withHomePage('https://www.gnu.org/software/gettext/') ->withLicense('https://www.gnu.org/licenses/licenses.html', Library::LICENSE_GPL) ->withManual('https://www.gnu.org/software/gettext/') //->withUrl('https://ftp.gnu.org/gnu/gettext/gettext-0.22.tar.xz') ->withUrl('https://ftpmirror.gnu.org/gnu/gettext/gettext-0.22.tar.xz') - ->withPrefix($libintl_prefix) + ->withPrefix($gettext_prefix) ->withConfigure( <<withDependentLibraries('libunistring', 'libiconv', 'ncurses', 'libxml2') ); - $p->withVariable('CPPFLAGS', '$CPPFLAGS -I' . $libintl_prefix . '/include'); - $p->withVariable('LDFLAGS', '$LDFLAGS -L' . $libintl_prefix . '/lib'); + $p->withVariable('CPPFLAGS', '$CPPFLAGS -I' . $gettext_prefix . '/include'); + $p->withVariable('LDFLAGS', '$LDFLAGS -L' . $gettext_prefix . '/lib'); $p->withVariable('LIBS', '$LIBS -lintl '); }; diff --git a/sapi/src/builder/library/icu.php b/sapi/src/builder/library/icu.php index e81247b868..9a07927ed6 100644 --- a/sapi/src/builder/library/icu.php +++ b/sapi/src/builder/library/icu.php @@ -36,7 +36,7 @@ ->withPkgName('icu-i18n') ->withPkgName('icu-io') ->withPkgName('icu-uc') - ->withBinPath($icu_prefix . '/bin/:' . $icu_prefix . "/sbin") + ->withBinPath([$icu_prefix . '/bin', $icu_prefix . '/sbin',]) ); $libs = $p->isMacos() ? '-lc++' : ' -lstdc++ '; diff --git a/sapi/src/builder/library/libuuid.php b/sapi/src/builder/library/util_linux.php similarity index 51% rename from sapi/src/builder/library/libuuid.php rename to sapi/src/builder/library/util_linux.php index ab138ee81c..1155397a4f 100644 --- a/sapi/src/builder/library/libuuid.php +++ b/sapi/src/builder/library/util_linux.php @@ -4,33 +4,50 @@ use SwooleCli\Preprocessor; return function (Preprocessor $p) { - $libuuid_prefix = LIBUUID_PREFIX; - $lib = new Library('libuuid'); + $util_linux_prefix = UTIL_LINUX_PREFIX; + $libiconv_prefix = ICONV_PREFIX; + $gettext_prefix = GETTEXT_PREFIX; + + $lib = new Library('util_linux'); $lib->withHomePage('http://en.wikipedia.org/wiki/Util-linux') ->withLicense('https://github.com/util-linux/util-linux/blob/master/COPYING', Library::LICENSE_GPL) ->withManual('http://en.wikipedia.org/wiki/Util-linux') ->withManual('http://en.wikipedia.org/wiki/Util-linux/util-linux/tree/v2.39.1/Documentation') ->withUrl('https://github.com/util-linux/util-linux/archive/refs/tags/v2.39.3.tar.gz') ->withFile('util-linux-v2.39.3.tar.gz') - ->withPrefix($libuuid_prefix) + ->withPrefix($util_linux_prefix) ->withConfigure( <<withPkgName('uuid') - ->withBinPath($libuuid_prefix . '/bin/:' . $libuuid_prefix . '/sbin/'); + ->withBinPath([$util_linux_prefix . '/bin', $util_linux_prefix . '/sbin',]) + ->withDependentLibraries('libiconv', 'gettext'); $p->addLibrary($lib); }; diff --git a/sapi/src/constants.php b/sapi/src/constants.php index 77052b7dfd..91f3465268 100644 --- a/sapi/src/constants.php +++ b/sapi/src/constants.php @@ -51,8 +51,8 @@ define("PGSQL_PREFIX", $p->getGlobalPrefix() . '/pgsql'); define("UNIX_ODBC_PREFIX", $p->getGlobalPrefix() . '/unix_odbc'); -define("LIBUUID_PREFIX", $p->getGlobalPrefix() . '/libuuid'); -define("LIBINTL_PREFIX", $p->getGlobalPrefix() . '/libintl'); +define("UTIL_LINUX_PREFIX", $p->getGlobalPrefix() . '/util_linux'); +define("GETTEXT_PREFIX", $p->getGlobalPrefix() . '/gettext'); define("LIBUNISTRING_PREFIX", $p->getGlobalPrefix() . '/libunistring'); define("LIBURING_PREFIX", $p->getGlobalPrefix() . '/liburing'); diff --git a/sapi/src/template/make.php b/sapi/src/template/make.php index ff0ade1651..4edb18986e 100755 --- a/sapi/src/template/make.php +++ b/sapi/src/template/make.php @@ -22,9 +22,9 @@ export PATH=binPaths) . PHP_EOL ?> OPTIONS="--disable-all \ ---enable-shared=no \ ---enable-static=yes \ ---enable-zts \ + --enable-shared=no \ + --enable-static=yes \ + --enable-zts \ extensionList as $item) : ?> options?> \ @@ -216,6 +216,8 @@ ./configure --help export_variables + export LDFLAGS="$LDFLAGS extraLdflags ?>" + export EXTRA_CFLAGS='extraCflags ?>' echo $LDFLAGS > getWorkDir() ?>/ldflags.log echo $CPPFLAGS > getWorkDir() ?>/cppflags.log echo $LIBS > getWorkDir() ?>/libs.log @@ -324,10 +326,20 @@ ;; esac fi + PLATFORM='' + ARCH=$(uname -m) + case $ARCH in + 'x86_64') + PLATFORM='linux/amd64' + ;; + 'aarch64') + PLATFORM='linux/arm64' + ;; + esac cd ${__PROJECT_DIR__}/sapi/docker echo "MIRROR=${MIRROR}" echo "BASE_IMAGE=${CONTAINER_BASE_IMAGE}" - docker build --no-cache -t :getBaseImageTag() ?> -f Dockerfile . --build-arg="MIRROR=${MIRROR}" --build-arg="BASE_IMAGE=${CONTAINER_BASE_IMAGE}" + docker build --no-cache -t :getBaseImageTag() ?> -f Dockerfile . --build-arg="MIRROR=${MIRROR}" --progress=plain --platform=${PLATFORM} --build-arg="BASE_IMAGE=${CONTAINER_BASE_IMAGE}" exit 0 elif [ "$1" = "docker-bash" ] ;then container=$(docker ps -a -f name= | tail -n +2 2> /dev/null) diff --git a/setup-php-runtime.sh b/setup-php-runtime.sh index 5f0f8f929d..05d4a882ee 100644 --- a/setup-php-runtime.sh +++ b/setup-php-runtime.sh @@ -117,7 +117,8 @@ if [ $OS = 'windows' ]; then else test -f ${APP_RUNTIME}.tar.xz || curl -LSo ${APP_RUNTIME}.tar.xz ${APP_DOWNLOAD_URL} test -f ${APP_RUNTIME}.tar || xz -d -k ${APP_RUNTIME}.tar.xz - test -f swoole-cli || tar -xvf ${APP_RUNTIME}.tar + test -f swoole-cli && rm -f swoole-cli + tar -xvf ${APP_RUNTIME}.tar chmod a+x swoole-cli cp -f ${__PROJECT__}/var/runtime/swoole-cli ${__PROJECT__}/bin/runtime/php fi @@ -161,4 +162,8 @@ echo " alias php='php -d curl.cainfo=${__PROJECT__}/bin/runtime/cacert.pem -d op echo " OR " echo " alias php='php -c ${__PROJECT__}/bin/runtime/php.ini' " echo " " +test $OS="macos" && echo "sudo xattr -d com.apple.quarantine ${__PROJECT__}/bin/runtime/php" +echo " " export PATH="${__PROJECT__}/bin/runtime:$PATH" +php -v + diff --git a/setup-swoole-cli-runtime.sh b/setup-swoole-cli-runtime.sh index 399300c251..f11aa468c8 100644 --- a/setup-swoole-cli-runtime.sh +++ b/setup-swoole-cli-runtime.sh @@ -118,7 +118,8 @@ if [ $OS = 'windows' ]; then else test -f ${APP_RUNTIME}.tar.xz || curl -LSo ${APP_RUNTIME}.tar.xz ${APP_DOWNLOAD_URL} test -f ${APP_RUNTIME}.tar || xz -d -k ${APP_RUNTIME}.tar.xz - test -f swoole-cli || tar -xvf ${APP_RUNTIME}.tar + test -f swoole-cli && rm -f swoole-cli + tar -xvf ${APP_RUNTIME}.tar chmod a+x swoole-cli cp -f ${__PROJECT__}/var/runtime/swoole-cli ${__PROJECT__}/bin/runtime/swoole-cli fi @@ -145,6 +146,8 @@ opcache.enable_cli=On opcache.jit=1225 opcache.jit_buffer_size=128M +; jit 更多配置参考 https://mp.weixin.qq.com/s/Tm-6XVGQSlz0vDENLB3ylA + expose_php=Off EOF @@ -202,4 +205,8 @@ echo " alias swoole-cli='swoole-cli -d curl.cainfo=${__PROJECT__}/bin/runtime/ca echo " OR " echo " alias swoole-cli='swoole-cli -c ${__PROJECT__}/bin/runtime/php.ini' " echo " " +test $OS="macos" && echo "sudo xattr -d com.apple.quarantine ${__PROJECT__}/bin/runtime/php" +echo " " echo " SWOOLE-CLI VERSION ${APP_VERSION}" +export PATH="${__PROJECT__}/bin/runtime:$PATH" +swoole-cli -v diff --git a/sync-source-code.php b/sync-source-code.php index 43b92091f0..c1419394e0 100644 --- a/sync-source-code.php +++ b/sync-source-code.php @@ -142,7 +142,6 @@ # TSRM cp -rf $SRC/TSRM/ ./TSRM - cp -rf $SRC/TSRM/TSRM.h main/TSRM.h cp -f $SRC/configure.ac ./configure.ac cp -f $SRC/buildconf ./buildconf @@ -156,7 +155,7 @@ test -f main/main.c.backup && rm -f main/main.c.backup test -f ext/opcache/config.m4.backup && rm -f ext/opcache/config.m4.backup - exit 0 + # fpm cp -rf $SRC/sapi/fpm/fpm ./sapi/cli/ @@ -164,7 +163,6 @@ sed -i.backup 's/{'-', 0, NULL}/{'P', 0, "fpm"},\n {'-', 0, NULL}/g' ./sapi/cli/fpm/fpm_main.c - # exit 0 # cli cp -rf $SRC/sapi/cli/ps_title.c ./sapi/cli