From c2327915dffd9572f3efd281d4a1285f1e2c734c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=BD=E5=90=A7=EF=BC=8C=E4=BD=A0=E6=83=B3=E8=AF=B4?= =?UTF-8?q?=E5=95=A5?= Date: Mon, 10 Jun 2024 08:28:36 +0800 Subject: [PATCH 1/6] upgrade setup-php-runtime.sh download-box build-docs (#650) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * upgrade setup-php-runtime.sh download-bx * 更新构建文档 * update README.md * update README.md * update README.md * update build doc * update setup-php-runtime.sh * update setup-php-runtime.sh * update build-release-example.sh * update README.md --- README.md | 20 ++++-- build-release-example.sh | 16 ++++- docs/Cygwin.md | 46 +++++++++----- docs/linux.md | 62 ++++++++++++++++++- docs/macOS.md | 36 ++++++++++- .../download-box-get-archive-from-server.sh | 7 +-- sapi/quickstart/windows/README.md | 4 +- setup-php-runtime.sh | 23 ++++--- 8 files changed, 171 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index 92f1cb3cba..d8c83bfa54 100644 --- a/README.md +++ b/README.md @@ -16,20 +16,28 @@ ## 相关文章 -- [Swoole-Cli 介绍](https://zhuanlan.zhihu.com/p/581695339) -- [Swoole-Cli 使用说明](https://wenda.swoole.com/detail/108876) -- [Swoole-Cli v5.0.0 版本新特性预览之新的运行模式](https://zhuanlan.zhihu.com/p/459983471) +- [Swoole-Cli 介绍、使用说明](https://wenda.swoole.com/detail/108876) - [Swoole-Cli 5.0.1 使用说明](https://wenda.swoole.com/detail/108876) -- [Swoole-Cli v5.0.1 PHP 的二进制发行版](https://zhuanlan.zhihu.com/p/581695339) -- [Swoole-Cli v5.0.2 增加 opcache/readline 扩展,强化 Cli-Server](https://zhuanlan.zhihu.com/p/610014616) +- [Swoole-Cli v5.0.0 版本新特性预览之新的运行模式](https://wenda.swoole.com/detail/108706) +- [Swoole-Cli v5.0.2 增加 opcache/readline 扩展,强化 Cli-Server](https://wenda.swoole.com/detail/108931) - [Swoole-Cli 已提供 Windows 平台 (cygwin64)支持](https://wenda.swoole.com/detail/108743) - [Swoole 5.1 增加更多数据库协程客户端支持](https://wenda.swoole.com/detail/109023) +- [Swoole v6 要来了!即将增加多线程支持](https://segmentfault.com/a/1190000044737434) +- [Swoole v6 开发计划 - 支持多线程运行模式](https://github.com/swoole/rfc/issues/85) +- [phpy:连接 PHP 与 Python 互调用库,为 PHP 引入 Python 生态,PHP 也可以写 AI 了](https://wenda.swoole.com/detail/109176) + +### 相关文章 知乎 + +- [Swoole-Cli v5.0.1 PHP 的二进制发行版](https://zhuanlan.zhihu.com/p/581695339) +- [Swoole-Cli v5.0.2 增加 opcache/readline 扩展,强化 Cli-Server](https://zhuanlan.zhihu.com/p/610014616) +- [Swoole v6 即将增加多线程支持](https://zhuanlan.zhihu.com/p/688462525) +- [phpy:连接 PHP 与 Python 互调用库,为 PHP 引入 Python 生态,PHP 也可以写 AI 了](https://zhuanlan.zhihu.com/p/670373512) ## 下载`swoole-cli`发行版 - [https://www.swoole.com/download](https://www.swoole.com/download) (recommend) -- [https://github.com/swoole/swoole-src/releases](https://github.com/swoole/swoole-src/releases) - [https://github.com/swoole/swoole-cli/releases](https://github.com/swoole/swoole-cli/releases) +- [https://github.com/swoole/swoole-src/releases](https://github.com/swoole/swoole-src/releases) ## `swoole-cli`构建文档 diff --git a/build-release-example.sh b/build-release-example.sh index 4ba94649b1..59f1f1e043 100644 --- a/build-release-example.sh +++ b/build-release-example.sh @@ -58,11 +58,14 @@ while [ $# -gt 0 ]; do export HTTP_PROXY="$2" export HTTPS_PROXY="$2" NO_PROXY="127.0.0.0/8,10.0.0.0/8,100.64.0.0/10,172.16.0.0/12,192.168.0.0/16" - NO_PROXY="${NO_PROXY},127.0.0.1,localhost" + NO_PROXY="${NO_PROXY},::1/128,fe80::/10,fd00::/8,ff00::/8" + NO_PROXY="${NO_PROXY},localhost" NO_PROXY="${NO_PROXY},.aliyuncs.com,.aliyun.com" NO_PROXY="${NO_PROXY},.tsinghua.edu.cn,.ustc.edu.cn" NO_PROXY="${NO_PROXY},.tencent.com" - NO_PROXY="${NO_PROXY},.sourceforge.net" + NO_PROXY="${NO_PROXY},ftpmirror.gnu.org" + NO_PROXY="${NO_PROXY},gitee.com,gitcode.com" + NO_PROXY="${NO_PROXY},.myqcloud.com,.swoole.com" export NO_PROXY="${NO_PROXY},.npmmirror.com" ;; --*) @@ -72,6 +75,15 @@ while [ $# -gt 0 ]; do shift $(($# > 0 ? 1 : 0)) done +if [ "$OS" = 'linux' ] ; then + if [ ! "$BASH_VERSION" ] ; then + echo "Please use bash to run this script ($0) " 1>&2 + echo "fix : " 1>&2 + echo "apk add bash' or sh sapi/quickstart/linux/alpine-init.sh " 1>&2 + exit 1 + fi +fi + # 构建环境依赖检查 CMDS_NUMS=0 CMDS=("flex" "pkg-config" "cmake" "re2c" "bison" "curl" "automake" "libtool" "clang" "xz" "zip" "unzip" "autoconf") diff --git a/docs/Cygwin.md b/docs/Cygwin.md index 316f725102..fccdf87601 100755 --- a/docs/Cygwin.md +++ b/docs/Cygwin.md @@ -14,27 +14,19 @@ ## 安装cygwin 和 cygwin 依赖项 -> 打开 windows 控制台,并找到 setup-x86_64.exe 所在目录, 执行如下命令 +> 打开 windows 控制台,并找到 setup-x86_64.exe 所在目录, 将 setup-x86_64.exe 复制到 `sapi\quickstart\windows\` 目录 +> 执行如下命令 ```bash -# 安装 cygwin -setup-x86_64.exe --site https://mirrors.ustc.edu.cn/cygwin/ - -# 安装 cygwin 依赖项 -setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site https://mirrors.ustc.edu.cn/cygwin/ --packages make,git,curl,wget,tar,libtool,bison,gcc-g++,autoconf,automake,openssl,libpcre2-devel,libssl-devel,libcurl-devel,libxml2-devel,libxslt-devel,libgmp-devel,ImageMagick,libpng-devel,libjpeg-devel,libfreetype-devel,libwebp-devel,libsqlite3-devel,zlib-devel,libbz2-devel,liblz4-devel,liblzma-devel,libzip-devel,libicu-devel,libonig-devel,libcares-devel,libsodium-devel,libyaml-devel,libMagick-devel,libzstd-devel,libbrotli-devel,libreadline-devel,libintl-devel,libpq-devel,libssh2-devel,libidn2-devel,gettext-devel,coreutils,openssl-devel - -setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site https://mirrors.ustc.edu.cn/cygwin/ --packages zip unzip icu libicu-devel -setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site https://mirrors.ustc.edu.cn/cygwin/ --packages libpq5 libpq-devel +# 自动安装 cygwin 和 cygwin 依赖项 +sapi\quickstart\windows\install-cygwin.bat - -# 打开 cygwin64 Terminal ``` -构建步骤 ------- -首先需要安装上述工具和库,然后 Clone 项目,并切换 `ext/swoole` -到对应的分支,如 `4.8.x` 或 `master` (`5.0.x`) +构建步骤 - 执行的命令 +==== +> 运行如下步骤,需要先 打开 cygwin64 Terminal ```shell @@ -44,15 +36,15 @@ git clone --recursive https://github.com/swoole/swoole-cli.git cd swoole-cli -# git submodule update --init +# git submodule update --init -f bash ./sapi/scripts/cygwin/install-re2c.sh - bash ./sapi/scripts/cygwin/cygwin-config-ext.sh bash ./sapi/scripts/cygwin/cygwin-config.sh bash ./sapi/scripts/cygwin/cygwin-build.sh bash ./sapi/scripts/cygwin/cygwin-archive.sh + ``` 构建步骤说明 @@ -126,3 +118,23 @@ libicu-devel icu ``` + +## 安装 cygwin 和 安装 cygwin 依赖项 具体执行的命令 + +> `sapi\quickstart\windows\install-cygwin.bat` 脚本包含的内容 + +```bash +# 安装 cygwin +setup-x86_64.exe --site https://mirrors.ustc.edu.cn/cygwin/ + +# 安装 cygwin 依赖项 +setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site https://mirrors.ustc.edu.cn/cygwin/ --packages make,git,curl,wget,tar,libtool,bison,gcc-g++,autoconf,automake,openssl,libpcre2-devel,libssl-devel,libcurl-devel,libxml2-devel,libxslt-devel,libgmp-devel,ImageMagick,libpng-devel,libjpeg-devel,libfreetype-devel,libwebp-devel,libsqlite3-devel,zlib-devel,libbz2-devel,liblz4-devel,liblzma-devel,libzip-devel,libicu-devel,libonig-devel,libcares-devel,libsodium-devel,libyaml-devel,libMagick-devel,libzstd-devel,libbrotli-devel,libreadline-devel,libintl-devel,libpq-devel,libssh2-devel,libidn2-devel,gettext-devel,coreutils,openssl-devel + +setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site https://mirrors.ustc.edu.cn/cygwin/ --packages zip unzip icu libicu-devel + +setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site https://mirrors.ustc.edu.cn/cygwin/ --packages libpq5 libpq-devel + + +# 打开 cygwin64 Terminal +``` + diff --git a/docs/linux.md b/docs/linux.md index a3c00f505a..e719d0930c 100644 --- a/docs/linux.md +++ b/docs/linux.md @@ -1,3 +1,40 @@ +# linux 环境下构建 swoole-cli + +## 运行环境要求 + +1. 容器 docker 运行环境 + +构建步骤 - 运行命令 +==== + +```shell + +git clone --recursive https://github.com/swoole/swoole-cli.git +cd swoole-cli + +bash setup-php-runtime.sh +composer install --no-interaction --no-autoloader --no-scripts --profile +composer dump-autoload --optimize --profile + +php prepare.php +inotify +apcu +ds +xlswriter +ssh2 +uuid +bash ./make.sh docker-build +bash ./make.sh docker-bash + +bash sapi/quickstart/linux/alpine-init.sh + +# 进入容器后需要再一次执行此命令 +php prepare.php +inotify +apcu +ds +xlswriter +ssh2 +uuid +bash ./make.sh all-library +bash ./make.sh config +bash ./make.sh build +bash ./make.sh archive + +./bin/swoole-cli -m +./bin/swoole-cli --ri swoole +file ./bin/swoole-cli + +``` + 构建镜像 ==== `Linux` 下需要在容器中构建,因此需要先构建 `swoole-cli-builder:base` 基础镜像。 @@ -16,7 +53,7 @@ 快速初始化构建环境 ==== -不执行 `./make.sh docker-build [china|ustc|tuna] ` 生成基础镜像 +跳过生成容器基础镜像 使用如下命令快速进入容器环境 便捷调整构建环境 @@ -73,3 +110,26 @@ make: ext/opcache/minilua: No such file or directory rm ext/opcache/minilua ./make.sh build ``` + +docker no found +---- +> 快速安装 docker 运行环境 + +```bash + +bash sapi/quickstart/linux/install-docker.sh + +# 使用中国镜像 +bash sapi/quickstart/linux/install-docker.sh --mirror china + + +``` + +fix slow alpine apk installations +---- + +```bash + +bash sapi/quickstart/linux/alpine-init.sh --mirror china + +``` diff --git a/docs/macOS.md b/docs/macOS.md index 7a8a458c75..cca330963e 100644 --- a/docs/macOS.md +++ b/docs/macOS.md @@ -1,7 +1,39 @@ -# 步骤 +# macOS 环境下构建 swoole-cli + +构建步骤 - 运行命令 +==== + +```shell + +git clone --recursive https://github.com/swoole/swoole-cli.git +cd swoole-cli + +bash setup-php-runtime.sh +composer install --no-interaction --no-autoloader --no-scripts --profile +composer dump-autoload --optimize --profile + +php prepare.php --without-docker=1 +inotify +apcu +ds +xlswriter +ssh2 +uuid + +bash sapi/quickstart/macos/macos-init.sh + +bash ./make.sh all-library +bash ./make.sh config +bash ./make.sh build +bash ./make.sh archive + +./bin/swoole-cli -m +./bin/swoole-cli --ri swoole +xattr -cr ./bin/swoole-cli +otool -L ./bin/swoole-cli + + +``` + +构建步骤简述 +==== 0. 清理 `brew` 安装的软件 -1. 执行 `php prepare.php --without-docker=1` +1. 执行 `php prepare.php --without-docker=1` 生成构建shell 脚本 2. 编译所有依赖的库 `./make.sh all-library` 3. 配置 `./make.sh config` 4. 构建 `./make.sh build` 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 05b631cb1c..4ba5c8487e 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="1b8bbd1b64e196b1d56c940fc62079fac8c2cd106867f9534fadb40ee02beaec" +ALL_DEPS_HASH="5fa1485c2408f05cbc548712917e6dbb8ecd5a631b558d6d512d4a6671f071e5" -DOMAIN='https://github.com/swoole/swoole-cli/releases/download/v5.1.1.0/' +DOMAIN='https://github.com/swoole/swoole-cli/releases/download/v5.1.3.0/' while [ $# -gt 0 ]; do case "$1" in --mirror) @@ -36,8 +36,7 @@ while [ $# -gt 0 ]; do done -URL="${DOMAIN}/all-archive.zip" -# URL="${DOMAIN}/all-deps.zip" # 下一个版本启用此命名 +URL="${DOMAIN}/all-deps.zip" test -f all-deps.zip || curl -Lo all-deps.zip ${URL} diff --git a/sapi/quickstart/windows/README.md b/sapi/quickstart/windows/README.md index a480aac1e4..f7df0e7867 100644 --- a/sapi/quickstart/windows/README.md +++ b/sapi/quickstart/windows/README.md @@ -7,9 +7,9 @@ ```shell # 自动下载 cygwin -sapi/quickstart/windows/download-cygwin.bat +sapi\quickstart\windows\download-cygwin.bat # 自动安装 cygwin -sapi/quickstart/windows/install-cygwin.bat +sapi\quickstart\windows\install-cygwin.bat ``` diff --git a/setup-php-runtime.sh b/setup-php-runtime.sh index 2e67f95c58..3cb838eeae 100644 --- a/setup-php-runtime.sh +++ b/setup-php-runtime.sh @@ -48,19 +48,20 @@ case $ARCH in ;; esac -VERSION='v5.0.3' +SWOOLE_VERSION='v5.1.3' +VERSION='v5.1.3.0' mkdir -p bin/runtime mkdir -p var/runtime cd ${__PROJECT__}/var/runtime -SWOOLE_CLI_DOWNLOAD_URL="https://github.com/swoole/swoole-src/releases/download/${VERSION}/swoole-cli-${VERSION}-${OS}-${ARCH}.tar.xz" +SWOOLE_CLI_DOWNLOAD_URL="https://github.com/swoole/swoole-cli/releases/download/${VERSION}/swoole-cli-${SWOOLE_VERSION}-${OS}-${ARCH}.tar.xz" COMPOSER_DOWNLOAD_URL="https://getcomposer.org/download/latest-stable/composer.phar" CACERT_DOWNLOAD_URL="https://curl.se/ca/cacert.pem" if [ $OS = 'windows' ]; then - SWOOLE_CLI_DOWNLOAD_URL="https://github.com/swoole/swoole-src/releases/download/${VERSION}/swoole-cli-${VERSION}-cygwin-${ARCH}.zip" + SWOOLE_CLI_DOWNLOAD_URL="https://github.com/swoole/swoole-cli/releases/download/${VERSION}/swoole-cli-${SWOOLE_VERSION}-cygwin-${ARCH}.zip" fi MIRROR='' @@ -72,8 +73,12 @@ while [ $# -gt 0 ]; do --proxy) export HTTP_PROXY="$2" export HTTPS_PROXY="$2" - NO_PROXY="127.0.0.0/8,10.0.0.0/8,100.64.0.0/10,172.16.0.0/12,192.168.0.0/16,198.18.0.0/15,169.254.0.0/16" - NO_PROXY="${NO_PROXY},127.0.0.1,localhost" + NO_PROXY="127.0.0.0/8,10.0.0.0/8,100.64.0.0/10,172.16.0.0/12,192.168.0.0/16" + NO_PROXY="${NO_PROXY},::1/128,fe80::/10,fd00::/8,ff00::/8" + NO_PROXY="${NO_PROXY},localhost" + NO_PROXY="${NO_PROXY},.aliyuncs.com,.aliyun.com,.tencent.com" + NO_PROXY="${NO_PROXY},.myqcloud.com,.swoole.com" + export NO_PROXY="${NO_PROXY},.tsinghua.edu.cn,.ustc.edu.cn,.npmmirror.com" ;; --*) echo "Illegal option $1" @@ -84,10 +89,10 @@ done case "$MIRROR" in china) - SWOOLE_CLI_DOWNLOAD_URL="https://wenda-1252906962.file.myqcloud.com/dist/swoole-cli-${VERSION}-${OS}-${ARCH}.tar.xz" + SWOOLE_CLI_DOWNLOAD_URL="https://wenda-1252906962.file.myqcloud.com/dist/swoole-cli-${SWOOLE_VERSION}-${OS}-${ARCH}.tar.xz" COMPOSER_DOWNLOAD_URL="https://mirrors.tencent.com/composer/composer.phar" if [ $OS = 'windows' ]; then - SWOOLE_CLI_DOWNLOAD_URL="https://wenda-1252906962.file.myqcloud.com/dist/swoole-cli-${VERSION}-cygwin-${ARCH}.zip" + SWOOLE_CLI_DOWNLOAD_URL="https://wenda-1252906962.file.myqcloud.com/dist/swoole-cli-${SWOOLE_VERSION}-cygwin-${ARCH}.zip" fi ;; @@ -98,11 +103,11 @@ chmod a+x composer.phar test -f cacert.pem || curl -LSo cacert.pem ${CACERT_DOWNLOAD_URL} -SWOOLE_CLI_RUNTIME="swoole-cli-${VERSION}-${OS}-${ARCH}" +SWOOLE_CLI_RUNTIME="swoole-cli-${SWOOLE_VERSION}-${OS}-${ARCH}" if [ $OS = 'windows' ]; then { - SWOOLE_CLI_RUNTIME="swoole-cli-${VERSION}-cygwin-${ARCH}" + SWOOLE_CLI_RUNTIME="swoole-cli-${SWOOLE_VERSION}-cygwin-${ARCH}" test -f ${SWOOLE_CLI_RUNTIME}.zip || curl -LSo ${SWOOLE_CLI_RUNTIME}.zip ${SWOOLE_CLI_DOWNLOAD_URL} test -d ${SWOOLE_CLI_RUNTIME} && rm -rf ${SWOOLE_CLI_RUNTIME} unzip "${SWOOLE_CLI_RUNTIME}.zip" From 70a6bcd9e8eb0f63bfa9d8891b52f4ac5296cfbd Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Tue, 18 Jun 2024 22:08:32 +0800 Subject: [PATCH 2/6] update quickstart script --- build-release-example.sh | 4 +- docs/linux.md | 3 + sapi/quickstart/linux/README.md | 7 +- sapi/quickstart/linux/alpine-init-minimal.sh | 44 +++++++++ sapi/quickstart/linux/debian-init-minimal.sh | 94 ++++++++++++++++++++ sapi/quickstart/linux/debian-init.sh | 2 +- sapi/quickstart/linux/install-docker.sh | 12 ++- sapi/src/Project.php | 7 +- 8 files changed, 165 insertions(+), 8 deletions(-) create mode 100644 sapi/quickstart/linux/alpine-init-minimal.sh create mode 100644 sapi/quickstart/linux/debian-init-minimal.sh diff --git a/build-release-example.sh b/build-release-example.sh index 59f1f1e043..8c932e8574 100644 --- a/build-release-example.sh +++ b/build-release-example.sh @@ -79,7 +79,7 @@ if [ "$OS" = 'linux' ] ; then if [ ! "$BASH_VERSION" ] ; then echo "Please use bash to run this script ($0) " 1>&2 echo "fix : " 1>&2 - echo "apk add bash' or sh sapi/quickstart/linux/alpine-init.sh " 1>&2 + echo "sh sapi/quickstart/linux/alpine-init-mini.sh " 1>&2 exit 1 fi fi @@ -188,7 +188,7 @@ fi # 定制构建选项 -OPTIONS='+apcu +ds +xlswriter +ssh2' +OPTIONS='+apcu +ds +xlswriter +ssh2 +uuid ' OPTIONS="${OPTIONS} --with-swoole-pgsql=1" OPTIONS="${OPTIONS} --with-global-prefix=${LIBRARY_INSTALL_PREFIX}" # OPTIONS="${OPTIONS} @macos" diff --git a/docs/linux.md b/docs/linux.md index e719d0930c..ebba0ba790 100644 --- a/docs/linux.md +++ b/docs/linux.md @@ -20,6 +20,9 @@ php prepare.php +inotify +apcu +ds +xlswriter +ssh2 +uuid bash ./make.sh docker-build bash ./make.sh docker-bash +# 准备bash 命令 +sh sapi/quickstart/linux/alpine-init-minimal.sh + bash sapi/quickstart/linux/alpine-init.sh # 进入容器后需要再一次执行此命令 diff --git a/sapi/quickstart/linux/README.md b/sapi/quickstart/linux/README.md index 7a4d9a4a5b..b59fe882ee 100644 --- a/sapi/quickstart/linux/README.md +++ b/sapi/quickstart/linux/README.md @@ -22,11 +22,14 @@ bash sapi/quickstart/linux/run-alpine-container.sh # 进入容器 bash sapi/quickstart/linux/connection-swoole-cli-alpine.sh +# 准备构建基础软件 bash git +sh sapi/quickstart/linux/alpine-init-minimal.sh + # 准备构建基础软件 -sh sapi/quickstart/linux/alpine-init.sh +bash sapi/quickstart/linux/alpine-init.sh # 准备构建基础软件 使用中科大镜像源 -sh sapi/quickstart/linux/alpine-init.sh --mirror china +bash sapi/quickstart/linux/alpine-init.sh --mirror china ``` diff --git a/sapi/quickstart/linux/alpine-init-minimal.sh b/sapi/quickstart/linux/alpine-init-minimal.sh new file mode 100644 index 0000000000..8a6c8d189a --- /dev/null +++ b/sapi/quickstart/linux/alpine-init-minimal.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +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 + --mirror) + MIRROR="$2" + ;; + --*) + echo "no found mirror option $1" + ;; + esac + shift $(($# > 0 ? 1 : 0)) +done + +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 + ;; +tencentyun | huaweicloud) # 云服务的内网镜像源 + test -f /etc/apk/repositories.save || cp /etc/apk/repositories /etc/apk/repositories.save + test "$MIRROR" = "tencentyun" && sed -i 's/dl-cdn.alpinelinux.org/mirrors.tencentyun.com/g' /etc/apk/repositories + test "$MIRROR" = "huaweicloud" && sed -i 's/dl-cdn.alpinelinux.org/repo.huaweicloud.com/g' /etc/apk/repositories + ;; + +esac + +apk update + +apk add bash git curl wget xz zip unzip ca-certificates diff --git a/sapi/quickstart/linux/debian-init-minimal.sh b/sapi/quickstart/linux/debian-init-minimal.sh new file mode 100644 index 0000000000..81dbe41442 --- /dev/null +++ b/sapi/quickstart/linux/debian-init-minimal.sh @@ -0,0 +1,94 @@ +#!/bin/bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) + +# use china mirror +# bash sapi/quickstart/linux/debian-init-mini.sh --mirror [ china | ustc | tuna | aliyuncs | tencentyun | huaweicloud ] + +MIRROR='' +while [ $# -gt 0 ]; do + case "$1" in + --mirror) + case "$2" in + china | ustc | tuna | aliyuncs | tencentyun | huaweicloud ) + MIRROR="$2" + ;; + esac + ;; + --*) + echo "Illegal option $1" + ;; + esac + 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 + 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@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 + +export DEBIAN_FRONTEND=noninteractive + +apt update -y + +apt install -y git curl wget ca-certificates xz-utils bzip2 p7zip lzip zip unzip diff --git a/sapi/quickstart/linux/debian-init.sh b/sapi/quickstart/linux/debian-init.sh index a3ed5d3e5b..caf55d326b 100644 --- a/sapi/quickstart/linux/debian-init.sh +++ b/sapi/quickstart/linux/debian-init.sh @@ -7,7 +7,7 @@ __DIR__=$( ) # use china mirror -# bash sapi/quickstart/linux/debian-init.sh --mirror [china | ustc | tuna | aliyuncs | tencentyun | huaweicloud] +# bash sapi/quickstart/linux/debian-init.sh --mirror [ china | ustc | tuna | aliyuncs | tencentyun | huaweicloud ] MIRROR='' while [ $# -gt 0 ]; do diff --git a/sapi/quickstart/linux/install-docker.sh b/sapi/quickstart/linux/install-docker.sh index 600111455c..ddcc2c9868 100644 --- a/sapi/quickstart/linux/install-docker.sh +++ b/sapi/quickstart/linux/install-docker.sh @@ -15,7 +15,17 @@ mkdir -p ${__PROJECT__}/var cd ${__PROJECT__}/var -curl -fsSL https://get.docker.com -o get-docker.sh +# 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 diff --git a/sapi/src/Project.php b/sapi/src/Project.php index d383a4328c..8a982365ee 100644 --- a/sapi/src/Project.php +++ b/sapi/src/Project.php @@ -82,9 +82,10 @@ public function withMd5sum(string $md5sum): static } /** + * 配置 文件 签名验证 * https://www.php.net/manual/zh/function.hash-algos.php * print_r(hash_algos()); - * @param string $algo + * @param string $algo [ 'md5' | 'sha1' | 'sha256' ] * @param string $hash * @return $this */ @@ -96,8 +97,10 @@ public function withFileHash(string $algo, string $hash): static return $this; } - /* + /** * hash 签名验证 ,hash 不匹配,删除文件 + * @param string $file + * @return bool */ public function hashVerify(string $file): bool { From 9678bcf9f54e3edaa876b59dcb1f4969a5ab166b Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Tue, 18 Jun 2024 22:12:00 +0800 Subject: [PATCH 3/6] update build-release-example.sh --- build-release-example.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-release-example.sh b/build-release-example.sh index 8c932e8574..c33b304c3d 100644 --- a/build-release-example.sh +++ b/build-release-example.sh @@ -79,7 +79,7 @@ if [ "$OS" = 'linux' ] ; then if [ ! "$BASH_VERSION" ] ; then echo "Please use bash to run this script ($0) " 1>&2 echo "fix : " 1>&2 - echo "sh sapi/quickstart/linux/alpine-init-mini.sh " 1>&2 + echo "apk add bash OR sh sapi/quickstart/linux/alpine-init-mini.sh " 1>&2 exit 1 fi fi @@ -188,7 +188,7 @@ fi # 定制构建选项 -OPTIONS='+apcu +ds +xlswriter +ssh2 +uuid ' +OPTIONS="${OPTIONS} +apcu +ds +xlswriter +ssh2 +uuid " OPTIONS="${OPTIONS} --with-swoole-pgsql=1" OPTIONS="${OPTIONS} --with-global-prefix=${LIBRARY_INSTALL_PREFIX}" # OPTIONS="${OPTIONS} @macos" From 0d9f547349a8bd76f618c3be47e3baf1275db1cc Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Tue, 18 Jun 2024 22:13:13 +0800 Subject: [PATCH 4/6] update docs/macOS.md --- docs/macOS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/macOS.md b/docs/macOS.md index cca330963e..b1d97da9cd 100644 --- a/docs/macOS.md +++ b/docs/macOS.md @@ -12,7 +12,7 @@ bash setup-php-runtime.sh composer install --no-interaction --no-autoloader --no-scripts --profile composer dump-autoload --optimize --profile -php prepare.php --without-docker=1 +inotify +apcu +ds +xlswriter +ssh2 +uuid +php prepare.php --without-docker=1 +apcu +ds +xlswriter +ssh2 +uuid bash sapi/quickstart/macos/macos-init.sh From 76595f286d327ac2a4c0e2620baa570871a973df Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Tue, 18 Jun 2024 22:48:22 +0800 Subject: [PATCH 5/6] update build-release-example.sh --- build-release-example.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-release-example.sh b/build-release-example.sh index c33b304c3d..3558e5f0ca 100644 --- a/build-release-example.sh +++ b/build-release-example.sh @@ -79,7 +79,7 @@ if [ "$OS" = 'linux' ] ; then if [ ! "$BASH_VERSION" ] ; then echo "Please use bash to run this script ($0) " 1>&2 echo "fix : " 1>&2 - echo "apk add bash OR sh sapi/quickstart/linux/alpine-init-mini.sh " 1>&2 + echo "apk add bash OR sh sapi/quickstart/linux/alpine-init-minimal.sh " 1>&2 exit 1 fi fi From 1c3843d4ae852917ad93df92464264ccbcc77cc9 Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Fri, 21 Jun 2024 20:49:23 +0800 Subject: [PATCH 6/6] update install-docker.sh --- sapi/quickstart/linux/install-docker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sapi/quickstart/linux/install-docker.sh b/sapi/quickstart/linux/install-docker.sh index ddcc2c9868..46c4b77ce7 100644 --- a/sapi/quickstart/linux/install-docker.sh +++ b/sapi/quickstart/linux/install-docker.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -exu +set -ex __DIR__=$( cd "$(dirname "$0")" pwd