diff --git a/.github/workflows/artifact-hash.yml b/.github/workflows/artifact-hash.yml new file mode 100644 index 0000000000..c1cb921d9a --- /dev/null +++ b/.github/workflows/artifact-hash.yml @@ -0,0 +1,47 @@ +name: artifact-hash + +on: + workflow_dispatch: + inputs: + version: + required: true + description: "发版 版本号 tag" + default: 'v1.7.1' + type: string + php-version: + required: true + description: "PHP 版本号 " + default: 'v8.1.31,v8.2.27,v8.3.15,v8.4.2' + type: string + enable_upload_cloud_object_storage: + required: false + type: boolean + description: "上传到云对象存储 (默认不需要上传)" + +jobs: + generate-artifact-hash: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Show Release File Hash + run: | + bash sapi/scripts/generate-artifact-hash.sh --version ${{ inputs.version }} --php-version ${{ inputs.php-version }} + + - name: production artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ inputs.version }}-sha256sum + retention-days: 90 + path: | + ${{ inputs.version }}-sha256sum + + - name: upload artifacts to cloud object storage + if: ${{ 0 && (github.repository == 'swoole/swoole-cli') && (inputs.enable_upload_cloud_object_storage == true) }} + env: + OSS_SECRET_ID: ${{ secrets.QCLOUD_OSS_SECRET_ID }} + OSS_SECRET_KEY: ${{ secrets.QCLOUD_OSS_SECRET_KEY }} + OSS_BUCKET: ${{ vars.QCLOUD_OSS_BUCKET }} + OSS_REGION: ${{ vars.QCLOUD_OSS_REGION }} + run: | + bash sapi/scripts/tencent-cloud-object-storage.sh --upload-all --swoole-cli-version ${{ inputs.version }} + diff --git a/.github/workflows/auto-cache-pool-tarball.yml b/.github/workflows/auto-cache-pool-tarball.yml index a9251b9dcd..0f50306fa2 100644 --- a/.github/workflows/auto-cache-pool-tarball.yml +++ b/.github/workflows/auto-cache-pool-tarball.yml @@ -61,7 +61,7 @@ jobs: key: source-code-tarball-pool - name: Clean Source Code Tarball Cache On Release - if: startsWith(github.ref, 'refs/tags/') + if: ${{ startsWith(github.ref, 'refs/tags/') }} run: rm -rf ${{ github.workspace }}/pool/* @@ -84,8 +84,8 @@ jobs: composer install --no-interaction --no-autoloader --no-scripts --profile --no-dev composer dump-autoload --optimize --profile --no-dev - php prepare.php +inotify +apcu +ds +xlswriter +ssh2 +uuid +mongodb --show-tarball-hash=1 - php prepare.php +apcu +ds +xlswriter +ssh2 +uuid @macos --show-tarball-hash=1 + php prepare.php +inotify --show-tarball-hash=1 + php prepare.php @macos --show-tarball-hash=1 cd ${{ github.workspace }}/pool/ zip -9 -r ${WORK_DIR}/all-deps.zip ext lib @@ -100,7 +100,6 @@ jobs: ls -A pool/ext/ - name: production artifacts - if: 1 uses: actions/upload-artifact@v4 with: name: all-deps @@ -111,7 +110,7 @@ jobs: - name: gh release uses: softprops/action-gh-release@v2 - if: startsWith(github.ref, 'refs/tags/') + if: ${{ startsWith(github.ref, 'refs/tags/') }} with: files: | all-deps.zip diff --git a/.github/workflows/download-webrtc.yml b/.github/workflows/download-webrtc.yml new file mode 100644 index 0000000000..ad3b60e11a --- /dev/null +++ b/.github/workflows/download-webrtc.yml @@ -0,0 +1,49 @@ +name: linux-download-ci + +on: + push: + pull_request: + +jobs: + download-webrtc: + runs-on: ubuntu-latest + if: 0 + steps: + - uses: actions/checkout@v4 + - name: prepare Environment + run: | + git config --global core.autocrlf false + # 不再关心文件的权限 + git config --global core.filemode false + # 让 Git 显示颜色,会让命令输出看起来更醒目 + git config --global color.ui true + sudo apt install -y curl wget bash + + - name: Prepare depot_tools + run: | + # https://webrtc.googlesource.com/src/+/main/docs/native-code/development/prerequisite-sw/ + # https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up + + git clone --progress -b main https://chromium.googlesource.com/chromium/tools/depot_tools.git + export PATH=${{ github.workspace }}/depot_tools:$PATH + echo "PATH=$PATH:${{ github.workspace }}/depot_tools" >> $GITHUB_ENV + + - name: Maximize build space + if: 1 + shell: bash + run: | + df -h + sudo rm -rf /usr/share/dotnet + sudo rm -rf /usr/local/lib/android + sudo rm -rf /opt/ghc + sudo rm -rf /opt/hostedtoolcache/CodeQL + sudo docker image prune --all --force + sudo docker builder prune -a + df -h + + - name: Download Webrtc + run: | + # https://webrtc.googlesource.com/src/+/main/docs/native-code/development + fetch webrtc + cd src && ./build/install-build-deps.sh + gclient sync diff --git a/.github/workflows/linux-aarch64.yml b/.github/workflows/linux-aarch64.yml index 6c040b8dab..9060cacd4b 100644 --- a/.github/workflows/linux-aarch64.yml +++ b/.github/workflows/linux-aarch64.yml @@ -3,7 +3,7 @@ name: build-linux-aarch64 on: [ push, pull_request ] env: - BUILD_PHP_VERSION: 8.2.13 + BUILD_PHP_VERSION: 8.2.27 jobs: linux-aarch64: @@ -12,9 +12,10 @@ jobs: strategy: matrix: php-version: - - "8.2.13" - - "8.1.27" - # - "8.3.3" + - "8.2.27" + - "8.1.31" + - "8.3.15" + - "8.4.2" steps: - uses: actions/checkout@v4 - name: Show Environment Info @@ -207,3 +208,13 @@ jobs: files: | php-cli-v${{ env.APP_VERSION }}-linux-arm64.tar.xz php-cli-v${{ env.APP_VERSION }}-linux-arm64-debug.tar.xz + + - name: upload artifacts to cloud object storage + if: ${{ 0 && (github.repository == 'swoole/swoole-cli') && (startsWith(github.ref, 'refs/tags/')) }} + env: + OSS_SECRET_ID: ${{ secrets.QCLOUD_OSS_SECRET_ID }} + OSS_SECRET_KEY: ${{ secrets.QCLOUD_OSS_SECRET_KEY }} + OSS_BUCKET: ${{ vars.QCLOUD_OSS_BUCKET }} + OSS_REGION: ${{ vars.QCLOUD_OSS_REGION }} + run: | + bash sapi/scripts/tencent-cloud-object-storage.sh --upload-file ${{ github.workspace }}/swoole-cli-v${{ env.APP_VERSION }}-linux-arm64.tar.xz diff --git a/.github/workflows/linux-riscv64.yml b/.github/workflows/linux-riscv64.yml index ff58b498e9..001522d65b 100644 --- a/.github/workflows/linux-riscv64.yml +++ b/.github/workflows/linux-riscv64.yml @@ -5,7 +5,13 @@ on: [ push, pull_request ] jobs: linux-riscv: if: 0 - runs-on: ubuntu-latest + runs-on: + # - ubuntu-latest + # https://github.com/apps/riscv-builders + # https://github.com/mengzhuo/GhostWrite/blob/main/.github/workflows/test.yml + - riscv-builders + - soc-spacemit-k1 + - soc-starfive-jh7100 steps: - uses: actions/checkout@v4 - name: Prepare Source Code diff --git a/.github/workflows/linux-x86_64.yml b/.github/workflows/linux-x86_64.yml index eb71bc450a..9bf131c864 100644 --- a/.github/workflows/linux-x86_64.yml +++ b/.github/workflows/linux-x86_64.yml @@ -3,45 +3,10 @@ name: build-linux-x86_64 on: push: pull_request: - workflow_dispatch: - inputs: - build_latest_swoole_or_swow: - required: true - description: "定制构建选项: 构建最新版的 swoole 或者 swow (此二者扩展不能同时启用)" - default: ' ' - type: choice - options: - - ' ' - - '-swoole +swoole_latest' - - '-swoole +swow_latest' - - '-swoole +swow' - php_version: - required: true - description: "定制构建选项: 指定 PHP 版本(版本号大于等于8.1)" - default: '--with-php-version=8.2.13' - type: choice - options: - - '--with-php-version=8.1.27' - - '--with-php-version=8.2.13' - - '--with-php-version=8.3.1' - build_type: - required: true - description: "定制构建选项: 指定构建类型" - default: '--with-build-type=release' - type: choice - options: - - '--with-build-type=release' - - '--with-build-type=dev' - build_options: - required: false - description: "定制构建选项: 请查看 docs/options.md" - default: ' ' - type: string - env: BRANCH_NAME: ${{ github.head_ref || github.ref_name }} - BUILD_PHP_VERSION: 8.2.13 + BUILD_PHP_VERSION: 8.2.27 jobs: linux-x86_64: @@ -51,6 +16,8 @@ jobs: - uses: actions/checkout@v4 - name: Show Environment Info run: | + echo "${{ github.event.head_commit.message }}" + echo "${{ github.event.workflow_run.head_commit.message }}" echo $PATH env docker info @@ -196,14 +163,6 @@ jobs: bash ./make.sh build bash ./make.sh archive - - name: Start Database - run: | - # 准备数据库容器 - export PATH=/usr/libexec/docker/cli-plugins/:$PATH - docker-compose version - docker container ls -a - # bash sapi/src/UnitTest/scripts/database/start.sh - - name: Show Build Result run: | ./bin/aria2c -v @@ -225,3 +184,4 @@ jobs: if: startsWith(github.ref, 'refs/tags/') with: files: aria2c-${{ env.APP_VERSION }}-linux-x64.tar.xz + diff --git a/.github/workflows/macos-aarch64.yml b/.github/workflows/macos-aarch64.yml index 08e2875b4b..95d8b6248c 100644 --- a/.github/workflows/macos-aarch64.yml +++ b/.github/workflows/macos-aarch64.yml @@ -3,7 +3,7 @@ name: build-macos-aarch64 on: [ push, pull_request ] env: - BUILD_PHP_VERSION: 8.2.13 + BUILD_PHP_VERSION: 8.2.27 jobs: macos-aarch64: @@ -17,7 +17,7 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Prepare build environment + - name: Show Environment Info run: | set -x uname -s @@ -26,24 +26,12 @@ jobs: sysctl -n hw.ncpu env echo $HOME + sw_vers + xcodebuild -version brew config - - bash sapi/quickstart/macos/macos-init.sh - - # sudo rm -rf /Library/Developer/CommandLineTools - # xcode-select --install - - # sudo xcode-select --reset - # sudo xcode-select -switch /Library/Developer/CommandLineTools - - # softwareupdate --list --verbose - # softwareupdate --install -a - # xcode-select --install - - # export SDKROOT=$(xcrun --show-sdk-path) + xcrun --show-sdk-path ls -lh $(xcrun --show-sdk-path) - # sudo xcode-select --switch /Applications/Xcode.app - # export MACOSX_DEPLOYMENT_TARGET=12.6 + clang --version ifconfig export IPV6=$(ifconfig en0 | grep "inet6 " | grep -v "inet6 fe80:" | awk '{print $2}' | cut -d'/' -f1 | sed -n '2p') @@ -55,6 +43,10 @@ jobs: # echo "BUILD_PHP_VERSION=${{ matrix.php-version }}" >> $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 diff --git a/.github/workflows/macos-x86_64.yml b/.github/workflows/macos-x86_64.yml index c550ecaf5a..954517ec3c 100644 --- a/.github/workflows/macos-x86_64.yml +++ b/.github/workflows/macos-x86_64.yml @@ -5,47 +5,45 @@ on: pull_request: env: - BUILD_PHP_VERSION: 8.2.13 + BUILD_PHP_VERSION: 8.2.27 jobs: macos-x86_64: if: 1 - runs-on: macos-12 + runs-on: macos-13 # macos-latest (macos-14) 变更了 CPU 架构,由 x86_64 变更为 arm64 # macos-14 CPU 架构 arm64 # macos-13 CPU 架构 x86_64 # macos-12 CPU 架构 x86_64 # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#choosing-github-hosted-runners + steps: - uses: actions/checkout@v4 - - name: Prepare build environment + - name: Show Environment Info run: | + set -x uname -s uname -m uname -r sysctl -n hw.ncpu env echo $HOME - + sw_vers + xcodebuild -version brew config - set -x - bash sapi/quickstart/macos/macos-init.sh - - # sudo rm -rf /Library/Developer/CommandLineTools - # xcode-select --install + xcrun --show-sdk-path + clang --version - # sudo xcode-select --reset - # sudo xcode-select -switch /Library/Developer/CommandLineTools - - # softwareupdate --list --verbose - # softwareupdate --install -a - # xcode-select --install - # xcode-select --print-path - - # export SDKROOT=$(xcrun --show-sdk-path) ls -lh $(xcrun --show-sdk-path) - # sudo xcode-select --switch /Applications/Xcode.app - # export MACOSX_DEPLOYMENT_TARGET=12.6 + + # find /Applications/Xcode.app -name stdio.h + xcodebuild -find make + xcodebuild -find gcc + xcodebuild -find g++ + xcodebuild -find clang + xcodebuild -find clang++ + find /Applications/Xcode.app -path '*/usr/include/stdio.h' + find $(xcode-select --print-path) -name stdio.h echo 'export PATH="/usr/local/opt/binutils/bin:$PATH"' >> /Users/runner/.bash_profile @@ -59,6 +57,10 @@ jobs: echo "BUILD_PHP_VERSION=${{ matrix.php-version }}" >> $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/ diff --git a/.github/workflows/runner-images.md b/.github/workflows/runner-images.md new file mode 100644 index 0000000000..cd909a2940 --- /dev/null +++ b/.github/workflows/runner-images.md @@ -0,0 +1,5 @@ +[runner-images](https://github.com/actions/runner-images/tree/main/images) + +[available-images](https://github.com/actions/runner-images?tab=readme-ov-file#available-images) + +[choosing-github-hosted-runners](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#choosing-github-hosted-runners) diff --git a/.github/workflows/runner-os-readme.md b/.github/workflows/runner-os-readme.md deleted file mode 100644 index 6eb0093f43..0000000000 --- a/.github/workflows/runner-os-readme.md +++ /dev/null @@ -1 +0,0 @@ -https://github.com/actions/runner-images/tree/main/images diff --git a/.github/workflows/windows-cygwin.yml b/.github/workflows/windows-cygwin.yml index 40956a6273..4d42ae7579 100644 --- a/.github/workflows/windows-cygwin.yml +++ b/.github/workflows/windows-cygwin.yml @@ -5,29 +5,40 @@ on: pull_request: env: - BUILD_PHP_VERSION: 8.2.13 + BUILD_PHP_VERSION: 8.2.27 jobs: windows-cygwin: if: 0 - runs-on: windows-latest + runs-on: windows-2022 strategy: matrix: php-version: - - "8.2.13" - - "8.1.27" - - "8.3.3" + - "8.2.27" + - "8.1.31" + - "8.3.15" + - "8.4.2" steps: - - name: Prepare git + - name: Show Environment Info + shell: cmd run: | - git config --global core.autocrlf false - git config --global core.eol lf - env + ver + wmic cpu get name, caption, maxclockspeed, status + systeminfo + systeminfo | findstr /B /C:"OS Name" /C:"OS Version" + systeminfo | findstr /B /C:"Manufacturer" /C:"Product" /C:"Version" + set ipconfig uname -a pwd ipconfig /all + - name: Prepare git + run: | + git config --global core.autocrlf false + git config --global core.eol lf + git config --global core.ignorecase false + - uses: actions/checkout@v4 - name: set php version # 参考文档: https://docs.github.com/zh/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell @@ -58,35 +69,46 @@ jobs: - name: Install Cygwin uses: cygwin/cygwin-install-action@v2 + with: + site: https://mirrors.kernel.org/sourceware/cygwin/ # with: # platform: x64 # packages: make wget tar libtool re2c 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 zip unzip - - name: Install Cygwin Packages + - name: Install Cygwin Packages with bash + if: 0 shell: C:\cygwin\bin\bash.EXE --noprofile --norc -e -o pipefail -o igncr {0} run: | ls -lah /cygdrive/c/ ls -lah /cygdrive/d/ - cp -f /cygdrive/c/setup.exe /cygdrive/c/cygwin/bin/setup-x86_64.exe - bash ./sapi/scripts/cygwin/install-cygwin.sh + - name: Install Cygwin Packages + if: 1 + run: | + Copy-Item -Path "C:\setup.exe" -Destination "${{ github.workspace }}\setup-x86_64.exe" + cmd /c .\sapi\quickstart\windows\cygwin-build\install-cygwin.bat + - name: Install re2c + shell: C:\cygwin\bin\bash.EXE --noprofile --norc -e -o pipefail -o igncr {0} run: | bash ./sapi/scripts/cygwin/install-re2c.sh - - name: Prepare + - name: Configure + shell: C:\cygwin\bin\bash.EXE --noprofile --norc -e -o pipefail -o igncr {0} run: | # git config --global --add safe.directory /cygdrive/d/a/swoole-cli/swoole-cli # git submodule update --init bash ./sapi/scripts/cygwin/cygwin-config-ext.sh --php-version ${{ env.BUILD_PHP_VERSION }} - name: Configure + shell: C:\cygwin\bin\bash.EXE --noprofile --norc -e -o pipefail -o igncr {0} run: | - bash ./sapi/scripts/cygwin/cygwin-config.sh + bash ./sapi/scripts/cygwin/cygwin-config.sh --php-version ${{ env.BUILD_PHP_VERSION }} - name: Build + shell: C:\cygwin\bin\bash.EXE --noprofile --norc -e -o pipefail -o igncr {0} run: | bash ./sapi/scripts/cygwin/cygwin-build.sh @@ -94,7 +116,8 @@ jobs: run: | ./bin/php.exe -v ./bin/php.exe -m - ./bin/php.exe --ri pdo_pgsql + ./bin/php.exe --ri mongodb + ./bin/php.exe --ri gd ./bin/php.exe --ri swoole ./bin/php.exe -r "echo PHP_VERSION;" @@ -138,8 +161,30 @@ jobs: - name: gh release uses: softprops/action-gh-release@v2 - if: startsWith(github.ref, 'refs/tags/') + if: ${{ startsWith(github.ref, 'refs/tags/') }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: files: php-cli-v${{ env.APP_VERSION }}-cygwin-x64.zip + + upload-to-cloud-object-storage: + if: 0 + runs-on: ubuntu-latest + needs: windows-cygwin + steps: + - name: Prepare Run Environment + run: + sudo apt install -y curl + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + - name: upload artifacts to cloud object storage + if: ${{ 0 && (github.repository == 'swoole/swoole-cli') && (startsWith(github.ref, 'refs/tags/')) }} + env: + OSS_SECRET_ID: ${{ secrets.QCLOUD_OSS_SECRET_ID }} + OSS_SECRET_KEY: ${{ secrets.QCLOUD_OSS_SECRET_KEY }} + OSS_BUCKET: ${{ vars.QCLOUD_OSS_BUCKET }} + OSS_REGION: ${{ vars.QCLOUD_OSS_REGION }} + run: | + FILE_NAME=$(ls -d swoole-cli-v*-cygwin-x64) + FILE="${{ github.workspace }}/${FILE_NAME}/${FILE_NAME}.zip" + bash sapi/scripts/tencent-cloud-object-storage.sh --upload-file ${FILE} diff --git a/.github/workflows/windows-native-2022.yml b/.github/workflows/windows-native-2022.yml index 04b7fbb718..1cf7b023e1 100644 --- a/.github/workflows/windows-native-2022.yml +++ b/.github/workflows/windows-native-2022.yml @@ -14,8 +14,8 @@ jobs: strategy: matrix: php-version: - # - "8.2.13" - # - "8.1.27" + # - "8.2.13" + # - "8.1.27" - "8.3.7" steps: @@ -31,51 +31,26 @@ jobs: ipconfig /all echo "BUILD_PHP_VERSION=${{ matrix.php-version }}" >> $Env:GITHUB_ENV -# - uses: msys2/setup-msys2@v2 -# with: -# install: >- -# curl git + # - uses: msys2/setup-msys2@v2 + # with: + # install: >- + # curl git - uses: actions/setup-dotnet@v1 - uses: ilammy/msvc-dev-cmd@v1.13.0 with: arch: amd64 - - name: prepare source code + - name: set swap shell: cmd run: | - git clone -b master --depth=1 https://github.com/php/php-sdk-binary-tools.git - git clone -b php-${{ env.BUILD_PHP_VERSION }} --depth=1 https://github.com/php/php-src.git - : 本命令无效 在这里无效,只是为了看输出 - call php-sdk-binary-tools\phpsdk-vs17-x64.bat - - - - name: test - shell: cmd - run: | - echo %~dp0 - echo %cd% - SET CURRENT_DIR=%~dp0 - - set PHP_SDK_ARCH=x64 - set PHP_SDK_BIN_PATH=D:\a\swoole-cli\swoole-cli\php-sdk-binary-tools\bin - set PHP_SDK_MSYS2_PATH=D:\a\swoole-cli\swoole-cli\php-sdk-binary-tools\msys2\usr\bin - set PHP_SDK_OS_ARCH=x64 - set PHP_SDK_PHP_CMD=D:\a\swoole-cli\swoole-cli\php-sdk-binary-tools\bin\php\do_php.bat - set PHP_SDK_ROOT_PATH=D:\a\swoole-cli\swoole-cli\php-sdk-binary-tools - set "PHP_SDK_VC_DIR=C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC" - set "PHP_SDK_VC_TOOLSET_VER=%VCToolsVersion%" - set PHP_SDK_VS=vs17 - set PHP_SDK_VS_NUM=17 - set "PHP_SDK_VS_SHELL_CMD=C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat amd64" - set "PATH=D:\a\swoole-cli\swoole-cli\php-sdk-binary-tools\bin;D:\a\swoole-cli\swoole-cli\php-sdk-binary-tools\msys2\usr\bin;%PATH%" - - set - cd php-src - call buildconf - call configure --help - call configure --disable-all --enable-cli --enable-static=yes --enable-shared=no - call nmake - D:\a\swoole-cli\swoole-cli\php-src\x64\Release_TS\php.exe -v - D:\a\swoole-cli\swoole-cli\php-src\x64\Release_TS\php.exe -m - + wmic diskdrive list brief + wmic logicaldisk + :: 查看分页设置 + wmic pagefile list /format:list + :: wmic computersystem where name="%computername%" set AutomaticManagedPagefile=True + :: 禁用自动管理 分页大小 + wmic computersystem where name="%computername%" set AutomaticManagedPagefile=False + :: 设置分页大小 + wmic pagefileset where name="D:\\pagefile.sys" set InitialSize=2048,MaximumSize=4096 + wmic pagefile list /format:list diff --git a/.github/workflows/windows-native-vs2019.yml b/.github/workflows/windows-native-vs2019.yml index a2d8dff1d8..386eeaf2ce 100644 --- a/.github/workflows/windows-native-vs2019.yml +++ b/.github/workflows/windows-native-vs2019.yml @@ -46,24 +46,6 @@ jobs: CURRENT_DIR=$(pwd) echo $CURRENT_DIR - # msys2 下载安装 git curl wget openssl zip unzip xz lzip 软件包 - bash sapi/quickstart/windows/native-build/msys2/msys2-install-soft.sh - - # 准备 PHP 运行时 并执行 composer install - bash sapi/quickstart/windows/native-build/msys2/msys2-download-php-runtime.sh - - # 提前准备下载依赖库 - bash sapi/download-box/download-box-get-archive-from-server.sh - - # 准备 依赖库 和 扩展 - bash sapi/quickstart/windows/native-build/msys2/msys2-download-source-code.sh - - # 准备 PHP 源码 和 PHP SDK - bash sapi/quickstart/windows/native-build/msys2/msys2-download-php-and-php-sdk.sh - - # 构建库准备环境依赖 - bash sapi/quickstart/windows/native-build/msys2/msys2-download-deps-soft.sh - - name: Install Soft shell: cmd run: | @@ -96,48 +78,7 @@ jobs: php -v perl -v nasm -v - cmd /c sapi\quickstart\windows\native-build\library\zlib.bat - cmd /c sapi\quickstart\windows\native-build\library\openssl.bat - cmd /c sapi\quickstart\windows\native-build\library\libssh2.bat - # cmd /c sapi\quickstart\windows\native-build\library\libyaml.bat - # cmd /c sapi\quickstart\windows\native-build\library\libexpat.bat - # cmd /c sapi\quickstart\windows\native-build\library\liblz4.bat - # cmd /c sapi\quickstart\windows\native-build\library\curl.bat - # cmd /c sapi\quickstart\windows\native-build\library\brotli.bat - # cmd /c sapi\quickstart\windows\native-build\library\libpng.bat - name: build php run: | $CURRENT_DIR = Get-Location - - cmd /c sapi\quickstart\windows\native-build\native-build-php-config.bat - - # cmd /c sapi\quickstart\windows\native-build\native-build-php-config-help.bat - - cmd /c sapi\quickstart\windows\native-build\native-build-php-build.bat - - cmd /c sapi\quickstart\windows\native-build\native-build-php-release.bat - - # cmd /c sapi\quickstart\windows\native-build\native-build-php-archive.bat - - - name: Show Build Result - run: | - $CURRENT_DIR = Get-Location - cd $CURRENT_DIR\php-src\ - - .\x64\Release\php.exe -v - .\x64\Release\php.exe -m - dumpbin /DEPENDENTS ".\x64\Release\php.exe" - - - name: production artifacts - uses: actions/upload-artifact@v4 - with: - name: php-cli-v${{ env.BUILD_PHP_VERSION }}-vs16-x64 - retention-days: 90 - path: "php-src/x64/Release/php.exe" - - - name: gh release - uses: softprops/action-gh-release@v2 - if: 0 && startsWith(github.ref, 'refs/tags/') - with: - files: "php-src/x64/Release_TS/php.exe" diff --git a/.github/workflows/windows-native-vs2022.yml b/.github/workflows/windows-native-vs2022.yml new file mode 100644 index 0000000000..4346795340 --- /dev/null +++ b/.github/workflows/windows-native-vs2022.yml @@ -0,0 +1,122 @@ +name: build-php-cli-windows-vs2022 + +on: + push: + pull_request: + +env: + BUILD_PHP_VERSION: 8.2.13 + +jobs: + windows-native: + if: 0 + runs-on: windows-2022 + strategy: + matrix: + php-version: + # - "8.2.13" + # - "8.1.27" + - "8.3.11" + + steps: + - uses: actions/checkout@v4 + - uses: ilammy/msvc-dev-cmd@v1 + with: + arch: amd64 + vsversion: + - name: show environment info + run: | + git config --global core.autocrlf false + git config --global core.eol lf + git config --global core.ignorecase false + env + ipconfig + uname -a + pwd + ipconfig /all + # 显示逻辑cpu 个数 + wmic cpu get NumberOfLogicalProcessors /value + # echo %NUMBER_OF_PROCESSORS% + Write-Output $env:NUMBER_OF_PROCESSORS + systeminfo + echo "BUILD_PHP_VERSION=${{ matrix.php-version }}" >> $Env:GITHUB_ENV + + - name: prepare deps soft + shell: cmd + run: | + sapi\quickstart\windows\native-build\windows-init.bat + + - name: Set Github ENV variables + run: | + $CURRENT_DIR = Get-Location + echo "PHP_SDK_ARCH=x64" >> $Env:GITHUB_ENV + echo "PHP_SDK_BIN_PATH=${CURRENT_DIR}\var\windows-build-deps\php-sdk-binary-tools\bin" >> $Env:GITHUB_ENV + echo "PHP_SDK_MSYS2_PATH=${CURRENT_DIR}\var\windows-build-deps\php-sdk-binary-tools\msys2\usr\bin" >> $Env:GITHUB_ENV + echo "PHP_SDK_OS_ARCH=x64" >> $Env:GITHUB_ENV + echo "PHP_SDK_PHP_CMD=${CURRENT_DIR}\var\windows-build-deps\php-sdk-binary-tools\bin\php\do_php.bat" >> $Env:GITHUB_ENV + echo "PHP_SDK_ROOT_PATH=${CURRENT_DIR}\var\windows-build-deps\php-sdk-binary-tools" >> $Env:GITHUB_ENV + echo "PHP_SDK_VC_DIR=C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC" >> $Env:GITHUB_ENV + echo "PHP_SDK_VC_TOOLSET_VER=$env:VCToolsVersion" >> $Env:GITHUB_ENV + echo "PHP_SDK_VS=vs17" >> $Env:GITHUB_ENV + echo "PHP_SDK_VS_NUM=17" >> $Env:GITHUB_ENV + echo "PHP_SDK_VS_SHELL_CMD=C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat amd64" >> $Env:GITHUB_ENV + + + $X_PATH = "${CURRENT_DIR}\var\windows-build-deps\php-sdk-binary-tools\bin;${CURRENT_DIR}\var\windows-build-deps\php-sdk-binary-tools\msys2\usr\bin;${CURRENT_DIR}\bin\runtime\nasm\;$env:PATH" + echo $X_PATH + echo "PATH=$X_PATH" >> $Env:GITHUB_ENV + + - name: show deps soft + if: 1 + run: | + $CURRENT_DIR = Get-Location + where perl + php -v + perl -v + nasm -v + where bison.exe + where re2c.exe + + - name: php prepare + shell: cmd + run: | + cd var\windows-build-deps\php-src\ + .\buildconf.bat -f + + - name: php config + shell: cmd + run: | + cd var\windows-build-deps\php-src\ + configure.bat ^ + --disable-all --disable-cgi --enable-cli ^ + --enable-sockets --enable-ctype --enable-pdo --enable-phar ^ + --enable-filter ^ + --enable-xmlreader --enable-xmlwriter ^ + --enable-tokenizer + + - name: php build + shell: cmd + run: | + cd var\windows-build-deps\php-src\ + nmake /E + + - name: Show Build Result + run: | + cd var\windows-build-deps\php-src\ + + .\x64\Release_TS\php.exe -v + .\x64\Release_TS\php.exe -m + dumpbin /DEPENDENTS ".\x64\Release_TS\php.exe" + + - name: production artifacts + uses: actions/upload-artifact@v4 + with: + name: php-cli-v${{ env.BUILD_PHP_VERSION }}-vs16-x64 + retention-days: 90 + path: "var/windows-build-deps/php-src/x64/Release_TS/php.exe" + + - name: gh release + uses: softprops/action-gh-release@v2 + if: ${{ 0 && startsWith(github.ref, 'refs/tags/') }} + with: + files: "var/windows-build-deps/php-src/x64/Release_TS/php.exe" diff --git a/.github/workflows/windows-native.yml.bak b/.github/workflows/windows-native.yml.bak deleted file mode 100644 index ac6507cd2b..0000000000 --- a/.github/workflows/windows-native.yml.bak +++ /dev/null @@ -1,186 +0,0 @@ -name: build-php-cli-windows - -on: - push: - pull_request: - -env: - BUILD_PHP_VERSION: 8.2.13 - -jobs: - windows-native: - if: 0 - runs-on: windows-2022 - # windows-latest, windows-2022, windows-2019 - # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#choosing-github-hosted-runners - # https://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md - strategy: - matrix: - php-version: - # - "8.2.13" - # - "8.1.27" - - "8.3.3" - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-dotnet@v1 - - name: show environment info - run: | - git config --global core.autocrlf false - git config --global core.eol lf - env - ipconfig - uname -a - pwd - ipconfig /all - - - - name: set php version - # 参考文档: https://docs.github.com/zh/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell - shell: bash - run: | - echo "BUILD_PHP_VERSION=${{ matrix.php-version }}" >> $GITHUB_ENV - - - name: Prepare submodule - run: | - ipconfig /all - # git submodule update --init - - - uses: msys2/setup-msys2@v2 - # - uses: cygwin/cygwin-install-action@master - # with: - # platform: x86_64 - # packages: git curl wget zip unzip tar xz - # shell: C:\cygwin\bin\bash.exe --norc -eo pipefail -o igncr '{0}' - - - name: download source code - shell: msys2 {0} - run: | - bash sapi/quickstart/windows/native-build/msys2-install-soft.sh - bash sapi/quickstart/windows/native-build/msys2-download-vs.sh - bash sapi/quickstart/windows/native-build/msys2-download-source-code.sh - - - name: build - if: 0 - # shell: cmd - shell: C:\Windows\system32\cmd.EXE /D /E:ON /V:OFF /S /C "CALL "{0}"" - # shell: C:\Windows\system32\cmd.EXE /D /E:ON /V:ON /F:ON /S /C "CALL "{0}"" - # shell: C:\Windows\system32\cmd.EXE /E:ON /V:ON /F:ON /k "%1" %* - run: | - sapi\quickstart\windows\native-build\native-build-step-1.bat - sapi\quickstart\windows\native-build\native-build-step-2.bat - sapi\quickstart\windows\native-build\native-build-step-3.bat - sapi\quickstart\windows\native-build\native-build-step-4.bat - - - name: Configure build for amd64 - uses: ilammy/msvc-dev-cmd@v1.9.0 - with: - arch: amd64 - run: set - - - name: Display the path - shell: cmd - run: echo %PATH% - - - name: phpsdk init - shell: cmd - run: | - sapi\quickstart\windows\native-build\native-build-step-1.bat - - - name: php prepare - shell: cmd - run: | - sapi\quickstart\windows\native-build\native-build-step-2.bat - - - name: php config - shell: cmd - run: | - sapi\quickstart\windows\native-build\native-build-step-3.bat - - - name: php build - shell: cmd - run: | - sapi\quickstart\windows\native-build\native-build-step-4.bat - - - name: Compile Visual Studio project with MSBuild - shell: cmd - run: ${{ '"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" && msbuild' }} - working-directory: path/to/your/project - - - name: install VS2022 - if: 0 - shell: cmd - run: | - dir - VisualStudioSetup.exe /? - start /wait vs_buildtools.exe --norestart --force --passive --wait > nul - echo %errorlevel% - start /wait VisualStudioSetup.exe --locale en-US --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.Component.MSBuild --add Microsoft.VisualStudio.Component.Roslyn.Compiler --add Microsoft.Component.MSBuild --add Microsoft.VisualStudio.Component.CoreBuildTools --add Microsoft.VisualStudio.Workload.MSBuildTools --path install="D:\VS" --path cache="D:\VS\cache" --path shared="D:\VS\shared" --norestart --force --passive --wait > nul - echo %errorlevel% - - name: Configure - if: 0 - run: | - bash ./sapi/scripts/cygwin/cygwin-config.sh - - - name: Build - if: 0 - run: | - bash ./sapi/scripts/cygwin/cygwin-build.sh - - - name: Show Build Result - if: 0 - run: | - ./bin/php.exe -v - ./bin/php.exe -m - ./bin/php.exe --ri pdo_pgsql - ./bin/php.exe --ri swoole - ./bin/php.exe -r "echo PHP_VERSION;" - - - name: get app version with bash - if: 0 - # 参考 https://github.com/marketplace/actions/install-cygwin - shell: C:\cygwin\bin\bash.EXE --noprofile --norc -e -o pipefail -o igncr {0} - # shell: C:\cygwin\bin\bash.EXE --login --noprofile --norc -e -o pipefail -o igncr {0} - run: | - ./bin/php.exe -v | awk '{print $2}' - - APP_VERSION=$(./bin/php.exe -v | head -n 1 | awk '{print $2}') - echo $APP_VERSION - echo "APP_VERSION=${APP_VERSION}" >> $GITHUB_ENV - - - name: get app version with PowerShell - if: 0 - run: | - ./bin/php.exe -v - $cmdOutput=./bin/php.exe -v - $cmdOutput=$cmdOutput | select -first 1 - $cmdOutput -match "(\d{1,2}\.\d{1,2}\.\d{1,2})" - $CYGWIN_APP_VERSION=$Matches[1] - echo $CYGWIN_APP_VERSION - echo "CYGWIN_APP_VERSION=$CYGWIN_APP_VERSION" >> $Env:GITHUB_ENV - - # 参考 https://github.com/orgs/community/discussions/26641 - # echo "APP_VERSION=${APP_VERSION}" >> $Env:GITHUB_ENV - # echo "APP_VERSION=$APP_VERSION" | Out-File -FilePath $env:GITHUB_ENV -Append - # Add-Content -Path $env:GITHUB_ENV -Value "name=$value" - # Add-Content -Path $env:GITHUB_ENV -Value "APP_VERSION=$APP_VERSION" - - - name: Archive - if: 0 - run: | - bash ./sapi/scripts/cygwin/cygwin-archive.sh - - - name: production artifacts - if: 0 - uses: actions/upload-artifact@v4 - with: - name: php-cli-v${{ env.APP_VERSION }}-cygwin-x64 - retention-days: 90 - path: php-cli-v${{ env.APP_VERSION }}-cygwin-x64.zip - - - name: gh release - uses: softprops/action-gh-release@v2 - if: startsWith(github.ref, 'refs/tags/') - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - files: php-cli-v${{ env.APP_VERSION }}-cygwin-x64.zip diff --git a/.gitignore b/.gitignore index 43a85838d4..a1e2a89421 100644 --- a/.gitignore +++ b/.gitignore @@ -318,6 +318,7 @@ tmp-php.ini /ext/loader8 /ext/ds /ext/xlswriter +/ext/uuid /.phpunit.result.cache /samples/sfx/*.phar .php-cs-fixer.cache @@ -340,7 +341,6 @@ sapi/quickstart/git-proxy.sh .github/workflows/ !.github/workflows/*.yml Makefile.backup -Dockerfile-all-dependencies-alpine php.ini sapi/webUI/deploy.sh !sapi/webUI/public/data/.gitkeep @@ -353,3 +353,11 @@ ldflags.log cppflags.log libs.log .env +ext/apcu/ +ext/ssh2/ +LICENSE +swoole-cli-* +php-cli-* +php-fpm-* +!sapi/patches + diff --git a/README.md b/README.md index 59fdb89b56..103d755e53 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,9 @@ git clone -b main https://github.com/jingjingxyk/build-static-aria2.git cd build-static-aria2 bash setup-php-runtime.sh +# 或者使用镜像 +# 来自 https://www.swoole.com/download +bash setup-php-runtime.sh --mirror china php prepare.php +aria2 bash make-install-deps.sh bash make.sh all-library @@ -55,6 +58,42 @@ bash make.sh config bash make.sh build bash make.sh archive + + +``` + +## 快速准备运行环境 + +### linux + +如容器已经安装,可跳过执行安装 docker 命令 + +```bash + +sh sapi/quickstart/linux/install-docker.sh +sh sapi/quickstart/linux/run-alpine-container.sh +sh sapi/quickstart/linux/connection-swoole-cli-alpine.sh +sh sapi/quickstart/linux/alpine-init.sh + +# 使用镜像源安装 +sh sapi/quickstart/linux/install-docker.sh --mirror china +sh sapi/quickstart/linux/alpine-init.sh --mirror china + +``` + +### macos + +如 homebrew 已安装,可跳过执行安装 homebrew 命令 + +```bash + +bash sapi/quickstart/macos/install-homebrew.sh +bash sapi/quickstart/macos/macos-init.sh + +# 使用镜像源安装 +bash sapi/quickstart/macos/install-homebrew.sh --mirror china +bash sapi/quickstart/macos/macos-init.sh --mirror china + ``` ## 一条命令执行整个构建流程 diff --git a/build-release-example.sh b/build-release-example.sh index 732b1c0553..052d8c45bb 100644 --- a/build-release-example.sh +++ b/build-release-example.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash __DIR__=$( cd "$(dirname "$0")" @@ -40,7 +40,6 @@ esac IN_DOCKER=0 WITH_DOWNLOAD_BOX=0 -WITH_BUILD_CONTAINER=0 WITH_WEB_UI=0 WITH_HTTP_PROXY=0 WITH_PHP_COMPOSER=1 @@ -79,10 +78,6 @@ while [ $# -gt 0 ]; do WITH_DOWNLOAD_BOX=1 OPTIONS="${OPTIONS} --without-docker=1 --skip-download=1 --with-dependency-graph=1 " ;; - --build-contianer) - WITH_BUILD_CONTAINER=1 - OPTIONS="${OPTIONS} --without-docker=1 " - ;; --webui) WITH_WEB_UI=1 OPTIONS="${OPTIONS} --without-docker=1 --skip-download=1 --with-web-ui=1 " @@ -219,6 +214,7 @@ if [ ${WITH_PHP_COMPOSER} -eq 1 ]; then # composer update --profile --prefer-dist --no-dev --optimize-autoloader # composer install --no-interaction --no-autoloader --no-scripts --profile # --no-dev + composer install --no-interaction --no-autoloader --no-scripts --prefer-dist -vv --profile # --no-dev composer dump-autoload --optimize --profile @@ -226,8 +222,6 @@ if [ ${WITH_PHP_COMPOSER} -eq 1 ]; then fi # 可用配置参数 -# --with-swoole-pgsql=1 -# --with-libavif=1 # --with-global-prefix=/usr/local/swoole-cli # --with-dependency-graph=1 # --with-web-ui @@ -265,20 +259,12 @@ else fi if [ ${WITH_DOWNLOAD_BOX} -eq 1 ]; then - echo " please exec script: " - echo " bash sapi/download-box/download-box-batch-downloader.sh " - echo " bash sapi/download-box/download-box-init.sh " - exit 0 -fi - -if [ ${WITH_BUILD_CONTAINER} -eq 1 ]; then - echo " please exec script: " - if [ "$MIRROR" = 'china' ]; then - echo " bash sapi/multistage-build-dependencies-container/all-dependencies-build-container.sh --composer_mirror tencent --mirror ustc " - else - echo " bash sapi/multistage-build-dependencies-container/all-dependencies-build-container.sh " - fi - exit 0 + { + echo " please exec script: " + echo " bash sapi/download-box/download-box-batch-downloader.sh " + echo " bash sapi/download-box/download-box-init.sh " + exit 0 + } fi if [ ${WITH_WEB_UI} -eq 1 ]; then @@ -293,10 +279,9 @@ if [ "$OS" = 'linux' ] && [ ${IN_DOCKER} -eq 0 ]; then exit 0 fi -bash make-install-deps.sh +set -ue -# 兼容上一版本已构建完毕的依赖库 -# bash sapi/quickstart/mark-install-library-cached.sh +bash make-install-deps.sh bash make.sh all-library @@ -309,18 +294,14 @@ bash make.sh archive exit 0 # 例子 -# bash build-release.sh --mirror china -# bash build-release.sh --mirror china --debug +# bash build-release-php.sh --mirror china +# bash build-release-php.sh --mirror china --debug # 例子 download-box -# bash build-release.sh --mirror china --download-box +# bash build-release-php.sh --mirror china --download-box # bash sapi/download-box/download-box-init.sh --proxy http://192.168.3.26:8015 -# 例子 build-contianer -# bash build-release.sh --mirror china --build-contianer -# bash sapi/multistage-build-dependencies-container/all-dependencies-build-container.sh --composer_mirror tencent --mirror ustc - # 例子 web ui -# bash build-release.sh --mirror china --webui +# bash build-release-php.sh --mirror china --webui # bash sapi/webUI/webui-init-data.sh # php sapi/webUI/bootstrap.php diff --git a/diff.php b/diff.php index b8a1d3fac7..cae604d8c4 100755 --- a/diff.php +++ b/diff.php @@ -18,8 +18,7 @@ ->remove('core'); ob_start(); -require_once __DIR__ . '/sapi/scripts/DownloadPHPSourceCode.php'; -$php_source_folder = PHP_SRC_DIR; +$php_source_folder = require_once __DIR__ . '/sapi/scripts/download-php-src-archive.php'; ob_end_clean(); $list_php_src = swoole_string(`ls -1 {$php_source_folder}/ext/`)->trim()->lower()->split(PHP_EOL) diff --git a/docs/Cygwin.md b/docs/Cygwin.md index fccdf87601..5fd4679cab 100755 --- a/docs/Cygwin.md +++ b/docs/Cygwin.md @@ -12,21 +12,43 @@ > 命令行同时安装多个包,包名之间使用逗号隔开 +## windows 环境下 配置 git 环境 + +1. 禁止Git在提交和检出时进行换行符的自动转换‌ +2. 使用`lf` 作为换行符 +3. 区分大小写 + +```shell + +# 下载git +curl.exe -fSLo Git-2.47.1-64-bit.exe https://github.com/git-for-windows/git/releases/download/v2.47.1.windows.1/Git-2.47.1-64-bit.exe + +# 命令行静默安装 git +start /wait .\Git-2.47.1-64-bit.exe /VERYSILENT /NORESTART /NOCANCEL /SP- /CLOSEONEXIT=1 /DIR="C:\Program Files\Git" + + +git config --global core.autocrlf false +git config --global core.eol lf +git config --global core.ignorecase false + +``` + ## 安装cygwin 和 cygwin 依赖项 -> 打开 windows 控制台,并找到 setup-x86_64.exe 所在目录, 将 setup-x86_64.exe 复制到 `sapi\quickstart\windows\` 目录 -> 执行如下命令 +> 打开windows CMD 终端,进入项目目录 ,执行如下命令 ```bash # 自动安装 cygwin 和 cygwin 依赖项 -sapi\quickstart\windows\install-cygwin.bat +.\sapi\quickstart\windows\cygwin-build\download-cygwin.bat +.\sapi\quickstart\windows\cygwin-build\install-cygwin.bat + ``` 构建步骤 - 执行的命令 ==== -> 运行如下步骤,需要先 打开 cygwin64 Terminal +> 运行如下步骤,打开 cygwin64 Terminal, 并进入项目目录,执行如下命令 ```shell @@ -116,19 +138,22 @@ libpq-devel (如果编译pgsql扩展) libpq5 (如果编译pgsql扩展) libicu-devel icu +libzstd-devel ``` ## 安装 cygwin 和 安装 cygwin 依赖项 具体执行的命令 -> `sapi\quickstart\windows\install-cygwin.bat` 脚本包含的内容 +> 多个包之间 使用逗号分隔 + +> 编辑修改此文件即可 `.\sapi\quickstart\windows\cygwin-build\install-cygwin.bat` ```bash # 安装 cygwin -setup-x86_64.exe --site https://mirrors.ustc.edu.cn/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 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 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 diff --git a/docs/extensions.md b/docs/extensions.md index d642f466ce..e472a0bc37 100644 --- a/docs/extensions.md +++ b/docs/extensions.md @@ -42,14 +42,16 @@ | gd | ✅ | ✅ | ✅ | ✅ | | opcache | ✅ | ✅ | ✅ | ✅ | | swoole | ✅ | ✅ | ✅ | ✅ | -| mongodb | ✅ | ❌ | ❌ | ✅ | -| ssh2 | ✅ | ✅ | ❌ | ❌ | -| apcu | ✅ | ✅ | ❌ | ❌ | -| ds | ✅ | ✅ | ✅ | ❌ | +| mongodb | ✅ | ✅ | ❌ | ✅ | +| ssh2 | ✅ | ✅ | ❌ | ✅ | +| apcu | ✅ | ✅ | ❌ | ✅ | +| ds | ✅ | ✅ | ✅ | ✅ | | inotify | ✅ | ❌ | ❌ | ❌ | | protobuf | ❌ | ❌ | ❌ | ❌ | -| uuid | ✅ | ✅ | ❌ | ❌ | +| uuid | ✅ | ✅ | ❌ | ✅ | | mailparse | ✅ | ✅ | ❌ | ❌ | +| gettext | ✅ | ❌ | ❌ | ❌ | +| xslwriter | ✅ | ✅ | ❌ | ✅ | ## 查看 新增的扩展 和 移除的扩展 diff --git a/docs/linux.md b/docs/linux.md index 01a69e5f5d..c6ed60fd91 100644 --- a/docs/linux.md +++ b/docs/linux.md @@ -3,38 +3,47 @@ ## 运行环境要求 1. 容器 docker 运行环境 +2. debian 系列 要求linux 内核大于 5.0 -构建步骤 - 运行命令 -==== +## linux 环境下构建 完整步骤 ```shell -git clone --recursive https://github.com/swoole/swoole-cli.git +git clone -b main https://github.com/swoole/swoole-cli.git cd swoole-cli +git submodule update --init -f -bash setup-php-runtime.sh -composer install --no-interaction --no-autoloader --no-scripts --profile -composer dump-autoload --optimize --profile - -# 生成构建脚本 make.sh -php prepare.php --without-docker --skip-download=1 -bash ./make.sh docker-build -bash ./make.sh docker-bash +bash sapi/quickstart/linux/install-docker.sh +bash sapi/quickstart/linux/run-alpine-container.sh +bash sapi/quickstart/linux/connection-swoole-cli-alpine.sh -# 准备bash 命令 sh sapi/quickstart/linux/alpine-init-minimal.sh - bash sapi/quickstart/linux/alpine-init.sh -# 进入容器后需要再一次执行此命令 -php prepare.php +inotify +apcu +ds +xlswriter +ssh2 +uuid +bash setup-php-runtime.sh + +__DIR__=$(pwd); +export PATH=${__DIR__}/bin/runtime/:$PATH +alias php="'${__DIR__}/bin/runtime/php -c ${__DIR__}/bin/runtime/php.ini'" + +composer install --no-interaction --no-autoloader --no-scripts --profile --no-dev +composer dump-autoload --optimize --profile --no-dev + +php prepare.php +apcu +ds +xlswriter +ssh2 +uuid bash make-install-deps.sh -bash ./make.sh all-library -bash ./make.sh config -bash ./make.sh build -bash ./make.sh archive +# 静态编译依赖库 +bash make.sh all-library + +# 静态编译 PHP 预处理 +bash make.sh config + +# 静态编译PHP (编译、汇编、链接) +bash make.sh build + +# 静态编译PHP (打包) +bash make.sh archive ./bin/swoole-cli -m ./bin/swoole-cli --ri swoole @@ -42,6 +51,51 @@ file ./bin/swoole-cli ``` +## 可使中国大陆软件镜像源命令脚本 + +```shell + +# 准备 docker 运行时 使用镜像 (镜像源 mirrors.tuna.tsinghua.edu.cn) +bash sapi/quickstart/linux/install-docker.sh --mirror china + +sh sapi/quickstart/linux/alpine-init-minimal.sh --mirror china + +bash sapi/quickstart/linux/alpine-init.sh --mirror china + +# 准备PHP 运行时 使用镜像 (镜像源 https://www.swoole.com/download) +bash setup-php-runtime.sh --mirror china + + + +``` + +## 可使用代理的命令脚本 + +```bash + +# 准备PHP 运行时 使用代理 +bash setup-php-runtime.sh --proxy http://192.168.3.26:8015 + +php prepare.php +apcu +ds +xlswriter +ssh2 +uuid --with-http-proxy=socks5h://127.0.0.1:2000 + +``` + + + +## 快速生成 构建脚本 make.sh (跳过下载依赖库源码) + +```shell + +# 生成构建脚本 make.sh +php prepare.php --without-docker --skip-download=1 +bash ./make.sh docker-build +bash ./make.sh docker-bash + +# 进入容器后需要再一次执行此命令 +php prepare.php +inotify +apcu +ds +xlswriter +ssh2 +uuid + +``` + 构建镜像 ==== `Linux` 下需要在容器中构建,因此需要先构建 `swoole-cli-builder:base` 基础镜像。 @@ -57,26 +111,7 @@ file ./bin/swoole-cli > 当 `C库` 变更时,应该修改 `swoole-cli-builder` 镜像的版本 > `make.sh build-all-library` 是可重入的,它会自动跳过已构建成功的库 -快速初始化构建环境 -==== - -跳过生成容器基础镜像 -使用如下命令快速进入容器环境 -便捷调整构建环境 -```bash -# 安装容器运行环境 -# bash sapi/quickstart/linux/install-docker.sh - -bash sapi/quickstart/linux/run-alpine-container.sh -bash sapi/quickstart/linux/alpine-init.sh - -# 使用镜像源 例子 -# bash sapi/quickstart/linux/install-docker.sh --mirror [ china | ustc | tuna ] -# bash sapi/quickstart/linux/alpine-init.sh --mirror [ china | ustc | tuna | tencentyun | huaweicloud ] -# bash sapi/quickstart/linux/alpine-init.sh --mirror china - -``` 构建 swoole-cli ==== diff --git a/docs/macOS.md b/docs/macOS.md index 81df28134f..f8141f4a9a 100644 --- a/docs/macOS.md +++ b/docs/macOS.md @@ -1,27 +1,50 @@ # macOS 环境下构建 swoole-cli -构建步骤 - 运行命令 -==== +## 构建准备 - 设置默认安装库目录的权限 ```shell -git clone --recursive https://github.com/swoole/swoole-cli.git +sudo mkdir -p /usr/local/swoole-cli +CURRENT_USER=$(whoami) && sudo chown -R ${CURRENT_USER}:staff /usr/local/swoole-cli + +``` + +## macos 环境下构建 完整步骤 + +```shell + +git clone -b main https://github.com/swoole/swoole-cli.git cd swoole-cli +git submodule update --init -f + +bash sapi/quickstart/macos/install-homebrew.sh +bash sapi/quickstart/macos/macos-init.sh 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 +apcu +ds +xlswriter +ssh2 +uuid +__DIR__=$(pwd); +export PATH=${__DIR__}/bin/runtime/:$PATH +alias php="'${__DIR__}/bin/runtime/php -c ${__DIR__}/bin/runtime/php.ini'" -bash sapi/quickstart/macos/macos-init.sh +composer install --no-interaction --no-autoloader --no-scripts --profile --no-dev +composer dump-autoload --optimize --profile --no-dev + +php prepare.php --without-docker=1 +apcu +ds +xlswriter +ssh2 +uuid bash make-install-deps.sh -bash ./make.sh all-library -bash ./make.sh config -bash ./make.sh build -bash ./make.sh archive +# 静态编译依赖库 +bash make.sh all-library + +# 静态编译 PHP 预处理 +bash make.sh config + +# 静态编译PHP (编译、汇编、链接) +bash make.sh build + +# 静态编译PHP (打包) +bash make.sh archive + ./bin/swoole-cli -m ./bin/swoole-cli --ri swoole @@ -31,37 +54,51 @@ otool -L ./bin/swoole-cli ``` -构建步骤简述 -==== +## 可使中国大陆软件镜像源命令脚本 -0. 清理 `brew` 安装的软件 -1. 执行 `php prepare.php --without-docker=1 @macos` 生成构建shell 脚本 -2. 编译所有依赖的库 `./make.sh all-library` -3. 配置 `./make.sh config` -4. 构建 `./make.sh build` +```shell + +sh sapi/quickstart/macos/install-homebrew.sh --mirror china + +sh sapi/quickstart/macos/macos-init.sh --mirror china -## 快速 初始化macos 构建环境 +# 准备PHP 运行时 使用镜像 (镜像源 https://www.swoole.com/download) +bash setup-php-runtime.sh --mirror china + + +``` -运行此命令解决构建过程中遇到的绝大部分问题 -如`homebrew`已安装,跳过执行此命令`bash sapi/quickstart/macos/install-homebrew.sh` +## 可使用代理的命令脚本 ```bash +# 准备PHP 运行时 使用代理 +bash setup-php-runtime.sh --proxy http://192.168.3.26:8015 -bash sapi/quickstart/macos/install-homebrew.sh -bash sapi/quickstart/macos/macos-init.sh +php prepare.php --without-docker=1 +apcu +ds +xlswriter +ssh2 +uuid --with-http-proxy=socks5h://127.0.0.1:2000 + +``` -# 使用homebrew镜像源 -# bash sapi/quickstart/macos/install-homebrew.sh --mirror ustc -# bash sapi/quickstart/macos/macos-init.sh --mirror ustc +## 准备依赖库源码 -# 设置默认安装库目录的权限 -CURRENT_USER=$(whoami) -sudo mkdir -p /usr/local/swoole-cli -CURRENT_USER=$(whoami) && sudo chown -R ${CURRENT_USER}:staff /usr/local/swoole-cli +> 源码来源: https://github.com/swoole/swoole-cli/releases/download/${TAG}/all-deps.zip + +```bash + +bash sapi/download-box/download-box-get-archive-from-server.sh + +bash sapi/download-box/download-box-get-archive-from-server.sh --mirror china ``` +## 构建步骤简述 + +0. 清理 `brew` 安装的软件 +1. 执行 `php prepare.php --without-docker=1 @macos` 生成构建shell 脚本 +2. 编译所有依赖的库 `./make.sh all-library` +3. 配置 `./make.sh config` +4. 构建 `./make.sh build` + ## 清理 使用 `brew` 安装的库可能会干扰 `swoole-cli` 的编译,必须要在构建之前将关联的软件进行卸载。在构建完成后再重新安装。 @@ -88,7 +125,9 @@ brew install wget curl libtool automake re2c llvm flex bison brew install gettext coreutils binutils libunistring -export PATH=/usr/local/opt/bison/bin:/usr/local/opt/llvm/bin:$PATH +HOMEBREW_PREFIX=$(brew --prefix) + +export PATH=${HOMEBREW_PREFIX}/opt/bison/bin:${HOMEBREW_PREFIX}/opt/llvm/bin:$PATH ``` diff --git a/docs/options.md b/docs/options.md index e1904025eb..5c84e4641b 100644 --- a/docs/options.md +++ b/docs/options.md @@ -26,7 +26,8 @@ SWOOLE_CLI_SKIP_DOWNLOAD=yes ./prepare.php --without-docker ``` > -参数设置优先于环境变量,当同时使用相同名称的参数设置和环境变量时,环境变量将被忽略,仅参数设置生效,例如:`SWOOLE_CLI_SKIP_DOWNLOAD=yes ./prepare.php --skip-download=no` +参数设置优先于环境变量,当同时使用相同名称的参数设置和环境变量时,环境变量将被忽略,仅参数设置生效,例如: +`SWOOLE_CLI_SKIP_DOWNLOAD=yes ./prepare.php --skip-download=no` ,有效的值为:`--skip-download=no`,环境变量 `SWOOLE_CLI_SKIP_DOWNLOAD=yes` 无效 @@ -212,7 +213,7 @@ php ./prepare.php --with-libavif=1 ``` show-tarball-hash ---- +---- 计算并显示已下载的源码包 HASH 值 @@ -223,3 +224,12 @@ with-build-shared-lib ```shell php ./prepare.php --with-build-shared-lib=1 ``` + +with-libavif +---- +GD库支持 AVIF图片格式 + +with-iouring +---- +swoole 启用支持 iouring 特性 + diff --git a/docs/upgrade.md b/docs/upgrade.md index 12a359c29f..3bfdf1b285 100644 --- a/docs/upgrade.md +++ b/docs/upgrade.md @@ -12,4 +12,12 @@ php sync-source-code.php php sync-source-code.php --action run +./bin/runtime/php -c ./bin/runtime/php.ini sync-source-code.php +./bin/runtime/php -c ./bin/runtime/php.ini sync-source-code.php --action run + ``` + +## 目录说明 + + pool :持久化目录,存放扩展、 PHP 、依赖库等文件,此目录下的文件不会被主动删除 + var :运行时目录,临时存在一些文件,在完成配置或构建后将被主动清空删除 diff --git a/prepare.php b/prepare.php index e2abf48899..2b2352c880 100755 --- a/prepare.php +++ b/prepare.php @@ -2,6 +2,7 @@ require __DIR__ . '/vendor/autoload.php'; +use SwooleCli\Exception; use SwooleCli\Preprocessor; use SwooleCli\Library; @@ -16,6 +17,7 @@ $p->setBuildType($buildType); } + # clean # clean old make.sh $p->cleanFile(__DIR__ . '/make.sh'); @@ -30,9 +32,9 @@ # PHP 默认版本 (此文件配置 /sapi/PHP-VERSION.conf 在 build_native_php分支 和 衍生分支 无效) -$php_version = '8.2.13'; -$php_version_id = '802013'; -$php_version_tag = 'php-8.2.13'; +$php_version = '8.2.27'; +$php_version_id = '802027'; +$php_version_tag = 'php-8.2.27'; if ($p->getInputOption('with-php-version')) { $subject = $p->getInputOption('with-php-version'); @@ -128,41 +130,25 @@ if ($p->isMacos()) { + //$p->setExtraLdflags('-undefined dynamic_lookup'); + //$p->setExtraLdflags(' -framework CoreFoundation'); + $p->setExtraLdflags(' '); + $homebrew_prefix = trim(shell_exec('brew --prefix')); + $p->withBinPath($homebrew_prefix . '/opt/llvm/bin') + ->withBinPath($homebrew_prefix . '/opt/flex/bin') + ->withBinPath($homebrew_prefix . '/opt/bison/bin') + ->withBinPath($homebrew_prefix . '/opt/libtool/bin') + ->withBinPath($homebrew_prefix . '/opt/m4/bin') + ->withBinPath($homebrew_prefix . '/opt/automake/bin/') + ->withBinPath($homebrew_prefix . '/opt/autoconf/bin/') + ->withBinPath($homebrew_prefix . '/opt/gettext/bin') + ->setLinker('ld64.lld'); + $p->setLogicalProcessors('$(sysctl -n hw.ncpu)'); } else { $p->setLogicalProcessors('$(nproc 2> /dev/null)'); } -if ($p->isMacos()) { - // -lintl -Wl,-framework -Wl,CoreFoundation - //$p->setExtraLdflags('-framework CoreFoundation -framework SystemConfiguration -undefined dynamic_lookup'); - - $p->setExtraLdflags('-undefined dynamic_lookup'); - if (is_file('/usr/local/opt/llvm/bin/ld64.lld')) { - $p->withBinPath('/usr/local/opt/llvm/bin') - ->withBinPath('/usr/local/opt/flex/bin') - ->withBinPath('/usr/local/opt/bison/bin') - ->withBinPath('/usr/local/opt/libtool/bin') - ->withBinPath('/usr/local/opt/m4/bin') - ->withBinPath('/usr/local/opt/automake/bin/') - ->withBinPath('/usr/local/opt/autoconf/bin/') - ->setLinker('ld64.lld'); - } elseif (is_file('/opt/homebrew/opt/llvm/bin/ld64.lld')) { //兼容 macos arm64 - $p->withBinPath('/opt/homebrew/opt/llvm/bin/') - ->withBinPath('/opt/homebrew/opt/flex/bin') - ->withBinPath('/opt/homebrew/opt/bison/bin') - ->withBinPath('/opt/homebrew/opt/libtool/bin') - ->withBinPath('/opt/homebrew/opt/m4/bin') - ->withBinPath('/opt/homebrew/opt/automake/bin/') - ->withBinPath('/opt/homebrew/opt/autoconf/bin/') - ->setLinker('ld64.lld'); - } else { - $p->setLinker('lld'); - } -} else { - $p->setLinker('ld.lld'); -} - $c_compiler = $p->getInputOption('with-c-compiler'); if ($c_compiler == 'gcc') { @@ -171,6 +157,7 @@ $p->setLinker('ld'); } + if ($p->getInputOption('with-build-shared-lib')) { define('BUILD_SHARED_LIBS', true); define('BUILD_STATIC_LIBS', false); @@ -221,7 +208,7 @@ #$p->setExtraCflags('-fno-ident -Os'); -$p->setExtraCflags(' -Os'); +$p->setExtraCflags(' -Os -fno-openmp'); // Generate make.sh @@ -236,3 +223,4 @@ function install_libraries(Preprocessor $p): void # $p->loadDependentLibrary('php'); } + diff --git a/run-tests.php b/run-tests.php index b718246654..39621a39aa 100755 --- a/run-tests.php +++ b/run-tests.php @@ -103,12 +103,12 @@ function show_usage(): void Do not delete 'all' files, 'php' test file, 'skip' or 'clean' file. - --set-timeout [n] - Set timeout for individual tests, where [n] is the number of + --set-timeout + Set timeout for individual tests, where is the number of seconds. The default value is 60 seconds, or 300 seconds when testing for memory leaks. - --context [n] + --context Sets the number of lines of surrounding context to print for diffs. The default value is 3. @@ -119,8 +119,8 @@ function show_usage(): void 'mem'. The result types get written independent of the log format, however 'diff' only exists when a test fails. - --show-slow [n] - Show all tests that took longer than [n] milliseconds to run. + --show-slow + Show all tests that took longer than milliseconds to run. --no-clean Do not execute clean section if any. @@ -530,7 +530,11 @@ function main(): void $just_save_results = true; break; case '--set-timeout': - $environment['TEST_TIMEOUT'] = $argv[++$i]; + $timeout = $argv[++$i] ?? ''; + if (!preg_match('/^\d+$/', $timeout)) { + error("'$timeout' is not a valid number of seconds, try e.g. --set-timeout 60 for 1 minute"); + } + $environment['TEST_TIMEOUT'] = intval($timeout, 10); break; case '--context': $context_line_count = $argv[++$i] ?? ''; @@ -545,7 +549,11 @@ function main(): void } break; case '--show-slow': - $slow_min_ms = $argv[++$i]; + $slow_min_ms = $argv[++$i] ?? ''; + if (!preg_match('/^\d+$/', $slow_min_ms)) { + error("'$slow_min_ms' is not a valid number of milliseconds, try e.g. --show-slow 1000 for 1 second"); + } + $slow_min_ms = intval($slow_min_ms, 10); break; case '--temp-source': $temp_source = $argv[++$i]; @@ -574,9 +582,10 @@ function main(): void $environment['SKIP_PERF_SENSITIVE'] = 1; if ($switch === '--msan') { $environment['SKIP_MSAN'] = 1; + $environment['MSAN_OPTIONS'] = 'intercept_tls_get_addr=0'; } - $lsanSuppressions = __DIR__ . '/azure/lsan-suppressions.txt'; + $lsanSuppressions = __DIR__ . '/.github/lsan-suppressions.txt'; if (file_exists($lsanSuppressions)) { $environment['LSAN_OPTIONS'] = 'suppressions=' . $lsanSuppressions . ':print_suppressions=0'; @@ -1275,6 +1284,10 @@ function system_with_timeout( } $timeout = $valgrind ? 300 : ($env['TEST_TIMEOUT'] ?? 60); + /* ASAN can cause a ~2-3x slowdown. */ + if (isset($env['SKIP_ASAN'])) { + $timeout *= 3; + } while (true) { /* hide errors from interrupted syscalls */ @@ -1575,6 +1588,10 @@ function run_all_tests_parallel(array $test_files, array $env, $redir_tested): v kill_children($workerProcs); error("Could not find worker stdout in array of worker stdouts, THIS SHOULD NOT HAPPEN."); } + if (feof($workerSock)) { + kill_children($workerProcs); + error("Worker $i died unexpectedly"); + } while (false !== ($rawMessage = fgets($workerSock))) { // work around fgets truncating things if (($rawMessageBuffers[$i] ?? '') !== '') { @@ -1873,6 +1890,9 @@ function run_test(string $php, $file, array $env): string $skipCache = new SkipCache($enableSkipCache, $cfg['keep']['skip']); } + $retried = false; +retry: + $temp_filenames = null; $org_file = $file; $orig_php = $php; @@ -1917,8 +1937,10 @@ function run_test(string $php, $file, array $env): string $tested = $test->getName(); - if ($num_repeats > 1 && $test->hasSection('FILE_EXTERNAL')) { - return skip_test($tested, $tested_file, $shortname, 'Test with FILE_EXTERNAL might not be repeatable'); + if ($test->hasSection('FILE_EXTERNAL')) { + if ($num_repeats > 1) { + return skip_test($tested, $tested_file, $shortname, 'Test with FILE_EXTERNAL might not be repeatable'); + } } if ($test->hasSection('CAPTURE_STDIO')) { @@ -1966,15 +1988,11 @@ function run_test(string $php, $file, array $env): string } } - if ($num_repeats > 1) { - if ($test->hasSection('CLEAN')) { - return skip_test($tested, $tested_file, $shortname, 'Test with CLEAN might not be repeatable'); - } - if ($test->hasSection('STDIN')) { - return skip_test($tested, $tested_file, $shortname, 'Test with STDIN might not be repeatable'); - } - if ($test->hasSection('CAPTURE_STDIO')) { - return skip_test($tested, $tested_file, $shortname, 'Test with CAPTURE_STDIO might not be repeatable'); + foreach (['CLEAN', 'STDIN', 'CAPTURE_STDIO'] as $section) { + if ($test->hasSection($section)) { + if ($num_repeats > 1) { + return skip_test($tested, $tested_file, $shortname, "Test with $section might not be repeatable"); + } } } @@ -2085,11 +2103,19 @@ function run_test(string $php, $file, array $env): string $ini_settings = $workerID ? ['opcache.cache_id' => "worker$workerID"] : []; // Additional required extensions + $extensions = []; if ($test->hasSection('EXTENSIONS')) { + $extensions = preg_split("/[\n\r]+/", trim($test->getSection('EXTENSIONS'))); + } + if (is_array($IN_REDIRECT) && $IN_REDIRECT['EXTENSIONS'] != []) { + $extensions = array_merge($extensions, $IN_REDIRECT['EXTENSIONS']); + } + + /* Load required extensions */ + if ($extensions != []) { $ext_params = []; settings2array($ini_overwrites, $ext_params); $ext_params = settings2params($ext_params); - $extensions = preg_split("/[\n\r]+/", trim($test->getSection('EXTENSIONS'))); [$ext_dir, $loaded] = $skipCache->getExtensions("$orig_php $pass_options $extra_options $ext_params $no_file_cache"); $ext_prefix = IS_WINDOWS ? "php_" : ""; $missing = []; @@ -2145,8 +2171,10 @@ function run_test(string $php, $file, array $env): string $ini = preg_replace('/{MAIL:(\S+)}/', $replacement, $ini); settings2array(preg_split("/[\n\r]+/", $ini), $ini_settings); - if ($num_repeats > 1 && isset($ini_settings['opcache.opt_debug_level'])) { - return skip_test($tested, $tested_file, $shortname, 'opt_debug_level tests are not repeatable'); + if (isset($ini_settings['opcache.opt_debug_level'])) { + if ($num_repeats > 1) { + return skip_test($tested, $tested_file, $shortname, 'opt_debug_level tests are not repeatable'); + } } } @@ -2241,6 +2269,7 @@ function run_test(string $php, $file, array $env): string $IN_REDIRECT['via'] = "via [$shortname]\n\t"; $IN_REDIRECT['dir'] = realpath(dirname($file)); $IN_REDIRECT['prefix'] = $tested; + $IN_REDIRECT['EXTENSIONS'] = $extensions; if (!empty($IN_REDIRECT['TESTS'])) { if (is_array($org_file)) { @@ -2671,6 +2700,9 @@ function run_test(string $php, $file, array $env): string } elseif ($test->hasSection('XLEAK')) { $warn = true; $info = " (warn: XLEAK section but test passes)"; + } elseif ($retried) { + $warn = true; + $info = " (warn: Test passed on retry attempt)"; } else { show_result("PASS", $tested, $tested_file, '', $temp_filenames); $junit->markTestAs('PASS', $shortname, $tested); @@ -2700,6 +2732,9 @@ function run_test(string $php, $file, array $env): string } elseif ($test->hasSection('XLEAK')) { $warn = true; $info = " (warn: XLEAK section but test passes)"; + } elseif ($retried) { + $warn = true; + $info = " (warn: Test passed on retry attempt)"; } else { show_result("PASS", $tested, $tested_file, '', $temp_filenames); $junit->markTestAs('PASS', $shortname, $tested); @@ -2710,6 +2745,10 @@ function run_test(string $php, $file, array $env): string $wanted_re = null; } + if (!$passed && !$retried && error_may_be_retried($test, $output)) { + $retried = true; + goto retry; + } // Test failed so we need to report details. if ($failed_headers) { @@ -2834,6 +2873,46 @@ function run_test(string $php, $file, array $env): string return $restype[0] . 'ED'; } +function is_flaky(TestFile $test): bool +{ + if ($test->hasSection('FLAKY')) { + return true; + } + if (!$test->hasSection('FILE')) { + return false; + } + $file = $test->getSection('FILE'); + $flaky_functions = [ + 'disk_free_space', + 'hrtime', + 'microtime', + 'sleep', + 'usleep', + ]; + $regex = '(\b(' . implode('|', $flaky_functions) . ')\()i'; + return preg_match($regex, $file) === 1; +} + +function is_flaky_output(string $output): bool +{ + $messages = [ + '404: page not found', + 'address already in use', + 'connection refused', + 'deadlock', + 'mailbox already exists', + 'timed out', + ]; + $regex = '(\b(' . implode('|', $messages) . ')\b)i'; + return preg_match($regex, $output) === 1; +} + +function error_may_be_retried(TestFile $test, string $output): bool +{ + return is_flaky_output($output) + || is_flaky($test); +} + /** * @return bool|int */ @@ -3395,6 +3474,9 @@ class JUnit 'execution_time' => 0, ]; + /** + * @throws Exception + */ public function __construct(array $env, int $workerID) { // Check whether a junit log is wanted. @@ -3612,6 +3694,9 @@ public function initSuite(string $suite_name): void $this->suites[$suite_name] = self::EMPTY_SUITE + ['name' => $suite_name]; } + /** + * @throws Exception + */ public function stopTimer(string $file_name): void { if (!$this->enabled) { @@ -3809,8 +3894,12 @@ class TestFile 'INI', 'ENV', 'EXTENSIONS', 'SKIPIF', 'XFAIL', 'XLEAK', 'CLEAN', 'CREDITS', 'DESCRIPTION', 'CONFLICTS', 'WHITESPACE_SENSITIVE', + 'FLAKY', ]; + /** + * @throws BorkageException + */ public function __construct(string $fileName, bool $inRedirect) { $this->fileName = $fileName; @@ -3851,6 +3940,9 @@ public function sectionNotEmpty(string $name): bool return !empty($this->sections[$name]); } + /** + * @throws Exception + */ public function getSection(string $name): string { if (!isset($this->sections[$name])) { @@ -3866,7 +3958,7 @@ public function getName(): string public function isCGI(): bool { - return $this->sectionNotEmpty('CGI') + return $this->hasSection('CGI') || $this->sectionNotEmpty('GET') || $this->sectionNotEmpty('POST') || $this->sectionNotEmpty('GZIP_POST') @@ -3887,6 +3979,7 @@ public function setSection(string $name, string $value): void /** * Load the sections of the test file + * @throws BorkageException */ private function readFile(): void { @@ -3949,6 +4042,9 @@ private function readFile(): void fclose($fp); } + /** + * @throws BorkageException + */ private function validateAndProcess(bool $inRedirect): void { // the redirect section allows a set of tests to be reused outside of diff --git a/sapi/multistage-build-dependencies-container/Dockerfile-all-dependencies-alpine b/sapi/build-dependencies-container/Dockerfile-all-dependencies-alpine similarity index 100% rename from sapi/multistage-build-dependencies-container/Dockerfile-all-dependencies-alpine rename to sapi/build-dependencies-container/Dockerfile-all-dependencies-alpine diff --git a/sapi/multistage-build-dependencies-container/README.md b/sapi/build-dependencies-container/README.md similarity index 83% rename from sapi/multistage-build-dependencies-container/README.md rename to sapi/build-dependencies-container/README.md index 9762eae89d..425505de60 100644 --- a/sapi/multistage-build-dependencies-container/README.md +++ b/sapi/build-dependencies-container/README.md @@ -15,17 +15,17 @@ > 二者容器镜像是一样的 + + ## 执行构建依赖库容器 ```bash -bash build-release-example.sh --mirror china --build-contianer - -bash sapi/multistage-build-dependencies-container/all-dependencies-build-container.sh +bash sapi/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 sapi/build-dependencies-container/all-dependencies-build-container.sh --composer_mirror tencent --mirror ustc ``` @@ -33,7 +33,7 @@ bash sapi/multistage-build-dependencies-container/all-dependencies-build-contain ```bash -bash sapi/multistage-build-dependencies-container/all-dependencies-run-container-test.sh +bash sapi/build-dependencies-container/all-dependencies-run-container-test.sh # 新开终端进入容器 docker exec -it swoole-cli-alpine-dev sh @@ -45,7 +45,6 @@ sh build-release-example.sh --mirror china ``` ## 为了方便分发,把容器镜像导出为文件 - > 目的:节省网络传输流量 (容器镜像不压缩情况下,大小超过 1GB) > 构建加速建议: 使用 抢占式高配置云服务器 加速构建 diff --git a/sapi/multistage-build-dependencies-container/all-dependencies-build-container.sh b/sapi/build-dependencies-container/all-dependencies-build-container.sh similarity index 92% rename from sapi/multistage-build-dependencies-container/all-dependencies-build-container.sh rename to sapi/build-dependencies-container/all-dependencies-build-container.sh index 34ec5ac827..f418296414 100644 --- a/sapi/multistage-build-dependencies-container/all-dependencies-build-container.sh +++ b/sapi/build-dependencies-container/all-dependencies-build-container.sh @@ -29,10 +29,8 @@ TIME=$(date -u '+%Y%m%dT%H%M%SZ') VERSION="1.0.0" TAG="all-dependencies-alpine-3.18-php8-v${VERSION}-${ARCH}-${TIME}" -ALIYUN_IMAGE="registry.cn-beijing.aliyuncs.com/jingjingxyk-public/app:build-swoole-cli-${TAG}" -IMAGE="docker.io/phpswoole/swoole-cli-builder:${TAG}" IMAGE="docker.io/jingjingxyk/build-swoole-cli:${TAG}" - +IMAGE="docker.io/phpswoole/swoole-cli-builder:${TAG}" COMPOSER_MIRROR="" @@ -94,9 +92,6 @@ cd ${__PROJECT__}/ echo ${IMAGE} > ${__PROJECT__}/var/all-dependencies-container.txt -docker tag ${IMAGE} ${ALIYUN_IMAGE} - -# docker push ${ALIYUN_IMAGE} # docker push ${IMAGE} @@ -105,7 +100,6 @@ docker tag ${IMAGE} ${ALIYUN_IMAGE} # bash build-release.sh --mirror china --build-contianer # 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-image-to-file.sh b/sapi/build-dependencies-container/all-dependencies-image-to-file.sh similarity index 100% rename from sapi/multistage-build-dependencies-container/all-dependencies-image-to-file.sh rename to sapi/build-dependencies-container/all-dependencies-image-to-file.sh diff --git a/sapi/multistage-build-dependencies-container/all-dependencies-run-container-test.sh b/sapi/build-dependencies-container/all-dependencies-run-container-test.sh similarity index 99% rename from sapi/multistage-build-dependencies-container/all-dependencies-run-container-test.sh rename to sapi/build-dependencies-container/all-dependencies-run-container-test.sh index 9f26e4fd3b..ff75b72eb6 100644 --- a/sapi/multistage-build-dependencies-container/all-dependencies-run-container-test.sh +++ b/sapi/build-dependencies-container/all-dependencies-run-container-test.sh @@ -26,4 +26,3 @@ if test -f $IMAGE_FILE; then else echo 'no container image' fi - diff --git a/sapi/multistage-build-dependencies-container/php.ini b/sapi/build-dependencies-container/php.ini similarity index 100% rename from sapi/multistage-build-dependencies-container/php.ini rename to sapi/build-dependencies-container/php.ini diff --git a/sapi/docker/Dockerfile b/sapi/docker/Dockerfile index a38a98fde5..8a7fcc6681 100644 --- a/sapi/docker/Dockerfile +++ b/sapi/docker/Dockerfile @@ -15,9 +15,9 @@ RUN if [ "${MIRROR}" = "tuna" ]; then { sed -i 's/dl-cdn.alpinelinux.org/mirrors RUN apk update RUN apk upgrade -RUN apk add vim alpine-sdk xz autoconf automake linux-headers clang-dev clang lld libtool cmake bison re2c gettext coreutils +RUN apk add vim alpine-sdk xz autoconf automake linux-headers clang-dev clang lld libtool cmake bison re2c coreutils RUN apk add bash tini RUN apk add libc++-static libltdl-static -RUN apk add gettext-dev +RUN apk add gettext gettext-dev RUN apk add pigz parallel WORKDIR /work diff --git a/sapi/docker/build-export-container.sh b/sapi/docker/build-export-container.sh index 039fb89ae1..bef08e724d 100644 --- a/sapi/docker/build-export-container.sh +++ b/sapi/docker/build-export-container.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash : <<'COMMENT' @@ -18,6 +18,8 @@ __PROJECT__=$( cd ${__DIR__} cd ${__PROJECT__} +# alpine 基础镜像 支持多架构 + CONTAINER_BASE_IMAGE='docker.io/library/alpine:3.18' CONTAIENR_NAME='swoole-cli-builder' MIRROR='' @@ -40,10 +42,6 @@ while [ $# -gt 0 ]; do --mirror) MIRROR="$2" ;; - --quickstart-container) - CONTAIENR_NAME='swoole-cli-alpine-dev' - # 从quickstart 生成的容器中拷贝 /usr/local/swoole-cli/ 文件夹,并生成新容器镜像 - ;; --*) echo "Illegal option $1" ;; diff --git a/sapi/docker/database/my.cnf b/sapi/docker/database/my.cnf new file mode 100644 index 0000000000..d934c69412 --- /dev/null +++ b/sapi/docker/database/my.cnf @@ -0,0 +1,27 @@ + +[client] +default-character-set=utf8mb4 +[mysql] +default-character-set=utf8mb4 + +[mysqld] +skip_ssl +skip-ssl-session-cache-mode + +# bind-address = 0.0.0.0 +bind-address = 0.0.0.0 +# bind-address = :: + +# 跳过密码登录 +# skip-grant-tables + +collation-server = utf8mb4_unicode_ci +init-connect='SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci' +character-set-server = utf8mb4 +innodb_ft_min_token_size = 1 +ft_min_word_len = 1 +innodb_ft_enable_stopword = OFF +ft_stopword_file = '' + + + diff --git a/sapi/docker/database/start.sh b/sapi/docker/database/start.sh new file mode 100644 index 0000000000..2c7ed6787c --- /dev/null +++ b/sapi/docker/database/start.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) + +cd ${__DIR__} + +docker-compose -f docker-compose.yaml up -d +docker-compose -f docker-compose.yaml ps + +docker container ls -a + +# wait postgresql ready + +docker inspect --format='{{json .State.Status}}' "postgresql" + +# docker exec -i postgresql cat /usr/local/bin/docker-entrypoint.sh + +docker inspect --format="{{json .State.Health }}" "postgresql" + +PG_HEALTH_STATUS=$(docker inspect --format='{{json .State.Health.Status }}' 'postgresql' | tr -d "\"") + +until [ "${PG_HEALTH_STATUS}" = "healthy" ]; do + sleep 3 + PG_HEALTH_STATUS=$(docker inspect --format='{{json .State.Health.Status }}' 'postgresql' | tr -d "\"") +done + +while ! nc -z 127.0.0.1 5432; do sleep 1; done +echo "Can you connect to a PostgreSQL database." diff --git a/sapi/docker/gitea/README.md b/sapi/docker/gitea/README.md new file mode 100644 index 0000000000..bf11a9eb21 --- /dev/null +++ b/sapi/docker/gitea/README.md @@ -0,0 +1,15 @@ + + +install gitea with docker + +https://docs.gitea.com/zh-cn/installation/install-with-docker + + + +k8s 使用的端口 + +https://kubernetes.io/zh-cn/docs/reference/networking/ports-and-protocols/ + +不带选择器的服务 +Services without selectors +https://kubernetes.io/docs/concepts/services-networking/service/#services-without-selectors \ No newline at end of file diff --git a/sapi/docker/gitea/docker-compose.yml b/sapi/docker/gitea/docker-compose.yml new file mode 100644 index 0000000000..cf62375aab --- /dev/null +++ b/sapi/docker/gitea/docker-compose.yml @@ -0,0 +1,42 @@ +version: "3" + +networks: + gitea: + external: false + +services: + server: + image: docker.io/gitea/gitea:1.22.6 + container_name: gitea + environment: + - USER_UID=1000 + - USER_GID=1000 + - GITEA__database__DB_TYPE=postgres + - GITEA__database__HOST=db:5432 + - GITEA__database__NAME=gitea + - GITEA__database__USER=gitea + - GITEA__database__PASSWD=gitea + restart: always + networks: + - gitea + volumes: + - ./gitea:/data + - /etc/timezone:/etc/timezone:ro + - /etc/localtime:/etc/localtime:ro + ports: + - "33001:3000" + - "33002:22" + depends_on: + - db + + db: + image: docker.io/library/postgres:17 + restart: always + environment: + - POSTGRES_USER=gitea + - POSTGRES_PASSWORD=gitea + - POSTGRES_DB=gitea + networks: + - gitea + volumes: + - ./postgres:/var/lib/postgresql/data \ No newline at end of file diff --git a/sapi/download-box/download-box-batch-downloader.sh b/sapi/download-box/download-box-batch-downloader.sh index 5015c9f957..1b4314935e 100644 --- a/sapi/download-box/download-box-batch-downloader.sh +++ b/sapi/download-box/download-box-batch-downloader.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -exu __DIR__=$( @@ -33,8 +33,6 @@ while [ $# -gt 0 ]; do shift $(($# > 0 ? 1 : 0)) done - - DOWNLOAD_BOX_DIR=${__PROJECT__}/var/download-box/ mkdir -p ${__PROJECT__}/var/download-box/ @@ -42,8 +40,7 @@ cd ${__PROJECT__}/var/download-box/ mkdir -p lib mkdir -p ext - -if [ -f download_library_urls.txt ] && [ -f download_extension_urls.txt ] ; then +if [ -f download_library_urls.txt ] && [ -f download_extension_urls.txt ]; then echo 'downloading source code tarball ' else echo 'please run script : ' @@ -56,10 +53,8 @@ bash sapi/download-box/download-box-dependencies-use-aria2.sh cd ${__PROJECT__} bash sapi/download-box/download-box-dependencies-use-git.sh - - +bash sapi/download-box/download-dependencies-use-aria2.sh # 例子 # bash build-release.sh --mirror china --download-box # bash sapi/download-box/download-box-batch-downloader.sh - diff --git a/sapi/download-box/download-box-build.sh b/sapi/download-box/download-box-build.sh index fd885e93f8..3e91fa179b 100644 --- a/sapi/download-box/download-box-build.sh +++ b/sapi/download-box/download-box-build.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -exu __DIR__=$( @@ -24,10 +24,8 @@ cp -f ${__PROJECT__}/bin/LICENSE . cp -f ${__PROJECT__}/bin/credits.html . cp -f ${__PROJECT__}/bin/ext-dependency-graph.pdf . - cd "${DOWNLOAD_BOX_DIR}" - test -f all-deps.zip && rm -rf all-deps.zip test -d ext && test -d lib && zip -9 -r all-deps.zip ext lib @@ -41,5 +39,5 @@ IMAGE="docker.io/phpswoole/swoole-cli-builder:${TAG}" IMAGE="docker.io/jingjingxyk/build-swoole-cli:${TAG}" docker build -t ${IMAGE} -f ./Dockerfile-dowload-box . --progress=plain -echo ${IMAGE} > download-box.txt +echo ${IMAGE} >download-box.txt docker push ${IMAGE} diff --git a/sapi/download-box/download-box-dependencies-use-aria2.sh b/sapi/download-box/download-box-dependencies-use-aria2.sh index c430387cb1..67a12fa6de 100644 --- a/sapi/download-box/download-box-dependencies-use-aria2.sh +++ b/sapi/download-box/download-box-dependencies-use-aria2.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -exu __DIR__=$( @@ -11,7 +11,6 @@ __PROJECT__=$( ) cd ${__PROJECT__} - DOWNLOAD_BOX_DIR=${__PROJECT__}/var/download-box/ mkdir -p "${DOWNLOAD_BOX_DIR}" mkdir -p "${DOWNLOAD_BOX_DIR}/lib/" @@ -19,7 +18,6 @@ mkdir -p "${DOWNLOAD_BOX_DIR}/ext/" cd "${DOWNLOAD_BOX_DIR}" - # https://aria2.github.io/manual/en/html/aria2c.html#http-ftp-segmented-downloads # https://aria2.github.io/manual/en/html/aria2c.html # -with-config-file-path=/usr/local/php/etc @@ -40,13 +38,10 @@ user_agent='Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 ( # --user-agent=$user_agent +test -f download_library_urls.txt && aria2c -c -j 10 -s 10 -x 8 -k 10M --allow-overwrite=true --max-tries=30 --retry-wait=15 \ + -d lib --input-file=download_library_urls.txt -test -f download_library_urls.txt && aria2c -c -j 10 -s 10 -x 8 -k 10M --allow-overwrite=true --max-tries=30 --retry-wait=15 \ - -d lib --input-file=download_library_urls.txt - - -test -f download_extension_urls.txt && aria2c -c -j 10 -s 10 -x 8 -k 10M --allow-overwrite=true --max-tries=30 --retry-wait=15 --user-agent=$user_agent \ - -d ext --input-file=download_extension_urls.txt - +test -f download_extension_urls.txt && aria2c -c -j 10 -s 10 -x 8 -k 10M --allow-overwrite=true --max-tries=30 --retry-wait=15 --user-agent=$user_agent \ + -d ext --input-file=download_extension_urls.txt cd ${__PROJECT__} diff --git a/sapi/download-box/download-box-dependencies-use-git.sh b/sapi/download-box/download-box-dependencies-use-git.sh index 135e110507..6abd73a640 100644 --- a/sapi/download-box/download-box-dependencies-use-git.sh +++ b/sapi/download-box/download-box-dependencies-use-git.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -exu __DIR__=$( @@ -18,9 +18,7 @@ mkdir -p "${DOWNLOAD_BOX_DIR}/ext/" cd "${DOWNLOAD_BOX_DIR}" - test -f download_library_use_git.sh && bash download_library_use_git.sh test -f download_extension_use_git.sh && bash download_extension_use_git.sh cd ${__PROJECT__} - diff --git a/sapi/download-box/download-box-get-archive-from-container.sh b/sapi/download-box/download-box-get-archive-from-container.sh index d6d612811f..94b98a1ffc 100644 --- a/sapi/download-box/download-box-get-archive-from-container.sh +++ b/sapi/download-box/download-box-get-archive-from-container.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -exu __DIR__=$( @@ -15,14 +15,12 @@ test -d ${__PROJECT__}/var/download-box/ || mkdir -p ${__PROJECT__}/var/download cd ${__PROJECT__}/var/download-box/ - -TAG='download-box-nginx-alpine-1.7-20231016T112539Z' +TAG='download-box-nginx-alpine-1.8-20231113T173944Z' IMAGE="docker.io/phpswoole/swoole-cli-builder:${TAG}" IMAGE="docker.io/jingjingxyk/build-swoole-cli:${TAG}" cd ${__PROJECT__}/var/download-box/ - container_id=$(docker create $IMAGE) # returns container ID docker cp $container_id:/usr/share/nginx/html/ext ext docker cp $container_id:/usr/share/nginx/html/lib lib @@ -38,4 +36,3 @@ mkdir -p pool/ext awk 'BEGIN { cmd="cp -ri var/download-box/lib/* pool/lib" ; print "n" |cmd; }' awk 'BEGIN { cmd="cp -ri var/download-box/ext/* pool/ext"; print "n" |cmd; }' - 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 e01341b9d1..0498c5279f 100644 --- a/sapi/download-box/download-box-get-archive-from-server.sh +++ b/sapi/download-box/download-box-get-archive-from-server.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -exu __DIR__=$( @@ -11,28 +11,28 @@ __PROJECT__=$( ) cd ${__PROJECT__} -mkdir -p pool/lib -mkdir -p pool/ext +mkdir -p pool/lib +mkdir -p pool/ext mkdir -p ${__PROJECT__}/var/download-box/ cd ${__PROJECT__}/var/download-box/ -if [ -f "${__PROJECT__}/sapi/PHP-VERSION.conf" ] ; then - DOMAIN='https://github.com/swoole/swoole-cli/releases/download/v5.1.3.0/' - ALL_DEPS_HASH="5fa1485c2408f05cbc548712917e6dbb8ecd5a631b558d6d512d4a6671f071e5" +if [ -f "${__PROJECT__}/sapi/PHP-VERSION.conf" ]; then + DOMAIN='https://github.com/swoole/swoole-cli/releases/download/v6.0.0.0/' + ALL_DEPS_HASH="a55699ecee994032f33266dfa37eabb49f1f6d6b6b65cdcf7b881cac09c63bea" else - DOMAIN='https://github.com/swoole/build-static-php/releases/download/v1.3.2/' - ALL_DEPS_HASH="15769d1003213bf8849ac73bf96bc7629b138a694e8367fb2139756e20c2901d" + DOMAIN='https://github.com/swoole/build-static-php/releases/download/v1.6.0/' + ALL_DEPS_HASH="771f8c695477be93da10847f3051fb054f0f829b242300e1ae2126b67f338664" fi while [ $# -gt 0 ]; do case "$1" in --mirror) - if [ "$2" = 'china' ] ; then + if [ "$2" = 'china' ]; then DOMAIN='https://swoole-cli.jingjingxyk.com/' - if [ ! -f "${__PROJECT__}/sapi/PHP-VERSION.conf" ] ; then - DOMAIN='https://php-cli.jingjingxyk.com/' + if [ ! -f "${__PROJECT__}/sapi/PHP-VERSION.conf" ]; then + DOMAIN='https://php-cli.jingjingxyk.com/' fi fi ;; @@ -43,10 +43,9 @@ while [ $# -gt 0 ]; do shift $(($# > 0 ? 1 : 0)) done - URL="${DOMAIN}/all-deps.zip" -test -f all-deps.zip || curl -Lo all-deps.zip ${URL} +test -f all-deps.zip || curl -fSLo all-deps.zip ${URL} # https://www.runoob.com/linux/linux-comm-unzip.html # -o 不必先询问用户,unzip执行后覆盖原有文件。 @@ -56,13 +55,13 @@ test -f all-deps.zip || curl -Lo all-deps.zip ${URL} HASH=$(sha256sum all-deps.zip | awk '{print $1}') # 签名验证失败,删除下载文件 -if [ ${HASH} != ${ALL_DEPS_HASH} ] ; then - echo 'hash signature is invalid !' - rm -f all-deps.zip - echo ' ' - echo ' Please Download Again ' - echo ' ' - exit 0 +if [ ${HASH} != ${ALL_DEPS_HASH} ]; then + echo 'hash signature is invalid !' + rm -f all-deps.zip + echo ' ' + echo ' Please Download Again ' + echo ' ' + exit 0 fi unzip -n all-deps.zip diff --git a/sapi/download-box/download-box-init.sh b/sapi/download-box/download-box-init.sh index 7a44435b43..e47269082b 100644 --- a/sapi/download-box/download-box-init.sh +++ b/sapi/download-box/download-box-init.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -x __DIR__=$( @@ -30,6 +30,3 @@ sh sapi/scripts/generate-dependency-graph.sh awk 'BEGIN { cmd="cp -ri pool/lib/* var/download-box/lib/ " ; print "n" |cmd; }' awk 'BEGIN { cmd="cp -ri pool/ext/* var/download-box/ext/ " ; print "n" |cmd; }' - - - diff --git a/sapi/download-box/download-box-server-run-test.sh b/sapi/download-box/download-box-server-run-test.sh index 64b065c3a1..f44af354f5 100644 --- a/sapi/download-box/download-box-server-run-test.sh +++ b/sapi/download-box/download-box-server-run-test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -exu __DIR__=$( diff --git a/sapi/download-box/web-server-nginx.sh b/sapi/download-box/web-server-nginx.sh index a59f484a71..f100c13443 100644 --- a/sapi/download-box/web-server-nginx.sh +++ b/sapi/download-box/web-server-nginx.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -exu __DIR__=$( @@ -15,7 +15,6 @@ DOCUMENT_ROOT=${__PROJECT__}/pool/ IMAGE=nginx:alpine - { docker stop download-box-web-server sleep 5 @@ -23,10 +22,8 @@ IMAGE=nginx:alpine echo $? } - docker run -d --rm --name download-box-web-server \ --p 9503:80 \ --v ${DOCUMENT_ROOT}:/usr/share/nginx/html/ \ --v ${__DIR__}/default.conf:/etc/nginx/conf.d/default.conf \ -${IMAGE} - + -p 9503:80 \ + -v ${DOCUMENT_ROOT}:/usr/share/nginx/html/ \ + -v ${__DIR__}/default.conf:/etc/nginx/conf.d/default.conf \ + ${IMAGE} diff --git a/sapi/download-box/web-server.php b/sapi/download-box/web-server.php index 1223dd701f..2621a292b8 100644 --- a/sapi/download-box/web-server.php +++ b/sapi/download-box/web-server.php @@ -42,7 +42,7 @@ 'application/json' ], 'display_errors' => true, - 'daemonize' => false, + 'daemonize' => true, 'log_file' => "/tmp/swoole-cli-download-box-web.log" # 'ssl_cert_file' => __DIR__.'/config/ssl.crt', # 'ssl_key_file' => __DIR__.'/config/ssl.key', diff --git a/sapi/multistage-build-dependencies-container/setup-container-mirror.sh b/sapi/multistage-build-dependencies-container/setup-container-mirror.sh deleted file mode 100644 index a1714f309e..0000000000 --- a/sapi/multistage-build-dependencies-container/setup-container-mirror.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -set -exu -__DIR__=$( - cd "$(dirname "$0")" - pwd -) -__PROJECT__=$( - cd ${__DIR__}/../../ - pwd -) - -if [[ -f /.dockerenv ]]; then - echo 'no running in docker' - exit 0 -fi - -mkdir -p ${__PROJECT__}/var -cd ${__PROJECT__}/var - -if [[ ! -f all-dependencies-container.txt ]]; then - echo 'no all-dependencies-container.txt file' - exit 0 -fi - -IMAGE=$(cat all-dependencies-container.txt) - -MIRROR_IMAGE=$(echo ${IMAGE} | sed 's@docker.io/phpswoole/swoole-cli-builder@registry-vpc.cn-beijing.aliyuncs.com/jingjingxyk-public/app@') - -docker tag ${IMAGE} ${MIRROR_IMAGE} - -docker push ${MIRROR_IMAGE} diff --git a/sapi/musl-cross-make/config.mak b/sapi/musl-cross-make/config.mak deleted file mode 100644 index ac9d59a8c0..0000000000 --- a/sapi/musl-cross-make/config.mak +++ /dev/null @@ -1,91 +0,0 @@ -# -# config.mak.dist - sample musl-cross-make configuration -# -# Copy to config.mak and edit as desired. -# - -# There is no default TARGET; you must select one here or on the make -# command line. Some examples: - -# TARGET = i486-linux-musl -TARGET = x86_64-linux-musl -# TARGET = arm-linux-musleabi -# TARGET = arm-linux-musleabihf -# TARGET = sh2eb-linux-muslfdpic -# ... - -# By default, cross compilers are installed to ./output under the top-level -# musl-cross-make directory and can later be moved wherever you want them. -# To install directly to a specific location, set it here. Multiple targets -# can safely be installed in the same location. Some examples: - -# OUTPUT = /opt/cross - OUTPUT = /usr/local/swoole-cli/musl_cross_make/ - -# By default, latest supported release versions of musl and the toolchain -# components are used. You can override those here, but the version selected -# must be supported (under hashes/ and patches/) to work. For musl, you -# can use "git-refname" (e.g. git-master) instead of a release. Setting a -# blank version for gmp, mpc, mpfr and isl will suppress download and -# in-tree build of these libraries and instead depend on pre-installed -# libraries when available (isl is optional and not set by default). -# Setting a blank version for linux will suppress installation of kernel -# headers, which are not needed unless compiling programs that use them. - -# BINUTILS_VER = 2.25.1 -GCC_VER = 11.2.0 -# MUSL_VER = git-master -# GMP_VER = -# MPC_VER = -# MPFR_VER = -# ISL_VER = -# LINUX_VER = - -# By default source archives are downloaded with wget. curl is also an option. - -# DL_CMD = wget -c -O -DL_CMD = curl -C - -L -o - -# Check sha-1 hashes of downloaded source archives. On gnu systems this is -# usually done with sha1sum. - -# SHA1_CMD = sha1sum -c -# SHA1_CMD = sha1 -c -# SHA1_CMD = shasum -a 1 -c - -# Something like the following can be used to produce a static-linked -# toolchain that's deployable to any system with matching arch, using -# an existing musl-targeted cross compiler. This only works if the -# system you build on can natively (or via binfmt_misc and qemu) run -# binaries produced by the existing toolchain (in this example, i486). - -# COMMON_CONFIG += CC="i486-linux-musl-gcc -static --static" CXX="i486-linux-musl-g++ -static --static" -# COMMON_CONFIG += CC="x86_64-linux-musl-gcc -static --static" CXX="x86_64-linux-musl-g++ -static --static" -COMMON_CONFIG += CC="gcc -static --static" CXX="g++ -static --static" - -# Recommended options for smaller build for deploying binaries: - -# COMMON_CONFIG += CFLAGS="-g0 -Os" CXXFLAGS="-g0 -Os" LDFLAGS="-s" -COMMON_CONFIG += CFLAGS="-g0 -O3" CXXFLAGS="-g0 -O3" LDFLAGS="-s" - -# Options you can add for faster/simpler build at the expense of features: - -COMMON_CONFIG += --disable-nls -GCC_CONFIG += --disable-libquadmath --disable-decimal-float -GCC_CONFIG += --disable-libitm -GCC_CONFIG += --disable-fixed-point -GCC_CONFIG += --disable-lto -GCC_CONFIG += --enable-default-pie --enable-static-pie - -# By default C and C++ are the only languages enabled, and these are -# the only ones tested and known to be supported. You can uncomment the -# following and add other languages if you want to try getting them to -# work too. - -GCC_CONFIG += --enable-languages=c,c++ - -# You can keep the local build path out of your toolchain binaries and -# target libraries with the following, but then gdb needs to be told -# where to look for source files. - -# COMMON_CONFIG += --with-debug-prefix-map=$(CURDIR)= diff --git a/sapi/quickstart/README.md b/sapi/quickstart/README.md index 3310d403c0..1d599901e6 100644 --- a/sapi/quickstart/README.md +++ b/sapi/quickstart/README.md @@ -1,116 +1,44 @@ # 快速初始化构建环境 -## 一个脚本执行整个流程 +## 一个脚本执行整个构建流程 -> 定制 build-release.sh 即可开始构建 +> 定制 build-release-php.sh 脚本 即可开始构建 ```bash - cp build-release-example.sh build-release.sh +cp build-release-example.sh build-release-php.sh - bash build-release.sh +bash build-release-php.sh ``` -## 准备 PHP 运行时 +## [构建选项](../../docs/options.md) -```bash - -# 准备 PHP 运行时 -bash sapi/quickstart/setup-php-runtime.sh - -# 准备PHP 运行时 使用代理 (需提前准备好代理) -bash sapi/quickstart/setup-php-runtime.sh --proxy http://192.168.3.26:8015 - -# 准备PHP 运行时 使用镜像 (镜像源 https://www.swoole.com/download) -bash sapi/quickstart/setup-php-runtime.sh --mirror china - -# 容器内准备 PHP 运行时 -bash sapi/quickstart/setup-php-runtime-in-docker.sh - -# 验证 -php -v -composer -v - -``` - -## 准备依赖库源码,来自镜像 - -> 可能部分源码包没有及时更新 ,请提 issues -> 缺失的部分,下一步执行时会自动到源站下载 - -```bash - -bash sapi/download-box/download-box-get-archive-from-server.sh - -``` - -## 准备 swoole 源码 - -> 拉取 swoole-cli 源码时没有拉取子模块,就需要执行这一步 - -```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' +## [linux 环境下构建 完整步骤](../../docs/linux.md) -export COMPOSER_ALLOW_SUPERUSER=1 +## [macos 环境下构建 完整步骤](../../docs/macOS.md) -composer update --optimize-autoloader +## [cygwin](../../docs/Cygwin.md) -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 - -``` +## [wsl](../../docs/wsl.md) ## 准备运行环境 (linux/macos/windows) 1. [ linux 快速启动 容器 构建环环境 ](linux/README.md) 1. [ windows cygwin 快速启动 构建环环境 ](windows/README.md) 1. [ macos 快速启动 构建环环境 ](macos/README.md) +1. [ 构建选项 ](../../docs/options.md) -## 构建依赖库 、构建swoole 、打包 +## 相同功能命令 不同写法 -```bash +```shell -# 构建所有依赖库 -bash make.sh all-library +git clone --recursive https://github.com/swoole/swoole-cli.git -bash make.sh config -bash make.sh build -bash make.sh archive +git submodule update --init --recursive ``` -## 更多构建参考文档 - -1. [cygwin](../../docs/Cygwin.md) -1. [linux](../../docs/linux.md) -1. [macos](../../docs/macOS.md) -1. [wsl](../../docs/wsl.md) -1. [构建选项](../../docs/options.md) - ## PHP 版本变更详情 1. [PHP 8.1.x 升级到 PHP 8.2.x 的变更](https://www.php.net/manual/zh/migration82.php) @@ -123,3 +51,4 @@ bash make.sh archive 1. [dockerhub](https://hub.docker.com/search?image_filter=official) 1. [开放原子容器镜像仓库](https://hub.atomgit.com/) + diff --git a/sapi/quickstart/build-native-php-example.sh b/sapi/quickstart/build-native-php-example.sh index a1cad4aa9a..63454ab2f1 100644 --- a/sapi/quickstart/build-native-php-example.sh +++ b/sapi/quickstart/build-native-php-example.sh @@ -1,18 +1,16 @@ #!/bin/env bash set -uex - OS=$(uname -s) ARCH=$(uname -m) - export CC=clang export CXX=clang++ export LD=ld.lld -if [ "$OS" = 'Linux' ] ;then +if [ "$OS" = 'Linux' ]; then -: <<'EOF' + : <<'EOF' # setup container environment docker run --rm -ti --init -v .:/work -w /work debian:11 @@ -24,15 +22,12 @@ EOF fi +if [ "$OS" = 'Darwin' ]; then -if [ "$OS" = 'Darwin' ] ;then - -export PATH=/usr/local/opt/bison/bin/:/usr/local/opt/llvm/bin/:$PATH + export PATH=/usr/local/opt/bison/bin/:/usr/local/opt/llvm/bin/:$PATH fi - - mkdir -p /tmp/t cd /tmp/t @@ -53,10 +48,6 @@ tar --strip-components=1 -C mongodb -xf mongodb-${MONGODB_VERSION}.tgz test -d php-src/ext/mongodb && rm -rf php-src/ext/mongodb mv mongodb php-src/ext/ - - - - cd php-src ./buildconf --force @@ -83,13 +74,11 @@ cd php-src make -j $(nproc) - -if [ "$OS" = 'Linux' ] ;then +if [ "$OS" = 'Linux' ]; then file sapi/cli/php readelf -h sapi/cli/php else - otool -L sapi/cli/php + otool -L sapi/cli/php fi - diff --git a/sapi/quickstart/clean-folder-for-extra-build.sh b/sapi/quickstart/clean-folder-for-extra-build.sh index f3cf964500..f6823e7b2a 100644 --- a/sapi/quickstart/clean-folder-for-extra-build.sh +++ b/sapi/quickstart/clean-folder-for-extra-build.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash - __DIR__=$( cd "$(dirname "$0")" pwd @@ -14,90 +13,97 @@ cd ${__PROJECT__} GIT_BRANCH=$(git branch | grep '* ' | awk '{print $2}') echo "current git branch : "$GIT_BRANCH -if [ $GIT_BRANCH = 'new_dev' ] ;then - echo ' Deleting folder is not allow in this branch : ' $GIT_BRANCH ; +if [ $GIT_BRANCH = 'new_dev' ]; then + echo ' Deleting folder is not allow in this branch : ' $GIT_BRANCH exit 0 fi echo '正在执行删除无关的文件或者文件夹' -cd ${__DIR__}/linux/ - +cd ${__PROJECT__}/sapi/quickstart/linux/ test -d SDS && rm -rf SDS test -d kubernetes && rm -rf kubernetes test -d qemu && rm -rf qemu test -d SDN && rm -rf SDN cd ${__PROJECT__}/sapi/ +test -d build-dependencies-container && rm -rf build-dependencies-container + +cd ${__PROJECT__}/ +test -f sync-source-code.php && rm -f sync-source-code.php +test -f setup-runtime.md && rm -rf setup-runtime.md +cd ${__PROJECT__}/sapi/ +test -d build-dependencies-container && rm -rf build-dependencies-container test -d tools && rm -rf tools cd ${__PROJECT__}/sapi/src/builder/ - test -d library_shared && rm -rf library_shared cd ${__PROJECT__}/sapi/src/ - test -d library_builder && rm -rf library_builder +test -d UnitTest && rm -rf UnitTest cd ${__PROJECT__}/sapi/docker/ - test -d database && rm -rf database - test -d database-ui && rm -rf database-ui - test -d elasticsearch && rm -rf elasticsearch - test -d grafana && rm -rf grafana - test -d minio && rm -rf minio - test -d mysql && rm -rf mysql - test -d neo4j && rm -rf neo4j - test -d nginx && rm -rf nginx - test -d postgis && rm -rf postgis - test -d rabbitmq && rm -rf rabbitmq - test -d redis && rm -rf redis - +test -d gitea && rm -rf gitea cd ${__PROJECT__}/.github/workflows -test -f ceph.yml && rm -rf ceph.yml -test -f kubernetes.yml && rm -rf kubernetes.yml -test -f ovn.yml && rm -rf ovn.yml -test -f ovn.yml && rm -rf ovn.yml +test -f ceph.yml && rm -rf ceph.yml +test -f kubernetes.yml && rm -rf kubernetes.yml +test -f ovn.yml && rm -rf ovn.yml +test -f build-debian-builder-container.sh && rm -rf build-debian-builder-container.sh +test -f download-webrtc.yml && rm -rf download-webrtc.yml +test -f windows-native-2022.yml && rm -rf windows-native-2022.yml +test -f windows-native-vs2019.yml && rm -rf windows-native-vs2019.yml +test -f windows-native-vs2022.yml && rm -rf windows-native-vs2022.yml +test -f artifact-hash.yml && rm -rf artifact-hash.yml +test -f auto-cache-pool-tarball.yml && rm -rf auto-cache-pool-tarball.yml +test -f linux-mips64le.yaml && rm -rf linux-mips64le.yaml +test -f linux-riscv64.yml && rm -rf linux-riscv64.yml +test -f runner-images.md && rm -rf runner-images.md cd ${__PROJECT__}/sapi/quickstart test -d swoole-install && rm -rf swoole-install +test -f build-native-php-example.sh && rm -rf build-native-php-example.sh +test -f clean-no-match-library-for-php.sh && rm -rf clean-no-match-library-for-php.sh +test -f mark-install-library-cached.sh && rm -rf mark-install-library-cached.sh + +cd ${__PROJECT__}/sapi/quickstart/windows/ +test -d msys2-build && rm -rf msys2-build +test -d native-build && rm -rf native-build cd ${__PROJECT__} -test -f setup-aria2-runtime.sh && rm -rf setup-aria2-runtime.sh -test -f setup-coturn-runtime.sh && rm -rf setup-coturn-runtime.sh -test -f setup-ffmpeg-runtime.sh && rm -rf setup-ffmpeg-runtime.sh +test -f setup-aria2-runtime.sh && rm -rf setup-aria2-runtime.sh +test -f setup-coturn-runtime.sh && rm -rf setup-coturn-runtime.sh +test -f setup-ffmpeg-runtime.sh && rm -rf setup-ffmpeg-runtime.sh test -f setup-go-runtime.sh && rm -rf setup-go-runtime.sh -test -f setup-nginx-runtime.sh && rm -rf setup-nginx-runtime.sh -test -f setup-nodejs-runtime.sh && rm -rf setup-nodejs-runtime.sh -test -f setup-php-cli-runtime.sh && rm -rf setup-php-cli-runtime.sh -test -f setup-php-fpm-runtime.sh && rm -rf setup-php-fpm-runtime.sh -test -f setup-privoxy-runtime.sh && rm -rf setup-privoxy-runtime.sh -test -f setup-socat-runtime.sh && rm -rf setup-socat-runtime.sh -test -f setup-supervisord.sh && rm -rf setup-supervisord.sh -test -f setup-swoole-cli-pre-runtime.sh && rm -rf setup-swoole-cli-pre-runtime.sh -test -f setup-webBenchmark-runtime.sh && rm -rf setup-webBenchmark-runtime.sh -test -f setup-swow-cli-runtime.sh && rm -rf setup-swow-cli-runtime.sh -test -f setup-php-fpm-7.4-runtime.sh && rm -rf setup-php-fpm-7.4-runtime.sh -test -f setup-swoole-cli-runtime.sh && rm -rf setup-swoole-cli-runtime.sh -test -f setup-php-cli-7.4-runtime.sh && rm -rf setup-php-cli-7.4-runtime.sh -test -f setup-php-cli-7.3-runtime.sh && rm -rf setup-php-cli-7.3-runtime.sh - +test -f setup-nginx-runtime.sh && rm -rf setup-nginx-runtime.sh +test -f setup-nodejs-runtime.sh && rm -rf setup-nodejs-runtime.sh +test -f setup-php-cli-runtime.sh && rm -rf setup-php-cli-runtime.sh +test -f setup-php-fpm-runtime.sh && rm -rf setup-php-fpm-runtime.sh +test -f setup-privoxy-runtime.sh && rm -rf setup-privoxy-runtime.sh +test -f setup-socat-runtime.sh && rm -rf setup-socat-runtime.sh +test -f setup-supervisord.sh && rm -rf setup-supervisord.sh +test -f setup-swoole-cli-pre-runtime.sh && rm -rf setup-swoole-cli-pre-runtime.sh +test -f setup-webBenchmark-runtime.sh && rm -rf setup-webBenchmark-runtime.sh +test -f setup-swow-cli-runtime.sh && rm -rf setup-swow-cli-runtime.sh +test -f setup-php-fpm-7.4-runtime.sh && rm -rf setup-php-fpm-7.4-runtime.sh +test -f setup-swoole-cli-runtime.sh && rm -rf setup-swoole-cli-runtime.sh +test -f setup-php-cli-7.4-runtime.sh && rm -rf setup-php-cli-7.4-runtime.sh +test -f setup-php-cli-7.3-runtime.sh && rm -rf setup-php-cli-7.3-runtime.sh cd ${__PROJECT__} echo '删除完毕' echo '' - - diff --git a/sapi/quickstart/linux/README.md b/sapi/quickstart/linux/README.md index c4045db1f5..553cc78bc4 100644 --- a/sapi/quickstart/linux/README.md +++ b/sapi/quickstart/linux/README.md @@ -107,3 +107,7 @@ bash sapi/quickstart/linux/debian-init.sh --mirror china sudo usermod -aG docker ${USER} ``` + +## 镜像搜索 + + https://help.mirrors.cernet.edu.cn/ diff --git a/sapi/quickstart/linux/SDN/NET-TOOLS/IPsec.md b/sapi/quickstart/linux/SDN/NET-TOOLS/IPsec.md new file mode 100644 index 0000000000..78b37c3d7d --- /dev/null +++ b/sapi/quickstart/linux/SDN/NET-TOOLS/IPsec.md @@ -0,0 +1,3 @@ +## IPsec 使用端口 + + UDP 500 和 4500 端口 diff --git a/sapi/quickstart/linux/SDN/OVN/README.md b/sapi/quickstart/linux/SDN/OVN/README.md new file mode 100644 index 0000000000..73dd723a99 --- /dev/null +++ b/sapi/quickstart/linux/SDN/OVN/README.md @@ -0,0 +1,104 @@ +## 分布式网关 和 集中式网关 都需要2个网卡才能连接外部网络 + +## 常用命令 + +```bash +ovn-nbctl show +ovn-sbctl show + +ovn-sbctl lflow-list + +ovn-sbctl list chassis + + +ovn-nbctl get-connection +ovn-sbctl get-connection + +ss -tuxlpn | grep -e '^\s*tcp\s.*\b:664[0-5]\b' -e '^\s*udp\s.*\b:6081\b' -e '^\s*u_str\s.*\bovn\b' | sed -r -e 's/\s+$//' + +``` + +```bash + +ovn-nbctl lr-policy-list lr01 +ovn-nbctl lr-route-list lr01 +ovn-nbctl ls-lb-list ls10 +ovn-nbctl list address_set +ovn-nbctl list acl +ovn-sbctl show +ovn-nbctl find logical_router_policy priority=100 + +ovn-sbctl list port_binding +ovn-nbctl list logical_router +ovn-nbctl list logical_router_port +ovn-nbctl list logical_switch +ovn-nbctl list logical_switch_port + +``` + +```bash + +ovn-nbctl show +ovn-nbctl lr-policy-list ovn-cluster +ovn-nbctl lr-route-list ovn-cluster +ovn-nbctl ls-lb-list ovn-default +ovn-nbctl list address_set +ovn-nbctl list acl + +ovn-nbctl list dhcp_options + +ovn-nbctl list gateway_chassis +ovn-nbctl find NAT type=snat + +ovn-sbctl list chassis +ovn-sbctl list port_binding +ovn-sbctl show + +ovn-sbctl --bare --columns name find Chassis hostname=ovn-gateway-test-01 + +ovs-appctl ovs/route/show + +``` + +```bash + +ovn-nbctl list Logical_Switch + +ovn-nbctl list Logical_Switch_Port + +ovn-nbctl list ACL + +ovn-nbctl list Logical_Router + +ovn-nbctl list Logical_Router_Port + +ovn-nbctl list Logical_Router_Static_Route + +ovn-nbctl list NAT + +ovn-nbctl list DHCP_Options + +ovn-nbctl list Gateway_Chassis + + + +ovn-sbctl list Chassis + +ovn-sbctl list Encap + +ovn-sbctl lflow-list + +ovn-sbctl --ovs lflow-list + +ovn-sbctl list Multicast_Group + +ovn-sbctl list Datapath_Binding + +ovn-sbctl list Port_Binding + +ovn-sbctl list MAC_Binding + +ovn-sbctl list DHCP_Options + +ovn-sbctl list Gateway_Chassis +``` diff --git a/sapi/quickstart/linux/SDN/OVS/bind-nic/bind-nic-ovn0/bind-br-ovn0.sh b/sapi/quickstart/linux/SDN/OVS/bind-nic/bind-nic-ovn0/bind-br-ovn0.sh new file mode 100644 index 0000000000..4a5e9f461e --- /dev/null +++ b/sapi/quickstart/linux/SDN/OVS/bind-nic/bind-nic-ovn0/bind-br-ovn0.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash + +set -eux + +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +cd ${__DIR__} + +ovs-vsctl --if-exists del-port br-int ovn0 +ovs-vsctl --may-exist add-port br-int ovn0 -- set interface ovn0 type=internal + +ip link set ovn0 up # 激活网桥 + +{ + ip addr add 10.4.20.2/24 dev ovn0 + ip route add 10.4.20.0/24 via 10.4.20.1 dev ovn0 + +} || +{ + echo $? +} + +# ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=external-network-provider:ovn0 + +ovs-vsctl set Interface ovn0 external_ids:iface-id=master01 + + +sysctl -w net.ipv4.ip_forward=1 +# iptables -t nat -A POSTROUTING -s 10.1.20.0/24 -o ovn0 -j MASQUERADE + +ip a + + + + +exit 0 + +ovs-dpctl show +ovs-dpctl dump-flows +ovs-appctl ovs/route/show +ovs-ofctl show br-int + +exit 0 + + + +iptables -t nat -L -n --line-number + +#iptables -t nat -A POSTROUTING -s 10.10.92.1/24 ! -d 10.10.92.1/24 -j SNAT --to-source 172.17.14.125 +#iptables -t nat -A POSTROUTING -s 10.10.92.0/24 -o br-eth0 -j MASQUERADE # eth0连接外网 +#iptables -A FORWARD -i eth0 -o veth-a -j ACCEPT +#iptables -A FORWARD -i veth-a -o eth0 -j ACCEPT + +iptables -t nat -L -n --line-number +# iptables -t nat -D POSTROUTING 21 + +#iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j SNAT --to 你的eth0地址 +iptables -t nat -A POSTROUTING -s 10.10.92.0/24 -o br-eth0 -j SNAT --to-source 172.17.14.125 +iptables -t nat -A POSTROUTING -s 10.10.92.1 -o br-eth0 -j SNAT --to-source 172.17.14.125 +iptables -t nat -A POSTROUTING -s 10.10.92.1/24 -o br-eth0 -j MASQUERADE +iptables -A PREROUTING -t nat -j DNAT -p tcp --dport 8090 -i $if_oam --to 192.168.9.217:8090 + +ip route add 192.168.10.0/24 via 172.17.14.125 src 10.10.92.1 + +iptables -t nat -A PREROUTING -d 10.10.92.1 -j DNAT --to-destination 10.10.92.2 + +route del default gw 192.168.1.1 +ip route add 10.10.92.1 via 172.17.14.125 + + + +ip route change default via 172.17.63.253 dev br-eth0 + +ip route show | column -t + diff --git a/sapi/quickstart/linux/SDN/OVS/bind-nic/bind-nic-ovn0/unbind-br-ovn0.sh.sh b/sapi/quickstart/linux/SDN/OVS/bind-nic/bind-nic-ovn0/unbind-br-ovn0.sh.sh new file mode 100644 index 0000000000..249a45ff12 --- /dev/null +++ b/sapi/quickstart/linux/SDN/OVS/bind-nic/bind-nic-ovn0/unbind-br-ovn0.sh.sh @@ -0,0 +1,21 @@ +#!/bin/env bash + +set -eux + +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +cd ${__DIR__} + +ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=' ' + +{ + ip link set ovn0 down +} || { + echo $? +} + +ovs-vsctl --if-exists del-port br-int ovn0 + +ip a diff --git a/sapi/quickstart/linux/SDN/OVS/ovs-port.md b/sapi/quickstart/linux/SDN/OVS/ovs-port.md new file mode 100644 index 0000000000..6a53a17666 --- /dev/null +++ b/sapi/quickstart/linux/SDN/OVS/ovs-port.md @@ -0,0 +1,21 @@ + +端口是收发数据包的单元。 +OpenvSwitch中,每个端口都属于一个特定的网桥。 +端口收到的数据包会经过流规则的处理,发往其他端口; +也会把其他端口来的数据包发送出去.主要有 + +port:端口,类型有normal、internal、patch、tunnel + +类型 说明 +Normal:用户可以把操作系统中的网卡绑定到ovs上,ovs会生成一个普通端口处理这块网卡进出的数据包。 +Internal:端口类型为internal时,ovs会创建一块虚拟网卡,端口收到的所有数据包都会交给该网卡,发出的包会通过该端口交给ovs。当ovs创建一个新网桥时,默认会创建一个与网桥同名的Internal Port +Patch:当机器中有多个ovs网桥时,可以使用Patch Port把两个网桥连起来。Patch Port总是成对出现,分别连接在两个网桥上,在两个网桥之间交换数据。 +Tunnel:隧道端口是一种虚拟端口,支持使用gre或vxlan等隧道技术与位于网络上其他位置的远程端口通讯。 + + + +Interface 接口是ovs与外部交换数据包的组件。一个接口就是操作系统的一块网卡,这块网卡可能是ovs生成的虚拟网卡,也可能是物理网卡挂载在ovs上,也可能是操作系统的虚拟网卡(TUN/TAP)挂载在ovs上。 +interface:网络接口设备。port是ovs网桥上的虚拟端口,interface挂载在port上。一般port和interface是一对一的关系,只有在配置port为bond模式后,port和interface是一对多的关系。这个网络接口设备可能是创建internal类型port时ovs自动生成的,也可能是挂载的主机网卡对应的接口。 + + + diff --git a/sapi/quickstart/linux/SDN/install-ovn-ovs.sh b/sapi/quickstart/linux/SDN/install-ovn-ovs.sh new file mode 100644 index 0000000000..382d305bf5 --- /dev/null +++ b/sapi/quickstart/linux/SDN/install-ovn-ovs.sh @@ -0,0 +1,162 @@ +#!/usr/bin/env bash +#set -euo pipefail + +set -eux +set -o pipefail + + +__DIR__=$(cd "$(dirname "$0")";pwd) +cd ${__DIR__} + +MIRROR='' +while [ $# -gt 0 ]; do + case "$1" in + --mirror) + MIRROR="$2" + ;; + --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" + NO_PROXY="${NO_PROXY},::1/128,fe80::/10,fd00::/8,ff00::/8" + NO_PROXY="${NO_PROXY},.aliyuncs.com,.aliyun.com,.tencent.com" + NO_PROXY="${NO_PROXY},.tsinghua.edu.cn,.ustc.edu.cn,.npmmirror.com" + NO_PROXY="${NO_PROXY},ftpmirror.gnu.org" + NO_PROXY="${NO_PROXY},gitee.com,gitcode.com" + NO_PROXY="${NO_PROXY},.myqcloud.com,.swoole.com" + NO_PROXY="${NO_PROXY},dl-cdn.alpinelinux.org" + NO_PROXY="${NO_PROXY},deb.debian.org,security.debian.org" + NO_PROXY="${NO_PROXY},archive.ubuntu.com,security.ubuntu.com" + NO_PROXY="${NO_PROXY},pypi.python.org,bootstrap.pypa.io" + export NO_PROXY="${NO_PROXY},localhost" + ;; + --*) + echo "Illegal option $1" + ;; + esac + shift $(($# > 0 ? 1 : 0)) +done + +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") + +if [ ${OS_ID} = 'debian' ] || [ ${OS_ID} = 'ubuntu' ] ; then + echo 'supported OS' +else + echo 'no supported OS' + exit 0 +fi +case "$MIRROR" in +china | tuna | ustc | aliyuncs ) + # 详情 http://mirrors.ustc.edu.cn/help/debian.html + # 容器内和容器外 镜像源配置不一样 + 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 + else + test -f /etc/apt/sources.list.save || cp -f /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 + fi + ;; +esac + +prepare(){ + + 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" + + update-locale LANG=en_US.UTF-8 + + apt install -y git curl python3 python3-pip python3-dev wget sudo file + apt install -y libssl-dev ca-certificates + + apt install -y \ + git gcc clang make cmake autoconf automake openssl python3 python3-pip libtool \ + openssl curl libssl-dev libcap-ng-dev uuid uuid-runtime + + apt install -y kmod iptables + apt install -y netcat-openbsd + apt install -y tcpdump nmap traceroute net-tools dnsutils iproute2 procps iputils-ping iputils-arping + apt install -y conntrack + apt install -y bridge-utils + apt install -y libelf-dev libbpf-dev # libxdp-dev + apt install -y graphviz + apt install -y libjemalloc2 libjemalloc-dev libnuma-dev libpcap-dev libunbound-dev libunwind-dev llvm-dev + apt install -y bc init ncat + # apt install -y isc-dhcp-server + # apt install -y libdpdk-dev + +} + +# test $(dpkg-query -l graphviz | wc -l) -eq 0 && prepare + +test $(command -v ncat | wc -l) -eq 0 && prepare + + + +CPU_NUMS=$(nproc) +CPU_NUMS=$(grep "processor" /proc/cpuinfo | sort -u | wc -l) + +cd ${__DIR__} +if test -d ovs +then + cd ${__DIR__}/ovs/ + # git pull --depth=1 --progress --rebase +else + git clone -b v3.3.1 https://github.com/openvswitch/ovs.git --depth=1 --progress +fi + +cd ${__DIR__} + +if test -d ovn +then + cd ${__DIR__}/ovn/ + # git pull --depth=1 --progress --rebase +else + git clone -b v24.03.2 https://github.com/ovn-org/ovn.git --depth=1 --progress +fi + +cd ${__DIR__} + +cd ${__DIR__}/ovs/ +./boot.sh +cd ${__DIR__}/ovs/ + + +./configure --help +./configure --enable-ssl +make -j $CPU_NUMS +sudo make install + +cd ${__DIR__}/ovn/ + +#test -d build && rm -rf build +#mkdir build +./boot.sh +cd ${__DIR__}/ovn/ + +./configure --help +./configure --enable-ssl \ +--with-ovs-source=${__DIR__}/ovs/ \ +--with-ovs-build=${__DIR__}/ovs/ + +make -j $CPU_NUMS +sudo make install + + +cd ${__DIR__} +rm -rf ${__DIR__}/ovn +rm -rf ${__DIR__}/ovs + 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 d137a51299..cb5048e98b 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 @@ -41,9 +40,9 @@ esac apk update -apk add vim alpine-sdk xz autoconf automake linux-headers clang-dev clang lld libtool cmake bison re2c gettext coreutils gcc g++ +apk add vim alpine-sdk xz autoconf automake linux-headers clang-dev clang lld libtool cmake bison re2c coreutils gcc g++ apk add bash zip unzip flex pkgconf ca-certificates -apk add tar gzip zip unzip bzip2 gettext-dev +apk add tar gzip zip unzip bzip2 gettext gettext-dev apk add bash 7zip # apk add bash p7zip @@ -56,7 +55,6 @@ apk add diffutils apk add netcat-openbsd socat apk add python3-dev apk add mercurial -apk add gettext-dev apk add pigz parallel apk add gnupg @@ -68,8 +66,9 @@ 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/arm64/README.md b/sapi/quickstart/linux/arm64/README.md index 32055f0ec4..accd2185ca 100644 --- a/sapi/quickstart/linux/arm64/README.md +++ b/sapi/quickstart/linux/arm64/README.md @@ -1,19 +1,14 @@ -# x86_64 运行 arm64 -> 使用 qemu-user-static 实现 +# 在 `x86_64` 平台模拟 `arm64` -## 参考文档 -qemu - https://www.qemu.org/ - https://github.com/qemu/qemu.git - -qemu-user-static - https://github.com/multiarch/qemu-user-static.git +使用 `qemu-user-static` 实现 -x86 平台利用 qemu-user-static 实现 arm64 平台 docker 镜像的运行和构建 - https://www.cnblogs.com/chen2ha/p/17180287.html +## 参考文档 -Docker在x86架构的物理机上跑Qemu-arm 容器 - https://blog.csdn.net/sunSHINEEzy/article/details/80015638 +- [qemu 官网](https://www.qemu.org/) +- [qemu GitHub](https://github.com/qemu/qemu.git) +- [qemu-user-static](https://github.com/multiarch/qemu-user-static.git) +- [x86 平台利用 qemu-user-static 实现 arm64 平台 docker 镜像的运行和构建](https://www.cnblogs.com/chen2ha/p/17180287.html) +- [Docker在x86架构的物理机上跑Qemu-arm 容器](https://blog.csdn.net/sunSHINEEzy/article/details/80015638) ROS 2指南(十一)——交叉编译 diff --git a/sapi/quickstart/linux/conatiner-sync-swoole-cli.sh b/sapi/quickstart/linux/conatiner-sync-swoole-cli.sh new file mode 100644 index 0000000000..557137f40f --- /dev/null +++ b/sapi/quickstart/linux/conatiner-sync-swoole-cli.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +cd ${__DIR__} + +# 容器之间同步 /usr/local/swoole-cli 目录 + +test -d /tmp/swoole-cli-builder && rm -rf /tmp/swoole-cli-builder + +docker cp swoole-cli-alpine-dev:/usr/local/swoole-cli/ /tmp/swoole-cli-builder + +docker cp /tmp/swoole-cli-builder swoole-cli-builder:/usr/local/swoole-cli + + +# docker cp /tmp/swoole-cli-builder swoole-cli-alpine-dev:/usr/local/swoole-cli + +# 运行的容器挂载目录 +# docker exec -it swoole-cli-builder mount --bind /tmp/swoole-cli-builder /usr/local/swoole-cli/ diff --git a/sapi/quickstart/linux/connection-swoole-cli-alpine.sh b/sapi/quickstart/linux/connection-swoole-cli-alpine.sh index db089a711c..a90c7ed051 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__=$( @@ -8,5 +8,4 @@ __DIR__=$( cd ${__DIR__} -docker exec -it swoole-cli-alpine-dev sh - +docker exec -it woole-cli-builder sh diff --git a/sapi/quickstart/linux/connection-swoole-cli-builder.sh b/sapi/quickstart/linux/connection-swoole-cli-builder.sh index 8fd8ffcd10..236b7b52b1 100644 --- a/sapi/quickstart/linux/connection-swoole-cli-builder.sh +++ b/sapi/quickstart/linux/connection-swoole-cli-builder.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -exu __DIR__=$( 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..742a049589 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 - ;; - *) - 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 @@ -92,3 +95,7 @@ export DEBIAN_FRONTEND=noninteractive apt update -y apt install -y git curl wget ca-certificates xz-utils bzip2 p7zip lzip zip unzip +apt install -y procps + +apt install -y ntp +# systemctl restart ntp diff --git a/sapi/quickstart/linux/debian-init.sh b/sapi/quickstart/linux/debian-init.sh index e2bb423604..c06ec83439 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__=$( @@ -16,7 +16,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 @@ -28,104 +28,107 @@ 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 - ;; - *) - 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 DEBIAN_FRONTEND=noninteractive +export TZ="UTC" +export TZ="Etc/UTC" +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 # dpkg-reconfigure locales # localedef -v -c -i en_US -f UTF-8 en_US.UTF-8 # update-locale +localedef -v -c -i en_US -f UTF-8 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" - -export TZ="UTC" -export TZ="Etc/UTC" -ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone - 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++ libtool-bin autopoint +apt install -y gcc g++ libtool-bin autopoint apt install -y linux-headers-generic apt install -y musl-dev musl-tools # apt install -y linux-headers-$(uname -r) -# apt install -y build-essential linux-headers-$(uname -r) +# 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 python3 python3-pip ninja-build diffutils apt install -y yasm nasm apt install -y meson -apt install -y netcat-openbsd socat -apt install -y gnupg +apt install -y netcat-openbsd socat +apt install -y gnupg procps case "$MIRROR" in china | tuna | ustc) @@ -136,4 +139,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/debian-linglong.sh b/sapi/quickstart/linux/debian-linglong.sh new file mode 100644 index 0000000000..59b290aa6d --- /dev/null +++ b/sapi/quickstart/linux/debian-linglong.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +set -x + +# 如意玲珑 新时代Linux桌面应用分发和治理方案 +# https://www.linglong.space/ +# https://linglong.dev/ + +apt install -y sudo apt-transport-https ca-certificates curl gpg + +apt install -y xdg-utils + + +# https://download.opensuse.org/repositories/home:/kamiyadm/Debian_12/ +mkdir -p /etc/apt/keyrings/ + +curl -fsSL https://download.opensuse.org/repositories/home:/kamiyadm/Debian_12/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/linglong-apt-keyring.gpg + +echo "deb [signed-by=/etc/apt/keyrings/linglong-apt-keyring.gpg] https://download.opensuse.org/repositories/home:/kamiyadm/Debian_12/ ./" | sudo tee /etc/apt/sources.list.d/linglong.list + +# 此方法设置不生效 +# sudo bash -c "echo 'deb [trusted=yes] https://download.opensuse.org/repositories/home:/kamiyadm/Debian_12/ ./' > /etc/apt/sources.list.d/linglong.list" + +# 镜像地址 +# https://help.mirrors.cernet.edu.cn/ + +# gnome-desktop +# apt install task-gnome-desktop + +# 玲珑应用商店 +# https://store.linglong.dev/ + +# 玲珑 的诞生 +# https://www.deepin.org/zh/deepin-linglong/ + +sudo apt update -y +sudo apt install -y linglong-builder linglong-box linglong-bin diff --git a/sapi/quickstart/linux/extra/README.md b/sapi/quickstart/linux/extra/README.md index 47cc3e2097..10b0ee3df3 100644 --- a/sapi/quickstart/linux/extra/README.md +++ b/sapi/quickstart/linux/extra/README.md @@ -1,20 +1,20 @@ +# 常见问题 +## 快速安装 `PHP` 解释器 -## 当环境中没有 PHP 解释器时 可以快速安装 PHP 解释器 +### Alpine ```bash +sh sapi/quickstart/linux/extra/alpine-php-init.sh +``` -# alpine - -sh sapi/quickstart/linux/extra/alpine-php-init.sh - -## debian +### Debian/Ubuntu +```bash bash sapi/quickstart/linux/extra/debian-php-init.sh - ``` -## download composer +## 安装 `Composer` ```bash curl -Lo /usr/local/bin/composer.phar https://getcomposer.org/download/latest-stable/composer.phar @@ -22,14 +22,14 @@ curl -Lo /usr/local/bin/composer.phar https://getcomposer.org/download/latest-s ln -sf /usr/local/bin/composer.phar /usr/local/bin/composer chmod a+x /usr/local/bin/composer - wget -O /usr/local/bin/composer https://mirrors.tencent.com/composer/composer.phar +wget -O /usr/local/bin/composer https://mirrors.tencent.com/composer/composer.phar - chmod a+x /usr/local/bin/composer +chmod a+x /usr/local/bin/composer ``` -## c c++编译器 组合 +## `C/C++` 编译器组合 -- 组合一 clang clang++ -- 组合二 gcc g++ +- `clang` + `clang++` +- `gcc` + `g++` diff --git a/sapi/quickstart/linux/install-docker-compose.sh b/sapi/quickstart/linux/install-docker-compose.sh index a090c6ce7a..830ed50268 100644 --- a/sapi/quickstart/linux/install-docker-compose.sh +++ b/sapi/quickstart/linux/install-docker-compose.sh @@ -24,12 +24,14 @@ if [ ! -f /usr/libexec/docker/cli-plugins/docker-compose ]; then # show more version info # https://github.com/docker/compose/releases - VERSION="v2.29.1" + VERSION="v2.32.1" curl -fsSL "https://github.com/docker/compose/releases/download/${VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose +else + export PATH=/usr/libexec/docker/cli-plugins/:$PATH fi docker-compose --version diff --git a/sapi/quickstart/linux/install-docker.sh b/sapi/quickstart/linux/install-docker.sh index c8b0f7f8fc..860c6f21a6 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__=$( @@ -28,7 +28,6 @@ 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 @@ -41,14 +40,15 @@ china | ustc | tuna) ;; 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 + set +u + unset http_proxy + unset https_proxy + unset HTTP_PROXY + unset HTTPS_PROXY + set -u fi - case "$MIRROR" in china | ustc) sed -i "s@https://mirrors.aliyun.com/docker-ce@https://mirrors.ustc.edu.cn/docker-ce@g" get-docker.sh diff --git a/sapi/quickstart/linux/kubernetes/.gitignore b/sapi/quickstart/linux/kubernetes/.gitignore new file mode 100644 index 0000000000..5bee9aa723 --- /dev/null +++ b/sapi/quickstart/linux/kubernetes/.gitignore @@ -0,0 +1,3 @@ +./kube-ovn +./calico +./helm/ diff --git a/sapi/quickstart/linux/kubernetes/README.md b/sapi/quickstart/linux/kubernetes/README.md new file mode 100644 index 0000000000..d64d87c168 --- /dev/null +++ b/sapi/quickstart/linux/kubernetes/README.md @@ -0,0 +1,130 @@ +# 自建 kubernetes v1.28 + +[kubernetes container-runtimes](https://kubernetes.io/docs/setup/production-environment/container-runtimes/#containerd) + +https://kubernetes.io/zh-cn/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/ + +[containerd getting started](https://github.com/containerd/containerd/blob/main/docs/getting-started.md) + +[ crictl ](https://github.com/kubernetes-sigs/cri-tools/blob/master/docs/crictl.md) + +[containerd releases ](https://github.com/containerd/containerd/releases) + +[containerd image mirroring](https://github.com/kubernetes/registry.k8s.io/blob/main/docs/mirroring/containerd.md) + +[runc release ](https://github.com/opencontainers/runc/releases) + +[cni-plugins](https://github.com/containernetworking/plugins/releases) + +[projectcalico/calico](https://github.com/projectcalico/calico.git) +[projectcalico/calico manifest ](https://docs.tigera.io/calico/latest/getting-started/kubernetes/self-managed-onprem/onpremises) + +[kubernetes accessing-dashboard](https://github.com/kubernetes/dashboard) +[kubernetes accessing-dashboard](https://github.com/kubernetes/dashboard/blob/master/docs/user/accessing-dashboard/README.md) +[kubernetes dashboard creating-sample-user ](https://github.com/kubernetes/dashboard/blob/master/docs/user/access-control/creating-sample-user.md) + +[metrics-server](https://github.com/kubernetes-sigs/metrics-server) + +[nginx ingress](https://kubernetes.github.io/ingress-nginx/deploy/#bare-metal-clusters) + +[kubernets ipvs](https://github.com/kubernetes/kubernetes/blob/master/pkg/proxy/ipvs/README.md) + +[网络插件 kubernets networking addons (calico CNI-Genie kube-ovn Multus)](https://kubernetes.io/docs/concepts/cluster-administration/addons/) + +```bash + +kubeadm config images list + +kubeadm init --image-repository=registry.k8s.io + +journalctl -f + + +kubectl get pod --all-namespaces + +crictl images +crictl pods +crictl ps + + + +journalctl -xe + + +``` + +## debian restart networking + +```bash + +systemctl restart networking + +``` + +## container registry + +```bash + +# docker.io (docker hub公共镜像库) +# gcr.io (Google container registry) +# registry.k8s.io (等同于gcr.io/google-containers) +# quay.io (Red Hat运营的镜像库) +# ghcr.io (github 运营的镜像库) + +# Registry Explorer +# https://explore.ggcr.dev/ + + +dockerd --debug + +``` + +## enable ipvs mod + +```bash + +kubectl edit configmap kube-proxy -n kube-system + +``` + +```text +# enable ipvs mod + + ## change mode from "" to ipvs + ## mode: ipvs + +``` + +## ingress-nginx nodeport + +```bash + +kubectl edit service/ingress-nginx-controller -n ingress-nginx + +``` + +```yaml + +type: NodePort +externalIPs: + - 192.168.3.26 +externalTrafficPolicy: Local + + +``` + +## restart pod + +```bash + +kubectl rollout restart deployment + +kubectl rollout restart statefulset + +kubectl delete pod + +``` + + +## Kubernetes 使用的端口和协议 +https://kubernetes.io/zh-cn/docs/reference/networking/ports-and-protocols/ diff --git a/sapi/quickstart/linux/kubernetes/debian-init.sh b/sapi/quickstart/linux/kubernetes/debian-init.sh new file mode 100644 index 0000000000..22f2eac938 --- /dev/null +++ b/sapi/quickstart/linux/kubernetes/debian-init.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +set -x +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +cd ${__DIR__} + +__PROJECT__=$( + cd ${__DIR__}/../../../../ + pwd +) +cd ${__PROJECT__} + + +cd ${__PROJECT__}/sapi/quickstart/linux/ + +bash debian-init-minimal.sh "$@" + + + +apt install -y sudo wget curl libssl-dev ca-certificates +apt install -y net-tools iproute2 +apt install -y ipvsadm conntrack iptables ebtables ethtool socat +apt install -y python3 python3-pip +apt install -y xz-utils lzip zip unzip p7zip +apt install -y nftables +apt install -y grub2-common procps +apt install -y util-linux +apt install -y iptables + + + +ip link +ip -a +cat /sys/class/dmi/id/product_uuid +# nc 127.0.0.1 6443 +stat -fc %T /sys/fs/cgroup/ diff --git a/sapi/quickstart/linux/kubernetes/install-cni-calio.sh b/sapi/quickstart/linux/kubernetes/install-cni-calio.sh new file mode 100644 index 0000000000..905096db93 --- /dev/null +++ b/sapi/quickstart/linux/kubernetes/install-cni-calio.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash + +set -x +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +cd ${__DIR__} + +__PROJECT__=$( + cd ${__DIR__}/../../../../ + pwd +) +cd ${__PROJECT__} +mkdir -p ${__PROJECT__}/var/kubernetes/ +cd ${__PROJECT__}/var/kubernetes/ + +while [ $# -gt 0 ]; do + case "$1" in + --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" + NO_PROXY="${NO_PROXY},127.0.0.1,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},.npmmirror.com" + export NO_PROXY="${NO_PROXY}" + ;; + + --*) + echo "Illegal option $1" + ;; + esac + shift $(($# > 0 ? 1 : 0)) +done + +# shellcheck disable=SC2034 +OS=$(uname -s) +# shellcheck disable=SC2034 +ARCH=$(uname -m) + + +mkdir -p calico +cd calico + +# CNI calico +# https://docs.tigera.io/calico/latest/getting-started/kubernetes/self-managed-onprem/onpremises +# https://github.com/projectcalico/calico/tags +VERSION="3.27.5" +curl -Lo calico-v${VERSION}.yaml https://raw.githubusercontent.com/projectcalico/calico/v${VERSION}/manifests/calico.yaml + +kubectl create -f calico-v${VERSION}.yaml + +curl -fSL https://github.com/projectcalico/calico/releases/download/v${VERSION}/calicoctl-linux-amd64 -o calicoctl +chmod +x ./calicoctl +mv ./calicoctl /usr/local/bin/ + +# more info +# https://docs.tigera.io/calico/latest/operations/calicoctl/configure/overview + +export DATASTORE_TYPE=kubernetes +export KUBECONFIG=~/.kube/config +calicoctl get nodes +calicoctl get workloadendpoints diff --git a/sapi/quickstart/linux/kubernetes/install-cni-kube-ovn.sh b/sapi/quickstart/linux/kubernetes/install-cni-kube-ovn.sh new file mode 100644 index 0000000000..39837442f1 --- /dev/null +++ b/sapi/quickstart/linux/kubernetes/install-cni-kube-ovn.sh @@ -0,0 +1,95 @@ +#!/usr/bin/env bash + +set -x +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +cd ${__DIR__} + +__PROJECT__=$( + cd ${__DIR__}/../../../../ + pwd +) +cd ${__PROJECT__} +mkdir -p ${__PROJECT__}/var/kubernetes/ +cd ${__PROJECT__}/var/kubernetes/ + +while [ $# -gt 0 ]; do + case "$1" in + --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" + NO_PROXY="${NO_PROXY},127.0.0.1,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},.npmmirror.com" + export NO_PROXY="${NO_PROXY}" + ;; + + --*) + echo "Illegal option $1" + ;; + esac + shift $(($# > 0 ? 1 : 0)) +done + +# shellcheck disable=SC2034 +OS=$(uname -s) +# shellcheck disable=SC2034 +ARCH=$(uname -m) + + +mkdir -p kube-ovn +cd kube-ovn + +# 从 Kube-OVN v1.12.0 版本开始,支持 Helm Chart 安装,默认部署为 Overlay 类型网络。 +# CNI kube-ovn +# https://github.com/kubeovn/kube-ovn?tab=readme-ov-file +# https://kubeovn.github.io/docs/stable/start/one-step-install/ +# https://github.com/kubeovn/kube-ovn/tags +VERSION="release-1.13" + +curl -fSLo kube-ovn-${VERSION}-install.sh https://raw.githubusercontent.com/kubeovn/kube-ovn/${VERSION}/dist/images/install.sh +curl -fSLo kube-ovn-${VERSION}-uninstall.sh https://raw.githubusercontent.com/kubeovn/kube-ovn/${VERSION}/dist/images/cleanup.sh +curl -fSLo kubectl-ko https://raw.githubusercontent.com/kubeovn/kube-ovn/${VERSION}/dist/images/kubectl-ko +unset HTTP_PROXY +unset HTTPS_PROXY + + + + +bash kube-ovn-${VERSION}-install.sh + +ip route show + +# 卸载 和 清理残余 + +cat >kube-ovn-${VERSION}-clean.sh < 0 ? 1 : 0)) +done + +# shellcheck disable=SC2034 +OS=$(uname -s) +# shellcheck disable=SC2034 +ARCH=$(uname -m) + +mkdir -p helm + +cd helm + +curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 + +chmod a+x ./get_helm.sh +bash ./get_helm.sh diff --git a/sapi/quickstart/linux/kubernetes/install-kubernetes-debian.sh b/sapi/quickstart/linux/kubernetes/install-kubernetes-debian.sh new file mode 100644 index 0000000000..4ea857dbb1 --- /dev/null +++ b/sapi/quickstart/linux/kubernetes/install-kubernetes-debian.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +set -x +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +cd ${__DIR__} + +mkdir -p kubernetes + +cd kubernetes + +# more info +# https://kubernetes.io/zh-cn/docs/setup/production-environment/tools/kubeadm/install-kubeadm/ + +sudo apt-get update +# apt-transport-https may be a dummy package; if so, you can skip that package +sudo apt-get install -y apt-transport-https ca-certificates curl gpg + +sudo mkdir -m 755 /etc/apt/keyrings + +RELEASE="$(curl -sSL https://dl.k8s.io/release/stable.txt)" +echo ${RELEASE} +K8S_VERSION=$(echo ${RELEASE} | cut -d '.' -f 1,2 ) +echo ${K8S_VERSION} + +curl -fsSL https://pkgs.k8s.io/core:/stable:/${K8S_VERSION}/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg + +echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/${K8S_VERSION}/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list + + +sudo apt-get update +sudo apt-get install -y kubelet kubeadm kubectl +sudo apt-mark hold kubelet kubeadm kubectl + + + + diff --git a/sapi/quickstart/linux/kubernetes/install-kubernetes-rhel.sh b/sapi/quickstart/linux/kubernetes/install-kubernetes-rhel.sh new file mode 100644 index 0000000000..187ae599ac --- /dev/null +++ b/sapi/quickstart/linux/kubernetes/install-kubernetes-rhel.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +set -x +__DIR__=$( + cd "$(dirname "$0")" + pwd +) + +cd ${__DIR__} + +# more info +# https://kubernetes.io/zh-cn/docs/setup/production-environment/tools/kubeadm/install-kubeadm/ + + +RELEASE="$(curl -sSL https://dl.k8s.io/release/stable.txt)" +echo ${RELEASE} +K8S_VERSION=$(echo ${RELEASE} | cut -d '.' -f 1,2) +echo ${K8S_VERSION} + +sudo setenforce 0 +sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config + +cat < 0 ? 1 : 0)) +done + +# shellcheck disable=SC2034 +OS=$(uname -s) +# shellcheck disable=SC2034 +ARCH=$(uname -m) + + + +ip link +ifconfig -a +cat /sys/class/dmi/id/product_uuid +nc 127.0.0.1 6443 + + +# https://github.com/containernetworking/plugins/tags +CNI_PLUGINS_VERSION="v1.5.1" +ARCH="amd64" +DEST="/opt/cni/bin" +mkdir -p "$DEST" +curl -L "https://github.com/containernetworking/plugins/releases/download/${CNI_PLUGINS_VERSION}/cni-plugins-linux-${ARCH}-${CNI_PLUGINS_VERSION}.tgz" | tar -C "$DEST" -xz + + +DOWNLOAD_DIR="/usr/local/bin" +mkdir -p "$DOWNLOAD_DIR" + +# https://github.com/kubernetes-sigs/cri-tools/tags +CRICTL_VERSION="v1.31.0" +ARCH="amd64" +# curl -L "https://github.com/kubernetes-sigs/cri-tools/releases/download/${CRICTL_VERSION}/crictl-${CRICTL_VERSION}-linux-${ARCH}.tar.gz" | tar -C $DOWNLOAD_DIR -xz + + +RELEASE="$(curl -sSL https://dl.k8s.io/release/stable.txt)" +ARCH="amd64" +cd $DOWNLOAD_DIR +curl -L --remote-name-all https://dl.k8s.io/release/${RELEASE}/bin/linux/${ARCH}/{kubeadm,kubelet,kubectl} + +# chmod +x {kubeadm,kubelet,kubectl} +chmod a+x /usr/local/bin/kubeadm +chmod a+x /usr/local/bin/kubelet +chmod a+x /usr/local/bin/kubectl + +# https://github.com/kubernetes/release/tags +RELEASE_VERSION="v0.17.2" +curl -sSL "https://raw.githubusercontent.com/kubernetes/release/${RELEASE_VERSION}/cmd/krel/templates/latest/kubelet/kubelet.service" | sed "s:/usr/bin:${DOWNLOAD_DIR}:g" | tee /etc/systemd/system/kubelet.service +mkdir -p /etc/systemd/system/kubelet.service.d +curl -sSL "https://raw.githubusercontent.com/kubernetes/release/${RELEASE_VERSION}/cmd/krel/templates/latest/kubeadm/10-kubeadm.conf" | sed "s:/usr/bin:${DOWNLOAD_DIR}:g" | tee /etc/systemd/system/kubelet.service.d/10-kubeadm.conf + + +systemctl enable --now kubelet + + diff --git a/sapi/quickstart/linux/kubernetes/install-metrics-server.sh b/sapi/quickstart/linux/kubernetes/install-metrics-server.sh new file mode 100644 index 0000000000..8ff6f3de1b --- /dev/null +++ b/sapi/quickstart/linux/kubernetes/install-metrics-server.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +set -x +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +cd ${__DIR__} + +__PROJECT__=$( + cd ${__DIR__}/../../../../ + pwd +) +cd ${__PROJECT__} +mkdir -p ${__PROJECT__}/var/kubernetes/ +cd ${__PROJECT__}/var/kubernetes/ + +while [ $# -gt 0 ]; do + case "$1" in + --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" + NO_PROXY="${NO_PROXY},127.0.0.1,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},.npmmirror.com" + export NO_PROXY="${NO_PROXY}" + ;; + + --*) + echo "Illegal option $1" + ;; + esac + shift $(($# > 0 ? 1 : 0)) +done + +# shellcheck disable=SC2034 +OS=$(uname -s) +# shellcheck disable=SC2034 +ARCH=$(uname -m) +# metrics-server +# https://github.com/kubernetes-sigs/metrics-server/ + +curl -L -o kubernetes-metrics-server.yaml https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml + +kubectl create -f kubernetes-metrics-server.yaml diff --git a/sapi/quickstart/linux/kubernetes/install-nginx-ingress.sh b/sapi/quickstart/linux/kubernetes/install-nginx-ingress.sh new file mode 100644 index 0000000000..0bdb26f4db --- /dev/null +++ b/sapi/quickstart/linux/kubernetes/install-nginx-ingress.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash + +set -x +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +cd ${__DIR__} + +__PROJECT__=$( + cd ${__DIR__}/../../../../ + pwd +) +cd ${__PROJECT__} +mkdir -p ${__PROJECT__}/var/kubernetes/ +cd ${__PROJECT__}/var/kubernetes/ + +while [ $# -gt 0 ]; do + case "$1" in + --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" + NO_PROXY="${NO_PROXY},127.0.0.1,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},.npmmirror.com" + export NO_PROXY="${NO_PROXY}" + ;; + + --*) + echo "Illegal option $1" + ;; + esac + shift $(($# > 0 ? 1 : 0)) +done + +# shellcheck disable=SC2034 +OS=$(uname -s) +# shellcheck disable=SC2034 +ARCH=$(uname -m) + +# nginx ingress +# https://kubernetes.github.io/ingress-nginx/deploy/#bare-metal-clusters +# https://github.com/kubernetes/ingress-nginx/tags +VERSION="1.11.3" + +curl -L -o nginx-ingress-v${VERSION}-deploy.yaml https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v${VERSION}/deploy/static/provider/baremetal/deploy.yaml + +kubectl create -f nginx-ingress-v${VERSION}-deploy.yaml diff --git a/sapi/quickstart/linux/kubernetes/kubeadm-init-example.sh b/sapi/quickstart/linux/kubernetes/kubeadm-init-example.sh new file mode 100644 index 0000000000..f91bff6b89 --- /dev/null +++ b/sapi/quickstart/linux/kubernetes/kubeadm-init-example.sh @@ -0,0 +1,118 @@ +#!/usr/bin/env bash + +export PATH=$PATH:/usr/sbin/ + +cat < 0 ? 1 : 0)) +done + +# export CONTAINER_RUNTIME_ENDPOINT="unix:///run/containerd/containerd.sock" +# export KUBECONFIG=/etc/kubernetes/admin.conf + +export KUBE_PROXY_MODE=ipvs + +# https://dl.k8s.io/release/stable-1.txt + +kubeadm config images list --v=5 --kubernetes-version=$(kubelet --version | awk -F ' ' '{print $2}') +kubeadm config images pull --v=5 --kubernetes-version=$(kubelet --version | awk -F ' ' '{print $2}') --cri-socket ${CRI_SOCKET} + +ip route show | grep -E '^default' + +NIC=$(ip link | grep eth0) +if [ $? -ne 0 ]; then + NIC=$(ip link | grep enp0s3) +fi + +if [ -z "${NIC}" ]; then + echo 'no found NIC' + exit 0 +fi + +IP=$(ip address show | grep ${NIC} | grep 'inet' | awk '{print $2}' | awk -F '/' '{print $1}') + +echo $IP + +swapoff -a +export KUBE_PROXY_MODE=ipvs +kubeadm init \ + --kubernetes-version=$(kubelet --version | awk -F ' ' '{print $2}') \ + --pod-network-cidr=10.244.0.0/16,fd00:11::/64 \ + --service-cidr=10.96.0.0/16,fd00:22::/112 \ + --token-ttl 0 \ + --v=5 \ + --cri-socket ${CRI_SOCKET} \ + --apiserver-advertise-address="${IP}" + +# --control-plane-endpoint='control-plane-endpoint-api.intranet.jingjingxyk.com:6443' +# --apiserver-advertise-address="${ip}" + +# --cri-socket "unix:///var/run/containerd/containerd.sock" +# --cri-socket "unix:///var/run/cri-dockerd.sock" + +mkdir -p $HOME/.kube +cp -f /etc/kubernetes/admin.conf $HOME/.kube/config +chown $(id -u):$(id -g) $HOME/.kube/config + +kubectl taint nodes --all node-role.kubernetes.io/control-plane- + +# https://github.com/kubernetes/kubernetes/blob/master/pkg/proxy/ipvs/README.md +# enable ipvs mod +# kubectl edit configmap kube-proxy -n kube-system +## change mode from "" to ipvs +## mode: ipvs + +lsmod | grep -e ip_vs -e nf_conntrack_ipv4 + +ipvsadm -ln +iptables -t nat -nL + +kubeadm token list + +openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | + openssl dgst -sha256 -hex | sed 's/^.* //' + +# create cluster + +# https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/ diff --git a/sapi/quickstart/linux/kubernetes/kubeadm-join-show-info.sh b/sapi/quickstart/linux/kubernetes/kubeadm-join-show-info.sh new file mode 100644 index 0000000000..9e4f69ad2a --- /dev/null +++ b/sapi/quickstart/linux/kubernetes/kubeadm-join-show-info.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + + + +TOKEN_HASH=$(openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //') + +# kubeadm token create +# kubeadm join --token : --discovery-token-ca-cert-hash sha256: + +JOIN_TOKEN=$(kubeadm token list | grep 'kubeadm init' | awk '{ print $1}') + +# more info +# https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/ + +kubeadm token list + +echo 'swapoff -a ' +echo 'kubeadm config images pull --v=5 ' + +echo "kubeadm join control-plane-endpoint-api.intranet.jingjingxyk.com:6443 --token ${JOIN_TOKEN} --discovery-token-ca-cert-hash sha256:${TOKEN_HASH} --control-plane --v=5 " + +echo "kubeadm join control-plane-endpoint-api.intranet.jingjingxyk.com:6443 --token ${JOIN_TOKEN} --discovery-token-ca-cert-hash sha256:${TOKEN_HASH} --v=5 " diff --git a/sapi/quickstart/linux/kubernetes/kubeadm-reset.sh b/sapi/quickstart/linux/kubernetes/kubeadm-reset.sh new file mode 100644 index 0000000000..cfcc8f78f4 --- /dev/null +++ b/sapi/quickstart/linux/kubernetes/kubeadm-reset.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +set -x +# kubectl drain --delete-emptydir-data --force --ignore-daemonsets + +# kubectl -n kube-system get cm kubeadm-config -o yaml + +{ kubeadm reset; } || { echo $?; } + +iptables -F && iptables -t nat -F && iptables -t mangle -F && iptables -X + +ipvsadm -C +ipvsadm --clear +test -f $HOME/.kube/config && rm -f $HOME/.kube/config + +# reboot diff --git a/sapi/quickstart/linux/kubernetes/kubernetes-dashboard.sh b/sapi/quickstart/linux/kubernetes/kubernetes-dashboard.sh new file mode 100644 index 0000000000..d78fbed2ec --- /dev/null +++ b/sapi/quickstart/linux/kubernetes/kubernetes-dashboard.sh @@ -0,0 +1,76 @@ +#!/usr/bin/env bash + +set -x +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +cd ${__DIR__} + +__PROJECT__=$( + cd ${__DIR__}/../../../../ + pwd +) +cd ${__PROJECT__} +mkdir -p ${__PROJECT__}/var/kubernetes/ +cd ${__PROJECT__}/var/kubernetes/ + +while [ $# -gt 0 ]; do + case "$1" in + --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" + NO_PROXY="${NO_PROXY},127.0.0.1,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},.npmmirror.com" + export NO_PROXY="${NO_PROXY}" + ;; + + --*) + echo "Illegal option $1" + ;; + esac + shift $(($# > 0 ? 1 : 0)) +done + +# shellcheck disable=SC2034 +OS=$(uname -s) +# shellcheck disable=SC2034 +ARCH=$(uname -m) + +# Kubernetes Dashboard 从版本 7.0.0 开始仅支持基于 Helm 的安装 + +helm repo add kubernetes-dashboard https://kubernetes.github.io/dashboard/ + +helm upgrade --install kubernetes-dashboard kubernetes-dashboard/kubernetes-dashboard --create-namespace --namespace kubernetes-dashboard + +exit 0 + + +kubectl -n kubernetes-dashboard get svc + +# To access Dashboard run: +kubectl -n kubernetes-dashboard port-forward svc/kubernetes-dashboard-kong-proxy 8443:443 + +# https://localhost:8443 + +exit 0 + +# docs +https://github.com/kubernetes/dashboard/blob/master/docs/user/accessing-dashboard/README.md + +exit 0 + +# https://github.com/kubernetes/dashboard/tags +VERSION="v2.7.0" +VERSION="v3.0.0-alpha0" + +curl -L -O https://raw.githubusercontent.com/kubernetes/dashboard/${VERSION}/charts/kubernetes-dashboard.yaml + +kubectl create -f kubernetes-dashboard.yaml + +# kubectl create -f kubernetes-dashboard-sample-user.yaml diff --git a/sapi/quickstart/linux/kubernetes/rhel-init.sh b/sapi/quickstart/linux/kubernetes/rhel-init.sh new file mode 100644 index 0000000000..ab43b10c4f --- /dev/null +++ b/sapi/quickstart/linux/kubernetes/rhel-init.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=$( + cd ${__DIR__}/../../../../ + pwd +) +cd ${__PROJECT__}/sapi/quickstart/linux/ + +bash rhel-init-minimal.sh "$@" + +# ip link +ifconfig -a +cat /sys/class/dmi/id/product_uuid +# nc 127.0.0.1 6443 +stat -fc %T /sys/fs/cgroup/ diff --git a/sapi/quickstart/linux/kubernetes/runtime/install-containerd.sh b/sapi/quickstart/linux/kubernetes/runtime/install-containerd.sh new file mode 100644 index 0000000000..ae57858da7 --- /dev/null +++ b/sapi/quickstart/linux/kubernetes/runtime/install-containerd.sh @@ -0,0 +1,112 @@ +#!/usr/bin/env bash + +set -x +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +cd ${__DIR__} + +__PROJECT__=$( + cd ${__DIR__}/../../../../../ + pwd +) +cd ${__PROJECT__} +mkdir -p ${__PROJECT__}/var/kubernetes/ +cd ${__PROJECT__}/var/kubernetes/ + +while [ $# -gt 0 ]; do + case "$1" in + --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" + NO_PROXY="${NO_PROXY},127.0.0.1,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},.npmmirror.com" + export NO_PROXY="${NO_PROXY}" + ;; + + --*) + echo "Illegal option $1" + ;; + esac + shift $(($# > 0 ? 1 : 0)) +done + +# shellcheck disable=SC2034 +OS=$(uname -s) +# shellcheck disable=SC2034 +ARCH=$(uname -m) + + +stat -fc %T /sys/fs/cgroup/ + +mkdir -p ${__PROJECT__}/var/kubernetes/containerd +cd ${__PROJECT__}/var/kubernetes/containerd + +# containerd +# https://github.com/containerd/containerd/tags + +VERSION="2.0.1" + +CONTAINERD_RELEASE_URL=https://github.com/containerd/containerd/releases/download/v${VERSION}/containerd-${VERSION}-linux-amd64.tar.gz +CONTAINERD_RELEASE=containerd-${VERSION}-linux-amd64.tar.gz + +curl -L -o $CONTAINERD_RELEASE $CONTAINERD_RELEASE_URL + +tar Cxzvf /usr/local $CONTAINERD_RELEASE + +mkdir -p /usr/local/lib/systemd/system/ +curl -L -o /usr/local/lib/systemd/system/containerd.service https://raw.githubusercontent.com/containerd/containerd/main/containerd.service + +systemctl daemon-reload +systemctl enable --now containerd +systemctl restart containerd + +mkdir -p /etc/containerd/ +containerd config default >/etc/containerd/config.toml + +sed -i 's/SystemdCgroup = false/SystemdCgroup = true/' /etc/containerd/config.toml +# sed -i s/disabled_plugins = \[\]/ / /etc/containerd/config.toml +sed 's/^disabled_plugins/#&/' /etc/containerd/config.toml +cat /etc/containerd/config.toml + +systemctl restart containerd + +# runc +# https://github.com/opencontainers/runc/tags + +VERSION="1.2.3" +curl -L -o runc.amd64 https://github.com/opencontainers/runc/releases/download/v${VERSION}/runc.amd64 + +install -m 755 runc.amd64 /usr/local/sbin/runc + +# kubernetes 需要如下配置 + +# cni-plugins +# https://github.com/containernetworking/plugins/tags + +VERSION="1.6.1" +mkdir -p /opt/cni/bin +curl -L -o cni-plugins-linux-amd64-v${VERSION}.tgz https://github.com/containernetworking/plugins/releases/download/v${VERSION}/cni-plugins-linux-amd64-v${VERSION}.tgz +tar Cxzvf /opt/cni/bin cni-plugins-linux-amd64-v${VERSION}.tgz + +# crictl +# https://github.com/kubernetes-sigs/cri-tools/tags + +VERSION="1.32.0" +# check latest version in /releases page +curl -L -o crictl-v${VERSION}-linux-amd64.tar.gz https://github.com/kubernetes-sigs/cri-tools/releases/download/v$VERSION/crictl-v${VERSION}-linux-amd64.tar.gz +tar zxvf crictl-v${VERSION}-linux-amd64.tar.gz -C /usr/local/bin +rm -f crictl-v${VERSION}-linux-amd64.tar.gz + +cat >/etc/crictl.yaml < 0 ? 1 : 0)) +done + +# shellcheck disable=SC2034 +OS=$(uname -s) +# shellcheck disable=SC2034 +ARCH=$(uname -m) + +mkdir -p cri-dockerd/packaging/systemd/ + +cd cri-dockerd +# cri-dockerd +# https://github.com/Mirantis/cri-dockerd/tags + +VERSION="0.3.15" +curl -L -O https://github.com/Mirantis/cri-dockerd/releases/download/v${VERSION}/cri-dockerd-${VERSION}.amd64.tgz + +tar --strip-components=1 -C . -xf cri-dockerd-${VERSION}.amd64.tgz + +curl -L -o packaging/systemd/cri-docker.service https://github.com/Mirantis/cri-dockerd/blob/master/packaging/systemd/cri-docker.service?raw=true +curl -L -o packaging/systemd/cri-docker.socket https://github.com/Mirantis/cri-dockerd/blob/master/packaging/systemd/cri-docker.socket?raw=true + +mkdir -p /usr/local/bin +install -o root -g root -m 0755 cri-dockerd /usr/local/bin/cri-dockerd +install packaging/systemd/* /etc/systemd/system +sed -i -e 's,/usr/bin/cri-dockerd,/usr/local/bin/cri-dockerd,' /etc/systemd/system/cri-docker.service + +systemctl daemon-reload +systemctl enable --now cri-docker.socket +systemctl status cri-docker.service | cat + +# crictl +# check latest version in /releases page +# https://github.com/kubernetes-sigs/cri-tools/tags + +VERSION="1.30.0" +curl -L -O https://github.com/kubernetes-sigs/cri-tools/releases/download/v${VERSION}/crictl-v${VERSION}-linux-amd64.tar.gz +tar zxvf crictl-v${VERSION}-linux-amd64.tar.gz -C /usr/local/bin +rm -f crictl-v${VERSION}-linux-amd64.tar.gz + +cat >/etc/crictl.yaml < 0 ? 1 : 0)) +done + +# shellcheck disable=SC2034 +OS=$(uname -s) +# shellcheck disable=SC2034 +ARCH=$(uname -m) + + +systemctl status containerd | cat + +# 使用系统源安装 目录位置为 /lib/systemd/system/containerd.service + +mkdir -p /usr/local/lib/systemd/system/containerd.service.d +cat >/usr/local/lib/systemd/system/containerd.service.d/http-proxy.conf < 0 ? 1 : 0)) +done + +# shellcheck disable=SC2034 +OS=$(uname -s) +# shellcheck disable=SC2034 +ARCH=$(uname -m) + +systemctl status docker | cat + +# 使用系统源安装 目录位置为 /lib/systemd/system/docker.service + +mkdir -p /lib/systemd/system/docker.service.d/ +cat >/lib/systemd/system/docker.service.d/http-proxy.conf </etc/apt/apt.conf.d/proxy.conf < 0 ? 1 : 0)) +done + +# mirror site +# https://mirror.rockylinux.org/mirrormanager/mirrors +# https://mirrors.almalinux.org/ + +case "$MIRROR" in +china) + case "$OS_RELEASE" in + almalinux) + sed -e 's|^mirrorlist=|#mirrorlist=|g' \ + -e 's|^# baseurl=https://repo.almalinux.org|baseurl=https://mirror.sjtu.edu.cn|g' \ + -i.bak \ + /etc/yum.repos.d/almalinux*.repo + ;; + rocky) + sed -e 's|^mirrorlist=|#mirrorlist=|g' \ + -e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://mirrors.ustc.edu.cn/rocky|g' \ + -i.bak \ + /etc/yum.repos.d/rocky*.repo + ;; + + esac + ;; +aliyun) + case "$OS_RELEASE" in + almalinux) + sed -e 's|^mirrorlist=|#mirrorlist=|g' \ + -e 's|^# baseurl=https://repo.almalinux.org|baseurl=https://mirrors.aliyun.com|g' \ + -i.bak \ + /etc/yum.repos.d/almalinux*.repo + ;; + rocky) + sed -e 's|^mirrorlist=|#mirrorlist=|g' \ + -e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://mirrors.aliyun.com/rockylinux|g' \ + -i.bak \ + /etc/yum.repos.d/rocky*.repo + ;; + + esac + ;; +*) + echo 'no use mirror' + ;; +esac + +dnf makecache + +yum install -y git wget ca-certificates + +{ yum install -y curl; } || { echo $?; } +{ yum install -y curl-minimal; } || { echo $?; } + +yum install -y sudo xz curl wget ca-certificates zip unzip bzip2 p7zip lzip +yum install -y which +yum install -y socat diff --git a/sapi/quickstart/linux/run-alpine-container-full.sh b/sapi/quickstart/linux/run-alpine-container-full.sh index 832ddc896a..4de8062389 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__=$( @@ -12,7 +12,7 @@ __PROJECT__=$( cd ${__DIR__} { - docker stop swoole-cli-alpine-dev + docker stop swoole-cli-builder sleep 5 } || { echo $? @@ -21,7 +21,7 @@ cd ${__DIR__} IMAGE=alpine:3.18 -:<<'EOF' +: <<'EOF' 启动此容器 已经内置了 php 、composer 、 编译好的依赖库 @@ -52,16 +52,16 @@ case $ARCH in 'x86_64') 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 + if [ "$MIRROR" = 'china' ]; then IMAGE=registry.cn-beijing.aliyuncs.com/jingjingxyk-public/app:${TAG} fi ;; 'aarch64') TAG=all-dependencies-alpine-3.18-php8-v1.0.0-aarch64-20240618T091126Z IMAGE=docker.io/jingjingxyk/build-swoole-cli:${TAG} - if [ "$MIRROR" = 'china' ] ; then - IMAGE=registry.cn-hangzhou.aliyuncs.com/jingjingxyk-public/app:${TAG} - fi + if [ "$MIRROR" = 'china' ]; then + IMAGE=registry.cn-hangzhou.aliyuncs.com/jingjingxyk-public/app:${TAG} + fi ;; *) echo "此 ${ARCH} 架构的容器 容器未配置" @@ -69,14 +69,12 @@ case $ARCH in ;; esac - cd ${__DIR__} -if [ $DEV_SHM -eq 1 ] ; then +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-builder -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-builder -d -v ${__PROJECT__}:/work -w /work --init $IMAGE tail -f /dev/null fi - diff --git a/sapi/quickstart/linux/run-alpine-container.sh b/sapi/quickstart/linux/run-alpine-container.sh index bcd371082f..c402ac11f2 100644 --- a/sapi/quickstart/linux/run-alpine-container.sh +++ b/sapi/quickstart/linux/run-alpine-container.sh @@ -12,7 +12,7 @@ __PROJECT__=$( cd ${__DIR__} { - docker stop swoole-cli-alpine-dev + docker stop swoole-cli-builder sleep 5 } || { echo $? @@ -27,9 +27,9 @@ while [ $# -gt 0 ]; do --mirror) MIRROR="$2" case "$MIRROR" in - china | openatom) - IMAGE="hub.atomgit.com/library/alpine:3.18" - ;; + china | openatom) + IMAGE="hub.atomgit.com/library/alpine:3.18" + ;; esac ;; esac @@ -37,4 +37,4 @@ while [ $# -gt 0 ]; do done cd ${__DIR__} -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-builder -d -v ${__PROJECT__}:/work -w /work --init $IMAGE tail -f /dev/null diff --git a/sapi/quickstart/linux/run-debian-container.sh b/sapi/quickstart/linux/run-debian-container.sh index 13f09fd579..828b9500dd 100644 --- a/sapi/quickstart/linux/run-debian-container.sh +++ b/sapi/quickstart/linux/run-debian-container.sh @@ -27,15 +27,19 @@ while [ $# -gt 0 ]; do --mirror) MIRROR="$2" case "$MIRROR" in - china | openatom) - IMAGE="hub.atomgit.com/library/debian:12" - ;; + china | openatom) + IMAGE="hub.atomgit.com/library/debian:12" + ;; esac ;; esac shift $(($# > 0 ? 1 : 0)) done - cd ${__DIR__} -docker run --rm --name swoole-cli-debian-dev -d -v ${__PROJECT__}:/work -w /work $IMAGE tail -f /dev/null +docker run --rm --name swoole-cli-debian-dev -d -v ${__PROJECT__}:/work -w /work --init $IMAGE tail -f /dev/null + +# docker run --rm --name debian-dev -d --init -ti debian:12 +# docker exec -it debian-dev bash + +# docker run --rm --name debian-dev --init -ti debian:12 diff --git a/sapi/quickstart/linux/run-rhel-container.sh b/sapi/quickstart/linux/run-rhel-container.sh index aaf36e645b..7ba17080d4 100644 --- a/sapi/quickstart/linux/run-rhel-container.sh +++ b/sapi/quickstart/linux/run-rhel-container.sh @@ -61,4 +61,4 @@ esac cd ${__DIR__} -docker run --rm --name swoole-cli-rhel-dev -d -v ${__PROJECT__}:/work -w /work $IMAGE tail -f /dev/null +docker run --rm --name swoole-cli-rhel-dev -d -v ${__PROJECT__}:/work -w /work --init $IMAGE tail -f /dev/null diff --git a/sapi/quickstart/linux/run-ubuntu-container.sh b/sapi/quickstart/linux/run-ubuntu-container.sh index 88e5b3d403..a88763ddb0 100644 --- a/sapi/quickstart/linux/run-ubuntu-container.sh +++ b/sapi/quickstart/linux/run-ubuntu-container.sh @@ -20,6 +20,7 @@ cd ${__DIR__} cd ${__DIR__} IMAGE=ubuntu:22.04 IMAGE=ubuntu:23.10 +IMAGE=ubuntu:24.04 MIRROR='' while [ $# -gt 0 ]; do @@ -27,9 +28,9 @@ while [ $# -gt 0 ]; do --mirror) MIRROR="$2" case "$MIRROR" in - china | openatom) - IMAGE="hub.atomgit.com/library/ubuntu:23.10" - ;; + china | openatom) + IMAGE="hub.atomgit.com/library/ubuntu:24.04" + ;; esac ;; esac @@ -37,4 +38,5 @@ while [ $# -gt 0 ]; do done cd ${__DIR__} -docker run --rm --name swoole-cli-ubuntu-dev -d -v ${__PROJECT__}:/work -w /work -e TZ='Etc/UTC' $IMAGE tail -f /dev/null + +docker run --rm --name swoole-cli-ubuntu-dev -d -v ${__PROJECT__}:/work -w /work -e TZ='Etc/UTC' --init $IMAGE tail -f /dev/null diff --git a/sapi/quickstart/linux/tini.sh b/sapi/quickstart/linux/tini.sh new file mode 100644 index 0000000000..f4d7b819a9 --- /dev/null +++ b/sapi/quickstart/linux/tini.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=$( + cd ${__DIR__}/../../../ + pwd +) +cd ${__PROJECT__} +mkdir -p ${__PROJECT__}/var/ +cd ${__PROJECT__}/var/ + + +# docker tini + +# https://cloud-atlas.readthedocs.io/zh-cn/latest/docker/init/docker_tini.html + + +TINI_VERSION v0.19.0 +curl -fsSLo tini https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini +chmod +x /tini + + +# ENTRYPOINT ["/tini", "--"] + +# Run your program under Tini +# CMD ["/your/program", "-and", "-its", "arguments"] +# or docker run your-image /your/program ... + + + diff --git a/sapi/quickstart/macos/install-homebrew.sh b/sapi/quickstart/macos/install-homebrew.sh index 73574bac0a..5a07a97c19 100644 --- a/sapi/quickstart/macos/install-homebrew.sh +++ b/sapi/quickstart/macos/install-homebrew.sh @@ -1,4 +1,4 @@ -!/bin/bash +#!/usr/bin/env bash set -x __DIR__=$( @@ -21,7 +21,14 @@ while [ $# -gt 0 ]; do case "$1" in --mirror) MIRROR="$2" - shift + ;; + --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" + NO_PROXY="${NO_PROXY},::1/128,fe80::/10,fd00::/8,ff00::/8" + NO_PROXY="${NO_PROXY},localhost" + export NO_PROXY="${NO_PROXY},.tsinghua.edu.cn,.ustc.edu.cn" ;; --*) echo "Illegal option $1" @@ -40,3 +47,6 @@ china) /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ;; esac + +brew config + diff --git a/sapi/quickstart/macos/macos-init.sh b/sapi/quickstart/macos/macos-init.sh index 4ead020231..fcee3e8915 100644 --- a/sapi/quickstart/macos/macos-init.sh +++ b/sapi/quickstart/macos/macos-init.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -x __DIR__=$( @@ -11,6 +11,16 @@ __PROJECT__=$( ) cd ${__PROJECT__} +# Show System Environment +uname -s +uname -m +uname -r +echo $HOME +sw_vers +xcodebuild -version +brew config +xcrun --show-sdk-path + MIRROR='' WITH_UPDATE=0 @@ -22,6 +32,19 @@ while [ $# -gt 0 ]; do --update) WITH_UPDATE=1 ;; + --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" + NO_PROXY="${NO_PROXY},::1/128,fe80::/10,fd00::/8,ff00::/8" + NO_PROXY="${NO_PROXY},localhost" + NO_PROXY="${NO_PROXY},.tsinghua.edu.cn,.ustc.edu.cn" + NO_PROXY="${NO_PROXY},.tencent.com" + 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" + ;; --*) echo "Illegal option $1" ;; @@ -40,20 +63,22 @@ china | ustc) export HOMEBREW_PIP_INDEX_URL="https://pypi.tuna.tsinghua.edu.cn/simple" export PIPENV_PYPI_MIRROR="https://pypi.tuna.tsinghua.edu.cn/simple" - # pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple - # pip3 config set global.index-url https://pypi.python.org/simple - + # 参考文档: https://help.mirrors.cernet.edu.cn/homebrew/ # 参考文档: https://help.mirrors.cernet.edu.cn/homebrew/ ;; - esac +HOMEBREW_PREFIX=$(brew --prefix) + + export HOMEBREW_NO_ANALYTICS=1 -export HOMEBREW_NO_AUTO_UPDATE=1 export HOMEBREW_INSTALL_FROM_API=1 +export HOMEBREW_NO_AUTO_UPDATE=1 if [ ${WITH_UPDATE} -eq 1 ]; then + unset HOMEBREW_NO_AUTO_UPDATE + case "$MIRROR" in china | ustc) brew tap --custom-remote --force-auto-update homebrew/cask https://mirrors.ustc.edu.cn/homebrew-cask.git @@ -67,11 +92,8 @@ if [ ${WITH_UPDATE} -eq 1 ]; then # brew tap --custom-remote --force-auto-update homebrew/services https://mirrors.ustc.edu.cn/homebrew-services.git ;; esac - + brew doctor brew update - - exit 0 - fi brew install wget curl libtool automake re2c llvm flex bison m4 autoconf @@ -94,22 +116,9 @@ brew install gnupg which glibtool -# maocs intel -# HOMEBREW_PREFIX: /usr/local -if [ -d /usr/local/opt/libtool/bin/ ]; then - ln -sf /usr/local/opt/libtool/bin/glibtool /usr/local/opt/libtool/bin/libtool - ln -sf /usr/local/opt/libtool/bin/glibtoolize /usr/local/opt/libtool/bin/libtoolize - export PATH=/usr/local/opt/libtool/bin/:$PATH -fi - -# macos M1 -# HOMEBREW_PREFIX=/opt/homebrew -# HOMEBREW_REPOSITORY=/opt/homebrew -if [ -d /opt/homebrew/opt/libtool/bin ]; then - ln -sf /opt/homebrew/opt/libtool/bin/glibtool /opt/homebrew/opt/libtool/bin/libtool - ln -sf /opt/homebrew/opt/libtool/bin/glibtoolize /opt/homebrew/opt/libtool/bin/libtoolize - export PATH=/opt/homebrew/opt/libtool/bin/:$PATH -fi +ln -sf ${HOMEBREW_PREFIX}/opt/libtool/bin/glibtool ${HOMEBREW_PREFIX}/opt/libtool/bin/libtool +ln -sf ${HOMEBREW_PREFIX}/opt/libtool/bin/glibtoolize ${HOMEBREW_PREFIX}/opt/libtool/bin/libtoolize +export PATH=${HOMEBREW_PREFIX}/opt/libtool/bin/:$PATH libtoolize --version libtool --help-all @@ -117,6 +126,7 @@ libtool --help-all which glibtool which libtool + brew uninstall --ignore-dependencies --force snappy brew uninstall --ignore-dependencies --force capstone @@ -139,27 +149,19 @@ trusted-host = https://pypi.tuna.tsinghua.edu.cn EOF + brew install xz zip unzip gzip bzip2 7zip p7zip brew install git ca-certificates -brew install yasm nasm -brew install ninja python3 brew install diffutils -brew install netcat socat +brew install socat brew install mercurial - -case "$MIRROR" in -china | tuna | ustc) - pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple - test "$MIRROR" = "ustc" && pip3 config set global.index-url https://mirrors.ustc.edu.cn/pypi/web/simple - ;; -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 +brew install meson ninja yasm nasm brew uninstall --ignore-dependencies --force snappy brew uninstall --ignore-dependencies --force capstone +brew uninstall --ignore-dependencies --force php + +which libtool + +brew install meson ninja yasm nasm diff --git a/sapi/quickstart/setup-php-runtime-in-docker.sh b/sapi/quickstart/setup-php-runtime-in-docker.sh index 16f9f34d61..145082bbbc 100644 --- a/sapi/quickstart/setup-php-runtime-in-docker.sh +++ b/sapi/quickstart/setup-php-runtime-in-docker.sh @@ -19,20 +19,28 @@ fi cd ${__DIR__} + if [ ! -f ${__PROJECT__}/var/runtime/swoole-cli ];then echo ' please run setup-php-runtime.sh ' exit 0 fi set -exu -export PATH="${__PROJECT__}/bin/runtime:$PATH" -cd ${__PROJECT__}/var/runtime +# 容器内 +if [ -f /.dockerenv ];then + + export PATH="${__PROJECT__}/bin/runtime:$PATH" + + cd ${__PROJECT__}/var/runtime -cp -f swoole-cli /usr/local/bin/ -cp -f composer.phar /usr/local/bin/ + cp -f swoole-cli /usr/local/bin/ + cp -f composer.phar /usr/local/bin/ -ln -sf /usr/local/bin/swoole-cli /usr/local/bin/php -ln -sf /usr/local/bin/composer.phar /usr/local/bin/composer + ln -sf /usr/local/bin/swoole-cli /usr/local/bin/php + ln -sf /usr/local/bin/composer.phar /usr/local/bin/composer -cd ${__PROJECT__}/ -php -v + cd ${__PROJECT__}/ + php -v + compoer list + +fi diff --git a/sapi/quickstart/windows/README.md b/sapi/quickstart/windows/README.md index af43d8e805..fa39654a9a 100644 --- a/sapi/quickstart/windows/README.md +++ b/sapi/quickstart/windows/README.md @@ -1,29 +1,32 @@ -# windows 快速准备构建环境 (2种构建方式) +# windows 快速准备构建环境 1. 原生构建 2. cygwin 环境 构建 + 3. msys2 环境 构建 -## 一、原生构建 - -### [windows 原生构建步骤](native-build/README.md) - -## 二、cygwin 环境 构建 - - cygwin 环境 构建 快速开始,双击如下两个脚本,自动下载cygwin 和 cygwin安装依赖库 +## windows 环境下 git 配置 ```shell -# 自动下载 cygwin -sapi\quickstart\windows\download-cygwin.bat -# 自动安装 cygwin -sapi\quickstart\windows\install-cygwin.bat - +git config --global core.autocrlf false +git config --global core.eol lf +git config --global core.ignorecase false +git config core.ignorecase false # 设置 Git 在 Windows 上也区分大小写 ``` -### [windows cygwin 构建步骤](../../../docs/Cygwin.md) +### [windows cygwin 环境 构建步骤](../../../docs/Cygwin.md) -## 三、其它 +### [windows 原生构建步骤](native-build/README.md) + +### 构建window PHP 工具 和 参考 + +[download windows PHP ](https://windows.php.net/download#php-8.2) +[windows build php 步骤](https://wiki.php.net/internals/windows/stepbystepbuild) +[Latest VC++](https://learn.microsoft.com/en-AU/cpp/windows/latest-supported-vc-redist) +[7zip](https://7-zip.org/) +[visualstudio](https://visualstudio.microsoft.com/zh-hans/downloads/) +[windows-sdk](https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/) ### windows 软连接例子 @@ -33,11 +36,9 @@ mklink composer composer.phar ``` -### cygwin mirror - https://cygwin.com/mirrors.html -### msys2 mirror and environment - https://www.msys2.org/dev/mirrors/ - https://www.msys2.org/docs/environments/ + + + diff --git a/sapi/quickstart/windows/cygwin-build/README.md b/sapi/quickstart/windows/cygwin-build/README.md new file mode 100644 index 0000000000..cea1c3554c --- /dev/null +++ b/sapi/quickstart/windows/cygwin-build/README.md @@ -0,0 +1,24 @@ +## cygwin workdir + +```shell + + DISK_DRIVE=$( df -h / | sed -n '2p' | awk '{ print $1 }' )$(pwd) + echo $DISK_DRIVE + WIND_DIR=$(echo $DISK_DRIVE | sed 's/\//\\/g') + +``` + +## 自动安装 cygwin 和 cygwin 依赖项 + +```bash + +# 自动安装 cygwin 和 cygwin 依赖项 +.\sapi\quickstart\windows\cygwin-build\download-cygwin.bat +.\sapi\quickstart\windows\cygwin-build\install-cygwin.bat + + +``` + +### cygwin mirror + + https://cygwin.com/mirrors.html diff --git a/sapi/quickstart/windows/cygwin-build/download-cygwin.bat b/sapi/quickstart/windows/cygwin-build/download-cygwin.bat index 25086a1f0b..1b5e928bf8 100644 --- a/sapi/quickstart/windows/cygwin-build/download-cygwin.bat +++ b/sapi/quickstart/windows/cygwin-build/download-cygwin.bat @@ -1,3 +1,23 @@ @echo off :: cygwin site: https://cygwin.com/ -start https://cygwin.com/setup-x86_64.exe +:: start https://cygwin.com/setup-x86_64.exe + +setlocal + + +echo %~dp0 +cd /d %~dp0 +cd /d ..\..\..\..\ + +set "__PROJECT__=%cd%" +echo %cd% + +md %__PROJECT__%\var\windows-cygwin-build-deps\ + +cd /d %__PROJECT__%\var\windows-cygwin-build-deps\ + +curl.exe -fSLo setup-x86_64.exe https://cygwin.com/setup-x86_64.exe + +copy .\setup-x86_64.exe %__PROJECT__%\ + +endlocal diff --git a/sapi/quickstart/windows/cygwin-build/install-cygwin.bat b/sapi/quickstart/windows/cygwin-build/install-cygwin.bat index 0f5c641412..947c6fa2d4 100644 --- a/sapi/quickstart/windows/cygwin-build/install-cygwin.bat +++ b/sapi/quickstart/windows/cygwin-build/install-cygwin.bat @@ -1,10 +1,42 @@ @echo off -:: 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 +:: cygwin site: https://cygwin.com/ +:: start https://cygwin.com/setup-x86_64.exe -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 +setlocal enableextensions enabledelayedexpansion -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 +echo %~dp0 +cd /d %~dp0 +cd /d ..\..\..\..\ +set "__PROJECT__=%cd%" +cd /d %__PROJECT__%\ +echo %cd% +:: package separate with commas + +set SITE="https://mirrors.kernel.org/sourceware/cygwin/" + +:getopt +if /i "%1" equ "--mirror" ( + if /i "%2" equ "china" ( + set SITE="https://mirrors.ustc.edu.cn/cygwin/" + ) +) +shift + +if not (%1)==() goto getopt + +if "%GITHUB_ACTIONS%"=="" ( + setup-x86_64.exe --quiet-mode --disable-buggy-antivirus --site %SITE% +) + +setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site %SITE% --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 + +setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site %SITE% --packages zip unzip + +setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site %SITE% --packages libpq5 libpq-devel + +setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site %SITE% --packages libzstd-devel + +endlocal diff --git a/sapi/quickstart/windows/msys2-build/README.md b/sapi/quickstart/windows/msys2-build/README.md new file mode 100644 index 0000000000..17e9179548 --- /dev/null +++ b/sapi/quickstart/windows/msys2-build/README.md @@ -0,0 +1,7 @@ + + + +### msys2 mirror and environment + + https://www.msys2.org/dev/mirrors/ + https://www.msys2.org/docs/environments/ diff --git a/sapi/quickstart/windows/msys2-build/download-msys2.bat b/sapi/quickstart/windows/msys2-build/download-msys2.bat new file mode 100644 index 0000000000..6cf2662546 --- /dev/null +++ b/sapi/quickstart/windows/msys2-build/download-msys2.bat @@ -0,0 +1,7 @@ +@echo off +:: msys2 site: https://www.msys2.org/ +:: start https://mirror.msys2.org/distrib/x86_64/msys2-x86_64-20230526.exe + +:: curl.exe -fSLo msys2-x86_64-20230526.exe https://mirror.msys2.org/distrib/x86_64/msys2-x86_64-20230526.exe +curl.exe -fSLo msys2-x86_64-20241208.exe https://repo.msys2.org/distrib/x86_64/msys2-x86_64-20241208.exe + diff --git a/sapi/quickstart/windows/native-build/msys2/install-msys2.md b/sapi/quickstart/windows/msys2-build/install-msys2.md similarity index 75% rename from sapi/quickstart/windows/native-build/msys2/install-msys2.md rename to sapi/quickstart/windows/msys2-build/install-msys2.md index cb51e75a9b..996bc61cde 100644 --- a/sapi/quickstart/windows/native-build/msys2/install-msys2.md +++ b/sapi/quickstart/windows/msys2-build/install-msys2.md @@ -34,7 +34,14 @@ pacman -Syy --noconfirm pacman -Syy --noconfirm git # msys2 环境下 拉取 swoole-cli 源码 -git clone --recursive https://github.com/jingjingxyk/swoole-cli.git +git clone --recursive https://github.com/swoole/swoole-cli.git +``` + +```shell + + +bin/runtime/php bin/runtime/composer.phar install --no-interaction --no-autoloader --no-scripts --profile --ignore-platform-req=ext-posix --ignore-platform-req=ext-yaml +bin/runtime/php bin/runtime/composer.phar dump-autoload --optimize --profile --ignore-platform-req=ext-posix --ignore-platform-req=ext-yaml ``` diff --git a/sapi/scripts/cygwin/install-msys2.sh b/sapi/quickstart/windows/msys2-build/install-msys2.sh similarity index 53% rename from sapi/scripts/cygwin/install-msys2.sh rename to sapi/quickstart/windows/msys2-build/install-msys2.sh index 7c4ce90916..54c22c9d73 100644 --- a/sapi/scripts/cygwin/install-msys2.sh +++ b/sapi/quickstart/windows/msys2-build/install-msys2.sh @@ -4,17 +4,20 @@ # # https://mirrors.tuna.tsinghua.edu.cn/msys2/distrib/x86_64/ -wget https://mirrors.tuna.tsinghua.edu.cn/msys2/distrib/x86_64/msys2-x86_64-20230318.exe +wget https://mirrors.tuna.tsinghua.edu.cn/msys2/distrib/x86_64/msys2-x86_64-20230318.exe # msys2 help # https://mirror.tuna.tsinghua.edu.cn/help/msys2/ - # 搜索包 pacman -Ss curl # 升级 pacman -Syu -# 安装包 -pacman -Sy git curl wget # 无须确认安装包 pacman -Sy --noconfirm git curl wget openssl + +pacman -Syy --noconfirm curl wget openssl zip unzip xz gcc gcc-g++ cmake make + +pacman -Syy --noconfirm openssl-devel libreadline + +pacman -Syy --noconfirm lzip diff --git a/sapi/quickstart/windows/native-build/msys2/msys2-download-source-code.sh b/sapi/quickstart/windows/msys2-build/prepare.sh similarity index 100% rename from sapi/quickstart/windows/native-build/msys2/msys2-download-source-code.sh rename to sapi/quickstart/windows/msys2-build/prepare.sh diff --git a/sapi/quickstart/windows/native-build/README.md b/sapi/quickstart/windows/native-build/README.md index f59dc71f40..adc25db376 100644 --- a/sapi/quickstart/windows/native-build/README.md +++ b/sapi/quickstart/windows/native-build/README.md @@ -1,49 +1,94 @@ # 构建原生 PHP - 1. 准备 msys2 环境 - 2. msys2 环境下 下载软件包 、PHP 运行时 、PHP SDK 等 - 3. CMD 环境执行构建 +## 二、CMD 环境构建 -## 一 、[msys2 环境 下载软件包 、PHP 运行时 、PHP SDK 等 ](msys2/README.md) +> bat 脚本不能包含中文 -## 二、CMD 环境构建 +> nmake并行编译 使用NMake命令,并在其后加上/MP选项 -```bat +> echo. >> makefile 给makefile 增加一空行 + +> link.exe 链接静态库 `link /OUT:myprogram.exe /LIBPATH:C:\libs myprogram.obj mylib.lib` + +``` + +git config --global core.autocrlf false +git config --global core.eol lf +git config --global core.ignorecase false -# 安装 vc 运行时 ( 可跳过 ) -sapi\quickstart\windows\native-build\install-vc-runtime.bat -sapi\quickstart\windows\native-build\install-visualstudio-2019.bat +``` -sapi\quickstart\windows\native-build\install-deps-soft.bat + +```bat -# vs2019 -cmd /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64 +:: vs2022 -# start /B -# cmd /c +%comspec% /k "d:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64 -sapi\quickstart\windows\native-build\library\zlib.bat +cmd /k "d:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64 -sapi\quickstart\windows\native-build\library\openssl.bat +:: start /B +:: cmd /c +:: powershell vs dev +:: C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -noe -c "&{Import-Module """D:\vs\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"""; Enter-VsDevShell 79dcbe64}" + +%comspec% /k "D:\vs\Common7\Tools\VsDevCmd.bat" +%comspec% /k "D:\vs\VC\Auxiliary\Build\vcvars64.bat" +%comspec% /k "D:\vs\VC\Auxiliary\Build\vcvarsamd64_x86.bat" +%ProgramFiles(x86)% +%USERPROFILE% +%NUMBER_OF_PROCESSORS% -cmd /k sapi\quickstart\windows\native-build\native-build-php-sdk-vs2019.bat :: phpsdk_deps -u :: phpsdk_buildtree phpdev -sapi\quickstart\windows\native-build\native-build-php-config.bat -sapi\quickstart\windows\native-build\native-build-php-build.bat +.\var\windows-build-deps\php-sdk-binary-tools\phpsdk-vs17-x64.bat + +.\sapi\quickstart\windows\native-build\config.bat +.\sapi\quickstart\windows\native-build\build.bat +.\sapi\quickstart\windows\native-build\clean.bat +.\sapi\quickstart\windows\native-build\show-var.bat + + +cd .\var\windows-build-deps\php-src\ +buildconf.bat -f +configure --help + +configure.bat ^ +--with-php-build="c:\php-cli" ^ +--with-extra-includes='' ^ +--with-extra-libs='' ^ +--disable-all --disable-cgi --enable-cli ^ +--enable-sockets --enable-ctype --enable-pdo --enable-phar ^ +--enable-filter ^ +--enable-xmlreader --enable-xmlwriter ^ +--enable-tokenizer -sapi\quickstart\windows\native-build\native-build-php-release.bat +::--enable-cli-win32 -sapi\quickstart\windows\native-build\native-build-php-archive.bat +nmake /E php.exe +dumpbin /DEPENDENTS ".\x64\Release_TS\php.exe" + +:: in powershell +cmd /c dumpbin /DEPENDENTS ".\x64\Release_TS\php.exe" +``` + +```shell +# 下载 vs2022 + +# 方式一 +curl -Lo VisualStudioSetup.exe 'https://c2rsetup.officeapps.live.com/c2r/downloadVS.aspx?sku=community&channel=Release&version=VS2022' +# 方式二 +curl -Lo VisualStudioSetup.exe 'https://aka.ms/vs/17/release/vs_community.exe' + ``` ## 实验 vs2022 环境构建 @@ -65,64 +110,200 @@ sapi\quickstart\windows\native-build\native-build-php-sdk-vs2022.bat ## 构建window PHP 工具 和 参考 -[ download windows PHP ](https://windows.php.net/download#php-8.2) - +[internals/windows/libs](https://wiki.php.net/internals/windows/libs) +[download windows PHP ](https://windows.php.net/download#php-8.2) +[windows build php 步骤](https://wiki.php.net/internals/windows/stepbystepbuild) [windows build php 步骤](https://wiki.php.net/internals/windows/stepbystepbuild_sdk_2) +[Latest VC++](https://learn.microsoft.com/en-AU/cpp/windows/latest-supported-vc-redist) +[7zip](https://7-zip.org/) +[visualstudio](https://visualstudio.microsoft.com/zh-hans/downloads/) +[windows-sdk](https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/) +[通过命令行使用 MSVC 工具集](https://learn.microsoft.com/zh-cn/cpp/build/building-on-the-command-line?view=msvc-170) +[Microsoft Visual C++ 可再发行程序包最新支持的下载](https://learn.microsoft.com/zh-cn/cpp/windows/latest-supported-vc-redist?view=msvc-170) +[Visual Studio 教程 | C++](https://learn.microsoft.com/zh-cn/cpp/get-started/?view=msvc-170) +[使用命令行参数安装、更新和管理 Visual Studio](https://learn.microsoft.com/zh-cn/visualstudio/install/use-command-line-parameters-to-install-visual-studio?view=vs-2022) +[Visual Studio 开发人员命令提示和开发人员 PowerShell](https://learn.microsoft.com/zh-cn/visualstudio/ide/reference/command-prompt-powershell?view=vs-2022&redirectedfrom=MSDN) -[internals/windows/libs](https://wiki.php.net/internals/windows/libs) +## 通过命令行使用 MSBuild + + https://learn.microsoft.com/zh-cn/cpp/build/msbuild-visual-cpp?view=msvc-170 + + // C:\Program Files\Microsoft Visual Studio\2022\Enterprise // + // C:\Program Files\Microsoft Visual Studio\2022\Community // + cl /? + +Windows SDK +https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/ + +消息编译器是 Windows SDK 的一部分 +消息编译器命令行在这里描述:MC.EXE + +## Visual Studio 生成工具组件目录 + +https://learn.microsoft.com/zh-cn/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2022 + +> MSVC 命令行工具使用 PATH、TMP、INCLUDE、LIB 和 LIBPATH 环境变量 ```shell -git config core.ignorecase false # 设置 Git 在 Windows 上也区分大小写 +VisualStudioSetup.exe +--locale en-US +--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 +--add Microsoft.Component.MSBuild +--add Microsoft.VisualStudio.Component.Roslyn.Compiler +--add Microsoft.Component.MSBuild +--add Microsoft.VisualStudio.Component.CoreBuildTools +--add Microsoft.VisualStudio.Workload.MSBuildTools +--add Microsoft.VisualStudio.Component.Windows11SDK.22000 +--add Microsoft.VisualStudio.Component.Windows10SDK.20348 +--add Microsoft.VisualStudio.Component.Windows10SDK +--path install="C:\VS" --path cache="C:\VS\cache" --path shared="C:\VS\shared" +--quiet --force --norestart +--channelId VisualStudio.16.Release ^ + +vs_buildtools.exe --quiet --force --norestart + +# 导出配置 +VisualStudioSetup.exe export --passive --force ``` -Latest VC++ -https://learn.microsoft.com/en-AU/cpp/windows/latest-supported-vc-redist +Microsoft Visual C++ 运行时库 +https://learn.microsoft.com/zh-cn/cpp/windows/latest-supported-vc-redist?view=msvc-170 +https://aka.ms/vs/17/release/vc_redist.x64.exe -7zip -https://7-zip.org/ +## 下载 visual studio 安装器 -visualstudio -https://visualstudio.microsoft.com/zh-hans/downloads/ + https://c2rsetup.officeapps.live.com/c2r/downloadVS.aspx?sku=community&channel=Release&version=VS2022 + https://c2rsetup.officeapps.live.com/c2r/downloadVS.aspx?sku=community&channel=Release&version=VS2019 -windows-sdk -https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/ + https://aka.ms/vs/17/release/vs_buildtools.exe -Windows PowerShell ISE 文本编辑器 + curl -Lo VisualStudioSetup.exe 'https://c2rsetup.officeapps.live.com/c2r/downloadVS.aspx?sku=community&channel=Release&version=VS2022' + curl -Lo VisualStudioSetup.exe 'https://aka.ms/vs/17/release/vs_community.exe' + curl -Lo vs_buildtools.exe 'https://aka.ms/vs/17/release/vs_buildtools.exe' -## 通过命令行使用 MSVC 工具集 +```shell +# 编译cpp +# https://learn.microsoft.com/zh-cn/cpp/build/walkthrough-creating-and-using-a-static-library-cpp?view=msvc-170 - https://learn.microsoft.com/zh-cn/cpp/build/building-on-the-command-line?view=msvc-170 +cl /c /EHsc MathLibrary.cpp -## 通过命令行使用 MSBuild +cl /EHsc /MT test-vc.cpp /link LIBCMT.LIB /NODEFAULTLIB:msvcrt.lib - https://learn.microsoft.com/zh-cn/cpp/build/msbuild-visual-cpp?view=msvc-170 +LINK first.obj second.obj third.obj /OUT:filename.exe - // C:\Program Files\Microsoft Visual Studio\2022\Enterprise // - // C:\Program Files\Microsoft Visual Studio\2022\Community // - cl /? +# 查看连接信息 -## Microsoft Visual C++ 可再发行程序包最新支持的下载 +dumpbin /DEPENDENTS test-vc.exe - https://learn.microsoft.com/zh-cn/cpp/windows/latest-supported-vc-redist?view=msvc-170 +``` -Windows SDK -https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/ +## 参考文档 -消息编译器是 Windows SDK 的一部分 -消息编译器命令行在这里描述:MC.EXE +1. [virtualstudio 命令行安装](https://learn.microsoft.com/zh-cn/visualstudio/install/use-command-line-parameters-to-install-visual-studio?view=vs-2022) +1. [使用命令行参数安装、更新和管理 Visual Studio](https://learn.microsoft.com/zh-cn/visualstudio/install/use-command-line-parameters-to-install-visual-studio?view=vs-2022) +1. [通过命令行使用 MSVC 工具集](https://learn.microsoft.com/zh-cn/cpp/build/building-on-the-command-line?view=msvc-170) +1. [从命令行使用 Microsoft C++ 工具集](https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170#download-and-install-the-tools) +1. [通过命令行使用 MSBuild](https://learn.microsoft.com/zh-cn/cpp/build/msbuild-visual-cpp?view=msvc-1700) +1. [Microsoft Visual C++ 最新运行时库](https://learn.microsoft.com/zh-cn/cpp/windows/latest-supported-vc-redist?view=msvc-170) +1. [Visual Studio 生成工具组件目录](https://learn.microsoft.com/zh-cn/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2022) +1. [Windows SDK](https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/) +1. [windows 环境下 构建 php 步骤](https://wiki.php.net/internals/windows/stepbystepbuild_sdk_2) +1. [VisualStudio 导入或导出安装配置](https://learn.microsoft.com/zh-cn/visualstudio/install/import-export-installation-configurations?view=vs-2022) +1. [Visual Studio 2019 版本 16.11 发行说明](https://learn.microsoft.com/zh-cn/visualstudio/releases/2019/release-notes) +1. [Visual Studio 2022 版本 17.9 发行说明](https://learn.microsoft.com/zh-cn/visualstudio/releases/2022/release-notes) +1. [MSVC 如何将清单嵌入到 C/C++ 应用程序中](https://learn.microsoft.com/zh-cn/cpp/build/understanding-manifest-generation-for-c-cpp-programs?view=msvc-170) +1. [Visual Studio 教程 | C++](https://learn.microsoft.com/zh-cn/cpp/get-started/?view=msvc-170) +1. [7zip](https://7-zip.org/) +1. [Visual Studio 许可证目录](https://visualstudio.microsoft.com/zh-hans/license-terms/) +1. [windows环境 使用ssh](https://learn.microsoft.com/zh-cn/windows-server/administration/openssh/openssh_install_firstuse) +1. [MSVC链接器选项](https://learn.microsoft.com/zh-cn/cpp/build/reference/linker-options?view=msvc-170) +1. [MSVC Mt.exe](https://learn.microsoft.com/en-us/windows/win32/sbscs/mt-exe?redirectedfrom=MSDN) +1. [/MD、/MT、/LD(使用运行时库)](https://learn.microsoft.com/zh-cn/cpp/build/reference/md-mt-ld-use-run-time-library?view=msvc-170) +1. [Install PowerShell on Windows, Linux, and macOS](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell?view=powershell-7.4) +1. [Sysinternals Utilities Index](https://learn.microsoft.com/en-us/sysinternals/downloads/) +1. [curl 8.11.1 for Windows](https://curl.se/windows/) +1. [windows php release ](https://windows.php.net/downloads/releases/archives/) +1. [通过命令行使用 MSVC 工具集](https://learn.microsoft.com/zh-cn/cpp/build/building-on-the-command-line?view=msvc-170) +1. [通过命令行使用 MSBuild](https://learn.microsoft.com/zh-cn/cpp/build/msbuild-visual-cpp?view=msvc-1700) +1. [Windows SDK](https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/) +1. [windows 环境下 构建 php 步骤](https://wiki.php.net/internals/windows/stepbystepbuild_sdk_2) +1. [VisualStudio 导入或导出安装配置](https://learn.microsoft.com/zh-cn/visualstudio/install/import-export-installation-configurations?view=vs-2022) +1. [Visual Studio 2019 版本 16.11 发行说明](https://learn.microsoft.com/zh-cn/visualstudio/releases/2019/release-notes) +1. [Visual Studio 2022 版本 17.9 发行说明](https://learn.microsoft.com/zh-cn/visualstudio/releases/2022/release-notes) -Visual Studio 教程 | C++ -https://learn.microsoft.com/zh-cn/cpp/get-started/?view=msvc-170 -## 使用命令行参数安装、更新和管理 Visual Studio +常用命令 说明 +MSBuild 生成项目或解决方案 +dotnet .NET CLI 命令 +dotnet run .NET CLI 命令 +clrver 用于 CLR 的 .NET Framework 工具 +ildasm 用于反汇编程序的 .NET Framework 工具 +CL C/C++ 编译工具 +NMAKE C/C++ 编译工具 +LIB C/C++ 生成工具 +DUMPBIN C/C++ 生成工具 -https://learn.microsoft.com/zh-cn/visualstudio/install/use-command-line-parameters-to-install-visual-studio?view=vs-2022 -## Visual Studio 生成工具组件目录 -https://learn.microsoft.com/zh-cn/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2022 +```bash + + +# https://github.com/notepad-plus-plus/notepad-plus-plus/ +test -f npp.8.6.7.Installer.x64.exe || curl -Lo npp.8.6.7.Installer.x64.exe https://github.com/notepad-plus-plus/notepad-plus-plus/releases/download/v8.6.7/npp.8.6.7.Installer.x64.exe + +# https://7-zip.org/ +test -f 7z2405-x64.exe || curl -Lo 7z2405-x64.exe https://7-zip.org/a/7z2405-x64.exe + + +test -f Git-2.45.1-64-bit.exe || curl -Lo Git-2.45.1-64-bit.exe https://github.com/git-for-windows/git/releases/download/v2.45.1.windows.1/Git-2.45.1-64-bit.exe + +# https://curl.se/windows/ + +test -f curl-8.8.0_1-win64-mingw.zip || curl -Lo curl-8.8.0_1-win64-mingw.zip https://curl.se/windows/dl-8.8.0_1/curl-8.8.0_1-win64-mingw.zip +test -d curl-8.8.0_1-win64-mingw && rm -rf curl-8.8.0_1-win64-mingw +unzip curl-8.8.0_1-win64-mingw.zip + +# https://libarchive.org/ +test -f libarchive-v3.7.4-amd64.zip || curl -Lo libarchive-v3.7.4-amd64.zip https://libarchive.org/downloads/libarchive-v3.7.4-amd64.zip +unzip libarchive-v3.7.4-amd64.zip + + +``` + +```bash + +# https://learn.microsoft.com/en-us/vcpkg/examples/installing-and-using-packages +# test -d vcpkg || git clone -b master --depth=1 https://github.com/microsoft/vcpkg + +# test -f Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle || curl -Lo Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle https://github.com/microsoft/winget-cli/releases/download/v1.7.11261/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle +# rem powershell "add-appxpackage .\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" +# rem winget install nasm -i + + +# winget install nasm -i +# https://repo.or.cz/w/nasm.git +# https://www.nasm.us/pub/nasm/releasebuilds/2.16.03/ +# https://github.com/netwide-assembler/nasm/blob/master/INSTALL +# https://github.com/netwide-assembler/nasm.git +# test -d nasm || git clone --depth=1 https://github.com/netwide-assembler/nasm.git +# test -f nasm-2.16.03-win64.zip || curl -Lo nasm-2.16.03-win64.zip https://www.nasm.us/pub/nasm/releasebuilds/2.16.03/win64/nasm-2.16.03-win64.zip +# https://github.com/jingjingxyk/swoole-cli/releases/tag/t-v0.0.3 +test -f nasm-2.16.03-win64.zip || curl -Lo nasm-2.16.03-win64.zip https://github.com/jingjingxyk/swoole-cli/releases/download/t-v0.0.3/nasm-2.16.03-win64.zip +test -d nasm && rm -rf nasm +unzip nasm-2.16.03-win64.zip +mv nasm-2.16.03 nasm +ls -lh nasm + + + +# https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/ +test -f strawberry-perl-5.38.2.2-64bit.msi || curl -Lo strawberry-perl-5.38.2.2-64bit.msi https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_53822_64bit/strawberry-perl-5.38.2.2-64bit.msi + + +``` + ```shell @@ -144,6 +325,10 @@ VisualStudioSetup.exe vs_buildtools.exe --quiet --force --norestart + + +dir "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" + ``` Microsoft Visual C++ 运行时库 @@ -194,4 +379,18 @@ dumpbin /DEPENDENTS test-vc.exe 1. [/MD、/MT、/LD(使用运行时库)](https://learn.microsoft.com/zh-cn/cpp/build/reference/md-mt-ld-use-run-time-library?view=msvc-170) 1. [Install PowerShell on Windows, Linux, and macOS](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell?view=powershell-7.4) 1. [Sysinternals Utilities Index](https://learn.microsoft.com/en-us/sysinternals/downloads/) +1. [用于检测和管理 Visual Studio 实例的工具](https://learn.microsoft.com/zh-cn/visualstudio/install/tools-for-managing-visual-studio-instances?view=vs-2022) + +```text + +set "OLD_TEXT=^"/LD /MD^"" +set "NEW_TEXT=^"/MT^"" + +for /f "delims=" %%i in ('type "%X_MAKEFILE%"') do ( + set "line=%%i" + set "line=!line:%OLD_TEXT%=%NEW_TEXT%!" + :: echo !line!>>"%X_MAKEFILE%" +) + +``` diff --git a/sapi/quickstart/windows/native-build/build-static-php.ps1 b/sapi/quickstart/windows/native-build/build-static-php.ps1 new file mode 100644 index 0000000000..33623433dc --- /dev/null +++ b/sapi/quickstart/windows/native-build/build-static-php.ps1 @@ -0,0 +1,47 @@ + +$__DIR__ = $PSScriptRoot + +$__DIR__ = Split-Path -Parent $MyInvocation.MyCommand.Definition +$__PROJECT__ = ( Convert-Path "$__DIR__\..\..\..\..\") + +Write-Host $__DIR__ +Write-Host $__PROJECT__ +Write-Host (Get-Location).Path + +<# + +var\windows-build-deps\php-sdk-binary-tools\phpsdk-vs17-x64.bat +cd var\windows-build-deps\php-src\ + +.\buildconf.bat -f +.\configure.bat --help + +configure.bat ^ +--disable-all --disable-cgi --enable-cli ^ +--enable-sockets --enable-ctype --enable-pdo --enable-phar ^ +--enable-filter ^ +--enable-xmlreader --enable-xmlwriter ^ +--enable-tokenizer + + + +nmake /E php.exe + +cd .\x64\Release_TS\ + +dumpbin /DEPENDENTS .\x64\Release_TS\php.exe + +# PHP 8.4 引入了默认的线程安全(ts)版本 + +dir .\var\windows-build-deps\php-sdk-binary-tools\msys2\usr\bin\ + +#> + +exit + + +Invoke-Expression "cmd /c $__PROJECT__\var\windows-build-deps\php-sdk-binary-tools\phpsdk-vs17-x64.bat" +Invoke-Expression "cmd /c $__PROJECT__\sapi\quickstart\windows\native-build\native-build-php-config.bat" + + +cd $__PROJECT__ diff --git a/sapi/quickstart/windows/native-build/build.bat b/sapi/quickstart/windows/native-build/build.bat index 58ad1a2bd9..3a3ff8c7cf 100644 --- a/sapi/quickstart/windows/native-build/build.bat +++ b/sapi/quickstart/windows/native-build/build.bat @@ -1,21 +1,82 @@ @echo off +setlocal enabledelayedexpansion rem show current file location echo %~dp0 -cd %~dp0 -cd ..\..\..\..\ +cd /d %~dp0 +cd /d ..\..\..\..\ -set __PROJECT__=%cd% -cd /d %__PROJECT__% +set "__PROJECT__=%cd%" +echo %cd% +cd %__PROJECT__%\var\windows-build-deps\php-src\ -rem cmd /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64 -rem cmd /k sapi\quickstart\windows\native-build\native-build-php-sdk-vs2019.bat +rem set "INCLUDE=%INCLUDE%;%__PROJECT__%\openssl\include\;%__PROJECT__%\zlib\include" +rem set "LIB=%LIB%;%__PROJECT__%\openssl\lib\;%__PROJECT__%\zlib\lib" +rem set "LIBPATH=%LIBPATH%;%__PROJECT__%\openssl\lib\;%__PROJECT__%\zlib\lib\" -cmd /k sapi\quickstart\windows\native-build\native-build-php-config.bat -cmd /k sapi\quickstart\windows\native-build\native-build-php-build.bat -cmd /k sapi\quickstart\windows\native-build\native-build-php-release.bat +set CL=/MP +rem set RTLIBCFG=static +rem nmake mode=static debug=false +rem nmake all -cd /d %__PROJECT__% -set __PROJECT__= +set X_MAKEFILE=%__PROJECT__%\var\windows-build-deps\php-src\Makefile + + +findstr /C:"x-release-php: " %X_MAKEFILE% >nul + +if errorlevel 1 ( +echo custom MAKEFILE x-release-php config! +goto x-release-php-start +) else ( +echo custom MAKEFI file exits ! +goto x-release-php-end +) + +:x-release-php-start + + +echo x-build-php-lib^: generated_files $(PHP_GLOBAL_OBJS) $(CLI_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(ASM_OBJS) $(MCFILE) >> %X_MAKEFILE% +echo x-release-php^: $(DEPS_CLI) $(CLI_GLOBAL_OBJS) x-build-php-lib $(PHP_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(ASM_OBJS) $(BUILD_DIR)^\php.exe.res $(BUILD_DIR)^\php.exe.manifest >> %X_MAKEFILE% + + + +rem https://www.cnblogs.com/sherry-best/archive/2013/04/15/3022705.html +rem https://learn.microsoft.com/zh-CN/cpp/c-runtime-library/crt-library-features?view=msvc-170&viewFallbackFrom=vs-2019 +rem echo ^@"$(LINK)" ^/nologo $(PHP_GLOBAL_OBJS) $(PHP_GLOBAL_OBJS_RESP) $(CLI_GLOBAL_OBJS) $(CLI_GLOBAL_OBJS_RESP) $(STATIC_EXT_OBJS_RESP) $(STATIC_EXT_OBJS) $(ASM_OBJS) $(LIBS) $(LIBS_CLI) $(BUILD_DIR)^\php.exe.res /out:$(BUILD_DIR)^\php.exe $(LDFLAGS) $(LDFLAGS_CLI) >> %x_makefile% +rem echo ^@"$(LINK)" ^/nologo $(DEPS_CLI) $(STATIC_EXT_OBJS_RESP) $(STATIC_EXT_LIBS) $(ASM_OBJS) $(LIBS) $(LIBS_CLI) $(BUILD_DIR)^\php.exe.res /out:$(BUILD_DIR)^\php.exe $(LDFLAGS) $(LDFLAGS_CLI) >> %x_makefile% +rem echo -@$(_VC_MANIFEST_EMBED_EXE) >> %x_makefile% +rem echo ^@echo SAPI sapi\cli build complete >> %x_makefile% +rem echo @if exist php.exe.manifest $(MT) -nologo -manifest php.exe.manifest -outputresource:php.exe >> %x_makefile% + +rem /WHOLEARCHIVE /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcrtd.lib /FORCE:MULTIPLE +rem libcpmt.lib libvcruntime.lib libucrt.lib msvcrt.lib +rem /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrtd.lib +rem libvcruntime.lib libcmt.lib + +rem /MANIFEST:php.exe.manifest /MANIFESTUAC:uiAccess /SUBSYSTEM:CONSOLE /subsystem:windows + +:x-release-php-end + + + +rem nmake /E x-release-php +:: nmake /E php.exe + + +:: nmake /E php.exe +nmake /E /f Makefile x-release-php + + + + +:: .\x64\Release\php.exe -v +:: .\x64\Release\php.exe -m +:: dumpbin /DEPENDENTS ".\x64\Release\php.exe" +:: dumpbin /DEPENDENTS ".\x64\Release_TS\php.exe" + + +cd %__PROJECT__% +endlocal + diff --git a/sapi/quickstart/windows/native-build/native-build-php-clean.bat b/sapi/quickstart/windows/native-build/clean.bat similarity index 73% rename from sapi/quickstart/windows/native-build/native-build-php-clean.bat rename to sapi/quickstart/windows/native-build/clean.bat index 2e0a72e3c9..33cdcc0879 100644 --- a/sapi/quickstart/windows/native-build/native-build-php-clean.bat +++ b/sapi/quickstart/windows/native-build/clean.bat @@ -8,7 +8,8 @@ cd /d ..\..\..\..\ set "__PROJECT__=%cd%" echo %cd% -cd %__PROJECT__%\php-src\ +cd /d %__PROJECT__%\var\windows-build-deps\php-src\ + nmake clean diff --git a/sapi/quickstart/windows/native-build/cmd-phpsdk-diff.md b/sapi/quickstart/windows/native-build/cmd-phpsdk-diff.md deleted file mode 100644 index 4e74a47be0..0000000000 --- a/sapi/quickstart/windows/native-build/cmd-phpsdk-diff.md +++ /dev/null @@ -1,65 +0,0 @@ -```bat - - -DevEnvDir=DevEnvDir=C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\ -ExtensionSdkDir=C:\Program Files (x86)\Microsoft SDKs\Windows Kits\10\ExtensionSDKs -EXTERNAL_INCLUDE=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\VS\include;C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\um;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\shared;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\winrt;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\cppwinrt - -Framework40Version=v4.0 -FrameworkDir=C:\Windows\Microsoft.NET\Framework64\ -FrameworkDir64=C:\Windows\Microsoft.NET\Framework64\ -FrameworkVersion=v4.0.30319 -FrameworkVersion64=v4.0.30319 - -HOST_ARCH_NAME=amd64 -INCLUDE=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\VS\include;C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\um;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\shared;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\winrt;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\cppwinrt -LIB=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\lib\x64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\ucrt\x64;C:\Program Files (x86)\Windows Kits\10\\lib\10.0.22000.0\\um\x64 -LIBPATH=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\lib\x64;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\lib\x86\store\references;C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.22000.0;C:\Program Files (x86)\Windows Kits\10\References\10.0.22000.0;C:\Windows\Microsoft.NET\Framework64\v4.0.30319 - -NUMBER_OF_PROCESSORS=8 - -Path=c:\msys64\home\Administrator\php-sdk-binary-tools\bin;c:\msys64\home\Administrator\php-sdk-binary-tools\msys2\usr\bin;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\bin\HostX64\x64;C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\bin\Roslyn;C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\\x64;C:\Program Files (x86)\Windows Kits\10\bin\\x64;C:\Program Files\Microsoft Visual Studio\2022\Community\\MSBuild\Current\Bin\amd64;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\;C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps -Path=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps; -PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC - -PHP_SDK_ARCH=x64 -PHP_SDK_BIN_PATH=c:\msys64\home\Administrator\php-sdk-binary-tools\bin -PHP_SDK_MSYS2_PATH=c:\msys64\home\Administrator\php-sdk-binary-tools\msys2\usr\bin -PHP_SDK_OS_ARCH=x64 -PHP_SDK_PHP_CMD=c:\msys64\home\Administrator\php-sdk-binary-tools\bin\php\do_php.bat -PHP_SDK_ROOT_PATH=c:\msys64\home\Administrator\php-sdk-binary-tools -PHP_SDK_VC_DIR=C:\Program Files\Microsoft Visual Studio\2022\Community\VC -PHP_SDK_VC_TOOLSET_VER=14.39.33523.0 -PHP_SDK_VS=vs17 -PHP_SDK_VS_NUM=17 -PHP_SDK_VS_SHELL_CMD="C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64 -Platform=x64 - -UCRTVersion=10.0.22000.0 -UniversalCRTSdkDir=C:\Program Files (x86)\Windows Kits\10\ - -VCIDEInstallDir=C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\VC\ -VCINSTALLDIR=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\ -VCToolsInstallDir=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\ -VCToolsRedistDir=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Redist\MSVC\14.38.33135\ -VCToolsVersion=14.39.33519 -VisualStudioVersion=17.0 -VS170COMNTOOLS=C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\ -VSCMD_ARG_app_plat=Desktop -VSCMD_ARG_HOST_ARCH=x64 -VSCMD_ARG_no_logo=yes -VSCMD_ARG_TGT_ARCH=x64 -VSCMD_VER=17.9.6 -VSINSTALLDIR=C:\Program Files\Microsoft Visual Studio\2022\Community\ - -WindowsLibPath=C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.22000.0;C:\Program Files (x86)\Windows Kits\10\References\10.0.22000.0 -WindowsSdkBinPath=C:\Program Files (x86)\Windows Kits\10\bin\ -WindowsSdkDir=C:\Program Files (x86)\Windows Kits\10\ -WindowsSDKLibVersion=10.0.22000.0\ -WindowsSdkVerBinPath=C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\ -WindowsSDKVersion=10.0.22000.0\ -__DOTNET_ADD_64BIT=1 -__DOTNET_PREFERRED_BITNESS=64 -__VSCMD_PREINIT_PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps; - -``` diff --git a/sapi/quickstart/windows/native-build/config.bat b/sapi/quickstart/windows/native-build/config.bat new file mode 100644 index 0000000000..f0fde19c06 --- /dev/null +++ b/sapi/quickstart/windows/native-build/config.bat @@ -0,0 +1,70 @@ +@echo off + +setlocal +rem show current file location +echo %~dp0 +cd /d %~dp0 +cd /d ..\..\..\..\ + +set "__PROJECT__=%cd%" +echo %cd% +cd /d %__PROJECT__%\var\windows-build-deps\php-src\ +echo %cd% + +if exist "Makefile" ( + nmake clean +) + +:: buildconf.bat -f + +echo "====================" + +:: configure.bat --help + + + +rem set "INCLUDE=%INCLUDE%;%__PROJECT__%\build\openssl\include\;%__PROJECT__%\build\zlib\include" +rem set "LIB=%LIB%;%__PROJECT__%\build\openssl\lib\;%__PROJECT__%\build\zlib\lib" +rem set "LIBPATH=%LIBPATH%;%__PROJECT__%\build\openssl\lib\;%__PROJECT__%\build\zlib\lib\" + +:: echo %INCLUDE% +:: echo %LIB% +:: echo %LIBPATH% + + +set "CFLAGS=/EHsc /MT " +set "LDFLAGS=/VERBOSE:LIB /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrtd.lib /DEFAULTLIB:libcmt.lib " + + + +rem set "LDFLAGS=/WHOLEARCHIVE /FORCE:MULTIPLE" + +configure.bat ^ +--with-php-build="c:\php-cli" ^ +--with-extra-includes='' ^ +--with-extra-libs='' ^ +--with-toolset=vs ^ +--disable-all --disable-cgi --enable-cli ^ +--enable-sockets --enable-ctype --enable-pdo --enable-phar ^ +--enable-filter ^ +--enable-xmlreader --enable-xmlwriter ^ +--enable-tokenizer + +:: --disable-zts ^ +:: --enable-apcu ^ +:: --enable-bcmath ^ +:: --enable-zlib ^ +:: --with-openssl=static ^ +:: --with-toolset=vs ^ +:: --with-extra-includes="%INCLUDE%" ^ +:: --with-extra-libs="%LIB%" + + +:: --enable-mbstring +:: --enable-redis ^ +:: --enable-phar-native-ssl +:: --enable-fileinfo +:: --with-curl=static + +cd /d %__PROJECT__% +endlocal diff --git a/sapi/quickstart/windows/native-build/download-msys2.bat b/sapi/quickstart/windows/native-build/download-msys2.bat deleted file mode 100644 index 35bd440020..0000000000 --- a/sapi/quickstart/windows/native-build/download-msys2.bat +++ /dev/null @@ -1,5 +0,0 @@ -@echo off -:: msys2 site: https://www.msys2.org/ -start https://mirror.msys2.org/distrib/x86_64/msys2-x86_64-20230526.exe - - diff --git a/sapi/quickstart/windows/native-build/download-soft.ps1 b/sapi/quickstart/windows/native-build/download-soft.ps1 new file mode 100644 index 0000000000..f7f6901c9c --- /dev/null +++ b/sapi/quickstart/windows/native-build/download-soft.ps1 @@ -0,0 +1,116 @@ +# PowerShell 切换为超级用户 +powershell -NoProfile -Command "Start-Process powershell -Verb RunAs" + +# PowerShell 命令称为 cmdlet(读作 command-let) +# PowerShell ISE主要用于编写和调试PowerShell脚本 +# 在 Windows PowerShell 中 curl 命令被映射为 Invoke-WebRequest + + +Get-Alias -Name curl +Get-Command curl +Get-Command curl.exe + +# 包管理器(winget、chocolatey、scoop) + +# 安裝 WinGet +# https://github.com/microsoft/winget-cli/releases/ +# https://github.com/microsoft/winget-cli/releases/download/v1.10.40-preview/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle + +Add-AppxPackage -Path ".\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" + +Invoke-WebRequest -Uri "https://aka.ms/MicrosoftWinget" -UseBasicParsing | Invoke-Expression + +Invoke-WebRequest -Uri https://github.com/asheroto/winget-install/releases/latest/download/winget-install.ps1 -OutFile .\winget-install.ps1 + +irm https://github.com/asheroto/winget-install/releases/latest/download/winget-install.ps1 | iex + +irm winget.pro | iex + +winget install notepad++ + +winget install --id Git.Git -e --source winget +# 换源 +winget source remove winget +winget source add winget https://mirrors.ustc.edu.cn/winget-source +winget source reset winget + + + + +# Chocolatey是一个开源的包管理器 +# https://chocolatey.org/ +Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) + +# https://community.chocolatey.org/install.ps1 + +irm https://community.chocolatey.org/install.ps1 | iex + +choco list +choco install -y copyq +choco install -y git +choco install -y winget +choco install -y microsoft-windows-terminal +choco install notepadplusplus + + +# Scoop是Windows的命令行安装程序。 +# https://github.com/ScoopInstaller/Install.git +Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser +Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression + +Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser +irm https://get.scoop.sh | iex +# irm get.scoop.sh -Proxy 'http://' | iex + +irm get.scoop.sh -outfile 'install.ps1' +.\install.ps1 -RunAsAdmin + +# 一行命令完成 +iex "& {$( irm get.scoop.sh )} -RunAsAdmin" + +# choco install +scoop install aria2 +scoop install notepad++ +scoop install winget +scoop install windows-terminal + + + +# Windows Terminal +# https://github.com/microsoft/terminal + +# Add-AppxPackage Microsoft.WindowsTerminal_.msixbundle +# https://github.com/microsoft/terminal/releases/download/v1.21.3231.0/Microsoft.WindowsTerminal_1.21.3231.0_8wekyb3d8bbwe.msixbundle + +Invoke-WebRequest -Uri "https://github.com/microsoft/terminal/releases/download/v1.21.3231.0/Microsoft.WindowsTerminal_1.21.3231.0_8wekyb3d8bbwe.msixbundle" -OutFile .\"Microsoft.WindowsTerminal_1.21.3231.0_8wekyb3d8bbwe.msixbundle" + +Add-AppxPackage -Path ".\Microsoft.UI.Xaml.2.8.x64.appx" +Add-AppxPackage -Path ".\Microsoft.WindowsTerminal_1.21.3231.0_8wekyb3d8bbwe.msixbundle" + +winget install --id Microsoft.WindowsTerminal -e + + + +# curl windows +# https://curl.se/windows/ + +Invoke-WebRequest -Uri https://github.com/git-for-windows/git/releases/download/v2.47.1.windows.1/Git-2.47.1-64-bit.exe -OutFile .\Git-2.47.1-64-bit.exe + +start /wait .\Git-2.47.1-64-bit.exe /VERYSILENT /NORESTART /NOCANCEL /SP- /CLOSEONEXIT=1 /DIR="C:\Program Files\Git" + + + + +# vcpkg +# https://learn.microsoft.com/zh-cn/vcpkg/get_started/overview +# https://vcpkg.io/en/packages + +git clone https://github.com/microsoft/vcpkg.git + + + +# nmake /f Makefile.vc mode=dll VC=17 MACHINE=x86 DEBUG=yes + + + + diff --git a/sapi/quickstart/windows/native-build/fast-build-static-php.bat b/sapi/quickstart/windows/native-build/fast-build-static-php.bat deleted file mode 100644 index 08a4dac135..0000000000 --- a/sapi/quickstart/windows/native-build/fast-build-static-php.bat +++ /dev/null @@ -1,28 +0,0 @@ -@echo off - -setlocal -rem show current file location -echo %~dp0 -cd /d %~dp0 -cd /d ..\..\..\..\ - -set "__PROJECT__=%cd%" -echo %cd% - -rem start cmd /k %__PROJECT__% -rem start /d %__PROJECT__% - -rem open new cmd termnial -start cmd /k sapi\quickstart\windows\native-build\install-vc-runtime.bat -start cmd /k sapi\quickstart\windows\native-build\install-deps-soft.bat -start cmd /k sapi\quickstart\windows\native-build\install-visualstudio.bat - -exit 0 -sapi\quickstart\windows\native-build\native-build-php-sdk-vs2019.bat -for /f "delims=" %%i in ('set') do start cmd /k sapi\quickstart\windows\native-build\native-build-php-config.bat -for /f "delims=" %%i in ('set') do start cmd /k sapi\quickstart\windows\native-build\native-build-php-config-help.bat -start cmd /k sapi\quickstart\windows\native-build\native-build-php-build.bat -start cmd /k sapi\quickstart\windows\native-build\native-build-php-build-release.bat -start cmd /k sapi\quickstart\windows\native-build\native-build-php-archive.bat - -endlocal diff --git a/sapi/quickstart/windows/native-build/install-deps-helper-soft.bat b/sapi/quickstart/windows/native-build/install-deps-helper-soft.bat deleted file mode 100644 index ce52dd0b8a..0000000000 --- a/sapi/quickstart/windows/native-build/install-deps-helper-soft.bat +++ /dev/null @@ -1,46 +0,0 @@ -@echo off - -rem chcp 65001 - -setlocal -rem show current file location -echo %~dp0 -cd /d %~dp0 -cd /d .\..\..\..\..\ - -set "__PROJECT__=%cd%" -echo %cd% - - -rem silent installation msi - -rem start /wait "" "安装程序路径.exe" /SILENT /NORESTART - - -:: 设置Git安装路径 -set "INSTALL_PATH=C:\Program Files\Git" - -:: 创建安装目录 -if not exist "%INSTALL_PATH%" mkdir "%INSTALL_PATH%" - -:: 静默安装Git -:: 查看git 安装参数 -:: %__PROJECT__%\Git-2.45.1-64-bit.exe /? -start /wait "" "%__PROJECT__%\Git-2.45.1-64-bit.exe" /VERYSILENT /NORESTART /NOCANCEL /SP- /CLOSEONEXIT=1 /DIR="%INSTALL_PATH%" - - - -:: 更新环境变量 - -echo git installing -set "PATH=%PATH%;%__PROJECT__%\php\;%__PROJECT__%\nasm\;C:\Strawberry\perl\bin;C:\Program Files\Git\bin;%__PROJECT__%\curl-8.8.0_1-win64-mingw\bin;%__PROJECT__%\libarchive\bin;" -echo %PATH% - - -perl -v -php -v -nasm -v -git version -curl -V - -endlocal diff --git a/sapi/quickstart/windows/native-build/install-deps-soft.bat b/sapi/quickstart/windows/native-build/install-deps-soft.bat deleted file mode 100644 index bfc053e112..0000000000 --- a/sapi/quickstart/windows/native-build/install-deps-soft.bat +++ /dev/null @@ -1,27 +0,0 @@ -@echo off - -rem chcp 65001 - -setlocal -rem show current file location -echo %~dp0 -cd /d %~dp0 -cd /d .\..\..\..\..\ - -set "__PROJECT__=%cd%" -echo %cd% - - -rem silent installation msi -rem msiexec /i strawberry-perl-5.38.2.2-64bit.msi /quiet - -msiexec /i strawberry-perl-5.38.2.2-64bit.msi /passive - -set "PATH=%PATH%;%__PROJECT__%\php\;%__PROJECT__%\nasm\;C:\Strawberry\perl\bin;" - -perl -v -php -v -nasm -v - - -endlocal diff --git a/sapi/quickstart/windows/native-build/install-example.md b/sapi/quickstart/windows/native-build/install-example.md deleted file mode 100644 index 3ec51fb0ff..0000000000 --- a/sapi/quickstart/windows/native-build/install-example.md +++ /dev/null @@ -1,91 +0,0 @@ -可以借助 MSYS2 环境 和 CMD 环境 进行构建 - -1. MSYS2 环境 用于下载软件 (msys2 集成了 Mingw 和 Cygwin ,同时还提供了包管理工具 `pacman`) -2. CMD 环境 安装Visual Studio -3. CMD 环境 执行编译 - -## msys2下载软件 - -1. 下载 msys2 [msys2](https://www.msys2.org/]) - > 浏览器打开,自动给下载 msys2: https://mirror.msys2.org/distrib/x86_64/msys2-x86_64-20240507.exe -1. 安装 msys2 - > 双击 `msys2-x86_64-20240507.exe ` 进行安装 -1. msys2安装软件 - ```shell - pacman -Syy --noconfirm git curl - ``` -1. msys2 环境下使用curl 下载软件 - ```shell - # 下载 vs2022 - - # 方式一 - curl -Lo VisualStudioSetup.exe 'https://c2rsetup.officeapps.live.com/c2r/downloadVS.aspx?sku=community&channel=Release&version=VS2022' - # 方式二 - curl -Lo VisualStudioSetup.exe 'https://aka.ms/vs/17/release/vs_community.exe' - - ``` - - ```shell - # 下载 php 源码 - git clone -b php-8.3.6 --depth=1 https://github.com/php/php-src.git - - # 下载 php-sdk for windows - # git clone -b php-sdk-2.2.0 --depth=1 https://github.com/php/php-sdk-binary-tools.git - git clone -b master --depth=1 https://github.com/php/php-sdk-binary-tools.git - - ``` - -## CMD 环境 安装VisualStudio - -1. [使用命令行参数安装、更新和管理 Visual Studio](https://learn.microsoft.com/zh-cn/visualstudio/install/use-command-line-parameters-to-install-visual-studio?view=vs-2022) -1. [Visual Studio 生成工具组件目录](https://learn.microsoft.com/zh-cn/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2022) - -> 使用命令行快速安装 VisualStudio 组件 - -```bat -cd c:\msys64\home\Administrator\ - -VisualStudioSetup.exe ^ ---locale en-US ^ ---add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 ^ ---add Microsoft.Component.MSBuild ^ ---add Microsoft.VisualStudio.Component.Roslyn.Compiler ^ ---add Microsoft.Component.MSBuild ^ ---add Microsoft.VisualStudio.Component.CoreBuildTools ^ ---add Microsoft.VisualStudio.Workload.MSBuildTools ^ ---add Microsoft.VisualStudio.Component.Windows11SDK.22000 ^ ---add Microsoft.VisualStudio.Component.Windows10SDK.20348 ^ ---add Microsoft.VisualStudio.Component.Windows10SDK ^ ---passive --force --norestart -``` - -## CMD 环境 编译构建 - -```bat -cd c:\msys64\home\Administrator\php-sdk-binary-tools -phpsdk-vs17-x64.bat - -``` - -```bat -cd c:\msys64\home\Administrator\php-src -buildconf.bat -configure.bat --help -configure.bat --disable-all --enable-cli --enable-static=yes --enable-shared=no -nmake - - -x64\Release_TS\php.exe -v -x64\Release_TS\php.exe -m - -``` - -## 参考文档 - -1. [通过命令行使用 MSVC 工具集](https://learn.microsoft.com/zh-cn/cpp/build/building-on-the-command-line?view=msvc-170) -1. [通过命令行使用 MSBuild](https://learn.microsoft.com/zh-cn/cpp/build/msbuild-visual-cpp?view=msvc-1700) -1. [Windows SDK](https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/) -1. [windows 环境下 构建 php 步骤](https://wiki.php.net/internals/windows/stepbystepbuild_sdk_2) -1. [VisualStudio 导入或导出安装配置](https://learn.microsoft.com/zh-cn/visualstudio/install/import-export-installation-configurations?view=vs-2022) -1. [Visual Studio 2019 版本 16.11 发行说明](https://learn.microsoft.com/zh-cn/visualstudio/releases/2019/release-notes) -1. [Visual Studio 2022 版本 17.9 发行说明](https://learn.microsoft.com/zh-cn/visualstudio/releases/2022/release-notes) diff --git a/sapi/quickstart/windows/native-build/install-soft-example.bat b/sapi/quickstart/windows/native-build/install-soft-example.bat new file mode 100644 index 0000000000..4a05e65492 --- /dev/null +++ b/sapi/quickstart/windows/native-build/install-soft-example.bat @@ -0,0 +1,15 @@ +@echo off + +REM 检查是否存在软件列表文件 +if not exist "software_list.txt" ( + echo Software list file does not exist! Please create the software list file and run the script again. + exit /b +) + +REM 逐行读取软件列表文件并安装软件 +for /f "tokens=*" %%a in (software_list.txt) do ( + echo Installing software: %%a + winget install %%a +) + +echo All software is already installed! diff --git a/sapi/quickstart/windows/native-build/install-vc-runtime.bat b/sapi/quickstart/windows/native-build/install-vc-runtime.bat deleted file mode 100644 index a99a7916f7..0000000000 --- a/sapi/quickstart/windows/native-build/install-vc-runtime.bat +++ /dev/null @@ -1,17 +0,0 @@ -@echo off - -setlocal -rem show current file location -echo %~dp0 -cd /d %~dp0 -cd /d .\..\..\..\..\ - -set "__PROJECT__=%cd%" -echo %cd% - - -vc_redist.x64.exe /install /passive /norestart -vc_redist.x86.exe /install /passive /norestart - - -endlocal diff --git a/sapi/quickstart/windows/native-build/install-visualstudio-2019.bat b/sapi/quickstart/windows/native-build/install-visualstudio-2019.bat deleted file mode 100644 index f8cbac549e..0000000000 --- a/sapi/quickstart/windows/native-build/install-visualstudio-2019.bat +++ /dev/null @@ -1,36 +0,0 @@ -@echo off - -setlocal -rem show current file location -echo %~dp0 -cd /d %~dp0 -cd /d .\..\..\..\..\ - -set "__PROJECT__=%cd%" -echo %cd% - - -vc_redist.x64.exe /install /passive /norestart -vc_redist.x86.exe /install /passive /norestart - - -VisualStudioSetup.exe ^ ---locale en-US ^ ---add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 ^ ---add Microsoft.VisualStudio.Component.VC.Modules.x86.x64 ^ ---add Microsoft.VisualStudio.Component.VC.CMake.Project ^ ---add Microsoft.VisualStudio.Component.Roslyn.Compiler ^ ---add Microsoft.VisualStudio.Component.Windows10SDK ^ ---add Microsoft.VisualStudio.Component.Windows11SDK.22000 ^ ---add Microsoft.Component.MSBuild ^ ---add Microsoft.VisualStudio.Workload.NativeDesktop ^ ---passive --force --norestart - - - -rem --add Microsoft.VisualStudio.Component.VC.Redist.14.Latest ^ -rem --add Microsoft.VisualStudio.Component.VC.CLI.Support ^ -rem --add Microsoft.VisualStudio.Component.VC.Redist.MSM ^ - - -endlocal diff --git a/sapi/quickstart/windows/native-build/msys2/README.md b/sapi/quickstart/windows/native-build/msys2/README.md deleted file mode 100644 index 1ee3980272..0000000000 --- a/sapi/quickstart/windows/native-build/msys2/README.md +++ /dev/null @@ -1,62 +0,0 @@ -# msys2 环境准备 - -## [安装 msys2 ](install-msys2.md) - -## 下载 msys2 环境 软件包 运行时 - -```bash - -bash sapi/quickstart/windows/native-build/msys2/prepare.sh - -bash sapi/quickstart/windows/native-build/msys2/download.sh - -``` - -```bash - -# msys2 下载安装 git curl wget openssl zip unzip xz lzip 软件包 -bash sapi/quickstart/windows/native-build/msys2/msys2-install-soft.sh - -# 下载 visualstudio 2019 -bash sapi/quickstart/windows/native-build/msys2/msys2-download-vs-2019.sh - -# 调用 CMD 窗口 安装 vc 运行时 -bash sapi/quickstart/windows/native-build/msys2/msys2-install-vc-runtime.sh - -# 准备 PHP 运行时 -bash sapi/quickstart/windows/native-build/msys2/msys2-download-php-runtime.sh - -# 提前准备下载依赖库 -bash sapi/download-box/download-box-get-archive-from-server.sh - - -# 准备 依赖库 和 扩展 -bash sapi/quickstart/windows/native-build/msys2/msys2-download-source-code.sh - -# 准备 PHP 源码 和 PHP SDK -bash sapi/quickstart/windows/native-build/msys2/msys2-download-php-and-php-sdk.sh - -# 构建库准备环境依赖 -bash sapi/quickstart/windows/native-build/msys2/msys2-download-deps-soft.sh - - - -``` - -## 实验 - -```bash - -# 下载辅助软件 (7zip notepad ) -bash sapi/quickstart/windows/native-build/msys2/msys2-download-helper-soft.sh - -# 下载 visualstudio 2022 -bash sapi/quickstart/windows/native-build/msys2/msys2-download-vs-2022.sh - - -``` - -## 参考文档 - -1. [windows php release ](https://windows.php.net/downloads/releases/archives/) - diff --git a/sapi/quickstart/windows/native-build/msys2/download.sh b/sapi/quickstart/windows/native-build/msys2/download.sh deleted file mode 100644 index ae37a757d8..0000000000 --- a/sapi/quickstart/windows/native-build/msys2/download.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env bash -set -x - -__DIR__=$( - cd "$(dirname "$0")" - pwd -) -__PROJECT__=$( - cd ${__DIR__}/../../../../../ - pwd -) -cd ${__PROJECT__} - - -# 准备 PHP 运行时 -bash sapi/quickstart/windows/native-build/msys2/msys2-download-php-runtime.sh - -# 提前准备下载依赖库 -bash sapi/download-box/download-box-get-archive-from-server.sh - - -# 准备 依赖库 和 扩展 -bash sapi/quickstart/windows/native-build/msys2/msys2-download-source-code.sh - -# 准备 PHP 源码 和 PHP SDK -bash sapi/quickstart/windows/native-build/msys2/msys2-download-php-and-php-sdk.sh - -# 构建库准备环境依赖 -bash sapi/quickstart/windows/native-build/msys2/msys2-download-deps-soft.sh - -start . -start . -start "cmd" -start "cmd" -start "cmd" diff --git a/sapi/quickstart/windows/native-build/msys2/msys2-download-deps-soft.sh b/sapi/quickstart/windows/native-build/msys2/msys2-download-deps-soft.sh deleted file mode 100644 index 1858a7b4db..0000000000 --- a/sapi/quickstart/windows/native-build/msys2/msys2-download-deps-soft.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env bash -set -x - -__DIR__=$( - cd "$(dirname "$0")" - pwd -) -__PROJECT__=$( - cd ${__DIR__}/../../../../../ - pwd -) -cd ${__PROJECT__} - -# https://learn.microsoft.com/en-us/vcpkg/examples/installing-and-using-packages -# test -d vcpkg || git clone -b master --depth=1 https://github.com/microsoft/vcpkg - -# test -f Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle || curl -Lo Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle https://github.com/microsoft/winget-cli/releases/download/v1.7.11261/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle -# rem powershell "add-appxpackage .\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -# rem winget install nasm -i - - -# winget install nasm -i -# https://repo.or.cz/w/nasm.git -# https://www.nasm.us/pub/nasm/releasebuilds/2.16.03/ -# https://github.com/netwide-assembler/nasm/blob/master/INSTALL -# https://github.com/netwide-assembler/nasm.git -# test -d nasm || git clone --depth=1 https://github.com/netwide-assembler/nasm.git -# test -f nasm-2.16.03-win64.zip || curl -Lo nasm-2.16.03-win64.zip https://www.nasm.us/pub/nasm/releasebuilds/2.16.03/win64/nasm-2.16.03-win64.zip -# https://github.com/jingjingxyk/swoole-cli/releases/tag/t-v0.0.3 -test -f nasm-2.16.03-win64.zip || curl -Lo nasm-2.16.03-win64.zip https://github.com/jingjingxyk/swoole-cli/releases/download/t-v0.0.3/nasm-2.16.03-win64.zip -test -d nasm && rm -rf nasm -unzip nasm-2.16.03-win64.zip -mv nasm-2.16.03 nasm -ls -lh nasm - - - -# https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/ -test -f strawberry-perl-5.38.2.2-64bit.msi || curl -Lo strawberry-perl-5.38.2.2-64bit.msi https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_53822_64bit/strawberry-perl-5.38.2.2-64bit.msi diff --git a/sapi/quickstart/windows/native-build/msys2/msys2-download-helper-soft.sh b/sapi/quickstart/windows/native-build/msys2/msys2-download-helper-soft.sh deleted file mode 100644 index db4ae6fc50..0000000000 --- a/sapi/quickstart/windows/native-build/msys2/msys2-download-helper-soft.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash -set -x - -__DIR__=$( - cd "$(dirname "$0")" - pwd -) -__PROJECT__=$( - cd ${__DIR__}/../../../../../ - pwd -) -cd ${__PROJECT__} - - -# https://github.com/notepad-plus-plus/notepad-plus-plus/ -test -f npp.8.6.7.Installer.x64.exe || curl -Lo npp.8.6.7.Installer.x64.exe https://github.com/notepad-plus-plus/notepad-plus-plus/releases/download/v8.6.7/npp.8.6.7.Installer.x64.exe - -# https://7-zip.org/ -test -f 7z2405-x64.exe || curl -Lo 7z2405-x64.exe https://7-zip.org/a/7z2405-x64.exe - - -test -f Git-2.45.1-64-bit.exe || curl -Lo Git-2.45.1-64-bit.exe https://github.com/git-for-windows/git/releases/download/v2.45.1.windows.1/Git-2.45.1-64-bit.exe - -# https://curl.se/windows/ - -test -f curl-8.8.0_1-win64-mingw.zip || curl -Lo curl-8.8.0_1-win64-mingw.zip https://curl.se/windows/dl-8.8.0_1/curl-8.8.0_1-win64-mingw.zip -test -d curl-8.8.0_1-win64-mingw && rm -rf curl-8.8.0_1-win64-mingw -unzip curl-8.8.0_1-win64-mingw.zip - -# https://libarchive.org/ -test -f libarchive-v3.7.4-amd64.zip || curl -Lo libarchive-v3.7.4-amd64.zip https://libarchive.org/downloads/libarchive-v3.7.4-amd64.zip -unzip libarchive-v3.7.4-amd64.zip - - diff --git a/sapi/quickstart/windows/native-build/msys2/msys2-download-php-and-php-sdk.sh b/sapi/quickstart/windows/native-build/msys2/msys2-download-php-and-php-sdk.sh deleted file mode 100644 index 5b5de1d4f9..0000000000 --- a/sapi/quickstart/windows/native-build/msys2/msys2-download-php-and-php-sdk.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash -set -x - -__DIR__=$( - cd "$(dirname "$0")" - pwd -) -__PROJECT__=$( - cd ${__DIR__}/../../../../../ - pwd -) -cd ${__PROJECT__} - - -test -d php-sdk-binary-tools || git clone -b master --depth=1 https://github.com/php/php-sdk-binary-tools.git -test -d php-src || git clone -b php-8.3.7 --depth=1 https://github.com/php/php-src.git - -cp -rf ext/* php-src/ext/ -ls -lh php-src/ext/ diff --git a/sapi/quickstart/windows/native-build/msys2/msys2-download-php-runtime.sh b/sapi/quickstart/windows/native-build/msys2/msys2-download-php-runtime.sh deleted file mode 100644 index d7e3e3efd8..0000000000 --- a/sapi/quickstart/windows/native-build/msys2/msys2-download-php-runtime.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env bash -set -x - -__DIR__=$( - cd "$(dirname "$0")" - pwd -) -__PROJECT__=$( - cd ${__DIR__}/../../../../../ - pwd -) -cd ${__PROJECT__} - -# https://windows.php.net/downloads/releases/archives/ - -test -d php/ && rm -rf php/ -test -f php-8.2.19-nts-Win32-vs16-x64.zip || curl -Lo php-8.2.19-nts-Win32-vs16-x64.zip https://windows.php.net/downloads/releases/archives/php-8.2.19-nts-Win32-vs16-x64.zip - -unzip -d php php-8.2.19-nts-Win32-vs16-x64.zip - -pwd -cp -f php/php.ini-production php/php.ini - -mkdir -p bin/runtime/ -test -f bin/runtime/composer.phar || curl -Lo bin/runtime/composer.phar https://getcomposer.org/download/latest-stable/composer.phar -export PATH=$PATH:${__PROJECT__}/php/ - -php -v - -df -h / -PHP_EXT_DIR='' -if [[ -n "$GITHUB_WORKSPACE" ]] && [[ -n "$GITHUB_ACTION" ]] ; then - PHP_EXT_DIR=${GITHUB_WORKSPACE}'\php\ext\' -else - DISK_DRIVE=$( df -h / | sed -n '2p' | awk '{ print $1 }' )$(pwd) - echo $DISK_DRIVE - WIND_DIR=$(echo $DISK_DRIVE | sed 's/\//\\/g') - - # PHP_EXT_DIR='C:\msys64\home\Administrator\swoole-cli\php\ext\' - PHP_EXT_DIR=${WIND_DIR}'\php\ext\' - echo $PHP_EXT_DIR -fi - -while [ $# -gt 0 ]; do - case "$1" in - --php-ext-dir) - PHP_EXT_DIR="$2" - ;; - esac - shift $(($# > 0 ? 1 : 0)) -done - -#echo 'extension_dir=C:\msys64\home\Administrator\swoole-cli\php\ext\' >> php/php.ini -echo "extension_dir=${PHP_EXT_DIR}" >> php/php.ini -echo 'extension=php_curl.dll' >> php/php.ini -echo 'extension=php_bz2.dll' >> php/php.ini -echo 'extension=php_openssl.dll' >> php/php.ini -echo 'extension=php_fileinfo.dll' >> php/php.ini - -php -v -php -m -php bin/runtime/composer.phar install --no-interaction --no-autoloader --no-scripts --profile --ignore-platform-req=ext-posix --ignore-platform-req=ext-yaml -php bin/runtime/composer.phar dump-autoload --optimize --profile --ignore-platform-req=ext-posix --ignore-platform-req=ext-yaml diff --git a/sapi/quickstart/windows/native-build/msys2/msys2-download-vs-2019.sh b/sapi/quickstart/windows/native-build/msys2/msys2-download-vs-2019.sh deleted file mode 100644 index 436c1a2c17..0000000000 --- a/sapi/quickstart/windows/native-build/msys2/msys2-download-vs-2019.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash -set -x - -__DIR__=$( - cd "$(dirname "$0")" - pwd -) -__PROJECT__=$( - cd ${__DIR__}/../../../../../ - pwd -) -cd ${__PROJECT__} - -unset HTTP_PROXY -unset HTTPS_PROXY -unset NO_PROXY - -curl -Lo VisualStudioSetup.exe 'https://c2rsetup.officeapps.live.com/c2r/downloadVS.aspx?sku=community&channel=Release&version=VS2019' -# curl -Lo VisualStudioSetup.exe 'https://aka.ms/vs/16/release/vs_community.exe' -# curl -Lo vs_buildtools.exe 'https://aka.ms/vs/16/release/vs_buildtools.exe' - -test -f vc_redist.x64.exe || curl -Lo vc_redist.x64.exe https://aka.ms/vs/16/release/vc_redist.x64.exe -test -f vc_redist.x86.exe || curl -Lo vc_redist.x86.exe https://aka.ms/vs/16/release/vc_redist.x86.exe - diff --git a/sapi/quickstart/windows/native-build/msys2/msys2-download-vs-2022.sh b/sapi/quickstart/windows/native-build/msys2/msys2-download-vs-2022.sh deleted file mode 100644 index ae6f761588..0000000000 --- a/sapi/quickstart/windows/native-build/msys2/msys2-download-vs-2022.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash -set -x - -__DIR__=$( - cd "$(dirname "$0")" - pwd -) -__PROJECT__=$( - cd ${__DIR__}/../../../../../ - pwd -) -cd ${__PROJECT__} - -unset HTTP_PROXY -unset HTTPS_PROXY -unset NO_PROXY - -curl -Lo VisualStudioSetup.exe 'https://c2rsetup.officeapps.live.com/c2r/downloadVS.aspx?sku=community&channel=Release&version=VS2022' -# curl -Lo VisualStudioSetup.exe 'https://aka.ms/vs/17/release/vs_community.exe' -# curl -Lo vs_buildtools.exe 'https://aka.ms/vs/17/release/vs_buildtools.exe' - -test -f vc_redist.x64.exe || curl -Lo vc_redist.x64.exe https://aka.ms/vs/17/release/vc_redist.x64.exe -test -f vc_redist.x86.exe || curl -Lo vc_redist.x86.exe https://aka.ms/vs/17/release/vc_redist.x86.exe - diff --git a/sapi/quickstart/windows/native-build/msys2/msys2-install-soft.sh b/sapi/quickstart/windows/native-build/msys2/msys2-install-soft.sh deleted file mode 100644 index 734e75d209..0000000000 --- a/sapi/quickstart/windows/native-build/msys2/msys2-install-soft.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -# 更新源 -pacman -Syy --noconfirm -# 无须确认安装包 -pacman -Syy --noconfirm git curl wget openssl zip unzip xz lzip - -# pacman -Syy --noconfirm binutils - diff --git a/sapi/quickstart/windows/native-build/msys2/prepare.sh b/sapi/quickstart/windows/native-build/msys2/prepare.sh deleted file mode 100644 index ecb3c92e79..0000000000 --- a/sapi/quickstart/windows/native-build/msys2/prepare.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash -set -x - -__DIR__=$( - cd "$(dirname "$0")" - pwd -) -__PROJECT__=$( - cd ${__DIR__}/../../../../../ - pwd -) -cd ${__PROJECT__} - -# msys2 下载安装 git curl wget openssl zip unzip xz lzip 软件包 -bash sapi/quickstart/windows/native-build/msys2/msys2-install-soft.sh - -# 下载 visualstudio 2019 -bash sapi/quickstart/windows/native-build/msys2/msys2-download-vs-2019.sh - -# 调用 CMD 窗口 安装 vc 运行时 -bash sapi/quickstart/windows/native-build/msys2/msys2-install-vc-runtime.sh - -start cmd -start cmd -start cmd diff --git a/sapi/quickstart/windows/native-build/native-build-php-archive.bat b/sapi/quickstart/windows/native-build/native-build-php-archive.bat deleted file mode 100644 index 55fba5c737..0000000000 --- a/sapi/quickstart/windows/native-build/native-build-php-archive.bat +++ /dev/null @@ -1,21 +0,0 @@ -@echo off - -setlocal -rem show current file location -echo %~dp0 -cd /d %~dp0 -cd /d ..\..\..\..\ - -set "__PROJECT__=%cd%" -echo %cd% -cd /d %__PROJECT__%\ -dir - -rem cd %__PROJECT__%\php-src\x64\Release_TS\ -cd /d %__PROJECT__%\php-src\x64\Release\ -dir - -rem .\php -v -rem .\php -m - -endlocal diff --git a/sapi/quickstart/windows/native-build/native-build-php-build-release.bat b/sapi/quickstart/windows/native-build/native-build-php-build-release.bat deleted file mode 100644 index fc1a9b45ff..0000000000 --- a/sapi/quickstart/windows/native-build/native-build-php-build-release.bat +++ /dev/null @@ -1,28 +0,0 @@ -@echo off - -setlocal -rem show current file location -echo %~dp0 -cd /d %~dp0 -cd /d ..\..\..\..\ - -set "__PROJECT__=%cd%" -echo %cd% -cd %__PROJECT__%\php-src\ - -set "INCLUDE=%INCLUDE%;%__PROJECT__%\openssl\include\;%__PROJECT__%\zlib\include" -set "LIB=%LIB%;%__PROJECT__%\openssl\lib\;%__PROJECT__%\zlib\lib" -set "LIBPATH=%LIBPATH%;%__PROJECT__%\openssl\lib\;%__PROJECT__%\zlib\lib\" - -copy %__PROJECT__%\thirdparty\openssl\ms\applink.c %__PROJECT__%\build\openssl\include\openssl\applink.c - -set CL=/MP -rem set RTLIBCFG=static -rem nmake mode=static debug=false -nmake - -rem nmake install - -cd %__PROJECT__% -endlocal - diff --git a/sapi/quickstart/windows/native-build/native-build-php-build.bat b/sapi/quickstart/windows/native-build/native-build-php-build.bat index 66bd1428c2..e65f9ca0fa 100644 --- a/sapi/quickstart/windows/native-build/native-build-php-build.bat +++ b/sapi/quickstart/windows/native-build/native-build-php-build.bat @@ -12,9 +12,9 @@ cd %__PROJECT__%\php-src\ -set "INCLUDE=%INCLUDE%;%__PROJECT__%\build\openssl\include\;%__PROJECT__%\build\zlib\include" -set "LIB=%LIB%;%__PROJECT__%\build\openssl\lib\;%__PROJECT__%\build\zlib\lib" -set "LIBPATH=%LIBPATH%;%__PROJECT__%\build\openssl\lib\;%__PROJECT__%\build\zlib\lib\" +rem set "INCLUDE=%INCLUDE%;%__PROJECT__%\build\openssl\include\;%__PROJECT__%\build\zlib\include" +rem set "LIB=%LIB%;%__PROJECT__%\build\openssl\lib\;%__PROJECT__%\build\zlib\lib" +rem set "LIBPATH=%LIBPATH%;%__PROJECT__%\build\openssl\lib\;%__PROJECT__%\build\zlib\lib\" echo %INCLUDE% echo %LIB% @@ -28,15 +28,16 @@ configure.bat ^ --enable-sockets --enable-ctype --enable-pdo --enable-phar ^ --enable-filter ^ --enable-xmlreader --enable-xmlwriter ^ ---enable-tokenizer ^ ---disable-zts ^ ---enable-apcu ^ ---enable-bcmath ^ ---enable-zlib ^ ---with-openssl=static ^ ---with-toolset=vs ^ ---with-extra-includes="%INCLUDE%" ^ ---with-extra-libs="%LIB%" +--enable-tokenizer + +:: --disable-zts ^ +:: --enable-apcu ^ +:: --enable-bcmath ^ +:: --enable-zlib ^ +:: --with-openssl=static ^ +:: --with-toolset=vs ^ +:: --with-extra-includes="%INCLUDE%" ^ +:: --with-extra-libs="%LIB%" :: --enable-mbstring @@ -47,5 +48,14 @@ configure.bat ^ cd /d %__PROJECT__% + +rem cd %__PROJECT__%\php-src\x64\Release_TS\ +cd /d %__PROJECT__%\php-src\x64\Release\ +dir + +rem .\php -v +rem .\php -m + + set __PROJECT__= endlocal diff --git a/sapi/quickstart/windows/native-build/native-build-php-config.bat b/sapi/quickstart/windows/native-build/native-build-php-config.bat deleted file mode 100644 index 6cd963e3e3..0000000000 --- a/sapi/quickstart/windows/native-build/native-build-php-config.bat +++ /dev/null @@ -1,18 +0,0 @@ -@echo off - -setlocal -rem show current file location -echo %~dp0 -cd /d %~dp0 -cd /d ..\..\..\..\ - -set "__PROJECT__=%cd%" -echo %cd% -cd %__PROJECT__%\php-src -echo %cd% - -buildconf.bat -f - -cd %__PROJECT__% - -endlocal diff --git a/sapi/quickstart/windows/native-build/native-build-php-release-show-var.bat b/sapi/quickstart/windows/native-build/native-build-php-release-show-var.bat deleted file mode 100644 index 8abdc150e7..0000000000 --- a/sapi/quickstart/windows/native-build/native-build-php-release-show-var.bat +++ /dev/null @@ -1,92 +0,0 @@ -@echo off - -setlocal enabledelayedexpansion -rem show current file location -echo %~dp0 -cd /d %~dp0 -cd /d ..\..\..\..\ - -set "__PROJECT__=%cd%" -echo %cd% -cd %__PROJECT__%\php-src\ - -set "INCLUDE=%INCLUDE%;%__PROJECT__%\openssl\include\;%__PROJECT__%\zlib\include" -set "LIB=%LIB%;%__PROJECT__%\openssl\lib\;%__PROJECT__%\zlib\lib" -set "LIBPATH=%LIBPATH%;%__PROJECT__%\openssl\lib\;%__PROJECT__%\zlib\lib\" - -set CL=/MP -rem set RTLIBCFG=static -rem nmake mode=static debug=false - -rem nmake all - - -set x_makefile=%__PROJECT__%\php-src\Makefile - - - -findstr /C:"x-show-var: " %x_makefile% -findstr /C:"x-show-var: " %x_makefile% >nul - -if errorlevel 1 ( -echo custom makefile x-show-var config! -goto x-release-php-start -) else ( -echo custom makefile file exits ! -goto x-release-php-end -) - -:x-release-php-start -echo #x-show-var >> %x_makefile% -echo x-show-var: >> %x_makefile% -echo ^@echo DEPS_CLI: $(DEPS_CLI) >> %x_makefile% -echo ^@echo ================== >> %x_makefile% -echo ^@echo CLI_GLOBAL_OBJ: $(CLI_GLOBAL_OBJS) >> %x_makefile% -echo ^@echo ================== >> %x_makefile% -rem echo ^@echo PHP_GLOBAL_OBJS: $(PHP_GLOBAL_OBJS) >> %x_makefile% -echo ^@echo ================== >> %x_makefile% -rem echo ^@echo STATIC_EXT_OBJS: $(STATIC_EXT_OBJS) >> %x_makefile% -echo ^@echo ================== >> %x_makefile% -echo ^@echo ASM_OBJS: $(ASM_OBJS) >> %x_makefile% -echo ^@echo ================== >> %x_makefile% -echo ^@echo STATIC_EXT_LIBS: $(STATIC_EXT_LIBS) >> %x_makefile% -echo ^@echo ================== >> %x_makefile% -echo ^@echo STATIC_EXT_LDFLAGS: $(STATIC_EXT_LDFLAGS) >> %x_makefile% -echo ^@echo ================== >> %x_makefile% -echo ^@echo STATIC_EXT_CFLAGS: $(STATIC_EXT_CFLAGS) >> %x_makefile% -echo ^@echo ================== >> %x_makefile% -echo ^@echo BUILD_DIR\PHPLIB: $(BUILD_DIR)\$(PHPLIB) >> %x_makefile% -echo ^@echo ================== >> %x_makefile% -echo ^@echo CLI_GLOBAL_OBJS_RESP: $(CLI_GLOBAL_OBJS_RESP) >> %x_makefile% -echo ^@echo ================== >> %x_makefile% -echo ^@echo PHP_LDFLAGS: $(PHP_LDFLAGS) >> %x_makefile% -echo ^@echo ================== >> %x_makefile% -echo ^@echo LIBS: $(LIBS) >> %x_makefile% -echo ^@echo ================== >> %x_makefile% -echo ^@echo LIBS_CLI: $(LIBS_CLI) >> %x_makefile% -echo ^@echo ================== >> %x_makefile% -echo ^@echo LDFLAGS: $(LDFLAGS) >> %x_makefile% -echo ^@echo ================== >> %x_makefile% -echo ^@echo LDFLAGS_CLI: $(LDFLAGS_CLI) >> %x_makefile% -echo ^@echo ================== >> %x_makefile% -echo ^@echo _VC_MANIFEST_EMBED_EXE: $(_VC_MANIFEST_EMBED_EXE) >> %x_makefile% -echo ^@echo ================== >> %x_makefile% -echo ^@echo PHPDEF: $(PHPDEF) >> %x_makefile% -echo ^@echo ================== >> %x_makefile% -echo ^@echo PHPDLL_RES: $(PHPDLL_RES) >> %x_makefile% -echo ^@echo ================== >> %x_makefile% -echo ^@echo ASM_OBJS: $(ASM_OBJS) >> %x_makefile% -echo ^@echo ================== >> %x_makefile% -echo ^@echo MCFILE: $(MCFILE) >> %x_makefile% -echo ^@echo ================== >> %x_makefile% - -:x-release-php-end - - -rem nmake show-variable -nmake x-show-var - -rem nmake install - -cd %__PROJECT__% -endlocal diff --git a/sapi/quickstart/windows/native-build/native-build-php-release.bat b/sapi/quickstart/windows/native-build/native-build-php-release.bat deleted file mode 100644 index 2f0b9af466..0000000000 --- a/sapi/quickstart/windows/native-build/native-build-php-release.bat +++ /dev/null @@ -1,74 +0,0 @@ -@echo off - -setlocal enabledelayedexpansion -rem show current file location -echo %~dp0 -cd /d %~dp0 -cd /d ..\..\..\..\ - -set "__PROJECT__=%cd%" -echo %cd% -cd %__PROJECT__%\php-src\ - -set "INCLUDE=%INCLUDE%;%__PROJECT__%\openssl\include\;%__PROJECT__%\zlib\include" -set "LIB=%LIB%;%__PROJECT__%\openssl\lib\;%__PROJECT__%\zlib\lib" -set "LIBPATH=%LIBPATH%;%__PROJECT__%\openssl\lib\;%__PROJECT__%\zlib\lib\" - -set CL=/MP -rem set RTLIBCFG=static -rem nmake mode=static debug=false - -rem nmake all - - -set x_makefile=%__PROJECT__%\php-src\Makefile - - - -findstr /C:"x-release-php: " %x_makefile% -findstr /C:"x-release-php: " %x_makefile% >nul - -if errorlevel 1 ( -echo custom makefile x-release-php config! -goto x-release-php-start -) else ( -echo custom makefile file exits ! -goto x-release-php-end -) - -:x-release-php-start -echo #custom build static link php library >> %x_makefile% -echo x-build-php-lib^: generated_files $(PHP_GLOBAL_OBJS) $(CLI_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(ASM_OBJS) $(MCFILE) >> %x_makefile% -echo #custom build php.exe >> %x_makefile% -echo x-release-php^: $(DEPS_CLI) $(CLI_GLOBAL_OBJS) x-build-php-lib $(PHP_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(ASM_OBJS) $(BUILD_DIR)^\php.exe.res $(BUILD_DIR)^\php.exe.manifest >> %x_makefile% -rem https://www.cnblogs.com/sherry-best/archive/2013/04/15/3022705.html -rem https://learn.microsoft.com/zh-CN/cpp/c-runtime-library/crt-library-features?view=msvc-170&viewFallbackFrom=vs-2019 -rem echo ^@"$(LINK)" ^/nologo $(PHP_GLOBAL_OBJS) $(PHP_GLOBAL_OBJS_RESP) $(CLI_GLOBAL_OBJS) $(CLI_GLOBAL_OBJS_RESP) $(STATIC_EXT_OBJS_RESP) $(STATIC_EXT_OBJS) $(ASM_OBJS) $(LIBS) $(LIBS_CLI) $(BUILD_DIR)^\php.exe.res /out:$(BUILD_DIR)^\php.exe $(LDFLAGS) $(LDFLAGS_CLI) >> %x_makefile% -echo ^@"$(LINK)" ^/nologo $(PHP_GLOBAL_OBJS) $(CLI_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(STATIC_EXT_LIBS) $(ASM_OBJS) $(LIBS) $(LIBS_CLI) $(BUILD_DIR)^\php.exe.res /out:$(BUILD_DIR)^\php.exe $(LDFLAGS) $(LDFLAGS_CLI) >> %x_makefile% -rem echo -@$(_VC_MANIFEST_EMBED_EXE) >> %x_makefile% -rem echo ^@echo SAPI sapi\cli build complete >> %x_makefile% -rem echo @if exist php.exe.manifest $(MT) -nologo -manifest php.exe.manifest -outputresource:php.exe >> %x_makefile% - -rem /WHOLEARCHIVE /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcrtd.lib /FORCE:MULTIPLE -rem libcpmt.lib libvcruntime.lib libucrt.lib msvcrt.lib -rem /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrtd.lib -rem libvcruntime.lib libcmt.lib - -rem /MANIFEST:php.exe.manifest /MANIFESTUAC:uiAccess /SUBSYSTEM:CONSOLE /subsystem:windows - -:x-release-php-end - - -rem nmake show-variable -nmake /E x-release-php -rem nmake x-build-php-lib - -rem nmake install - -.\x64\Release\php.exe -v -.\x64\Release\php.exe -m -dumpbin /DEPENDENTS ".\x64\Release\php.exe" - -cd %__PROJECT__% -endlocal - diff --git a/sapi/quickstart/windows/native-build/native-build-php-sdk-vs2019.bat b/sapi/quickstart/windows/native-build/native-build-php-sdk-vs2019.bat deleted file mode 100644 index caff661c75..0000000000 --- a/sapi/quickstart/windows/native-build/native-build-php-sdk-vs2019.bat +++ /dev/null @@ -1,30 +0,0 @@ -@echo off - -rem show current file location -echo %~dp0 -cd %~dp0 -cd ..\..\..\..\ - -set __PROJECT__=%cd% -cd /d %__PROJECT__% - -rem %__PROJECT__%\php-sdk-binary-tools\phpsdk-vs16-x64.bat - - -set PHP_SDK_ARCH=x64 -set PHP_SDK_BIN_PATH=%__PROJECT__%\php-sdk-binary-tools\bin\ -set PHP_SDK_MSYS2_PATH=%__PROJECT__%\php-sdk-binary-tools\msys2\usr\bin\ -set PHP_SDK_OS_ARCH=x64 -set PHP_SDK_PHP_CMD=%__PROJECT__%\php-sdk-binary-tools\bin\php\do_php.bat -set PHP_SDK_ROOT_PATH=%__PROJECT__%\php-sdk-binary-tools\ -set "PHP_SDK_VC_DIR=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC" -set "PHP_SDK_VC_TOOLSET_VER=%VCToolsVersion%" -set PHP_SDK_VS=vs16 -set PHP_SDK_VS_NUM=16 -set "PHP_SDK_VS_SHELL_CMD=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat amd64" -set "PATH=%__PROJECT__%\php-sdk-binary-tools\bin;%__PROJECT__%\php-sdk-binary-tools\msys2\usr\bin;%__PROJECT__%\php\;%__PROJECT__%\nasm\;C:\Strawberry\perl\bin;C:\Program Files\Git\bin;%PATH%" -echo %PATH% - -cd /d %__PROJECT__% - -set __PROJECT__= diff --git a/sapi/quickstart/windows/native-build/native-build-php-sdk-vs2022.bat b/sapi/quickstart/windows/native-build/native-build-php-sdk-vs2022.bat deleted file mode 100644 index 22156b5a49..0000000000 --- a/sapi/quickstart/windows/native-build/native-build-php-sdk-vs2022.bat +++ /dev/null @@ -1,30 +0,0 @@ -@echo off - -rem show current file location -echo %~dp0 -cd %~dp0 -cd ..\..\..\..\ - -set __PROJECT__=%cd% -cd /d %__PROJECT__% - -rem %__PROJECT__%\php-sdk-binary-tools\phpsdk-vs17-x64.bat - - -set PHP_SDK_ARCH=x64 -set PHP_SDK_BIN_PATH=%__PROJECT__%\php-sdk-binary-tools\bin\ -set PHP_SDK_MSYS2_PATH=%__PROJECT__%\php-sdk-binary-tools\msys2\usr\bin\ -set PHP_SDK_OS_ARCH=x64 -set PHP_SDK_PHP_CMD=%__PROJECT__%\php-sdk-binary-tools\bin\php\do_php.bat -set PHP_SDK_ROOT_PATH=%__PROJECT__%\php-sdk-binary-tools\ -set "PHP_SDK_VC_DIR=C:\Program Files\Microsoft Visual Studio\2022\Community\VC" -set "PHP_SDK_VC_TOOLSET_VER=%VCToolsVersion%" -set PHP_SDK_VS=vs17 -set PHP_SDK_VS_NUM=17 -set "PHP_SDK_VS_SHELL_CMD=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat amd64" -set "PATH=%__PROJECT__%\php-sdk-binary-tools\bin;%__PROJECT__%\php-sdk-binary-tools\msys2\usr\bin;%PATH%" -echo %PATH% - -cd /d %__PROJECT__% - -set __PROJECT__= diff --git a/sapi/quickstart/windows/native-build/native-build-php-config-help.bat b/sapi/quickstart/windows/native-build/php-sdk.bat similarity index 58% rename from sapi/quickstart/windows/native-build/native-build-php-config-help.bat rename to sapi/quickstart/windows/native-build/php-sdk.bat index 17d42ee116..965fa68b0a 100644 --- a/sapi/quickstart/windows/native-build/native-build-php-config-help.bat +++ b/sapi/quickstart/windows/native-build/php-sdk.bat @@ -1,6 +1,5 @@ @echo off -setlocal rem show current file location echo %~dp0 cd /d %~dp0 @@ -8,10 +7,8 @@ cd /d ..\..\..\..\ set "__PROJECT__=%cd%" echo %cd% -cd %__PROJECT__%\php-src -configure.bat --help +.\var\windows-build-deps\php-sdk-binary-tools\phpsdk-vs17-x64.bat -cd %__PROJECT__% +cd /d %__PROJECT__% -endlocal diff --git a/sapi/quickstart/windows/native-build/prepare.bat b/sapi/quickstart/windows/native-build/prepare.bat deleted file mode 100644 index 4b1f7f9532..0000000000 --- a/sapi/quickstart/windows/native-build/prepare.bat +++ /dev/null @@ -1,20 +0,0 @@ -@echo off - -rem show current file location -echo %~dp0 -cd %~dp0 -cd ..\..\..\..\ - -set __PROJECT__=%cd% -cd /d %__PROJECT__% - - -start /wait sapi\quickstart\windows\native-build\install-vc-runtime.bat - -start /wait sapi\quickstart\windows\native-build\install-visualstudio-2019.bat - -start /wait sapi\quickstart\windows\native-build\install-deps-soft.bat - -cd /d %__PROJECT__% - -set __PROJECT__= diff --git a/sapi/quickstart/windows/native-build/run.bat b/sapi/quickstart/windows/native-build/run.bat new file mode 100644 index 0000000000..40d0025f80 --- /dev/null +++ b/sapi/quickstart/windows/native-build/run.bat @@ -0,0 +1,18 @@ +@echo off + +setlocal +rem show current file location +echo %~dp0 +cd /d %~dp0 +cd /d ..\..\..\..\ + +set "__PROJECT__=%cd%" +echo %cd% + +call %__PROJECT__%\sapi\quickstart\windows\native-build\config.bat +call %__PROJECT__%\sapi\quickstart\windows\native-build\x_custom_config.bat +call %__PROJECT__%\sapi\quickstart\windows\native-build\build.bat + + +cd /d %__PROJECT__% +endlocal diff --git a/sapi/quickstart/windows/native-build/show-var.bat b/sapi/quickstart/windows/native-build/show-var.bat new file mode 100644 index 0000000000..02524d6607 --- /dev/null +++ b/sapi/quickstart/windows/native-build/show-var.bat @@ -0,0 +1,113 @@ +@echo off + +setlocal enabledelayedexpansion +rem show current file location +echo %~dp0 +cd /d %~dp0 +cd /d ..\..\..\..\ + +set "__PROJECT__=%cd%" +echo %cd% + + +cd %__PROJECT__%\var\windows-build-deps\php-src\ +dir + +rem set "INCLUDE=%INCLUDE%;%__PROJECT__%\openssl\include\;%__PROJECT__%\zlib\include" +rem set "LIB=%LIB%;%__PROJECT__%\openssl\lib\;%__PROJECT__%\zlib\lib" +rem set "LIBPATH=%LIBPATH%;%__PROJECT__%\openssl\lib\;%__PROJECT__%\zlib\lib\" + +set CL=/MP +rem set RTLIBCFG=static +rem nmake mode=static debug=false + +rem nmake all + + +set X_MAKEFILE=%__PROJECT__%\var\windows-build-deps\php-src\Makefile + + + +findstr /C:"x-show-var: " %X_MAKEFILE% +findstr /C:"x-show-var: " %X_MAKEFILE% > nul + +if errorlevel 1 ( + echo custom MAKEFILE x-show-var config! + goto x-release-php-start +) else ( + echo custom MAKEFILE file exits ! + goto x-release-php-end +) + +:x-release-php-start + +echo x-show-var: >> %X_MAKEFILE% +echo ^@echo DEPS_CLI: $(DEPS_CLI) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo CLI_GLOBAL_OBJ: $(CLI_GLOBAL_OBJS) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo ASM_OBJS: $(ASM_OBJS) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo STATIC_EXT_LIBS: $(STATIC_EXT_LIBS) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo STATIC_EXT_LDFLAGS: $(STATIC_EXT_LDFLAGS) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo STATIC_EXT_CFLAGS: $(STATIC_EXT_CFLAGS) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo BUILD_DIR\PHPLIB: $(BUILD_DIR)\$(PHPLIB) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo CLI_GLOBAL_OBJS_RESP: $(CLI_GLOBAL_OBJS_RESP) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo PHP_LDFLAGS: $(PHP_LDFLAGS) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo LIBS: $(LIBS) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo LIBS_CLI: $(LIBS_CLI) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo LDFLAGS: $(LDFLAGS) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo LDFLAGS_CLI: $(LDFLAGS_CLI) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo _VC_MANIFEST_EMBED_EXE: $(_VC_MANIFEST_EMBED_EXE) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo PHPDEF: $(PHPDEF) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo PHPDLL_RES: $(PHPDLL_RES) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo ASM_OBJS: $(ASM_OBJS) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo MCFILE: $(MCFILE) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% + + + +:x-release-php-end + + +rem nmake show-variable +nmake x-show-var + +rem nmake install + +cd %__PROJECT__% +endlocal +======= +cd %__PROJECT__%\var\windows-build-deps\php-src\ + +where sed.exe + +dir %__PROJECT__%\var\windows-build-deps\php-sdk-binary-tools\msys2\usr\bin\ + + + +:: vswhere.exe -products* -requires +:: vswhere.exe -legacy -prerelease -format json +:: vswhere.exe -legacy -prerelease -format json | jq + +:: vswhere.exe -legacy -prerelease + +nmake /E /f Makefile x-show-var + +cd %__PROJECT__% +endlocal + diff --git a/sapi/quickstart/windows/native-build/vs-tools/export-visualstudio-vsconfig.bat b/sapi/quickstart/windows/native-build/vs-tools/export-visualstudio-vsconfig.bat deleted file mode 100644 index 7a843a4f7f..0000000000 --- a/sapi/quickstart/windows/native-build/vs-tools/export-visualstudio-vsconfig.bat +++ /dev/null @@ -1,14 +0,0 @@ -@echo off - -setlocal -rem show current file location -echo %~dp0 -cd /d %~dp0 -cd /d .\..\..\..\..\..\ - -set "__PROJECT__=%cd%" -echo %cd% - -VisualStudioSetup.exe export --passive --force - -endlocal diff --git a/sapi/quickstart/windows/native-build/win7-download-curl.bat b/sapi/quickstart/windows/native-build/win7-download-curl.bat new file mode 100644 index 0000000000..d27ca7498e --- /dev/null +++ b/sapi/quickstart/windows/native-build/win7-download-curl.bat @@ -0,0 +1,51 @@ +@echo off + +setlocal enableextensions enabledelayedexpansion + + +echo %~dp0 +cd /d %~dp0 +cd /d ..\..\..\..\ + +set "__PROJECT__=%cd%" +echo %cd% + +md %__PROJECT__%\var\windows-build-deps\ + +cd /d %__PROJECT__%\var\windows-build-deps\ + +where powershell + +powershell -command "Write-Output (Get-Date)" +rem powershell -file path\to\your\script.ps1 + +if exist "curl-8.8.0_1-win64-mingw\curl-8.8.0_1-win64-mingw\bin\curl.exe" ( + echo The file exists. +) else ( + echo The file does not exist. + powershell -command "Invoke-WebRequest -Uri https://curl.se/windows/dl-8.8.0_1/curl-8.8.0_1-win64-mingw.zip -OutFile .\curl-8.8.0_1-win64-mingw.zip " + rem powershell -command "Invoke-WebRequest -Uri https://www.7-zip.org/a/7z2409-x64.exe -OutFile .\7z2409-x64.exe " + + rem .\7z2409-x64.exe /S + rem set "PATH=%ProgramFiles%\7-Zip;%PATH%;" + rem "C:\Program Files\7-Zip\7z.exe" x "%__PROJECT__%\var\windows-build-deps\curl-8.8.0_1-win64-mingw.zip" -o"%__PROJECT__%\var\windows-build-deps\curl-8.8.0_1-win64-mingw\" +) + +if exist "curl-8.8.0_1-win64-mingw\curl-8.8.0_1-win64-mingw\bin\curl.exe" ( + powershell -command Remove-Item -Path "%__PROJECT__%\var\windows-build-deps\curl-8.8.0_1-win64-mingw" -Recurse +) + +powershell -command Expand-Archive -Path 'curl-8.8.0_1-win64-mingw.zip' -DestinationPath 'curl-8.8.0_1-win64-mingw' -Force + +set "PATH=%__PROJECT__%\var\windows-build-deps\curl-8.8.0_1-win64-mingw\curl-8.8.0_1-win64-mingw\bin;%PATH%" +dir %__PROJECT__%\var\windows-build-deps\curl-8.8.0_1-win64-mingw\curl-8.8.0_1-win64-mingw\bin +where curl.exe +curl.exe -V + +rem C:\Windows\System32\curl.exe + + + + + +endlocal diff --git a/sapi/quickstart/windows/native-build/windows-init-download-helper-soft.bat b/sapi/quickstart/windows/native-build/windows-init-download-helper-soft.bat new file mode 100644 index 0000000000..9c31d43c60 --- /dev/null +++ b/sapi/quickstart/windows/native-build/windows-init-download-helper-soft.bat @@ -0,0 +1,36 @@ +setlocal + + +echo %~dp0 +cd /d %~dp0 +cd /d .\..\..\..\..\ + +set "__PROJECT__=%cd%" +echo %cd% + +md %__PROJECT__%\var\windows-build-deps\ + +cd /d %__PROJECT__%\var\windows-build-deps\ + +:: set http_proxy=http://127.0.0.1:8016 +:: set https_proxy=http://127.0.0.1:8016 + + +curl.exe -fSLo npp.8.6.7.Installer.x64.exe https://github.com/notepad-plus-plus/notepad-plus-plus/releases/download/v8.6.7/npp.8.6.7.Installer.x64.exe +curl.exe -fSLo socat-v1.8.0.1-cygwin-x64.zip https://github.com/jingjingxyk/build-static-socat/releases/download/v2.2.1/socat-v1.8.0.1-cygwin-x64.zip +curl.exe -fSLo Microsoft.WindowsTerminal_1.21.3231.0_8wekyb3d8bbwe.msixbundle https://github.com/microsoft/terminal/releases/download/v1.21.3231.0/Microsoft.WindowsTerminal_1.21.3231.0_8wekyb3d8bbwe.msixbundle +curl.exe -fSLo winget-install.ps1 https://github.com/asheroto/winget-install/releases/latest/download/winget-install.ps1 +curl.exe -fSLo chocolatey-install.ps1 https://community.chocolatey.org/install.ps1 +curl.exe -fSLo scoop-install.ps1 https://get.scoop.sh + + + + + +:: curl.exe -fSLo npp.8.6.7.Installer.x64.exe https://php-cli.jingjingxyk.com/npp.8.6.7.Installer.x64.exe +:: curl.exe -fSLo socat-v1.8.0.1-cygwin-x64.zip https://php-cli.jingjingxyk.com/socat-v1.8.0.1-cygwin-x64.zip + +:: curl.exe -fSLo curl-8.11.1_1-win64-mingw.zip https://curl.se/windows/dl-8.11.1_1/curl-8.11.1_1-win64-mingw.zip +:: curl.exe -fSLo curl-8.11.1_1-win64arm-mingw.zip https://curl.se/windows/dl-8.11.1_1/curl-8.11.1_1-win64a-mingw.zip + +endlocal diff --git a/sapi/quickstart/windows/native-build/windows-init-download.bat b/sapi/quickstart/windows/native-build/windows-init-download.bat new file mode 100644 index 0000000000..7a5113bb85 --- /dev/null +++ b/sapi/quickstart/windows/native-build/windows-init-download.bat @@ -0,0 +1,56 @@ +setlocal + + +echo %~dp0 +cd /d %~dp0 +cd /d ..\..\..\..\ + +set "__PROJECT__=%cd%" +echo %cd% + +md %__PROJECT__%\var\windows-build-deps\ + +cd /d %__PROJECT__%\var\windows-build-deps\ + +:: set http_proxy=http://127.0.0.1:8016 +:: set https_proxy=http://127.0.0.1:8016 + +curl.exe -fSLo Git-2.47.1-64-bit.exe https://github.com/git-for-windows/git/releases/download/v2.47.1.windows.1/Git-2.47.1-64-bit.exe +curl.exe -fSLo strawberry-perl-5.38.2.2-64bit.msi https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_53822_64bit/strawberry-perl-5.38.2.2-64bit.msi +curl.exe -fSLo nasm-2.16.03-win64.zip https://www.nasm.us/pub/nasm/releasebuilds/2.16.03/win64/nasm-2.16.03-win64.zip +curl.exe -fSLo 7z2409-x64.exe https://www.7-zip.org/a/7z2409-x64.exe +curl.exe -fSLo libarchive-v3.7.4-amd64.zip https://libarchive.org/downloads/libarchive-v3.7.4-amd64.zip + +:: vs2019 +:: curl -Lo VisualStudioSetup.exe 'https://c2rsetup.officeapps.live.com/c2r/downloadVS.aspx?sku=community&channel=Release&version=VS2019' +:: curl -Lo VisualStudioSetup.exe 'https://aka.ms/vs/16/release/vs_community.exe' + +:: vs2022 +curl.exe -fSLo vc_redist.x64.exe https://aka.ms/vs/17/release/vc_redist.x64.exe +:: curl -fSL VisualStudioSetup.exe 'https://aka.ms/vs/17/release/vs_community.exe' +curl.exe -fSLo VisualStudioSetup.exe "https://c2rsetup.officeapps.live.com/c2r/downloadVS.aspx?sku=community&channel=Release&version=VS2022" + + +curl.exe -fSLo jq-windows-amd64.exe https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-windows-amd64.exe + +curl.exe https://windows.php.net/downloads/releases/releases.json | jq-windows-amd64.exe ".[\"8.3\"].[\"nts-vs16-x64\"].[\"zip\"].[\"path\"]" -r > TEMP_PHP_RUNTIME_FILE + +set /p PHP_RUNIME_FILE= %__PROJECT__%\bin\runtime\php.ini + + + +echo %comspec% +echo %ProgramFiles% +set "PATH=%ProgramFiles%\Git\bin;%__PROJECT__%\bin\runtime\;%__PROJECT__%\bin\runtime\nasm\;%__PROJECT__%\bin\runtime\php;%__PROJECT__%\bin\runtime\libarchive\bin;%PATH%" +echo "%PATH%" + +:: git config --global core.autocrlf false +:: git config --global core.eol lf +:: git config --global core.ignorecase false + +perl -v +nasm -v +git version +curl -V +dir %__PROJECT__%\bin\runtime\php\ext\ +php -c %__PROJECT__%\bin\runtime\php.ini -v +php -c %__PROJECT__%\bin\runtime\php.ini -m +php -c %__PROJECT__%\bin\runtime\php.ini --ri curl + + + + +endlocal diff --git a/sapi/quickstart/windows/native-build/windows-init-uninstall-vs-tools.bat b/sapi/quickstart/windows/native-build/windows-init-uninstall-vs-tools.bat new file mode 100644 index 0000000000..24796a3f13 --- /dev/null +++ b/sapi/quickstart/windows/native-build/windows-init-uninstall-vs-tools.bat @@ -0,0 +1,27 @@ +@echo off + +setlocal + + +echo %~dp0 + + +cd /d %~dp0 +cd /d ..\..\..\..\ + + +set "__PROJECT__=%cd%" +echo %cd% + +md %__PROJECT__%\var\windows-build-deps\ + + +cd /d %__PROJECT__%\var\windows-build-deps\ +dir + +.\VisualStudioSetup.exe ^ +uninstall ^ +--path install="D:\vs" --path cache="D:\vs-cached" ^ +--passive --force --norestart + +endlocal diff --git a/sapi/quickstart/windows/native-build/windows-init.bat b/sapi/quickstart/windows/native-build/windows-init.bat new file mode 100644 index 0000000000..26f29953ba --- /dev/null +++ b/sapi/quickstart/windows/native-build/windows-init.bat @@ -0,0 +1,25 @@ +@echo off + +setlocal + + +echo %~dp0 +cd /d %~dp0 +cd /d ..\..\..\..\ + +set "__PROJECT__=%cd%" +echo %cd% + + +if not exist "%__PROJECT__%\var\windows-build-deps\php-nts-Win32-x64.zip" ( + echo "windows php runtime no found " + echo "php runtime downloading ..." + call "%__PROJECT__%\sapi\quickstart\windows\native-build\windows-init-download.bat" + echo "php runtime downloaded" +) + +call "%__PROJECT__%\sapi\quickstart\windows\native-build\windows-init-install.bat" +rem call "%__PROJECT__%\sapi\quickstart\windows\native-build\windows-init-install-vs-tools.bat" +rem call "%__PROJECT__%\sapi\quickstart\windows\native-build\windows-init-uninstall-vs-tools.bat" + +endlocal diff --git a/sapi/quickstart/windows/native-build/x_custom_config.bat b/sapi/quickstart/windows/native-build/x_custom_config.bat new file mode 100644 index 0000000000..5a23c09485 --- /dev/null +++ b/sapi/quickstart/windows/native-build/x_custom_config.bat @@ -0,0 +1,139 @@ +@echo off + +setlocal enableextensions enabledelayedexpansion +rem show current file location +echo %~dp0 +cd /d %~dp0 +cd /d ..\..\..\..\ + +set "__PROJECT__=%cd%" +echo %cd% + +cd /d %__PROJECT__%\var\windows-build-deps\php-src\ + +set X_MAKEFILE=%__PROJECT__%\var\windows-build-deps\php-src\Makefile + +:: set "PATH=%ProgramFiles%\7-Zip;%ProgramFiles%\Git\bin;%__PROJECT__%\bin\runtime\;%__PROJECT__%\bin\runtime\nasm\;%__PROJECT__%\bin\runtime\php;%__PROJECT__%\bin\runtime\libarchive\bin;%PATH%" + +rem https://learn.microsoft.com/zh-cn/cpp/error-messages/tool-errors/linker-tools-warning-lnk4098?view=msvc-170&redirectedfrom=MSDN +rem https://learn.microsoft.com/zh-cn/cpp/build/reference/md-mt-ld-use-run-time-library?view=msvc-170 +rem /VERBOSE:LIB /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrtd.lib + + +sed.exe -i 's/\/LD \/MD/\/MT/' %X_MAKEFILE% +sed.exe -i 's/\/D _USRDLL/ /' %X_MAKEFILE% + +findstr /C:"x-show-var: " %X_MAKEFILE% +findstr /C:"x-show-var: " %X_MAKEFILE% > nul + +if errorlevel 1 ( + echo "custom x-show-var config !" + goto x-custom-show-var-start +) else ( + echo "custom x-show-var config file exits !" + goto x-custom-show-var-end +) + +:x-custom-show-var-start +echo x-show-var: >> %X_MAKEFILE% +echo ^@echo DEPS_CLI: $(DEPS_CLI) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo CLI_GLOBAL_OBJ: $(CLI_GLOBAL_OBJS) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo ASM_OBJS: $(ASM_OBJS) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo STATIC_EXT_LIBS: $(STATIC_EXT_LIBS) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo STATIC_EXT_LDFLAGS: $(STATIC_EXT_LDFLAGS) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo STATIC_EXT_CFLAGS: $(STATIC_EXT_CFLAGS) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo BUILD_DIR\PHPLIB: $(BUILD_DIR)\$(PHPLIB) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo BUILD_DIR\PHPDLL: $(BUILD_DIR)\$(PHPDLL) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo CLI_GLOBAL_OBJS_RESP: $(CLI_GLOBAL_OBJS_RESP) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo PHP_LDFLAGS: $(PHP_LDFLAGS) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo LIBS: $(LIBS) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo LIBS_CLI: $(LIBS_CLI) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo LDFLAGS: $(LDFLAGS) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo LDFLAGS_CLI: $(LDFLAGS_CLI) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo _VC_MANIFEST_EMBED_EXE: $(_VC_MANIFEST_EMBED_EXE) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo PHPDEF: $(PHPDEF) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo PHPDLL_RES: $(PHPDLL_RES) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo ASM_OBJS: $(ASM_OBJS) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% +echo ^@echo MCFILE: $(MCFILE) >> %X_MAKEFILE% +echo ^@echo ================== >> %X_MAKEFILE% + +:x-custom-show-var-end + + +findstr /C:"x-release-php:" %X_MAKEFILE% >nul + +if errorlevel 1 ( + echo "custom x-release-php config !" + goto x-release-php-start +) else ( + echo "custom x-release-php config file exits !" + goto x-release-php-end +) + +:x-release-php-start +echo. >> %X_MAKEFILE% +rem echo x-release-php^:$(DEPS_CLI) $(CLI_GLOBAL_OBJS) $(BUILD_DIR)\$(PHPLIB) $(BUILD_DIR)\php.exe.res $(BUILD_DIR)\php.exe.manifest >> %X_MAKEFILE% +rem echo @"$(LINK)" /nologo $(CLI_GLOBAL_OBJS_RESP) $(BUILD_DIR)\$(PHPLIB) $(LIBS_CLI) $(BUILD_DIR)\php.exe.res /out:$(BUILD_DIR)\php.exe $(LDFLAGS) $(LDFLAGS_CLI) $(LIBS) >> %X_MAKEFILE% +rem echo -@$(_VC_MANIFEST_EMBED_EXE) >> %X_MAKEFILE% + + + +rem echo x-custom-php-lib^:generated_files $(PHP_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(ASM_OBJS) $(MCFILE) >> %X_MAKEFILE% +rem echo ^@copy win32\build\default.manifest $(BUILD_DIR)\$(PHPDLL).manifest ^>nul >> %X_MAKEFILE% +rem echo ^# @$(CC) $(PHP_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(STATIC_EXT_LIBS) $(LIBS) $(PHPDLL_RES) /link /out:$(BUILD_DIR)\$(PHPDLL) $(PHP8_PGD_OPTION) $(PHP_LDFLAGS) $(LDFLAGS) $(STATIC_EXT_LDFLAGS) +rem echo ^@"$(LINK)" $(PHP_GLOBAL_OBJS_RESP) $(STATIC_EXT_OBJS_RESP) $(STATIC_EXT_LIBS) $(LIBS) $(ASM_OBJS) $(PHPDLL_RES) /out:$(BUILD_DIR)\$(PHPDLL) $(PHP8_PGD_OPTION) $(PHP_LDFLAGS) $(LDFLAGS) $(STATIC_EXT_LDFLAGS) +rem echo ^-@$(_VC_MANIFEST_EMBED_DLL) >> %X_MAKEFILE% + + +:: $(BUILD_DIR)\$(PHPLIB) replace to x-custom-php-lib + +rem echo x-release-php^: $(DEPS_CLI) $(PHP_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(ASM_OBJS) $(MCFILE) $(BUILD_DIR)\php.exe.res $(BUILD_DIR)\php.exe.manifest >> %X_MAKEFILE% +rem echo x-release-php^: $(DEPS_CLI) $(CLI_GLOBAL_OBJS) $(PHP_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(ASM_OBJS) $(MCFILE) $(BUILD_DIR)\php.exe.res $(BUILD_DIR)\php.exe.manifest >> %X_MAKEFILE% +echo x-release-php^: $(DEPS_CLI) $(CLI_GLOBAL_OBJS) $(PHP_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(ASM_OBJS) $(MCFILE) $(BUILD_DIR)\php.exe.res $(BUILD_DIR)\php.exe.manifest >> %X_MAKEFILE% +echo ^@$(CC) /VERBOSE:LIB $(PHP_GLOBAL_OBJS) +rem echo @"$(LINK)" /nologo $(CLI_GLOBAL_OBJS_RESP) $(PHP_GLOBAL_OBJS_RESP) $(STATIC_EXT_OBJS_RESP) $(STATIC_EXT_LIBS) $(ASM_OBJS) $(LIBS_CLI) $(BUILD_DIR)\php.exe.res /out:$(BUILD_DIR)\php.exe $(LDFLAGS) $(LDFLAGS_CLI) $(LIBS) >> %X_MAKEFILE% +rem echo -@$(_VC_MANIFEST_EMBED_EXE) >> %X_MAKEFILE% + +rem /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrtd.lib + + +rem https://www.cnblogs.com/sherry-best/archive/2013/04/15/3022705.html +rem https://learn.microsoft.com/zh-CN/cpp/c-runtime-library/crt-library-features?view=msvc-170&viewFallbackFrom=vs-2019 + +rem echo ^@"$(LINK)" ^/nologo $(PHP_GLOBAL_OBJS) $(PHP_GLOBAL_OBJS_RESP) $(CLI_GLOBAL_OBJS) $(CLI_GLOBAL_OBJS_RESP) $(STATIC_EXT_OBJS_RESP) $(STATIC_EXT_OBJS) $(ASM_OBJS) $(LIBS) $(LIBS_CLI) $(BUILD_DIR)^\php.exe.res /out:$(BUILD_DIR)^\php.exe $(LDFLAGS) $(LDFLAGS_CLI) >> %x_makefile% +rem echo ^@"$(LINK)" ^/nologo $(DEPS_CLI) $(STATIC_EXT_OBJS_RESP) $(STATIC_EXT_LIBS) $(ASM_OBJS) $(LIBS) $(LIBS_CLI) $(BUILD_DIR)^\php.exe.res /out:$(BUILD_DIR)^\php.exe $(LDFLAGS) $(LDFLAGS_CLI) >> %x_makefile% +rem echo -@$(_VC_MANIFEST_EMBED_EXE) >> %x_makefile% +rem echo ^@echo SAPI sapi\cli build complete >> %x_makefile% +rem echo @if exist php.exe.manifest $(MT) -nologo -manifest php.exe.manifest -outputresource:php.exe >> %x_makefile% + +rem /WHOLEARCHIVE /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcrtd.lib /FORCE:MULTIPLE +rem libcpmt.lib libvcruntime.lib libucrt.lib msvcrt.lib +rem /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrtd.lib +rem libvcruntime.lib libcmt.lib + +rem /MANIFEST:php.exe.manifest /MANIFESTUAC:uiAccess /SUBSYSTEM:CONSOLE /subsystem:windows + +:x-release-php-end + + + +cd %__PROJECT__% +endlocal diff --git a/sapi/quickstart/windows/powershell-download.md b/sapi/quickstart/windows/powershell-download.md new file mode 100644 index 0000000000..6548913915 --- /dev/null +++ b/sapi/quickstart/windows/powershell-download.md @@ -0,0 +1,12 @@ +参考 powershell 下载文件 + +```bash + +Invoke-WebRequest -Uri "https://github.com/wixtoolset/wix3/releases/download/wix3141rtm/wix314-binaries.zip" -OutFile wix.zip +Expand-Archive -Path .\wix.zip -DestinationPath wix\bin + +``` + +参考 github action windows 构建 + +https://github.com/OpenVPN/openvpn-build/blob/master/.github/workflows/build.yaml diff --git a/sapi/quickstart/windows/windows-downloader.md b/sapi/quickstart/windows/windows-downloader.md new file mode 100644 index 0000000000..8dae4b31a9 --- /dev/null +++ b/sapi/quickstart/windows/windows-downloader.md @@ -0,0 +1,16 @@ +## windows 终端下载器 + +### winget + + winget source remove winget + winget source add winget https://mirrors.ustc.edu.cn/winget-source --trust-level trusted + + https://mirrors.ustc.edu.cn/help/winget-source.html + +### scoop + + https://scoop.sh/ + +## choco + + https://chocolatey.org/install#generic diff --git a/sapi/quickstart/windows/windows.md b/sapi/quickstart/windows/windows.md new file mode 100644 index 0000000000..7911036e98 --- /dev/null +++ b/sapi/quickstart/windows/windows.md @@ -0,0 +1,27 @@ +# 构建window PHP 工具 和 参考 + +[download windows PHP ](https://windows.php.net/download#php-8.2) + +[windows build php 步骤](https://wiki.php.net/internals/windows/stepbystepbuild) + +## windows 环境下 git 配置 + +```shell +git config --global core.autocrlf false +git config --global core.eol lf +git config --global core.ignorecase false +git config core.ignorecase false # 设置 Git 在 Windows 上也区分大小写 +``` + +[Latest VC++](https://learn.microsoft.com/en-AU/cpp/windows/latest-supported-vc-redist) +[7zip](https://7-zip.org/) +[visualstudio](https://visualstudio.microsoft.com/zh-hans/downloads/) +[windows-sdk](https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/) + +## windows 软连接例子 + +```bash + +mklink composer composer.phar + +``` diff --git a/sapi/scripts/DownloadPHPSourceCode.php b/sapi/scripts/DownloadPHPSourceCode.php deleted file mode 100644 index 4c299da290..0000000000 --- a/sapi/scripts/DownloadPHPSourceCode.php +++ /dev/null @@ -1,29 +0,0 @@ -> ~/.bash_aliases +echo "alias cygwin='C:/cygwin64/setup-x86_64.exe -q -P'" >>~/.bash_aliases source ~/.bash_aliases # add bash_aliases to bashrc if missing -echo "source ~/.bash_aliases" >> ~/.profile +echo "source ~/.bash_aliases" >>~/.profile # win7 可能运行不了,因为缺少https证书 。使用镜像地址,请选在http 协议 setup-x86_64.exe --help setup-x86_64.exe -q -s http://mirror.internode.on.net setup-x86_64.exe -q -s http://mirrors.ustc.edu.cn/cygwin/ -C:/cygwin/setup-x86_64.exe --no-shortcuts --quiet-mode --disable-buggy-antivirus --packages wget,tar,libtool,re2c,bison,gcc-g++,autoconf,automake,openssl +C:/cygwin/setup-x86_64.exe --no-shortcuts --quiet-mode --disable-buggy-antivirus --packages wget,tar,libtool,re2c,bison,gcc-g++,autoconf,automake,openssl exit 0 -./setup-x86_64.exe --no-shortcuts -q -s http://mirrors.ustc.edu.cn/cygwin/ --packages make - +./setup-x86_64.exe --no-shortcuts -q -s http://mirrors.ustc.edu.cn/cygwin/ --packages make # 安装apt-cyg 参考: https://zhuanlan.zhihu.com/p/66930502 @@ -69,11 +58,10 @@ exit 0 # base tar wget bzip2 gawk xz # curl -Lo apt-cyg rawgit.com/transcode-open/apt-cyg/master/apt-cyg -lynx -source rawgit.com/transcode-open/apt-cyg/master/apt-cyg > apt-cyg +lynx -source rawgit.com/transcode-open/apt-cyg/master/apt-cyg >apt-cyg install apt-cyg /bin apt-cyg --help # apt-cyg mirror https://mirrors.ustc.edu.cn/cygwin/ -apt-cyg install wget tar libtool re2c 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 libreadline-devel libintl-devel libpq-devel libssh2-devel libidn2-devel gettext-devel coreutils - +apt-cyg install wget tar libtool re2c 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 libreadline-devel libintl-devel libpq-devel libssh2-devel libidn2-devel gettext-devel coreutils diff --git a/sapi/scripts/cygwin/cygwin-build.sh b/sapi/scripts/cygwin/cygwin-build.sh index 47e254b9f6..00f0d1e8f3 100755 --- a/sapi/scripts/cygwin/cygwin-build.sh +++ b/sapi/scripts/cygwin/cygwin-build.sh @@ -14,13 +14,24 @@ cd ${__PROJECT__}/php-src mkdir -p bin/.libs -make -j $(nproc) cli +LOGICAL_PROCESSORS=$(nproc) + +set +u +if [ -n "${GITHUB_ACTION}" ]; then + if test $LOGICAL_PROCESSORS -ge 4; then + LOGICAL_PROCESSORS=$((LOGICAL_PROCESSORS - 2)) + fi + make cli + # make -j $LOGICAL_PROCESSORS +else + make -j $LOGICAL_PROCESSORS cli +fi +set -u ${__PROJECT__}/php-src/sapi/cli/php.exe -v cp -f ${__PROJECT__}/php-src/sapi/cli/php.exe ${__PROJECT__}/bin/ - ${__PROJECT__}/bin/php.exe -v ${__PROJECT__}/bin/php.exe -m ${__PROJECT__}/bin/php.exe --ri swoole diff --git a/sapi/scripts/cygwin/cygwin-config-ext.sh b/sapi/scripts/cygwin/cygwin-config-ext.sh index afbc4a20b6..5b036f55f4 100644 --- a/sapi/scripts/cygwin/cygwin-config-ext.sh +++ b/sapi/scripts/cygwin/cygwin-config-ext.sh @@ -12,13 +12,15 @@ __PROJECT__=$( cd ${__PROJECT__} ROOT=${__PROJECT__} -PHP_VERSION='8.2.13' -SWOOLE_VERSION=v5.1.3 +PHP_VERSION='8.2.27' +SWOOLE_VERSION='v6.0.0' +X_PHP_VERSION='8.2' while [ $# -gt 0 ]; do case "$1" in --php-version) PHP_VERSION="$2" + X_PHP_VERSION=$(echo ${PHP_VERSION:0:3}) ;; --swoole-version) SWOOLE_VERSION="$2" @@ -30,7 +32,7 @@ while [ $# -gt 0 ]; do shift $(($# > 0 ? 1 : 0)) done -REDIS_VERSION=6.0.2 +REDIS_VERSION=6.1.0 MONGODB_VERSION=1.17.2 YAML_VERSION=2.2.2 IMAGICK_VERSION=3.7.0 @@ -76,6 +78,9 @@ if [ ! -d $ROOT/ext/imagick ]; then fi tar xvf imagick-${IMAGICK_VERSION}.tgz mv imagick-${IMAGICK_VERSION} $ROOT/ext/imagick + if [ "$X_PHP_VERSION" = "8.4" ]; then + sed -i.backup "s/php_strtolower(/zend_str_tolower(/" $ROOT/ext/imagick/imagick.c + fi fi if [ ! -f swoole-${SWOOLE_VERSION}.tgz ]; then @@ -102,3 +107,13 @@ mkdir -p php-src tar --strip-components=1 -C php-src -xf php-${PHP_VERSION}.tar.gz cd $ROOT + +if [ ! -d $ROOT/ext/pgsql ]; then + mv $ROOT/php-src/ext/pgsql $ROOT/ext/pgsql +fi + +cd $ROOT + +ls -lh $ROOT +ls -lh $ROOT/ext/ +cd $ROOT diff --git a/sapi/scripts/cygwin/cygwin-config.sh b/sapi/scripts/cygwin/cygwin-config.sh index b9c1eb8ce9..7750ddd65f 100755 --- a/sapi/scripts/cygwin/cygwin-config.sh +++ b/sapi/scripts/cygwin/cygwin-config.sh @@ -11,12 +11,39 @@ __PROJECT__=$( ) cd ${__PROJECT__} +OPTIONS='' +OPTIONS+=' --enable-swoole-thread ' +OPTIONS+=' --enable-brotli ' +OPTIONS+=' --enable-zstd ' +OPTIONS+=' --enable-zts ' +OPTIONS+=' --disable-opcache-jit ' + +X_PHP_VERSION='' +while [ $# -gt 0 ]; do + case "$1" in + --php-version) + PHP_VERSION="$2" + X_PHP_VERSION=$(echo ${PHP_VERSION:0:3}) + if [ "$X_PHP_VERSION" = "8.4" ]; then + OPTIONS+='' + fi + ;; + --*) + echo "Illegal option $1" + ;; + esac + shift $(($# > 0 ? 1 : 0)) +done + mkdir -p ${__PROJECT__}/bin/ # cp -f ${__PROJECT__}/php-src/ext/openssl/config0.m4 ${__PROJECT__}/php-src/ext/openssl/config.m4 cp -rf ${__PROJECT__}/ext/* ${__PROJECT__}/php-src/ext/ cd ${__PROJECT__}/php-src/ +if [ "$X_PHP_VERSION" = "8.4" ] || [ "$X_PHP_VERSION" = "8.3" ] || [ "$X_PHP_VERSION" = "8.2" ] || [ "$X_PHP_VERSION" = "8.1" ]; then + sed -i.backup 's/!defined(__HAIKU__)/!defined(__HAIKU__) \&\& !defined(__CYGWIN__)/' TSRM/TSRM.c +fi # export CPPFLAGS="-I/usr/include" # export CFLAGS="-DZEND_WIN32=1 -DPHP_WIN32=1 -DWIN32 " @@ -26,52 +53,52 @@ cd ${__PROJECT__}/php-src/ ./buildconf --force test -f Makefile && make clean ./configure --prefix=/usr --disable-all \ - --enable-opcache \ - --disable-fiber-asm \ - --without-pcre-jit \ - --with-openssl --enable-openssl \ - --with-curl \ - --with-iconv \ - --enable-intl \ - --with-bz2 \ - --enable-bcmath \ - --enable-filter \ - --enable-session \ - --enable-tokenizer \ - --enable-mbstring \ - --enable-ctype \ - --with-zlib \ - --enable-posix \ - --enable-sockets \ - --enable-pdo \ - --with-sqlite3 \ - --enable-phar \ - --enable-pcntl \ - --enable-mysqlnd \ - --with-mysqli \ - --enable-fileinfo \ - --with-pdo_mysql \ - --enable-soap \ - --with-xsl \ - --with-gmp \ - --enable-exif \ - --with-sodium \ - --enable-xml --enable-simplexml --enable-xmlreader --enable-xmlwriter --enable-dom --with-libxml \ - --enable-gd --with-jpeg --with-freetype \ - --enable-swoole --enable-sockets --enable-mysqlnd --enable-swoole-curl --enable-cares \ - --enable-swoole-pgsql \ - --enable-swoole-sqlite \ - --enable-redis \ - --with-imagick \ - --with-yaml \ - --with-readline + \ + --disable-fiber-asm \ + --without-pcre-jit \ + --with-openssl --enable-openssl \ + --with-curl \ + --with-iconv \ + --enable-intl \ + --with-bz2 \ + --enable-bcmath \ + --enable-filter \ + --enable-session \ + --enable-tokenizer \ + --enable-mbstring \ + --enable-ctype \ + --with-zlib \ + --enable-posix \ + --enable-sockets \ + --enable-pdo \ + --with-sqlite3 \ + --enable-phar \ + --enable-pcntl \ + --enable-mysqlnd \ + --with-mysqli \ + --enable-fileinfo \ + --with-pdo_mysql \ + --enable-soap \ + --with-xsl \ + --with-gmp \ + --enable-exif \ + --with-sodium \ + --enable-xml --enable-simplexml --enable-xmlreader --enable-xmlwriter --enable-dom --with-libxml \ + --enable-gd --with-jpeg --with-freetype \ + --enable-swoole --enable-sockets --enable-mysqlnd --enable-swoole-curl --enable-cares \ + --enable-swoole-pgsql \ + --enable-swoole-sqlite \ + --enable-redis \ + --enable-opcache \ + --disable-opcache-jit \ + --with-imagick \ + --with-yaml \ + --with-readline \ + ${OPTIONS} -# --with-zip # cygwin libzip-devel 版本库暂不支持函数 zip_encryption_method_supported (2020年新增函数) # --with-pdo-pgsql \ # --with-pgsql # --with-pdo-sqlite \ - -# swoole v6 参数 -# --enable-swoole-thread \ -# --enable-zts \ - +# --with-zip # cygwin libzip-devel 版本库暂不支持函数 zip_encryption_method_supported (2020年新增函数) +# --enable-zts +# --disable-opcache-jit diff --git a/sapi/scripts/cygwin/install-cygwin.sh b/sapi/scripts/cygwin/install-cygwin.sh index 910cefd94e..25b330ad66 100644 --- a/sapi/scripts/cygwin/install-cygwin.sh +++ b/sapi/scripts/cygwin/install-cygwin.sh @@ -15,7 +15,6 @@ ROOT=${__PROJECT__} # cp -f /cygdrive/c/setup-x86_64.exe /cygdrive/c/cygwin/bin/setup-x86_64.exe # cp -f /cygdrive/c/setup.exe /cygdrive/c/cygwin/bin/setup-x86_64.exe - # download cygwin # wget https://cygwin.com/setup-x86_64.exe @@ -28,12 +27,11 @@ ROOT=${__PROJECT__} ## https://mirrors.tuna.tsinghua.edu.cn/cygwin/ ## 多个包之间,用逗号分隔 - SITE='https://mirrors.kernel.org/sourceware/cygwin/' while [ $# -gt 0 ]; do case "$1" in --mirror) - if [ "$2" = 'china' ] ; then + if [ "$2" = 'china' ]; then SITE='https://mirrors.ustc.edu.cn/cygwin/' fi ;; @@ -44,11 +42,15 @@ while [ $# -gt 0 ]; do shift $(($# > 0 ? 1 : 0)) done -# setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site http://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,zip,unzip -#setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site http://mirrors.ustc.edu.cn/cygwin/ --packages - -setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site $SITE --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,zip,unzip -setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site $SITE --packages zip unzip icu libicu-devel -setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site $SITE --packages libpq5 libpq-devel +set +u +if [ -z "${GITHUB_ACTION}" ]; then + # 非 github 构建环境下创建启动图标 + setup-x86_64.exe --quiet-mode --disable-buggy-antivirus --site $SITE +fi +set -u +setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site $SITE --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,zip,unzip +setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site $SITE --packages zip unzip icu libicu-devel +setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site $SITE --packages libpq5 libpq-devel +setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site $SITE --packages libzstd-devel diff --git a/sapi/scripts/cygwin/upload-oss.sh b/sapi/scripts/cygwin/upload-oss.sh deleted file mode 100644 index 9e0e384f28..0000000000 --- a/sapi/scripts/cygwin/upload-oss.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash - -set -exu -__DIR__=$( - cd "$(dirname "$0")" - pwd -) -__PROJECT__=$( - cd ${__DIR__}/../../../ - pwd -) -cd ${__PROJECT__} - -exit 0 - -## tencentyun upload oss -## https://cloud.tencent.com/document/product/436/63144 - -test -f coscli-windows.exe || wget https://github.com/tencentyun/coscli/releases/download/v0.13.0-beta/coscli-windows.exe - -./coscli-windows cp swoole-cli-v".SWOOLE_VERSION."-cygwin-x64 cos://examplebucket-1250000000/test.txt -e cos.ap-chengdu.myqcloud.com - - diff --git a/sapi/scripts/download-php-src-archive.php b/sapi/scripts/download-php-src-archive.php new file mode 100644 index 0000000000..536d075f1c --- /dev/null +++ b/sapi/scripts/download-php-src-archive.php @@ -0,0 +1,32 @@ + 0 ? 1 : 0)) +done + +mkdir -p ${__PROJECT__}/var/artifact-hash/${VERSION} +cd ${__PROJECT__}/var/artifact-hash/${VERSION} + +UNIX_DOWNLOAD_SWOOLE_CLIE_RUNTIME() { + OS="$1" + ARCH="$2" + APP_VERSION="$3" + APP_DOWNLOAD_URL="https://github.com/swoole/build-static-php/releases/download/${VERSION}/${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}.tar.xz" + APP_RUNTIME="${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}" + test -f ${APP_RUNTIME}.tar.xz || curl -fSLo ${APP_RUNTIME}.tar.xz ${APP_DOWNLOAD_URL} + + APP_DOWNLOAD_URL="https://github.com/swoole/build-static-php/releases/download/${VERSION}/${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}-debug.tar.xz" + APP_RUNTIME="${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}-debug" + test -f ${APP_RUNTIME}.tar.xz || curl -fSLo ${APP_RUNTIME}.tar.xz ${APP_DOWNLOAD_URL} +} + +UNIX_DOWNLOAD() { + APP_VERSION="$1" + UNIX_DOWNLOAD_SWOOLE_CLIE_RUNTIME "linux" "x64" "${APP_VERSION}" + UNIX_DOWNLOAD_SWOOLE_CLIE_RUNTIME "linux" "arm64" "${APP_VERSION}" + UNIX_DOWNLOAD_SWOOLE_CLIE_RUNTIME "macos" "x64" "${APP_VERSION}" + UNIX_DOWNLOAD_SWOOLE_CLIE_RUNTIME "macos" "arm64" "${APP_VERSION}" +} + +WINDOWS_DOWNLOAD_SWOOLE_CLIE_RUNTIME() { + APP_VERSION="$1" + ARCH="x64" + APP_DOWNLOAD_URL="https://github.com/swoole/build-static-php/releases/download/${VERSION}/${APP_NAME}-${APP_VERSION}-cygwin-${ARCH}.zip" + + APP_RUNTIME="${APP_NAME}-${APP_VERSION}-cygwin-${ARCH}" + test -f ${APP_RUNTIME}.zip || curl -fSLo ${APP_RUNTIME}.zip ${APP_DOWNLOAD_URL} +} +WINDOWS_DOWNLOAD() { + WINDOWS_DOWNLOAD_SWOOLE_CLIE_RUNTIME "$1" +} + +RUN_DOWNLOAD() { + UNIX_DOWNLOAD "$1" + WINDOWS_DOWNLOAD "$1" +} + +DOWNLOAD() { + declare -A PHP_VERSIONS + PHP_VERSIONS[0]="v8.2.27" + PHP_VERSIONS[1]="v8.1.31" + PHP_VERSIONS[2]="v8.3.15" + PHP_VERSIONS[3]="v8.4.2" + for i in "${!PHP_VERSIONS[@]}"; do + # echo ${PHP_VERSIONS[$i]} + RUN_DOWNLOAD "${PHP_VERSIONS[$i]}" + done + +} + +test -f all-deps.zip || curl -fSLo all-deps.zip https://github.com/swoole/build-static-php/releases/download/${VERSION}/all-deps.zip + +DOWNLOAD + +ls -p | grep -v '/$' | xargs sha256sum + +ls -p | grep -v '/$' | xargs sha256sum >${__PROJECT__}/${VERSION}-sha256sum diff --git a/sapi/scripts/tencent-cloud-object-storage.sh b/sapi/scripts/tencent-cloud-object-storage.sh new file mode 100644 index 0000000000..ad3522bc03 --- /dev/null +++ b/sapi/scripts/tencent-cloud-object-storage.sh @@ -0,0 +1,157 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=$( + cd ${__DIR__}/../../ + pwd +) +cd ${__PROJECT__} + +## tencentyun upload oss +## 下载与安装配置 +## https://cloud.tencent.com/document/product/436/63144 + +APP_VERSION="v1.0.3" +APP_NAME="coscli" +APP_RUNTIME="${APP_NAME}-${APP_VERSION}" + +OS=$(uname -s) +ARCH=$(uname -m) + +case $OS in +'Linux') + APP_RUNTIME+='-linux' + ;; +'Darwin') + APP_RUNTIME+='-darwin' + ;; +*) + case $OS in + 'MSYS_NT'* | 'MINGW64_NT'* | 'CYGWIN_NT'*) + OS="windows" + APP_RUNTIME+='-windows' + echo ' 暂不支持 ' + exit 0 + ;; + *) + echo 'NO SUPPORT OS' + exit 0 + ;; + esac + + ;; +esac + +case $ARCH in +'x86_64') + APP_RUNTIME+='-amd64' + ;; +'aarch64' | 'arm64') + APP_RUNTIME+='-arm64' + ;; +*) + echo 'NO SUPPORT CPU ARCH ' + exit 0 + ;; +esac + +SWOOLE_CLI_VERSION='v6.0.0.0' +SWOOLE_VERSION='v6.0.0' +UPLOAD_FILE='' +UPLOAD_TYPE='' +PROXY_OPTION='' +while [ $# -gt 0 ]; do + case "$1" in + --swoole-cli-version) + SWOOLE_CLI_VERSION="$2" + ;; + --upload-file) + UPLOAD_FILE="$2" + UPLOAD_TYPE='single' + ;; + --upload-all) + UPLOAD_TYPE='all' + ;; + --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" + NO_PROXY="${NO_PROXY},::1/128,fe80::/10,fd00::/8,ff00::/8" + NO_PROXY="${NO_PROXY},localhost" + export NO_PROXY="${NO_PROXY},.myqcloud.com,.swoole.com" + PROXY_OPTION="--proxy $2" + ;; + --show) + UPLOAD_TYPE="show" + ;; + esac + shift $(($# > 0 ? 1 : 0)) +done + +mkdir -p ${__PROJECT__}/var/tencent-cloud-object-storage/ +cd ${__PROJECT__}/var/tencent-cloud-object-storage/ + +CLOUD_OBJECT_STORAGE_CONFIG=${__PROJECT__}/var/tencent-cloud-object-storage/.tencent-cloud-object-storage.yaml +if [ ! -f ${CLOUD_OBJECT_STORAGE_CONFIG} ]; then + cp -f ${__PROJECT__}/sapi/scripts/tencent-cloud-object-storage.yaml ${CLOUD_OBJECT_STORAGE_CONFIG} + set +u + if [ -n "${OSS_SECRET_ID}" ] && [ -n "${OSS_SECRET_KEY}" ]; then + sed -i.bak "s/\${{ secrets.QCLOUD_OSS_SECRET_ID }}/${OSS_SECRET_ID}/" ${CLOUD_OBJECT_STORAGE_CONFIG} + sed -i.bak "s/\${{ secrets.QCLOUD_OSS_SECRET_KEY }}/${OSS_SECRET_KEY}/" ${CLOUD_OBJECT_STORAGE_CONFIG} + sed -i.bak "s/\${{ vars.QCLOUD_OSS_BUCKET }}/${OSS_BUCKET}/" ${CLOUD_OBJECT_STORAGE_CONFIG} + sed -i.bak "s/\${{ vars.QCLOUD_OSS_REGION }}/${OSS_REGION}/" ${CLOUD_OBJECT_STORAGE_CONFIG} + fi + set -u +fi + +if [ "${OS}" == 'windows' ]; then + APP_RUNTIME+=".exe" +fi + +test -f ${APP_RUNTIME} || curl -fSLo ${APP_RUNTIME} https://github.com/tencentyun/coscli/releases/download/${APP_VERSION}/${APP_RUNTIME} +chmod a+x ${APP_RUNTIME} + +BUCKET_NAME=$(grep "\- name: " ${CLOUD_OBJECT_STORAGE_CONFIG} | sed 's/\- name: //g' | sed 's/^ *//;s/ *$//' | tr -d '"') +COSCLI="${__PROJECT__}/var/tencent-cloud-object-storage/${APP_RUNTIME} --config-path ${CLOUD_OBJECT_STORAGE_CONFIG} --log-path ${__PROJECT__}/var/tencent-cloud-object-storage/coscli.log " +COS_BUCKET_FOLDER="cos://${BUCKET_NAME}/dist/" + +if [ "${UPLOAD_TYPE}" == 'all' ]; then + if [ ! -d ${__PROJECT__}/var/artifact-hash/${SWOOLE_CLI_VERSION} ]; then + bash ${__PROJECT__}/sapi/scripts/generate-artifact-hash.sh --version ${SWOOLE_CLI_VERSION} ${PROXY_OPTION} + fi +fi + +set +u +if [ -n "$HTTP_PROXY" ] || [ -n "$HTTPS_PROXY" ]; then + unset $HTTP_PROXY + unset $HTTPS_PROXY +fi +set -u + +if [ "${UPLOAD_TYPE}" == 'all' ]; then + SWOOLE_VERSION=$(echo ${SWOOLE_CLI_VERSION} | awk -F '.' '{ printf "%s.%s.%s" ,$1,$2,$3 }') + cd ${__PROJECT__}/var/artifact-hash/${SWOOLE_CLI_VERSION} + ${COSCLI} sync swoole-cli-${SWOOLE_VERSION}-cygwin-x64.zip ${COS_BUCKET_FOLDER} + ${COSCLI} sync swoole-cli-${SWOOLE_VERSION}-linux-arm64.tar.xz ${COS_BUCKET_FOLDER} + ${COSCLI} sync swoole-cli-${SWOOLE_VERSION}-linux-x64.tar.xz ${COS_BUCKET_FOLDER} + ${COSCLI} sync swoole-cli-${SWOOLE_VERSION}-macos-arm64.tar.xz ${COS_BUCKET_FOLDER} + ${COSCLI} sync swoole-cli-${SWOOLE_VERSION}-macos-x64.tar.xz ${COS_BUCKET_FOLDER} + cd ${__PROJECT__} + exit 0 +fi + +if [ "${UPLOAD_TYPE}" == 'single' ]; then + ${COSCLI} sync ${UPLOAD_FILE} ${COS_BUCKET_FOLDER} + exit 0 +fi + +if [ "${UPLOAD_TYPE}" == 'show' ]; then + # cat ${CLOUD_OBJECT_STORAGE_CONFIG} + # ${COSCLI} --help + ${COSCLI} ls ${COS_BUCKET_FOLDER} + exit 0 +fi diff --git a/sapi/scripts/tencent-cloud-object-storage.yaml b/sapi/scripts/tencent-cloud-object-storage.yaml new file mode 100644 index 0000000000..dc7e963fb0 --- /dev/null +++ b/sapi/scripts/tencent-cloud-object-storage.yaml @@ -0,0 +1,17 @@ +cos: + base: + secretid: "${{ secrets.QCLOUD_OSS_SECRET_ID }}" + secretkey: "${{ secrets.QCLOUD_OSS_SECRET_KEY }}" + sessiontoken: "" + protocol: https + mode: SecretKey + cvmrolename: "" + closeautoswitchhost: "true" + buckets: + - name: "${{ vars.QCLOUD_OSS_BUCKET }}" + alias: "${{ vars.QCLOUD_OSS_BUCKET }}" + region: "${{ vars.QCLOUD_OSS_REGION }}" + # endpoint: cos.ap-shanghai.myqcloud.com + # endpoint: wenda-1252906962.cos.accelerate.myqcloud.com + endpoint: "cos.accelerate.myqcloud.com" + ofs: false diff --git a/sapi/src/Library.php b/sapi/src/Library.php index 7e981bb230..fec3286403 100644 --- a/sapi/src/Library.php +++ b/sapi/src/Library.php @@ -30,13 +30,7 @@ class Library extends Project public string $prefix = '/usr'; - public string $binPath = ''; - - public bool $cleanBuildDirectory = false; - - public bool $cleanPreInstallDirectory = false; - - public string $preInstallDirectory = ''; + public string|array $binPath = ''; public bool $skipBuildLicense = false; @@ -44,14 +38,14 @@ class Library extends Project public bool $skipBuildInstall = false; - public string $untarArchiveCommand = 'tar'; - public string $label = ''; public string $enablePkgNames = 'yes'; public bool $enableBuildLibraryCached = true; + public string $untarArchiveCommand = 'tar'; + public array $preInstallCommands = []; public bool $enableBuildLibraryHttpProxy = false; @@ -151,41 +145,19 @@ 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; } - - public function withCleanBuildDirectory(bool $cleanBuildDirectory = true): static - { - $this->cleanBuildDirectory = $cleanBuildDirectory; - return $this; - } - - public function withCleanPreInstallDirectory(string $preInstallDir): static - { - if (!empty($preInstallDir) && (str_starts_with($preInstallDir, PHP_CLI_GLOBAL_PREFIX))) { - if (PHP_CLI_BUILD_TYPE == 'dev') { - $this->cleanPreInstallDirectory = true; - $this->preInstallDirectory = $preInstallDir; - } - } - return $this; - } - +// withCleanBuildDirectory( +// withCleanPreInstallDirectory( public function disablePkgNames(): static { $this->enablePkgNames = 'no'; return $this; } - public function withUntarArchiveCommand(string $command): static - { - $this->untarArchiveCommand = $command; - return $this; - } - public function withSkipBuildLicense(): static { @@ -256,7 +228,9 @@ public function withPreInstallCommand(string $os, string $preInstallCommand): st public function withBuildLibraryHttpProxy( bool $enableBuildLibraryHttpProxy = true, bool $enableBuildLibraryGitProxy = false - ): static { + ): static + { + $this->enableBuildLibraryHttpProxy = $enableBuildLibraryHttpProxy; $this->enableBuildLibraryGitProxy = $enableBuildLibraryGitProxy; return $this; @@ -295,4 +269,14 @@ public function withEnv(): static $this->enableEnv = true; return $this; } + + /** + * @param string $command [ tar | tar-default | unzip ] + * @return $this + */ + public function withUntarArchiveCommand(string $command): static + { + $this->untarArchiveCommand = $command; + return $this; + } } diff --git a/sapi/src/Preprocessor.php b/sapi/src/Preprocessor.php index d4fdc3eaa7..5e1b6cd289 100644 --- a/sapi/src/Preprocessor.php +++ b/sapi/src/Preprocessor.php @@ -104,54 +104,21 @@ 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', - 'redis', - 'swoole', - 'yaml', - 'imagick', - //'mongodb', //php8.2 需要处理依赖库问题 more info : https://github.com/mongodb/mongo-php-driver/issues/1445 - 'gd', - ]; + // 'opcache', //需要修改源码才能实现 + // 'mongodb', //php8.2 需要处理依赖库问题 more info : https://github.com/mongodb/mongo-php-driver/issues/1445 + + protected array $extEnabled = []; + protected array $extEnabledBuff = []; + protected array $endCallbacks = []; protected array $extCallbacks = []; protected array $beforeConfigure = []; protected array $releaseArchives = []; - protected string $configureVarables; + protected string $configureVariables; + protected string $buildType = 'release'; protected bool $inVirtualMachine = false; @@ -163,9 +130,10 @@ class Preprocessor protected function __construct() { + $this->setOsType($this->getRealOsType()); + $this->extEnabled = require __DIR__ . '/builder/enabled_extensions.php'; //重置默认扩展 $this->extEnabled = []; - $this->setOsType($this->getRealOsType()); } @@ -224,16 +192,6 @@ public function getBaseImageTag(): string } } - public function getBaseImageDockerFile(): string - { - $arch = $this->getSystemArch(); - if ($arch == 'x64') { - return 'Dockerfile'; - } else { - return 'Dockerfile' . '-' . $arch; - } - } - public function setPhpSrcDir(string $phpSrcDir) { $this->phpSrcDir = $phpSrcDir; @@ -314,12 +272,12 @@ public function setExtraCflags(string $flags) $this->extraCflags = $flags; } - public function setConfigureVarables(string $varables) + public function setConfigureVariables(string $variables): void { - $this->configureVarables = $varables; + $this->configureVariables = $variables; } - public function setExtraOptions(string $options) + public function setExtraOptions(string $options): void { $this->extraOptions = $options; } @@ -402,7 +360,7 @@ public function setProxyConfig(string $shell = '', string $httpProxy = ''): stat /* * sockat 代理例子 * http://www.dest-unreach.org/socat/doc/socat.html - * socat - socks4a:::%h:%p,socksport=2000 + * socat - socks4a::%h:%p,socksport=2000 * socat - proxy::%h:%p,proxyport=2000 */ @@ -455,7 +413,8 @@ public function setExtEnabled(array $extEnabled = []): static return $this; } - public function donotInstallLibrary(): void + + public function doNotInstallLibrary(): void { $this->installLibrary = false; } @@ -468,8 +427,7 @@ public function donotInstallLibrary(): void * @param string $httpProxyConfig * @return void */ - - protected function downloadFile(string $url, string $file, object $project = null, string $httpProxyConfig = ''): void + protected function downloadFile(string $url, string $file, ?object $project = null, string $httpProxyConfig = ''): void { # $userAgent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36'; # echo `curl --user-agent '{$userAgent}' --connect-timeout 15 --retry 5 --retry-delay 5 -Lo '{$file}' '{$url}' `; @@ -482,7 +440,7 @@ protected function downloadFile(string $url, string $file, object $project = nul if ($this->getInputOption('with-downloader') === 'wget') { $cmd = "wget {$url} -O {$file} -t {$retry_number} --wait={$wait_retry} -T {$connect_timeout} "; } else { - $cmd = "curl --connect-timeout {$connect_timeout} --retry {$retry_number} --retry-delay {$wait_retry} -Lo '{$file}' '{$url}' "; + $cmd = "curl --connect-timeout {$connect_timeout} --retry {$retry_number} --retry-delay {$wait_retry} -fSLo '{$file}' '{$url}' "; } $cmd = $httpProxyConfig . PHP_EOL . $cmd; echo $cmd; @@ -636,7 +594,11 @@ public function addLibrary(Library $lib): void } 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)) { @@ -772,7 +734,8 @@ public function addExtension(Extension $ext): void echo '[ext/' . $ext_name . '] cached ' . PHP_EOL; } } else { - echo $cmd = "tar --strip-components=1 -C $dst_dir -xf {$ext->path}"; + $cmd = "tar --strip-components=1 -C $dst_dir -xf {$ext->path}"; + echo "[Extension] " . $cmd; echo PHP_EOL; echo `$cmd`; echo PHP_EOL; @@ -1068,7 +1031,7 @@ protected function deleteDirectoryIfExists($path): bool /** * Scan and load config files in directory */ - protected function scanConfigFiles(string $dir, array &$extAvailabled) + protected function scanConfigFiles(string $dir, array &$extAvailable): void { $files = scandir($dir); foreach ($files as $f) { @@ -1077,14 +1040,14 @@ protected function scanConfigFiles(string $dir, array &$extAvailabled) } $path = $dir . '/' . $f; if (is_dir($path)) { - $this->scanConfigFiles($path, $extAvailabled); + $this->scanConfigFiles($path, $extAvailable); } else { - $extAvailabled[basename($f, '.php')] = require $path; + $extAvailable[basename($f, '.php')] = require $path; } } } - public function loadDependentExtension($extension_name) + public function loadDependentExtension($extension_name): void { if (!isset($this->extensionMap[$extension_name])) { $file = realpath(__DIR__ . '/builder/extension/' . $extension_name . '.php'); @@ -1155,14 +1118,20 @@ public function execute(): void } $this->mkdirIfNotExists($this->libraryDir, 0777, true); $this->mkdirIfNotExists($this->extensionDir, 0777, true); + + if (BUILD_SHARED_LIBS) { $this->globalPrefix = '/usr/local/swoole-cli-shared'; } + + $this->deleteDirectoryIfExists($this->getWorkExtDir()); + include __DIR__ . '/constants.php'; //构建依赖库安装脚本 //libraries_builder($this); - $extAvailabled = []; - $this->scanConfigFiles(__DIR__ . '/builder/extension', $extAvailabled); + $extAvailable = []; + $this->scanConfigFiles(__DIR__ . '/builder/extension', $extAvailable); + $confPath = $this->getInputOption('conf-path'); if ($confPath) { $confDirList = explode(':', $confPath); @@ -1170,33 +1139,23 @@ public function execute(): void if (!is_dir($dir)) { continue; } - $this->scanConfigFiles($dir, $extAvailabled); + $this->scanConfigFiles($dir, $extAvailable); } } install_libraries($this); $this->extEnabled = array_unique($this->extEnabled); foreach ($this->extEnabled as $ext) { - if (!isset($extAvailabled[$ext])) { + if (!isset($extAvailable[$ext])) { echo "unsupported extension[$ext]\n"; continue; } - ($extAvailabled[$ext])($this); + ($extAvailable[$ext])($this); if (isset($this->extCallbacks[$ext])) { ($this->extCallbacks[$ext])($this); } } - if ($this->isMacos()) { - if (is_file('/usr/local/opt/bison/bin/bison')) { - $this->withBinPath('/usr/local/opt/bison/bin'); - } elseif (is_file('/opt/homebrew/opt/bison/bin/bison')) { //兼容 github action - $this->withBinPath('/opt/homebrew/opt/bison/bin/'); - } else { - $this->loadDependentLibrary("bison"); - } - } - // autoload extension depend extension foreach ($this->extensionMap as $ext) { foreach ($ext->dependentExtensions as $extension_name) { @@ -1253,12 +1212,14 @@ public function execute(): void $this->generateFile(__DIR__ . '/template/make-install-deps.php', $this->rootDir . '/make-install-deps.sh'); $this->generateFile(__DIR__ . '/template/make.php', $this->rootDir . '/make.sh'); + $this->generateFile(__DIR__ . '/template/make-env.php', $this->rootDir . '/make-env.sh'); $this->generateFile( __DIR__ . '/template/make-export-variables.php', $this->rootDir . '/make-export-variables.sh' ); + shell_exec('chmod a+x ' . $this->rootDir . '/make.sh'); $this->mkdirIfNotExists($this->rootDir . '/bin'); $this->generateFile(__DIR__ . '/template/license.php', $this->rootDir . '/bin/LICENSE'); $this->generateFile(__DIR__ . '/template/credits.php', $this->rootDir . '/bin/credits.html'); @@ -1267,7 +1228,7 @@ public function execute(): void if ($this->getInputOption('with-dependency-graph')) { $this->generateFile( - __DIR__ . '/template/extension-dependency-graph.php', + __DIR__ . '/template/extension_dependency_graph.php', $this->rootDir . '/bin/ext-dependency-graph.graphviz.dot' ); } @@ -1292,6 +1253,7 @@ public function execute(): void } } + public function getRealOsType(): string { switch (PHP_OS) { diff --git a/sapi/src/UnitTest/MainTest.php b/sapi/src/UnitTest/MainTest.php index feb62c87bc..5edc9949b7 100644 --- a/sapi/src/UnitTest/MainTest.php +++ b/sapi/src/UnitTest/MainTest.php @@ -43,6 +43,7 @@ public function testGd(): void $this->assertEquals($info["BMP Support"], true); $this->assertEquals($info["TGA Read Support"], true); $this->assertEquals($info["JIS-mapped Japanese Font Support"], false); + $this->assertEquals($info["AVIF Support"], true); } public function testImagick(): void diff --git a/sapi/src/UnitTest/SwoolePGSQLTest.php b/sapi/src/UnitTest/SwoolePGSQLTest.php index 72f3540e47..cdc203ce34 100644 --- a/sapi/src/UnitTest/SwoolePGSQLTest.php +++ b/sapi/src/UnitTest/SwoolePGSQLTest.php @@ -9,6 +9,9 @@ use function Swoole\Coroutine\run; +error_reporting(E_ALL); +ini_set("display_errors", "on"); + final class SwoolePGSQLTest extends TestCase { private $pg = null; @@ -16,6 +19,7 @@ final class SwoolePGSQLTest extends TestCase public function testSwoolePGSQL(): void { + run(function () { $this->createDataBase(); $this->createTable(); @@ -23,7 +27,9 @@ public function testSwoolePGSQL(): void $this->selectTableData(); $this->deleteTableData(); $this->dropTable(); + $this->pg = null; $this->dropDatabase(); + $this->pg_master = null; }); } @@ -33,15 +39,17 @@ public function createDataBase() $pg = new PostgreSQL(); $conn = $pg->connect("host=127.0.0.1 port=5432 dbname=postgres user=postgres password=example"); - if (!$conn) { - $this->assertNotTrue($conn, 'pgsql connection postgres error,error info :' . $pg->error); - return false; - } + $this->assertTrue($conn, 'pgsql connection postgres Error ,Error Info : ' . $pg->error); + $this->pg_master = $pg; $stmt = $pg->query("SELECT * FROM pg_database WHERE datname = 'user_center'"); - $arr = $stmt->fetchAssoc(); - if (empty($arr)) { - $sql = <<fetchAll(); + if (!empty($arr)) { + $this->dropDatabase(); + } + + + $sql = <<query($sql); - $this->assertEquals(0, $pg->errCode, 'create database user_center sucess' . $pg->error); - } - + echo $sql . PHP_EOL; + $pg->query($sql); + $this->assertEquals(0, $pg->errCode, 'create database user_center Error ,Error Info : ' . $pg->error); } public function createTable() @@ -64,10 +70,8 @@ public function createTable() $pg = new PostgreSQL(); $conn = $pg->connect("host=127.0.0.1 port=5432 dbname=user_center user=postgres password=example"); - if (!$conn) { - $this->assertNotTrue($conn, 'erro_info' . $pg->error); - return; - } + $this->assertTrue($conn, 'connection database user_center Error ,Error Info : ' . $pg->error); + $this->pg = $pg; $sql = "select * from pg_tables where schemaname = 'public' and tablename='users'"; $stmt = $pg->query($sql); @@ -102,8 +106,9 @@ public function createTable() alter table users alter column id set default nextval('users_id_seq'); EOF; + echo $table . PHP_EOL; $pg->query($table); - $this->assertEquals(0, $pg->errCode, 'create table users sucess' . $pg->error); + $this->assertEquals(0, $pg->errCode, 'create table users Error ,Error Info : ' . $pg->error); } } @@ -147,19 +152,18 @@ public function insertTableData() ] ]; - echo $sql; + echo $sql . PHP_EOL; $stmt = $this->pg->prepare($sql); - - $i = 100; + $i = 30; while ($i >= 1) { foreach ($list as $data) { $res = $stmt->execute($data); } $i--; } - $this->assertGreaterThanOrEqual(1, $stmt->affectedRows(), 'insert data sucess' . $this->pg->error); - var_dump($stmt->affectedRows()); + + $this->assertGreaterThanOrEqual(1, $stmt->affectedRows(), 'insert data Error ,Error Info : ' . $this->pg->error); } public function selectTableData() @@ -170,11 +174,11 @@ public function selectTableData() EOF; - echo $sql; + echo $sql . PHP_EOL; $stmt = $this->pg->query($sql); $list = $stmt->fetchAll(); - $this->assertGreaterThan(1, count($list), 'select data' . $this->pg->error); + $this->assertGreaterThan(1, count($list), 'select data Error ,Error Info : ' . $this->pg->error); } public function deleteTableData() @@ -185,27 +189,26 @@ public function deleteTableData() EOF; - echo $sql; + echo $sql . PHP_EOL; $stmt = $this->pg->prepare($sql); $stmt->execute(['username2']); - $this->assertGreaterThan(10, $stmt->affectedRows(), 'delete data' . $this->pg->error); + $this->assertGreaterThan(10, $stmt->affectedRows(), 'delete data Error ,Error Info : ' . $this->pg->error); } public function dropTable() { $sql = <<<'EOF' -DROP TABLE users ; -DROP SEQUENCE users_id_seq ; +DROP TABLE IF EXISTS users ; +DROP SEQUENCE IF EXISTS users_id_seq ; EOF; - echo $sql; - + echo $sql . PHP_EOL; $this->pg->query($sql); - $this->assertEquals(0, $this->pg->errCode, 'drop table users' . $this->pg->error); + $this->assertEquals(0, $this->pg->errCode, 'drop table users Error ,Error Info : ' . $this->pg->error); } public function dropDatabase() @@ -215,10 +218,8 @@ public function dropDatabase() DROP DATABASE IF EXISTS user_center EOF; - echo $sql; - + echo $sql . PHP_EOL; $this->pg_master->query($sql); - echo PHP_EOL . $this->pg->error . PHP_EOL; - $this->assertEquals(0, $this->pg_master->errCode, 'drop database user_center' . $this->pg_master->error); + $this->assertEquals(0, $this->pg_master->errCode, 'drop database user_center Error ,Error Info : ' . $this->pg_master->error); } } diff --git a/sapi/src/UnitTest/SwoolePGSQLTestV5x.php b/sapi/src/UnitTest/SwoolePGSQLTestV5x.php new file mode 100644 index 0000000000..1b3d3692a6 --- /dev/null +++ b/sapi/src/UnitTest/SwoolePGSQLTestV5x.php @@ -0,0 +1,225 @@ +createDataBase(); + $this->createTable(); + $this->insertTableData(); + $this->selectTableData(); + $this->deleteTableData(); + $this->dropTable(); + $this->pg = null; + $this->dropDatabase(); + $this->pg_master = null; + }); + } + + + public function createDataBase() + { + + $pg = new PostgreSQL(); + $conn = $pg->connect("host=127.0.0.1 port=5432 dbname=postgres user=postgres password=example"); + $this->assertTrue($conn, 'pgsql connection postgres Error ,Error Info : ' . $pg->error); + + $this->pg_master = $pg; + $stmt = $pg->query("SELECT * FROM pg_database WHERE datname = 'user_center'"); + $arr = $stmt->fetchAll(); + if (!empty($arr)) { + $this->dropDatabase(); + } + + + $sql = <<query($sql); + $this->assertEquals(0, $pg->errCode, 'create database user_center Error ,Error Info : ' . $pg->error); + } + + public function createTable() + { + $pg = new PostgreSQL(); + + $conn = $pg->connect("host=127.0.0.1 port=5432 dbname=user_center user=postgres password=example"); + $this->assertTrue($conn, 'connection database user_center Error ,Error Info : ' . $pg->error); + + $this->pg = $pg; + $sql = "select * from pg_tables where schemaname = 'public' and tablename='users'"; + $stmt = $pg->query($sql); + $res = $stmt->fetchAll(); + if (empty($res)) { + # USER 是PGSQL 关键字,不能用作表名 + $table = <<<'EOF' +CREATE TABLE users ( + id bigint NOT NULL , + username varchar(32) NOT NULL , + nickname varchar(40) NOT NULL, + password varchar(255) NOT NULL , + salt varchar(255) NOT NULL, + avatar varchar(255) DEFAULT '' , + email varchar(100) DEFAULT NULL , + mobile varchar(16) DEFAULT NULL , + created_at TIMESTAMPTZ DEFAULT current_timestamp , + updated_at TIMESTAMPTZ DEFAULT NULL , + login_at TIMESTAMPTZ DEFAULT NULL , + status SMALLINT DEFAULT 0 , + login_channel SMALLINT DEFAULT NULL , + PRIMARY KEY (id) +) ; + +CREATE SEQUENCE users_id_seq +START WITH 1 +INCREMENT BY 1 +NO MINVALUE +NO MAXVALUE +CACHE 1; + +alter table users alter column id set default nextval('users_id_seq'); + +EOF; + echo $table . PHP_EOL; + $pg->query($table); + $this->assertEquals(0, $pg->errCode, 'create table users Error ,Error Info : ' . $pg->error); + } + } + + public function insertTableData() + { + $password = 'example'; + $salt = bin2hex(openssl_random_pseudo_bytes(rand(4, 20))); + $password = hash('sha256', $password, false) . $salt; + # ISO8601 + $time = date('c', time()); + $time = date('Y-m-d\TH:i:s.Z\Z', time()); + + $sql = <<pg->prepare($sql); + $i = 30; + while ($i >= 1) { + foreach ($list as $data) { + $res = $stmt->execute($data); + } + $i--; + } + + $this->assertGreaterThanOrEqual(1, $stmt->affectedRows(), 'insert data Error ,Error Info : ' . $this->pg->error); + } + + public function selectTableData() + { + $sql = <<pg->query($sql); + $list = $stmt->fetchAll(); + $this->assertGreaterThan(1, count($list), 'select data Error ,Error Info : ' . $this->pg->error); + } + + public function deleteTableData() + { + $sql = <<<'EOF' +DELETE FROM users +WHERE username=$1 + +EOF; + + echo $sql . PHP_EOL; + + $stmt = $this->pg->prepare($sql); + + $stmt->execute(['username2']); + + $this->assertGreaterThan(10, $stmt->affectedRows(), 'delete data Error ,Error Info : ' . $this->pg->error); + } + + public function dropTable() + { + $sql = <<<'EOF' + +DROP TABLE IF EXISTS users ; +DROP SEQUENCE IF EXISTS users_id_seq ; +EOF; + + echo $sql . PHP_EOL; + $this->pg->query($sql); + $this->assertEquals(0, $this->pg->errCode, 'drop table users Error ,Error Info : ' . $this->pg->error); + } + + public function dropDatabase() + { + $sql = <<<'EOF' + +DROP DATABASE IF EXISTS user_center +EOF; + + echo $sql . PHP_EOL; + $this->pg_master->query($sql); + $this->assertEquals(0, $this->pg_master->errCode, 'drop database user_center Error ,Error Info : ' . $this->pg_master->error); + } +} diff --git a/sapi/src/UnitTest/SwoolePGSQLTestV6.php b/sapi/src/UnitTest/SwoolePGSQLTestV6.php new file mode 100644 index 0000000000..8a4ff28a93 --- /dev/null +++ b/sapi/src/UnitTest/SwoolePGSQLTestV6.php @@ -0,0 +1,202 @@ +createDataBase(); + $this->createTable(); + $this->insertTableData(); + $this->selectTableData(); + $this->deleteTableData(); + $this->dropTable(); + $this->pg = null; + $this->dropDatabase(); + $this->pg_master = null; + }); + Runtime::setHookFlags($oriFlags); + error_reporting($oriErrorLevel); + } + + protected function createDataBase() + { + $dbh = new \PDO("pgsql:dbname=postgres;host=127.0.0.1;port=5432", "postgres", "example"); + $this->assertEquals(NULL, $dbh->errorCode(), 'pgsql connection postgres Error ,Error Info : ' . $dbh->errorInfo()[2]); + + $this->pg_master = $dbh; + $res = $dbh->query("SELECT * FROM pg_database WHERE datname = 'user_center'", \PDO::FETCH_ASSOC); + $arr = $res->fetchAll(); + if (!empty($arr)) { + $this->dropDatabase(); + } + + + $sql = <<exec($sql); + $this->assertEquals(0, $res, 'create database user_center Error ,Error Info : ' . $dbh->errorInfo()[2]); + } + + protected function createTable() + { + $dbh = new \PDO("pgsql:dbname=user_center;host=127.0.0.1;port=5432", "postgres", "example"); + $this->assertEquals(NULL, $dbh->errorCode(), 'connection database user_center Error ,Error Info : ' . $dbh->errorInfo()[2]); + + $this->pg = $dbh; + $sql = "select * from pg_tables where schemaname = 'public' and tablename='users'"; + $stmt = $this->pg->query($sql, \PDO::FETCH_ASSOC); + $res = $stmt->fetchAll(); + if (empty($res)) { + # USER 是PGSQL 关键字,不能用作表名 + $table = <<<'EOF' +CREATE TABLE users ( + id bigint NOT NULL , + username varchar(32) NOT NULL , + nickname varchar(40) NOT NULL, + password varchar(255) NOT NULL , + salt varchar(255) NOT NULL, + avatar varchar(255) DEFAULT '' , + email varchar(100) DEFAULT NULL , + mobile varchar(16) DEFAULT NULL , + created_at TIMESTAMPTZ DEFAULT current_timestamp , + updated_at TIMESTAMPTZ DEFAULT NULL , + login_at TIMESTAMPTZ DEFAULT NULL , + status SMALLINT DEFAULT 0 , + login_channel SMALLINT DEFAULT NULL , + PRIMARY KEY (id) +) ; + +CREATE SEQUENCE users_id_seq +START WITH 1 +INCREMENT BY 1 +NO MINVALUE +NO MAXVALUE +CACHE 1; + +alter table users alter column id set default nextval('users_id_seq'); + +EOF; + echo $table . PHP_EOL; + $res = $this->pg->exec($table); + $this->assertEquals(0, $res, 'create table users Error ,Error Info : ' . $dbh->errorInfo()[2]); + } + } + + protected function insertTableData() + { + $password = 'example'; + $salt = bin2hex(openssl_random_pseudo_bytes(rand(4, 20))); + $password = hash('sha256', $password, false) . $salt; + # ISO8601 + $time = date('c', time()); + $time = date('Y-m-d\TH:i:s.Z\Z', time()); + + $sql = <<pg->prepare($sql); + // :username, :nickname, :password, :salt, :avatar, :email, :mobile, :updated_at, :login_channel + $stmt->bindValue(':username', "username", \PDO::PARAM_STR); + $stmt->bindValue(':nickname', "example", \PDO::PARAM_STR); + $stmt->bindValue(':password', $password, \PDO::PARAM_STR); + $stmt->bindValue(':salt', $salt, \PDO::PARAM_STR); + $stmt->bindValue(':avatar', "https://wenda.swoole.com/dist/skin1/images/logo.png", \PDO::PARAM_STR); + $stmt->bindValue(':email', "example2@qq.com", \PDO::PARAM_STR); + $stmt->bindValue(':mobile', "861888888888", \PDO::PARAM_STR); + $stmt->bindValue(':updated_at', $time, \PDO::PARAM_STR); + $stmt->bindValue(':login_channel', 1, \PDO::PARAM_INT); + $res = $stmt->execute(); + + $this->assertTrue($res, 'insert data Error ,Error Info : ' . $this->pg->errorInfo()[2]); + } + + protected function selectTableData() + { + $sql = <<pg->query($sql); + $list = $stmt->fetchAll(); + $this->assertGreaterThan(0, count($list), 'select data Error ,Error Info : ' . $stmt->errorInfo()[2]); + } + + protected function deleteTableData() + { + $sql = <<<'EOF' +DELETE FROM users +WHERE username=:username + +EOF; + + echo $sql . PHP_EOL; + + $stmt = $this->pg->prepare($sql); + $stmt->bindValue(":username", "username", \PDO::PARAM_STR); + + $stmt->execute(); + + $this->assertGreaterThan(0, $stmt->rowCount(), 'delete data Error ,Error Info : ' . $this->pg->errorInfo()[2]); + } + + protected function dropTable() + { + $sql = <<<'EOF' + +DROP TABLE IF EXISTS users ; +DROP SEQUENCE IF EXISTS users_id_seq ; +EOF; + + echo $sql . PHP_EOL; + $res = $this->pg->exec($sql); + $this->assertEquals(0, $res, 'drop table users Error ,Error Info : ' . $this->pg->errorInfo()[2]); + } + + protected function dropDatabase() + { + $sql = <<<'EOF' + +DROP DATABASE IF EXISTS user_center +EOF; + + echo $sql . PHP_EOL; + $this->pg_master->exec($sql); + $this->assertEquals("00000", $this->pg_master->errorCode(), 'drop database user_center Error ,Error Info : ' . $this->pg_master->errorInfo()[2]); + } +} diff --git a/sapi/src/UnitTest/scripts/database/docker-compose.yaml b/sapi/src/UnitTest/scripts/database/docker-compose.yaml new file mode 100644 index 0000000000..1b0a17061a --- /dev/null +++ b/sapi/src/UnitTest/scripts/database/docker-compose.yaml @@ -0,0 +1,52 @@ +version: "3" +services: + postgresql-server: + image: postgres:16-alpine + # image: postgis/postgis:16-3.4-alpine + hostname: "postgresql" + container_name: "postgresql" + ports: + - "5432:5432" + environment: + - "POSTGRES_PASSWORD=example" + # 容器内数据目录 /var/lib/postgresql/data + # auth_user: postgres + # auth_password: example + healthcheck: + test: [ "CMD-SHELL", "psql -U postgres -d postgres -c 'SELECT 1' || exit 1" ] + interval: 10s + timeout: 3s + retries: 3 + + mysql-server: + image: mysql:8-debian + # image: mariadb:10.6.14-focal + container_name: mysql-server + command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --tls-version='' + environment: + MYSQL_ROOT_PASSWORD: "example" + # MARIADB_USER: root + MARIADB_PASSWORD: "example" + MARIADB_ROOT_PASSWORD: "example" + ports: + - "3306:3306" + # 容器内数据目录 /var/lib/mysql + volumes: + - ./my.cnf:/etc/mysql/conf.d/my.cnf + healthcheck: + test: 'mysql --user=root --password=example --execute "SHOW DATABASES;"' + + redis-server: + image: redis:7-alpine + ports: + - "6379:6379" + # 容器内数据目录 /data + + mongodb-server: + image: mongo:latest + environment: + MONGO_INITDB_ROOT_USERNAME: root + MONGO_INITDB_ROOT_PASSWORD: example + ports: + - "27017:27017" + # 容器内数据目录 /data/db diff --git a/sapi/src/builder/enabled_extensions.php b/sapi/src/builder/enabled_extensions.php new file mode 100644 index 0000000000..4513a44d00 --- /dev/null +++ b/sapi/src/builder/enabled_extensions.php @@ -0,0 +1,48 @@ +withHomePage('https://opencv.org/') diff --git a/sapi/src/builder/library/aom.php b/sapi/src/builder/library/aom.php index 4d5ab90eac..6c4ae97720 100644 --- a/sapi/src/builder/library/aom.php +++ b/sapi/src/builder/library/aom.php @@ -9,20 +9,17 @@ $lib->withHomePage('https://aomedia.googlesource.com/aom') ->withLicense('https://aomedia.googlesource.com/aom/+/refs/heads/main/LICENSE', Library::LICENSE_SPEC) ->withManual('https://aomedia.googlesource.com/aom') - ->withUrl('https://aomedia.googlesource.com/aom') - ->withFile('aom-v3.7.0.tar.gz') - ->withDownloadScript( - 'aom', - <<withManual('https://aomedia.googlesource.com/aom/+/refs/tags/v3.10.0') + ->withUrl('https://aomedia.googlesource.com/aom/+archive/c2fe6bf370f7c14fbaf12884b76244a3cfd7c5fc.tar.gz') + ->withFile('aom-v3.10.0.tar.gz') ->withPrefix($aom_prefix) + ->withUntarArchiveCommand('tar-default') + ->withBuildCached(false) ->withConfigure( <<withUrl('https://dlcdn.apache.org//apr/apr-util-1.6.3.tar.gz') ->withManual('https://apr.apache.org/compiling_unix.html') ->withPrefix($example_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($example_prefix) ->withBuildCached(false) ->withConfigure( <<withPrefix($asterisk_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($asterisk_prefix) ->withBuildCached(false) ->withConfigure( <<addLibrary( - (new Library('bison')) - ->withHomePage('https://www.gnu.org/software/bison/') - ->withUrl('https://ftpmirror.gnu.org/gnu/bison/bison-3.8.tar.gz') - ->withFileHash('md5', 'b9971f4f58690b7737ab7592d5a0a4e0') - ->withLicense('https://www.gnu.org/licenses/gpl-3.0.html', Library::LICENSE_GPL) - ->withConfigure( - " - ./configure --help - ./configure --prefix={$bison_prefix} - " - ) - ->withBinPath($bison_prefix . '/bin/') - ); -}; diff --git a/sapi/src/builder/library/boost.php b/sapi/src/builder/library/boost.php index 1cb0ca211d..5ffea646f0 100644 --- a/sapi/src/builder/library/boost.php +++ b/sapi/src/builder/library/boost.php @@ -24,9 +24,6 @@ ->withManual('https://www.boost.org/doc/libs/1_83_0/more/getting_started/unix-variants.html') ->withPrefix($boost_prefix) - //->withCleanBuildDirectory() - //->withCleanPreInstallDirectory($boost_prefix) - //->withBuildCached(false) ->withBuildScript( <<withUntarArchiveCommand('xz') ->withPrefix($example_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($example_prefix) ->withBuildScript( <<withPrefix($example_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($example_prefix) ->withBuildCached(false) ->withPreInstallCommand( 'debian', diff --git a/sapi/src/builder/library/coreutils.php b/sapi/src/builder/library/coreutils.php index c99f69798d..2182ac91aa 100644 --- a/sapi/src/builder/library/coreutils.php +++ b/sapi/src/builder/library/coreutils.php @@ -20,7 +20,6 @@ ->withFile('coreutils-9.1.tar.gz') ->withHttpProxy(false) ->withPrefix($coreutils_prefix) - ->withCleanBuildDirectory() ->withBuildCached(false) ->withConfigure( <<withHomePage('https://code.videolan.org/videolan/dav1d/') ->withLicense('https://code.videolan.org/videolan/dav1d/-/blob/master/COPYING', Library::LICENSE_BSD) ->withManual('https://code.videolan.org/videolan/dav1d') - ->withFile('dav1d-v1.3.0.tar.gz') - ->withDownloadScript( - 'dav1d', - <<withUrl('https://code.videolan.org/videolan/dav1d/-/archive/1.5.0/dav1d-1.5.0.tar.gz') + ->withFile('dav1d-1.5.0.tar.gz') ->withPrefix($dav1d_prefix) - ->withPreInstallCommand( - 'alpine', - <<withPreInstallCommand( - 'macos', - <<withBuildScript( <<withPkgName('dav1d') ->withBinPath($dav1d_prefix . '/bin/') - //->withDependentLibraries('sdl2') ); }; diff --git a/sapi/src/builder/library/dpdk.php b/sapi/src/builder/library/dpdk.php index e18b804742..16429ba462 100644 --- a/sapi/src/builder/library/dpdk.php +++ b/sapi/src/builder/library/dpdk.php @@ -48,7 +48,6 @@ apt install python3-pyelftools EOF ) - ->withCleanBuildDirectory() ->withBuildCached(false) ->withBuildScript( <<withBuildCached(false) ->withPrefix($example_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($example_prefix) ->withPreInstallCommand( 'debian', <<withUntarArchiveCommand('xz') ->withPrefix($example_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($example_prefix) ->withBuildScript( <<withPrefix($freeswitch_prefix) ->withBuildCached(false) - ->withCleanBuildDirectory() ->withPreInstallCommand( 'alpine', <<withCleanBuildDirectory() ->withBuildScript( <<withBuildCached(false) ->withPrefix($freetdm_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($freetdm_prefix) ->withBuildScript( <<withManual('https://frrouting.org/doc/') ->withBuildCached(false) ->withPrefix($example_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($example_prefix) ->withConfigure( <<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://ftp.gnu.org/gnu/gettext/gettext-0.22.5.tar.gz') + ->withUrl('https://ftpmirror.gnu.org/gettext/gettext-0.22.5.tar.gz') + ->withFileHash('sha256', "ec1705b1e969b83a9f073144ec806151db88127f5e40fe5a94cb6c8fa48996a0") ->withPrefix($gettext_prefix) + //->withInstallCached(false) ->withConfigure( <<withBinPath($gettext_prefix . '/bin/') //因为只需要libintl ,其它不启用 - ->withDependentLibraries('libunistring', 'libiconv', 'ncurses', 'libxml2') + ->withDependentLibraries('libunistring', 'libiconv', 'ncurses', 'libxml2', 'zlib') ); + + $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/glfw.php b/sapi/src/builder/library/glfw.php index 64d2be6814..401eb65702 100644 --- a/sapi/src/builder/library/glfw.php +++ b/sapi/src/builder/library/glfw.php @@ -20,8 +20,6 @@ EOF ) ->withPrefix($glfw_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($glfw_prefix) ->withBuildScript( <<withFile('gnulib-latest.tar.gz') - ->withCleanBuildDirectory() ->withBuildScript( <<withManual('https://gitlab.com/gnutls/gnutls.git') ->withManual('https://www.gnutls.org/download.html') ->withPrefix($gnutls_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($gnutls_prefix) ->withConfigure( <<withCleanBuildDirectory() - - // 自动清理安装目录 - ->withCleanPreInstallDirectory($example_prefix) - //明确申明 不使用构建缓存 例子: thirdparty/openssl (每次都解压全新源代码到此目录) ->withBuildCached(false) diff --git a/sapi/src/builder/library/gupnp_igd.php b/sapi/src/builder/library/gupnp_igd.php index 74feb56cb7..f40a4824f6 100644 --- a/sapi/src/builder/library/gupnp_igd.php +++ b/sapi/src/builder/library/gupnp_igd.php @@ -13,7 +13,6 @@ ->withUntarArchiveCommand('xz') ->withPrefix($GUPnP_prefix) ->withBuildCached(false) - ->withCleanBuildDirectory() ->withBuildScript( <<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/libarchive.php b/sapi/src/builder/library/libarchive.php index 8883d45b80..42750baef2 100644 --- a/sapi/src/builder/library/libarchive.php +++ b/sapi/src/builder/library/libarchive.php @@ -44,8 +44,6 @@ EOF ) ->withPrefix($libarchive_prefix) - //->withBuildCached(false) - ->withCleanPreInstallDirectory($libarchive_prefix) /* ->withConfigure( <<addLibrary( (new Library('libavif')) ->withHomePage('https://aomediacodec.github.io/av1-avif/') ->withLicense('https://github.com/AOMediaCodec/libavif/', Library::LICENSE_BSD) ->withManual('https://github.com/AOMediaCodec/libavif/ext/') - ->withUrl('https://github.com/AOMediaCodec/libavif/archive/refs/tags/v1.0.1.tar.gz') - ->withFile('libavif-v1.0.1.tar.gz') + ->withUrl('https://github.com/AOMediaCodec/libavif/archive/refs/tags/v1.1.1.tar.gz') + ->withFile('libavif-v1.1.1.tar.gz') ->withPrefix($libavif_prefix) ->withConfigure( <<withHomePage('https://github.com/BLAKE2/libb2.git') ->withLicense('https://github.com/BLAKE2/libb2#CC0-1.0-1-ov-file', Library::LICENSE_SPEC) ->withManual('https://github.com/BLAKE2/libb2.git') + ->withUrl('https://github.com/BLAKE2/libb2/archive/refs/tags/v0.98.1.tar.gz') ->withFile('libb2-v0.98.1.tar.gz') - ->withDownloadScript( - 'libb2', - <<withPrefix($libb2_prefix) ->withConfigure( <<withCleanPreInstallDirectory($libbpf_prefix) - //->withBuildCached(false) ->withBuildScript( <<withPrefix($libbson_prefix) ->withAutoUpdateFile() ->withBuildCached(false) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($libbson_prefix) ->withConfigure( <<withAutoUpdateFile() ->withBuildCached(false) - //->withCleanPreInstallDirectory($libelf_prefix) ->withBuildScript( <<withUrl('http://dist.schmorp.de/libev/libev-4.33.tar.gz') ->withManual('http://cvs.schmorp.de/libev/README') ->withPrefix($libev_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($libev_prefix) ->withConfigure( <<withFile('fribidi-v1.0.12.tar.gz') ->withLabel('library') ->withPrefix($libfribidi_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($libfribidi_prefix) ->withBuildScript( <<withBuildCached(false) ->withPrefix($libfvad_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($libfvad_prefix) ->withConfigure( <<withFile('libgav1-latest.tar.gz') ->withManual('https://chromium.googlesource.com/codecs/libgav1/+/refs/heads/main') - ->withDownloadScript( - 'libgav1', - <<withUrl('https://chromium.googlesource.com/codecs/libgav1/+archive/e386d8f1fb983200972d159b9be47fd5d0776708.tar.gz') + ->withFile('libgav1-v0.19.0.tar.gz') ->withPrefix($libgav1_prefix) + ->withUntarArchiveCommand('tar-default') + ->withBuildCached(false) ->withConfigure( <<withPrefix($libgomp_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($libgomp_prefix) ->withBuildCached(false) ->withBuildScript( <<withUrl('https://ftpmirror.gnu.org/gnu/libiconv/libiconv-1.17.tar.gz') ->withMirrorUrl('https://mirrors.tuna.tsinghua.edu.cn/gnu/libiconv/libiconv-1.17.tar.gz') ->withMirrorUrl('https://mirrors.ustc.edu.cn/gnu/libiconv/libiconv-1.17.tar.gz') - ->withFileHash('md5', 'd718cd5a59438be666d1575855be72c3') ->withPrefix($libiconv_prefix) - ->withConfigure('./configure --prefix=' . $libiconv_prefix . ' enable_static=yes enable_shared=no') + ->withConfigure( + <<withBinPath($libiconv_prefix . '/bin/') ->withScriptAfterInstall( <<addLibrary( - (new Library('libintl')) - ->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) - ->withConfigure( - <<withDependentLibraries('libunistring', 'libiconv', 'ncurses', 'libxml2') - ); - - $p->withVariable('CPPFLAGS', '$CPPFLAGS -I' . $libintl_prefix . '/include'); - $p->withVariable('LDFLAGS', '$LDFLAGS -L' . $libintl_prefix . '/lib'); - $p->withVariable('LIBS', '$LIBS -lintl '); -}; diff --git a/sapi/src/builder/library/libjxl.php b/sapi/src/builder/library/libjxl.php index 729b2cc12e..990f332b83 100644 --- a/sapi/src/builder/library/libjxl.php +++ b/sapi/src/builder/library/libjxl.php @@ -12,8 +12,6 @@ ->withManual('https://github.com/libjxl/libjxl/blob/main/BUILDING.md') ->withFile('libjpegxl-v0.8.1.tar.gz') ->withPrefix($libjxl_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($libjxl_prefix) ->withBuildScript( <<withPrefix($libks_prefix) ->withBuildCached(false) - ->withCleanBuildDirectory() ->withPreInstallCommand( 'debian', <<withPkgName('liblzma') - ->withBinPath($liblzma_prefix . '/bin/') + //->withBinPath($liblzma_prefix . '/bin/') ->withDependentLibraries('libiconv') ); }; diff --git a/sapi/src/builder/library/libmemcached.php b/sapi/src/builder/library/libmemcached.php new file mode 100644 index 0000000000..59c73d9394 --- /dev/null +++ b/sapi/src/builder/library/libmemcached.php @@ -0,0 +1,39 @@ +withHomePage('libmemcached.org/libMemcached.html') + ->withLicense('https://libmemcached.org/License.html', Library::LICENSE_BSD) + ->withManual('http://docs.libmemcached.org/') + ->withUrl('https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz') + ->withPrefix($libmemcached_prefix) + ->withConfigure( + <<addLibrary($lib); + + +}; diff --git a/sapi/src/builder/library/libmemcached_awesome.php b/sapi/src/builder/library/libmemcached_awesome.php new file mode 100644 index 0000000000..15e8b56de5 --- /dev/null +++ b/sapi/src/builder/library/libmemcached_awesome.php @@ -0,0 +1,51 @@ +withHomePage('https://github.com/awesomized/libmemcached') + ->withLicense('https://github.com/awesomized/libmemcached/blob/v1.x/LICENSE', Library::LICENSE_BSD) + ->withManual('https://awesomized.github.io/libmemcached/') + ->withUrl('https://github.com/awesomized/libmemcached/archive/refs/tags/1.1.4.tar.gz') + ->withFile('libmemcached-awesome-1.1.4.tar.gz') + ->withPrefix($libmemcached_awesome_prefix) + ->withBuildScript( + <<withScriptAfterInstall( + <<withPkgName('libmemcached'); + + $p->addLibrary($lib); + + $libs = $p->isMacos() ? '-lc++' : ' -lstdc++ '; + $p->withVariable('LIBS', '$LIBS ' . $libs); +}; diff --git a/sapi/src/builder/library/libmlx5.php b/sapi/src/builder/library/libmlx5.php index 03678b9f73..7a8689c2af 100644 --- a/sapi/src/builder/library/libmlx5.php +++ b/sapi/src/builder/library/libmlx5.php @@ -19,11 +19,6 @@ EOF ) ->withPrefix($libmlx5_prefix) - /* - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($libmlx5_prefix) - ->withBuildCached(false) - */ ->withPreInstallCommand( 'alpine', <<withHomePage('https://www.bytereef.org/mpdecimal/') ->withLicense('https://www.bytereef.org/mpdecimal/download.html', Library::LICENSE_BSD) ->withManual('https://www.bytereef.org/mpdecimal/quickstart.html') ->withUrl('https://www.bytereef.org/software/mpdecimal/releases/mpdecimal-4.0.0.tar.gz') - ->withPrefix($mpdecimal_prefix) + ->withFileHash('sha256', '942445c3245b22730fd41a67a7c5c231d11cb1b9936b9c0f76334fb7d0b4468c') + ->withPrefix($libmpdecimal_prefix) + ->withBuildCached(false) ->withConfigure( <<withPkgName('libmpdec'); + ->withPkgName('libmpdec') + ->withPkgName('libmpdec++'); $p->addLibrary($lib); }; diff --git a/sapi/src/builder/library/libpam.php b/sapi/src/builder/library/libpam.php index 12051fa1cf..e59c446897 100644 --- a/sapi/src/builder/library/libpam.php +++ b/sapi/src/builder/library/libpam.php @@ -33,13 +33,6 @@ // 当--with-build_type=dev 时 如下2个配置才生效 - // 自动清理构建目录 - ->withCleanBuildDirectory() - - // 自动清理安装目录 - ->withCleanPreInstallDirectory($libpam_prefix) - - //明确申明 不使用构建缓存 例子: thirdparty/openssl (每次都解压全新源代码到此目录) ->withBuildCached(false) diff --git a/sapi/src/builder/library/libpsl.php b/sapi/src/builder/library/libpsl.php index 5bbe9af30a..63f14be286 100644 --- a/sapi/src/builder/library/libpsl.php +++ b/sapi/src/builder/library/libpsl.php @@ -21,7 +21,6 @@ ) ->withPrefix($libpsl_prefix) ->withBuildCached(false) - ->withCleanBuildDirectory() ->withBuildScript( <<withPrefix($librime_prefix) - - ->withCleanBuildDirectory() - // 自动清理安装目录 用于调试 - ->withCleanPreInstallDirectory($librime_prefix) - //明确申明 不使用构建缓存 用于调试 ->withBuildCached(false) /** 使用 cmake 构建 start **/ diff --git a/sapi/src/builder/library/libsasl.php b/sapi/src/builder/library/libsasl.php index 9476df39c3..d23f323ad3 100644 --- a/sapi/src/builder/library/libsasl.php +++ b/sapi/src/builder/library/libsasl.php @@ -21,7 +21,7 @@ ./configure \ --prefix={$libsasl_prefix} \ --enable-static=yes \ - --enable-shared=no \ + --enable-shared=no EOF ) diff --git a/sapi/src/builder/library/libseccomp.php b/sapi/src/builder/library/libseccomp.php index e951133ee5..07c92ba7cf 100644 --- a/sapi/src/builder/library/libseccomp.php +++ b/sapi/src/builder/library/libseccomp.php @@ -21,8 +21,6 @@ ) ->withPrefix($example_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($example_prefix) ->withBuildCached(false) ->withConfigure( <<withUntarArchiveCommand('xz') ->withPrefix($example_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($example_prefix) ->withBuildScript( <<withManual('http://www.net-snmp.org/docs/INSTALL.html') ->withBuildCached(false) ->withPrefix($libsnmp_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($libsnmp_prefix) ->withConfigure( <<withPrefix($libsoup_prefix) ->withBuildCached(false) - ->withCleanBuildDirectory() + ->withBuildScript( <<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) - ->withConfigure( - <<withPkgName('uuid') - ->withBinPath($libuuid_prefix . '/bin/:' . $libuuid_prefix . '/sbin/'); - - $p->addLibrary($lib); -}; diff --git a/sapi/src/builder/library/libuv.php b/sapi/src/builder/library/libuv.php index da435064f9..6956d2ed35 100644 --- a/sapi/src/builder/library/libuv.php +++ b/sapi/src/builder/library/libuv.php @@ -19,8 +19,6 @@ EOF ) ->withPrefix($libuv_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($libuv_prefix) ->withConfigure( <<withPrefix($libx11_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($libx11_prefix) ->withBuildCached(false) ->withConfigure( diff --git a/sapi/src/builder/library/libxdp.php b/sapi/src/builder/library/libxdp.php index 24da5de91c..d3ebc1bef3 100644 --- a/sapi/src/builder/library/libxdp.php +++ b/sapi/src/builder/library/libxdp.php @@ -22,8 +22,6 @@ EOF ) ->withPrefix($libxdp_prefix) - ->withBuildCached(false) - ->withCleanPreInstallDirectory($libxdp_prefix) ->withPreInstallCommand( 'alpine', <<withHomePage('https://gitlab.gnome.org/GNOME/libxml2/') ->withManual('https://gitlab.gnome.org/GNOME/libxml2/-/wikis') + ->withFile('libxml2-v2.9.14.tar.gz') ->withLicense('https://www.opensource.org/licenses/mit-license.html', Library::LICENSE_MIT) - ->withUrl('https://gitlab.gnome.org/GNOME/libxml2/-/archive/v2.9.10/libxml2-v2.9.10.tar.gz') - ->withFileHash('md5', 'b18faee9173c3378c910f6d7d1493115') + ->withUrl('https://github.com/GNOME/libxml2/archive/refs/tags/v2.9.14.tar.gz') + ->withFileHash('md5', '801d9101ff91e258c02c74d2166323c3') ->withPrefix($libxml2_prefix) ->withConfigure( <<withHomePage('https://gitlab.gnome.org/GNOME/libxslt/-/wikis/home') ->withManual('https://gitlab.gnome.org/GNOME/libxslt/-/wikis/home') ->withLicense('http://www.opensource.org/licenses/mit-license.html', Library::LICENSE_MIT) - ->withUrl('https://gitlab.gnome.org/GNOME/libxslt/-/archive/v1.1.34/libxslt-v1.1.34.tar.gz') - ->withFileHash('md5', '0b89ee955fd13326d40e762242da7f84') + ->withUrl('https://github.com/GNOME/libxslt/archive/refs/tags/v1.1.34.tar.gz') + ->withFile('libxslt-v1.1.34.tar.gz') + ->withFileHash('md5', 'a96b227436c0f394a59509fc7bfefcb4') ->withPrefix($libxslt_prefix) ->withConfigure( <<withHomePage('https://chromium.googlesource.com/libyuv/libyuv') ->withLicense('https://chromium.googlesource.com/libyuv/libyuv/+/refs/heads/main/LICENSE', Library::LICENSE_SPEC) ->withManual('https://chromium.googlesource.com/libyuv/libyuv') - ->withFile('libyuv-latest.tar.gz') - //->withAutoUpdateFile() - ->withDownloadScript( - 'libyuv', - <<withDownloadScript( - 'libyuv', - <<withUrl('https://chromium.googlesource.com/libyuv/libyuv/+archive/refs/heads/main.tar.gz') + //->withFile('libyuv-main.tar.gz') + ->withUrl('https://chromium.googlesource.com/libyuv/libyuv/+archive/b0f72309c6c0b952d0198be5a5b5106f089fe1c5.tar.gz') + ->withFile('libyuv-b0f72309c6c0b952d0198be5a5b5106f089fe1c5.tar.gz') ->withPrefix($libyuv_prefix) - //->withAutoUpdateFile() + ->withUntarArchiveCommand('tar-default') ->withBuildCached(false) - //->withInstallCached(false) - ->withBuildScript( - <<withBuildScript( <<withScriptAfterInstall( @@ -76,9 +51,10 @@ EOF ) ->withBinPath($libyuv_prefix . '/bin/') - ->withDependentLibraries('libjpeg') - - ; + ->withDependentLibraries('libjpeg'); $p->addLibrary($lib); + $p->withVariable('CPPFLAGS', '$CPPFLAGS -I' . $libyuv_prefix . '/include'); + $p->withVariable('LDFLAGS', '$LDFLAGS -L' . $libyuv_prefix . '/lib'); + $p->withVariable('LIBS', '$LIBS -lyuv'); }; diff --git a/sapi/src/builder/library/libzookeeper.php b/sapi/src/builder/library/libzookeeper.php index 638a5c5b4b..2cc8a9e69e 100644 --- a/sapi/src/builder/library/libzookeeper.php +++ b/sapi/src/builder/library/libzookeeper.php @@ -27,11 +27,6 @@ ->withBuildCached(false) ->withBuildLibraryHttpProxy() ->withPrefix($libzookeeper_prefix) - // 自动清理构建目录 - ->withCleanBuildDirectory() - - // 自动清理安装目录 - ->withCleanPreInstallDirectory($libzookeeper_prefix) ->withConfigure( <<withBuildCached(false) ->withPrefix($example_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($example_prefix) - ->withBuildScript( <<withPrefix($nginx_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($nginx_prefix) ->withConfigure( <<withFile('numa-v2.0.16.tar.gz') ->withManual('https://github.com/numactl/numactl/blob/master/INSTALL.md') ->withPrefix($numa_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($numa_prefix) ->withConfigure( <<withPrefix($iddawc_prefix) - // 自动清理安装目录 - ->withCleanPreInstallDirectory($iddawc_prefix) //明确申明 不使用构建缓存 例子: thirdparty/openssl (每次都解压全新源代码到此目录) ->withBuildCached(false) diff --git a/sapi/src/builder/library/opencl.php b/sapi/src/builder/library/opencl.php index b6e03cfc3e..41f93eeed7 100644 --- a/sapi/src/builder/library/opencl.php +++ b/sapi/src/builder/library/opencl.php @@ -19,7 +19,6 @@ EOF ) ->withPrefix($opencl_prefix) - ->withCleanPreInstallDirectory($opencl_prefix) //->withAutoUpdateFile() //->withBuildCached(false) ->withBuildLibraryHttpProxy() diff --git a/sapi/src/builder/library/opencv.php b/sapi/src/builder/library/opencv.php index 58b9e038ca..6c27b39987 100644 --- a/sapi/src/builder/library/opencv.php +++ b/sapi/src/builder/library/opencv.php @@ -111,8 +111,6 @@ EOF ) ->withPrefix($opencv_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($opencv_prefix) ->withBuildLibraryHttpProxy(true) ->withBuildCached(false) ->withBuildScript( diff --git a/sapi/src/builder/library/opengl.php b/sapi/src/builder/library/opengl.php index dd5a5c79aa..44640f7feb 100644 --- a/sapi/src/builder/library/opengl.php +++ b/sapi/src/builder/library/opengl.php @@ -15,8 +15,6 @@ EOF ) ->withPrefix($opengl_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($opengl_prefix) ->withBuildScript( <<withPrefix($example_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($example_prefix) - ->withConfigure( <<withUrl('https://www.openssl.org/source/openssl-1.1.1t.tar.gz') ->withLicense('https://github.com/openssl/openssl/blob/master/LICENSE.txt', Library::LICENSE_APACHE2) ->withPrefix($openssl_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($openssl_prefix) ->withConfigure( <<withManual('https://github.com/KhronosGroup/OpenXR-SDK.git') ->withBuildCached(false) ->withPrefix($OpenXR_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($OpenXR_prefix) ->withBuildScript( <<withUrl('ftp://ftp.ossp.org/pkg/lib/uuid/uuid-1.6.1.tar.gz') ->withHttpProxy(false) ->withPrefix($ossp_uuid_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($ossp_uuid_prefix) ->withBuildCached(false) ->withConfigure( <<withFile('pcre-8.45.tar.gz') ->withPrefix($pcre_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($pcre_prefix) ->withConfigure( <<withCleanBuildDirectory() - ->withCleanPreInstallDirectory($pgsql_prefix) - ->withBuildCached(false) - */ ->withBuildScript( <<withCleanBuildDirectory() - ->withCleanPreInstallDirectory($pgsql_prefix) + ->withBuildCached(false) */ ->withBuildCached(false) diff --git a/sapi/src/builder/library/php.php b/sapi/src/builder/library/php.php index 857aae8532..02dda507cb 100644 --- a/sapi/src/builder/library/php.php +++ b/sapi/src/builder/library/php.php @@ -5,29 +5,31 @@ return function (Preprocessor $p) { $php_install_prefix = BUILD_PHP_INSTALL_PREFIX; + $php_tag = BUILD_PHP_VERSION; $php_src = $p->getPhpSrcDir(); $build_dir = $p->getBuildDir(); $p->addLibrary( (new Library('php')) - ->withUrl('https://github.com/php/php-src/archive/refs/tags/php-' . BUILD_PHP_VERSION . '.tar.gz') + ->withUrl('https://github.com/php/php-src/archive/refs/tags/php-' . $php_tag . '.tar.gz') ->withHomePage('https://www.php.net/') ->withLicense('https://github.com/php/php-src/blob/master/LICENSE', Library::LICENSE_PHP) ->withPrefix($php_install_prefix) - ->withCleanBuildDirectory() + ->withBuildCached(false) + ->withInstallCached(false) ->withBuildScript( << {$php_src}/X-PHP-VERSION + rm -rf php cd {$build_dir}/ EOF ) ->withLdflags('') ->withPkgConfig('') - ->withBuildCached(false) ); }; diff --git a/sapi/src/builder/library/pjproject.php b/sapi/src/builder/library/pjproject.php index 5c327d8834..841b7c0846 100644 --- a/sapi/src/builder/library/pjproject.php +++ b/sapi/src/builder/library/pjproject.php @@ -24,8 +24,6 @@ EOF ) ->withPrefix($pjproject_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($pjproject_prefix) ->withBuildCached(false) ->withBuildScript( <<withCleanBuildDirectory() - - // 自动清理安装目录 - ->withCleanPreInstallDirectory($example_prefix) - - //明确申明 不使用构建缓存 //例子: thirdparty/openssl (每次都解压全新源代码到此目录) ->withBuildCached(false) diff --git a/sapi/src/builder/library/postgis.php b/sapi/src/builder/library/postgis.php index 3aecf90489..7459208ccb 100644 --- a/sapi/src/builder/library/postgis.php +++ b/sapi/src/builder/library/postgis.php @@ -18,8 +18,6 @@ ) ->withBuildCached(false) ->withPrefix($example_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($example_prefix) ->withBuildScript( <<isMacos() ? '' : ' -static '; + $static_flag = $p->isMacos() ? '' : ' -static '; $libs = $p->isMacos() ? '-lc++' : ' -lstdc++ '; $lib = new Library('python3'); $lib->withHomePage('https://www.python.org/') ->withLicense('https://docs.python.org/3/license.html', Library::LICENSE_LGPL) ->withManual('https://www.python.org') + ->withManual('https://github.com/python/cpython.git') ->withUrl('https://www.python.org/ftp/python/3.12.2/Python-3.12.2.tgz') + //->withUrl('https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz') + //->withUrl('https://github.com/python/cpython/archive/refs/tags/v3.13.0.tar.gz') ->withPrefix($python3_prefix) ->withBuildCached(false) - //->withInstallCached(false) + ->withInstallCached(true) ->withBuildScript( <<> Modules/Setup.local + # sed -i.backup 's/^_ctypes _ctypes\/_ctypes\.c/# \1/' Modules/Setup.stdlib + # sed -i.backup 's/^_scproxy _scproxy\.c/# \1/' Modules/Setup.stdlib - sed -i.bak "s/^\*shared\*/\*static\*/g" Modules/Setup.stdlib - cat Modules/Setup.stdlib > Modules/Setup.local + # sed -i.backup 's/^xxlimited xxlimited\.c/# \1/' Modules/Setup.stdlib + # sed -i.backup 's/^xxlimited_35 xxlimited_35\.c/# \1/' Modules/Setup.stdlib - # make -j {$p->getMaxJob()} LDFLAGS="\$LDFLAGS " LINKFORSHARED=" " + cp -f Modules/Setup.stdlib Modules/Setup.local + + CFLAGS="\$CFLAGS " \ + CPPFLAGS="\$CPPFLAGS " \ + LDFLAGS="\$LDFLAGS " \ + LIBS="\$LIBS " \ + CFLAGSFORSHARED="" CCSHARED="" LDSHARED="" LDCXXSHARED="" LINKFORSHARED="" \ + MODULE_BUILDTYPE=static \ make -j {$p->getMaxJob()} make install + mkdir -p {$python3_prefix}/_hacl/include/ + cp -f Modules/_hacl/libHacl_Hash_SHA2.a {$python3_prefix}/lib/ + cp -f Modules/_hacl/*.h {$python3_prefix}/_hacl/include/ + {$python3_prefix}/bin/python3 -E -c 'import sys ; from sysconfig import get_platform ; print("%s-%d.%d" % (get_platform(), *sys.version_info[:2])) ; ' {$python3_prefix}/bin/python3 -E -c 'import sys ; print(sys.modules) ; ' {$python3_prefix}/bin/python3 -E -c 'import sys ; print(dir(sys)) ; ' @@ -128,64 +129,58 @@ {$python3_prefix}/bin/python3-config --ldflags {$python3_prefix}/bin/python3-config --libs + PYTHONPATH=$({$python3_prefix}/bin/python3 -c "import site, os; print(os.path.join(site.USER_BASE, 'lib', 'python', 'site-packages'))") + echo \${PYTHONPATH} - mkdir -p {$python3_prefix}/python_hacl - cp -rf {$p->getBuildDir()}/python3/Modules/_hacl/* {$python3_prefix}/python_hacl/ - - - unset CFLAGS - unset CPPFLAGS - unset LDFLAGS - unset LIBS - unset LINKFORSHARED - - unset CCSHARED - unset LDSHARED - unset LDCXXSHARED - - unset LIBLZMA_CFLAGS - unset LIBLZMA_LIBS - - unset CURSES_CFLAGS - unset CURSES_LIBS - - unset PANEL_CFLAGS - unset PANEL_LIBS - - unset LIBMPDEC_CFLAGS - unset LIBMPDEC_LDFLAGS - - unset LIBEXPAT_CFLAGS - unset LIBEXPAT_LDFLAGS - - unset OPENSSL_LDFLAGS - unset OPENSSL_LIBS - unset OPENSSL_INCLUDES - - unset LIBB2_CFLAGS - unset LIBB2_LIBS - + # PYTHONPATH={$p->getGlobalPrefix()}/bin/python3/bin/ + # PYTHONHOME=/custom/output EOF ) + ->withScriptAfterInstall( + <<withPkgName('python3-embed') //->withPkgName('python3') - //->withPkgName('python3-embed') - //->withBinPath($python3_prefix . '/bin/') - //依赖其它静态链接库 - ->withDependentLibraries('zlib', 'openssl', 'sqlite3', 'bzip2', 'liblzma', 'readline', 'ncurses', 'libuuid', 'libintl', 'libexpat', 'mpdecimal', 'libb2'); + ->withDependentLibraries( + 'libmpdecimal', + 'libb2', + 'readline', + 'ncurses', + 'libexpat', + 'zlib', + 'openssl', + 'sqlite3', + 'bzip2', + 'liblzma', + 'util_linux', + 'gettext' + ); $p->addLibrary($lib); - $p->withVariable('CPPFLAGS', '$CPPFLAGS -I' . $python3_prefix . '/python_hacl/'); - $p->withVariable('CPPFLAGS', '$CPPFLAGS -I' . $python3_prefix . '/python_hacl/include/'); - # $p->withVariable('LDFLAGS', '$LDFLAGS -l:' . $python3_prefix . '/python_hacl/libHacl_Hash_SHA2.a'); - $p->withVariable('LDFLAGS', '$LDFLAGS -L' . $python3_prefix . '/python_hacl/'); - $p->withVariable('LIBS', '$LIBS -lHacl_Hash_SHA2'); + if ($p->isMacos()) { + //$p->withVariable('LDFLAGS', '$LDFLAGS -framework CoreFoundation '); + //module _scproxy needs SystemConfiguration and CoreFoundation framework + //$p->withVariable('LDFLAGS', '$LDFLAGS -framework SystemConfiguration -framework CoreFoundation '); + } + //libHacl_Hash_SHA2.a + $p->withVariable('LIBS', '$LIBS -lHacl_Hash_SHA2'); + $p->withVariable('CPPFLAGS', "\$CPPFLAGS -I{$python3_prefix}/_hacl/include/"); }; # 构建独立版本 python 参考 # https://github.com/indygreg/python-build-standalone.git +# 参考文档: https://wiki.python.org/moin/BuildStatically +# https://knazarov.com/posts/statically_linked_python_interpreter/ + # 配置参考 https://docs.python.org/zh-cn/3.12/using/configure.html -# 参考文档: https://wiki.python.org/moin/BuildStatically + +# https://github.com/python/cpython diff --git a/sapi/src/builder/library/rav1e.php b/sapi/src/builder/library/rav1e.php index 56221159fe..2f3119ce7a 100644 --- a/sapi/src/builder/library/rav1e.php +++ b/sapi/src/builder/library/rav1e.php @@ -14,8 +14,6 @@ ->withFile('rav1e-v0.6.6.tar.gz') ->withPrefix($rav1e_prefix) ->withBuildCached(false) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($rav1e_prefix) ->withBuildScript( <<withHomePage('http://www.dest-unreach.org/socat/') ->withLicense('http://www.dest-unreach.org/socat/doc/README', Library::LICENSE_GPL) //->withUrl('http://www.dest-unreach.org/socat/download/socat-1.7.4.4.tar.gz') - ->withFile('socat-1.8.0.0.tar.gz') + ->withFile('socat-1.8.0.1.tar.gz') ->withDownloadScript( 'socat', <<withBuildCached(false) diff --git a/sapi/src/builder/library/spirv_tools.php b/sapi/src/builder/library/spirv_tools.php index ae49cedf7a..abfebf1b1d 100644 --- a/sapi/src/builder/library/spirv_tools.php +++ b/sapi/src/builder/library/spirv_tools.php @@ -20,8 +20,6 @@ EOF ) ->withPrefix($openssl_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($openssl_prefix) ->withBuildCached(false) ->withBuildScript( <<withDownloadScript( - 'SVT-AV1', - <<withFile('SVT-AV1-v1.7.0.tar.gz') ->withManual('https://gitlab.com/AOMediaCodec/SVT-AV1.git') ->withManual('https://gitlab.com/AOMediaCodec/SVT-AV1/-/blob/master/Docs/Build-Guide.md') + ->withUrl('https://gitlab.com/AOMediaCodec/SVT-AV1/-/archive/v2.2.1/SVT-AV1-v2.2.1.tar.gz') + ->withFile('SVT-AV1-v2.2.1.tar.gz') ->withPrefix($svt_av1_prefix) - ->withPreInstallCommand( - 'alpine', - <<withPreInstallCommand( - 'macos', - <<withBuildScript( <<getMaxJob()} - make install + cmake --build . --config Release + + cmake --build . --config Release --target install EOF ) ->withPkgName('SvtAv1Enc') - ->withPkgName('SvtAv1Dec') ->withBinPath($svt_av1_prefix . '/bin/'); $p->addLibrary($lib); diff --git a/sapi/src/builder/library/sysrepo.php b/sapi/src/builder/library/sysrepo.php index 162365627b..6ca8757563 100644 --- a/sapi/src/builder/library/sysrepo.php +++ b/sapi/src/builder/library/sysrepo.php @@ -17,8 +17,6 @@ ->withManual('https://github.com/sysrepo/sysrepo.git') ->withBuildCached(false) ->withPrefix($example_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($example_prefix) ->withBuildScript( <<withFile('tcmalloc.zip') ->withPrefix($tcmalloc_preifx) ->withUntarArchiveCommand('unzip') - ->withCleanBuildDirectory() + ->withConfigure( <<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') - ->withFile('util-linux-v2.39.1.tar.gz') + //->withUrl('https://github.com/util-linux/util-linux/archive/refs/tags/v2.39.3.tar.gz') + ->withFile('util-linux-v2.39.3.tar.gz') //->withAutoUpdateFile() ->withHttpProxy(true, true) ->withDownloadScript( @@ -26,51 +32,47 @@ # git config --global core.gitproxy "{$p->getRootDir()}/bin/runtime/git-proxy" - git clone -b v2.39.2 --depth=1 git://git.kernel.org/pub/scm/utils/util-linux/util-linux.git + git clone -b v2.39.3 --depth=1 git://git.kernel.org/pub/scm/utils/util-linux/util-linux.git # git config --global core.gitproxy "" EOF ) ->withPrefix($util_linux_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($util_linux_prefix) - //->withBuildCached(false) - ->withBuildLibraryHttpProxy(true, true) ->withConfigure( <<withBinPath(GETTEXT_PREFIX . '/bin/') - ->withDependentLibraries('gettext') - ->withSkipBuildLicense(); + ->withPkgName('uuid') + ->withBinPath([$util_linux_prefix . '/bin', $util_linux_prefix . '/sbin',]) + ->withDependentLibraries('libiconv', 'gettext'); $p->addLibrary($lib); -}; - -/* - - -export GIT_PROXY_COMMAND=/tmp/git-proxy; - -cat > \$GIT_PROXY_COMMAND <<___eof___ -#!/bin/bash -# socat - PROXY:{$http_proxy_host}:\$1:\$2,proxyport={$http_proxy_port} -nc -X connect -x {$http_proxy_host}:{$http_proxy_port} "\\$1" "\\$2" -___eof___ - -chmod +x \$GIT_PROXY_COMMAND; +}; - */ diff --git a/sapi/src/builder/library/vlc.php b/sapi/src/builder/library/vlc.php index 938c3c6339..fe24473462 100644 --- a/sapi/src/builder/library/vlc.php +++ b/sapi/src/builder/library/vlc.php @@ -24,7 +24,6 @@ ->withBuildCached(false) //->withUntarArchiveCommand('xz') ->withPrefix($vlc_prefix) - ->withCleanPreInstallDirectory($vlc_prefix) ->withPreInstallCommand( 'alpine', <<withPrefix($example_prefix) - ->withCleanBuildDirectory() - ->withCleanPreInstallDirectory($example_prefix) ->withBuildCached(false) ->withBuildScript( <<withPrefix($example_prefix) - ->withCleanBuildDirectory() //build_type=dev 才生效 自动清理构建目录 用于调试 - ->withCleanPreInstallDirectory($example_prefix) //build_type=dev 才生效 自动清理安装目录 用于调试 ->withBuildCached(false) //明确申明 不使用构建缓存 ->withBuildLibraryHttpProxy() //构建过程中添加代理 (特殊库才需要,比如构建 rav1e 库,构建过程中会自动到代码仓库下载) diff --git a/sapi/src/builder/library_shared/chromium.php b/sapi/src/builder/library_shared/chromium.php new file mode 100644 index 0000000000..1166830f5c --- /dev/null +++ b/sapi/src/builder/library_shared/chromium.php @@ -0,0 +1,38 @@ +withHomePage('https://chromium.googlesource.com/chromium/src') + ->withLicense('https://https://chromium.googlesource.com/chromium/src/+/refs/heads/main/LICENSE', Library::LICENSE_SPEC) + ->withManual('https://chromium.googlesource.com/chromium/src') + ->withDownloadScript( + 'chromium', + <<withBuildCached(false) + ->withPrefix($example_prefix) + ->withBuildScript( + <<withDependentLibraries('depot_tools') + ; + + $p->addLibrary($lib); +}; + +# chromium 引用 github 上的库 +/* + + https://chromium.googlesource.com/external/github.com/ + + */ diff --git a/sapi/src/builder/library_shared/dpdk.php b/sapi/src/builder/library_shared/dpdk.php new file mode 100644 index 0000000000..1b256ea97b --- /dev/null +++ b/sapi/src/builder/library_shared/dpdk.php @@ -0,0 +1,175 @@ +addLibrary( + (new Library('dpdk')) + ->withHomePage('http://core.dpdk.org/') + ->withLicense('https://core.dpdk.org/contribute/', Library::LICENSE_BSD) + ->withManual('https://github.com/DPDK/dpdk.git') + ->withManual('http://core.dpdk.org/doc/') + ->withManual('https://core.dpdk.org/doc/quick-start/') + ->withFile('dpdk-v23.11.tar.gz') + ->withDownloadScript( + 'dpdk-stable', + <<withPreInstallCommand( + 'alpine', + <<withPreInstallCommand( + 'ubuntu', + <<withBuildCached(false) + ->withBuildScript( + <<withBinPath($dpdk_prefix . '/bin/') + /* + ->withDependentLibraries( + 'jansson', + 'zlib', + 'openssl', + 'libmlx5', + 'libnl', + 'liblzma', + 'liblz4', + 'libiconv', + 'libzstd', + 'bzip2', + 'nettle', + 'bzip2', + 'libxml2', + 'libiconv', + 'gmp', + 'libarchive', + 'numa', + 'libpcap', + 'libxdp', + 'libbpf', + 'libbsd', + + ) + */ + ->withPkgName('libdpdk-libs') + ->withPkgName('libdpdk') + ); +}; + +/* + +DPDK (Data Plane Development Kit) + +PPS(Packet Per Second) + +PMD(Poll Mode Driver) + +UIO(Userspace I/O) + +Zero Copy、无系统调用的好处 零拷贝 + + +https://cloud.tencent.com/developer/article/1198333 + +https://www.packetcoders.io/what-is-dpdk/ + + */ diff --git a/sapi/src/builder/library_shared/vtk.php b/sapi/src/builder/library_shared/vtk.php new file mode 100644 index 0000000000..861f95d04c --- /dev/null +++ b/sapi/src/builder/library_shared/vtk.php @@ -0,0 +1,56 @@ +withHomePage('https://www.vtk.org/') + ->withLicense('https://gitlab.kitware.com/vtk/vtk/-/blob/master/Copyright.txt', Library::LICENSE_BSD) + ->withManual('https://gitlab.kitware.com/vtk/vtk/-/blob/master/Documentation/dev/build.md#building-vtk') + ->withManual('https://docs.vtk.org/en/latest/build_instructions/index.html') + ->withFile('vtk-latest.tar.gz') + ->withDownloadScript( + 'vtk', + <<withPrefix($vtk_prefix) + ->withBuildScript( + <<withDependentLibraries( + 'ffmpeg', + 'libosmesa' + //'open_mpi' + ); + + $p->addLibrary($lib); +}; diff --git a/sapi/src/builder/library_shared/webrtc.php b/sapi/src/builder/library_shared/webrtc.php new file mode 100644 index 0000000000..68c324e608 --- /dev/null +++ b/sapi/src/builder/library_shared/webrtc.php @@ -0,0 +1,38 @@ +withHomePage('https://webrtc.googlesource.com/src') + ->withLicense('https://webrtc.googlesource.com/src/+/refs/heads/main/LICENSE', Library::LICENSE_SPEC) + ->withManual('https://webrtc.googlesource.com/src') + ->withDownloadScript( + 'webrtc', + <<withBuildCached(false) + ->withPrefix($example_prefix) + ->withBuildScript( + <<withDependentLibraries('depot_tools') + + ; + + $p->addLibrary($lib); +}; + +/* + * webrtc 和 chromium 使用同样的构建系统 + * + */ diff --git a/sapi/src/builder/library_shared/xorg_util_macros.php b/sapi/src/builder/library_shared/xorg_util_macros.php new file mode 100644 index 0000000000..4a3d37e6ed --- /dev/null +++ b/sapi/src/builder/library_shared/xorg_util_macros.php @@ -0,0 +1,38 @@ +withHomePage('https://gitlab.freedesktop.org/xorg/util/macros/') + ->withLicense('https://gitlab.freedesktop.org/xorg/util/macros/-/blob/master/COPYING', Library::LICENSE_SPEC) + ->withManual('https://gitlab.freedesktop.org/xorg/util/macros/-/blob/util-macros-1.20.0/INSTALL') + ->withFile('xorg-util-macros-1.20.0.tar.gz') + ->withDownloadScript( + 'macros', + <<withPrefix($xorg_util_macros_prefix) + ->withConfigure( + <<withPkgName('xorg-macros') + ->withPkgConfig($xorg_util_macros_prefix . '/share/pkgconfig/') + ; + + $p->addLibrary($lib); + + // xutils 包含了必须的 + // 参考 https://salsa.debian.org/xorg-team/app/xutils-dev +}; diff --git a/sapi/src/constants.php b/sapi/src/constants.php index fa8de6fca2..b7121d665f 100644 --- a/sapi/src/constants.php +++ b/sapi/src/constants.php @@ -47,8 +47,6 @@ define("BISON_PREFIX", $p->getGlobalPrefix() . '/bison'); define("NGHTTP2_PREFIX", $p->getGlobalPrefix() . '/nghttp2'); -define("LIBFFI_PREFIX", $p->getGlobalPrefix() . '/libffi'); - define("LIBEV_PREFIX", $p->getGlobalPrefix() . '/libev'); define("LIBUV_PREFIX", $p->getGlobalPrefix() . '/libuv'); @@ -127,22 +125,14 @@ define('LIBRSVG_PREFIX', $p->getGlobalPrefix() . '/librsvg'); -define('GETTEXT_PREFIX', $p->getGlobalPrefix() . '/gettext'); - 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'); -define("ZOOKEEPER_PREFIX", $p->getGlobalPrefix() . '/zookeeper'); - -define("LIBEVENT_PREFIX", $p->getGlobalPrefix() . '/libevent'); - -define("SNAPPY_PREFIX", $p->getGlobalPrefix() . '/snappy'); -define("LIBSASL_PREFIX", $p->getGlobalPrefix() . '/sasl'); - define("LIBARCHIVE_PREFIX", $p->getGlobalPrefix() . '/libarchive'); define("SOCAT_PREFIX", $p->getGlobalPrefix() . '/socat'); @@ -197,7 +187,6 @@ define("LIBPCAP_PREFIX", $p->getGlobalPrefix() . '/libpcap'); define("PORTAUDIO_PREFIX", $p->getGlobalPrefix() . '/portaudio'); define("LIBKS_PREFIX", $p->getGlobalPrefix() . '/libks'); -define("UTIL_LINUX_PREFIX", $p->getGlobalPrefix() . '/util_linux'); define("LIBATOMIC_PREFIX", $p->getGlobalPrefix() . '/libatomic'); define("UPNP_PREFIX", $p->getGlobalPrefix() . '/upnp'); @@ -219,6 +208,10 @@ define("APR_PREFIX", $p->getGlobalPrefix() . '/apr'); define("APR_UTIL_PREFIX", $p->getGlobalPrefix() . '/apr-util'); + +define("PYTHON3_PREFIX", $p->getGlobalPrefix() . '/python3'); +define("LIBMPDECIMAL_PREFIX", $p->getGlobalPrefix() . '/libmpdecimal'); +define("LIBB2_PREFIX", $p->getGlobalPrefix() . '/libb2'); define("LIBEXPAT_PREFIX", $p->getGlobalPrefix() . '/libexpat'); @@ -227,11 +220,21 @@ define("LIBGAV1_PREFIX", $p->getGlobalPrefix() . '/libgav1'); define("AOM_PREFIX", $p->getGlobalPrefix() . '/aom'); define("SVT_AV1_PREFIX", $p->getGlobalPrefix() . '/svt_av1'); +define("LIBYUV_PREFIX", $p->getGlobalPrefix() . '/libyuv'); + + +define("ZOOKEEPER_PREFIX", $p->getGlobalPrefix() . '/zookeeper'); +define("LIBEVENT_PREFIX", $p->getGlobalPrefix() . '/libevent'); +define("SNAPPY_PREFIX", $p->getGlobalPrefix() . '/snappy'); +define("LIBSASL_PREFIX", $p->getGlobalPrefix() . '/sasl'); define("LIBTIFF_PREFIX", $p->getGlobalPrefix() . '/libtiff'); define("LIBRAW_PREFIX", $p->getGlobalPrefix() . '/libraw'); define("LCMS2_PREFIX", $p->getGlobalPrefix() . '/lcms2'); +define("LIBMEMCACHED_PREFIX", $p->getGlobalPrefix() . '/libmemcached'); +define("LIBMEMCACHED_AWESOME_PREFIX", $p->getGlobalPrefix() . '/libmemcached_awesome'); + define("GRPC_PREFIX", $p->getGlobalPrefix() . '/grpc'); define("RE2_PREFIX", $p->getGlobalPrefix() . '/re2'); @@ -263,9 +266,6 @@ define("GFLAGS_PREFIX", $p->getGlobalPrefix() . '/gflags'); define("LEVELDB_PREFIX", $p->getGlobalPrefix() . '/leveldb'); -define("PYTHON3_PREFIX", $p->getGlobalPrefix() . '/python3'); -define("MPDECIMAL_PREFIX", $p->getGlobalPrefix() . '/mpdecimal'); -define("LIBB2_PREFIX", $p->getGlobalPrefix() . '/libb2'); define("LIBOPENCC_PREFIX", $p->getGlobalPrefix() . '/libopencc'); define("LIBYAML_CPP_PREFIX", $p->getGlobalPrefix() . '/libyaml_cpp'); @@ -321,15 +321,17 @@ define("PJPROJECT_PREFIX", $p->getGlobalPrefix() . '/pjproject'); define("QEMU_PREFIX", $p->getGlobalPrefix() . '/qemu'); + +define("LIBFFI_PREFIX", $p->getGlobalPrefix() . '/libffi'); + + define("STRONGSWAN_PREFIX", $p->getGlobalPrefix() . '/strongswan'); define("MUSL_CROSS_MAKE_PREFIX", $p->getGlobalPrefix() . '/musl_cross_make'); define("MUSL_LIBC_PREFIX", $p->getGlobalPrefix() . '/musl_libc'); - define("ABSL_PREFIX", $p->getGlobalPrefix() . '/absl'); - define("GPAC_PREFIX", $p->getGlobalPrefix() . '/gpac'); define("SNDIO_AUDIO_PREFIX", $p->getGlobalPrefix() . '/sndio_audio'); @@ -340,9 +342,6 @@ define("V4L_UTILS_PREFIX", $p->getGlobalPrefix() . '/v4l_utils'); define("LIBOAUTH2_PREFIX", $p->getGlobalPrefix() . '/liboauth2'); define("CJOSE_PREFIX", $p->getGlobalPrefix() . '/cjose'); -define("LIBYUV_PREFIX", $p->getGlobalPrefix() . '/libyuv'); -define("EXAMPLE_PREFIX", $p->getGlobalPrefix() . '/example'); - - +define("EXAMPLE_PREFIX", $p->getGlobalPrefix() . '/example'); diff --git a/sapi/src/library_builder/GPG.md b/sapi/src/library_builder/GPG.md new file mode 100644 index 0000000000..6cc82385ed --- /dev/null +++ b/sapi/src/library_builder/GPG.md @@ -0,0 +1,7 @@ +## 如何使用 GPG 签名 + + https://gitee.com/help/articles/4248#article-header0 + + gpg 签名验证例子 + https://github.com/phar-io/phive + diff --git a/sapi/src/library_builder/PVE.md b/sapi/src/library_builder/PVE.md new file mode 100644 index 0000000000..fae817576a --- /dev/null +++ b/sapi/src/library_builder/PVE.md @@ -0,0 +1,11 @@ +## 换源 + + http://mirrors.ustc.edu.cn/help/proxmox.html + +## download + + https://www.proxmox.com/en/downloads + https://www.proxmox.com/en/downloads/proxmox-virtual-environment/iso/proxmox-ve-8-3-iso-installer + curl -fSLo proxmox-ve_8.3-1.iso https://enterprise.proxmox.com/iso/proxmox-ve_8.3-1.iso + SHA256SUM="b5c2d10d6492d2d763e648bc8562d0f77a90c39fac3a664e676e795735198b45" + sha256sum proxmox-ve_8.3-1.iso diff --git a/sapi/src/library_builder/README.md b/sapi/src/library_builder/README.md new file mode 100644 index 0000000000..621e106aaa --- /dev/null +++ b/sapi/src/library_builder/README.md @@ -0,0 +1,41 @@ +## CNC + + CNC(数控机床)是计算机数字控制机床(Computer Numerical Control)的简称 + +## 虚拟化 + + kvm : CPU 和内存虚拟化 + CEPH: 存储虚拟化 + OVS: 网络虚拟化 + +## FPV 模拟器 + + Liftoff模拟器 + +## 判断命令是否支持 + +```bash + +command -v debian-sa1 > /dev/null && debian-sa1 1 1 + +``` + +包管理(Package Management) +版本管理(Version Management) +环境管理(Environmental Management) + +版本管理 +PYTHON3 +Python 管理工具 —— conda 详情: https://zhuanlan.zhihu.com/p/638540652 +pyenv pipenv venv +PHP +phpbrew +nodejs +nvm +npm-check-updates + +## 桌面应用程序开发框架比较:Electron、Flutter、Tauri、React Native 和 Qt + +## Flatpak vs. Snap vs. AppImage vs. 玲珑 + + https://www.linglong.space/guide/start/whatis.html diff --git a/sapi/src/library_builder/chromium.md b/sapi/src/library_builder/chromium.md new file mode 100644 index 0000000000..cabc73ddfa --- /dev/null +++ b/sapi/src/library_builder/chromium.md @@ -0,0 +1,20 @@ +chromium 截图 + +打开开发者工具,cmd + shift + p 自带。 + +按下 F12 + +## electron + + https://www.electronjs.org/zh/docs/latest/ + +## Chromium Embedded Framework (CEF) + + https://github.com/chromiumembedded/cef + +## ungoogled-chromium + + https://github.com/ungoogled-software/ungoogled-chromium + +## remote-debug + --remote-debugging-address=0.0.0.0 --remote-debugging-port=9222 diff --git a/sapi/src/library_builder/cloud-init.md b/sapi/src/library_builder/cloud-init.md new file mode 100644 index 0000000000..ce6f142eea --- /dev/null +++ b/sapi/src/library_builder/cloud-init.md @@ -0,0 +1,3 @@ + + +https://cloudinit.readthedocs.io/en/latest/tutorial/index.html diff --git a/sapi/src/library_builder/compiler.md b/sapi/src/library_builder/compiler.md new file mode 100644 index 0000000000..a8b1bdb746 --- /dev/null +++ b/sapi/src/library_builder/compiler.md @@ -0,0 +1,118 @@ +交叉编译 cross-compile binutils + +宿主机(host) + +目标机(target) + +prefix:交叉编译器的安装位置 + +xxx-xxxx-xxxxx 平台描述 + +交叉编译器 + +预处理器(preprocessor) +编译器前端(frontend) +负责解析(parse)输入的源代码 负责语义(semantic checking)的检查 最终的结果常常是一个抽象的语法树(abstract syntax tree,或 +AST) +编译器后端(backend) +主要负责分析,优化中间代码(Intermediate representation)以及生成机器代码(Code Generation) + +g++ your_program.cpp -o your_program -ldl -Wl,-Bstatic -lxx -Wl,-Bdynamic + +-Wl,-Bstatic 表示后面的库需要静态链接,-Wl,-Bdynamic 表示后面的库需要动态链接。 + +ld main.o -o main.out -pie --no-dynamic-linker + +-Wl,--no-dynamic-linker + +pkg-config libelf --exists + +CC 编译器,对C源文件进行编译处理,生成汇编文件 +LD 链接器(来自"链接编辑器"或"加载程序")。 + +CPP 代表" C预处理程序" +CXX 是C ++编译器 +AS 是汇编语言编译器 将汇编文件生成目标文件(汇编文件使用的是指令助记符, AS将它翻译成机器码) +AR 是一个存档维护程序 打包器,用于库操作,可以通过该工具从一个库中删除或者增加目标代码模块 +STRIP:以最终生成的可执行文件或者库文件作为输入,然后消除掉其中的源码 +NM:查看静态库文件中的符号表 +Objdump:查看静态库或者动态库的方法签名 + +cmake 生成依赖图 +cmake --graphviz=./ffmpeg.dot + +CMake toolchain file for cross compiling +cmake -DCMAKE_TOOLCHAIN_FILE="crosscompile.cmake" + +clang 传递编译器参数例子: +clang -o vlc vlc.c.o -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -pie -Wl,--start-group modules/access/http/libvlc_http.a +compat/libcompat.a src/libvlccore.a -pthread -lm -ldl -Wl,--end-group + +由于 OpenMP 内置于编译器中,因此无需安装外部库即可编译此代码 +https://curc.readthedocs.io/en/latest/programming/OpenMP-C.html + +自动微分 Adolc +https://github.com/coin-or/ADOL-C.git + + * # 需要特别设置的地方 + * // CFLAGS='-static -O2 -Wall' + + * 位置无关的可执行文件 + * 直接编译可执行文件 -fPIE + * 直接编译成库 -fPIC + 地址无关代码(Position Independent Code, PIC) + +BPF CO-RE (Compile Once – Run Everywhere) +https://github.com/libbpf/libbpf#bpf-co-re-compile-once--run-everywhere + +# static-pie + +# 位置无关的可执行文件(PIE)。PIE 是启用地址空间布局随机化 (ASLR) 的先决条件 + +## macos 库支持静态编译, 二进制程序不支持静态编译 + + LIBS='-framework CoreFoundation -framework CoreServices -framework SystemConfiguration" + +MIPS架构 龙芯处理器 +s390x IBMSystemz系列大型机硬件平台 +ppc64le 基于Power架构 + +clang with MUSL + +clang hello.c -I /usr/include/x86_64-linux-musl --target=x86_64-unknown-linux-musl -nostdlib + +TLS的四种模式 Global Dynamic,Local Dynamic,Initial Exec和Local Exec + +单词缩写解释 +Acronyms relevant to Executable and Linkable Format (ELF) +https://stevens.netmeister.org/631/elf.html + +ABI: Application binary interface +a.out: Assembler output file format +PIC: Position independent code +PIE: Position independent executable + +libtoolize --force --copy --automake +aclocal +autoheader +automake --foreign --copy --add-missing +autoconf +export CFLAGS="-O2 -Wall -W -Wunused-const-variable=0 -pipe -g" + +预处理 gcc -E 、clang -E +编译 gcc -S 、clang -S +汇编 gcc -c 、clang -c +链接 gcc -o 、clang -o + +C++中的volatile 阻止编译器优化变量 + +## 生成动态库 (lib 开头 , .so 结尾 ) + + gcc -fPIC -shared test.c -O libtest.so + +## 生成静态库(lib 开头 , .a 结尾 ) + + gcc -c test.c + ar -crv libtest.a test.o + + diff --git a/sapi/src/library_builder/docker-desktop.md b/sapi/src/library_builder/docker-desktop.md new file mode 100644 index 0000000000..fa795a9068 --- /dev/null +++ b/sapi/src/library_builder/docker-desktop.md @@ -0,0 +1,37 @@ +## 容器中访问宿主机 + + host.docker.internal 解析为宿主机主机使用的内部 IP 地址 + gateway.docker.internal + +## docker-compose 健康检查 + + healthcheck: + test: curl --fail http://localhost:5000/ || exit 1 + interval: 40s + timeout: 30s + retries: 3 + start_period: 60s + +## 健康检查三个参数 + + - AUTOHEAL_INTERVAL=60 + - AUTOHEAL_START_PERIOD=300 + - AUTOHEAL_DEFAULT_STOP_TIMEOUT=10 + +## docker 健康检查 + # https://docs.docker.com/engine/containers/run/#healthchecks + + docker run --name=test -d \ + --health-cmd='stat /etc/passwd || exit 1' \ + --health-interval=2s \ + busybox sleep 1d + +## 容器内操控容器控制命令 + + volumes: + - /var/run/docker.sock:/var/run/docker.sock + +## 远程访问容器 + + socat -d -d TCP-L:2375,fork UNIX:/var/run/docker.sock + diff --git a/sapi/src/library_builder/electron/README.md b/sapi/src/library_builder/electron/README.md new file mode 100644 index 0000000000..c80004bbdd --- /dev/null +++ b/sapi/src/library_builder/electron/README.md @@ -0,0 +1,12 @@ +## electron + + https://www.electronjs.org/zh/docs/latest/ + +## Chromium Embedded Framework (CEF) + + https://github.com/chromiumembedded/cef + +## ungoogled-chromium + + https://github.com/ungoogled-software/ungoogled-chromium + https://ungoogled-software.github.io/ungoogled-chromium-binaries/ diff --git a/sapi/src/library_builder/electron/electron.md b/sapi/src/library_builder/electron/electron.md new file mode 100644 index 0000000000..817a2401bc --- /dev/null +++ b/sapi/src/library_builder/electron/electron.md @@ -0,0 +1,9 @@ +## electron for flatpak + + https://docs.flatpak.org/en/latest/electron.html + +## electron for appimage + https://www.electron.build/configuration/appimage.html + +## electron for windows + https://www.electronjs.org/docs/latest/development/build-instructions-windows diff --git a/sapi/src/library_builder/fail2ban.md b/sapi/src/library_builder/fail2ban.md new file mode 100644 index 0000000000..b802acd17b --- /dev/null +++ b/sapi/src/library_builder/fail2ban.md @@ -0,0 +1,4 @@ + +设置 Fail2ban + +https://docs.gitea.com/zh-cn/administration/fail2ban-setup diff --git a/sapi/src/library_builder/ffmpeg.md b/sapi/src/library_builder/ffmpeg.md new file mode 100644 index 0000000000..71949e711b --- /dev/null +++ b/sapi/src/library_builder/ffmpeg.md @@ -0,0 +1,40 @@ +# ffmpeg 功能特性与依赖库关系对照表 + +```text +--enable-libplacebo [libplacebo](https://code.videolan.org/videolan/libplacebo) +--enable-libzvbi [zvbi](https://svn.code.sf.net/p/zapping/svn/trunk/vbi) +--enable-openssl [openssl](https://github.com/quictls/openssl/) +--enable-libwebp [libwebp](https://chromium.googlesource.com/webm/libwebp) +--enable-libxml2 [libxml2](https://gitlab.gnome.org/GNOME/libxml2/) +--enable-libsvtav1 [SVT-AV1](https://gitlab.com/AOMediaCodec/SVT-AV1.git) +--enable-libaom [aom](https://aomedia.googlesource.com/aom) +--enable-lcms2 [lcms2](https://littlecms.com/color-engine/) +--enable-gmp [gmp](https://gmplib.org/) +--enable-libx264 [x264](https://github.com/mirror/x264.git) +--enable-libx265 [x265](https://bitbucket.org/multicoreware/x265_git.git) +--enable-random []() +--enable-libfreetype [freetype](https://freetype.org/) +--enable-libvpx [libvpx](https://chromium.googlesource.com/webm/libvpx) +--enable-ffplay []() +--enable-sdl2 [sdl2](https://github.com/libsdl-org/SDL.git) +--enable-libdav1d [dav1d](https://code.videolan.org/videolan/dav1d/) +--enable-libopus [libopus](https://opus-codec.org/) +--enable-libopenh264 [openh264](https://github.com/cisco/openh264.git) +--enable-libfdk-aac [fdk-aac](https://github.com/mstorsjo/fdk-aac.git) +--enable-libfribidi [libfribidi](https://github.com/fribidi/fribidi.git) +--enable-librabbitmq [librabbitmq](https://github.com/alanxz/rabbitmq-c.git) +--enable-libspeex [speex](https://speex.org/) 被opus 取代 +``` + +## 视频协议标准 + +```text + ONVIF 协议 onvif(Open Network Video Interface Forum) + RTSP + gb28181 标准 + + + ``` + +gpac MP4Box +https://github.com/gpac/gpac.git diff --git a/sapi/src/library_builder/file-system.md b/sapi/src/library_builder/file-system.md new file mode 100644 index 0000000000..5b180417b6 --- /dev/null +++ b/sapi/src/library_builder/file-system.md @@ -0,0 +1,3 @@ +## btrfs openzfs lvm + + 快照功能比较有用 diff --git a/sapi/src/library_builder/git.md b/sapi/src/library_builder/git.md new file mode 100644 index 0000000000..5344d269cc --- /dev/null +++ b/sapi/src/library_builder/git.md @@ -0,0 +1,273 @@ +```bash + +git gc --prune=now + + +git shortlog -s ${1-} | +cut -b8- | +sort | uniq + +``` + +## 添加子模块 + +```shell + + + git submodule add https://github.com/swoole/swoole-src.git ext/swoole + + + +``` + +## 检出 + +```shell + +git submodule update --init -f + +# git submodule update --init --force --remote + + +``` + +## 删除子模块 + +```bash + +git submodule deinit ext/swoole + +git submodule deinit -f ext/swoole + +rm -rf .git/modules/ext/swoole/ + +git rm -rf ext/swoole/ + +``` + +## 创建空的新分支 + +```bash +git checkout --orphan static-php-cli-next + +git rm -rf . + +``` + +## 创建新分支来自远程仓库 + +```shell + +git fetch -a +git checkout -b new-branch-name origin/existing-branch-name + +``` + +## 清理未跟踪的文件 谨慎使用 + +```bash +git clean -df +``` + +```bash +git clone --single-branch --depth=1 https://github.com/jingjingxyk/swoole-cli.git + + +git fsck --lost-found # 查看记录 +``` + +## 合并时不保留commit 信息 + +```bash +git merge --squash branch_name + +``` + +## 当前分支 hash + +```bash +git rev-parse HEAD + +``` + +```bash + +git config core.ignorecase false # 设置 Git 在 Windows 上也区分大小写 + +git reflog # 查看所有的提交历史 +git reset --hard c761f5c # 回退到指定的版本 + +``` + +## 节省网络流量 + +```bash + +git clone --recurse-submodules --single-branch -b main --progress --depth=1 + + +git log --pretty=oneline + +git stash list + +git remote show origin +git branch -a +git branch -r +git remote prune origin +git remote prune origin --dry-run + + +git gc --prune=now + + + +``` + +## 单个文件回滚 + +```bash +git log + +git checkout commit_id filename + + + +``` + +## git 恢复被删除的整个文件夹 + +```shell + +git log --oneline -- experimental-features/v3/rules/example/ +git checkout commit_id -- experimental-features/v3/rules/example/ + +``` + +## git commits 出现累积叠加 解决办法 + +```bash + +git merge dev --squash + +git branch -D dev +git checkout -b dev + +``` + +## 创建新的空分支 + +```bash + +git checkout -b --orphan new_branch + +git rm -rf . + +``` + +## 获取提交时间 + +```bash + + # 获得提交时间 + TZ=UTC git show --date=format-local:%Y%m%d%k%M%S + +``` + +## 合并两个无关的仓库 + +```bash +git merge --allow-unrelated-histories +``` + +## 查看提交日志 + +```bash + +git log --oneline + +``` + +```bash + +GITVERSION="git --git-dir $(pwd)/.git rev-parse --short HEAD" +GITTAG="git --git-dir $(pwd)/.git describe --all --always --dirty" +GITBRANCH="git --git-dir $(pwd)/.git name-rev --name-only HEAD" + + +GIT_COMMIT:=$(git describe --dirty --always) +GIT_BRANCH:=$(git rev-parse --abbrev-ref HEAD -- | head -1) +DATE:=$(date +"%Y-%m-%d") + +git config --global --add safe.directory "$GITHUB_WORKSPACE" + +``` + +## 设置 分支 跟踪 + +```bash + +git branch --set-upstream-to=origin/main main +``` + +## 查看当前分支 + +```shell + +git rev-parse --abbrev-ref HEAD + +git log --pretty=%ad-%h --date=format:'%Y%m%d%H%M' -n 1 | cat + + +TZ=UTC git show --quiet --date='format-local:%Y%m%dT%H%M%SZ' --format="%cd" + +``` + +## windows git 配置 代理 + +```shell + +# download socat +curl.exe -fSLo socat-v1.8.0.1-cygwin-x64.zip https://github.com/jingjingxyk/build-static-socat/releases/download/v2.2.1/socat-v1.8.0.1-cygwin-x64.zip + +curl.exe -fSLo socat-v1.8.0.1-cygwin-x64.zip https://php-cli.jingjingxyk.com/socat-v1.8.0.1-cygwin-x64.zip + + +curl.exe -fSLo cacert.pem https://curl.se/ca/cacert.pem + +``` + +``` + +.\socat -d -d TCP4-LISTEN:8016,reuseaddr,fork ssl:http-proxy.xiaoshuogeng.com:8017,verify=1,snihost=http-proxy.xiaoshuogeng.com,commonname=http-proxy.xiaoshuogeng.com,openssl-min-proto-version=TLS1.3,openssl-max-proto-version=TLS1.3,verify=1,cafile=cacert.pem + + +``` + +```text +vi ~\.ssh\config + + +Host github.com + Hostname github.com + Port 22 + PreferredAuthentications publickey + StrictHostKeyChecking no + IdentityFile /c/Users/admin/.ssh/github-ssh-key-id-rsa + # ProxyCommand nc -X 5 -x localhost:2000 %h %p + # ProxyCommand socat - socks4a:localhost:%h:%p,socksport=2000 + ProxyCommand "C:\Users\admin\socat-v1.8.0.1-cygwin-x64\socat-v1.8.0.1-cygwin-x64\socat" - proxy:localhost:%h:%p,proxyport=8016 + +```` + +```shell + + +git config --global core.autocrlf false +git config --global core.eol lf +git config --global core.ignorecase false + +# 不再关心文件的权限 +git config --global core.filemode false +# 让 Git 显示颜色,会让命令输出看起来更醒目 +git config --global color.ui true +``` diff --git a/sapi/src/library_builder/gitea.md b/sapi/src/library_builder/gitea.md new file mode 100644 index 0000000000..0cff13e56f --- /dev/null +++ b/sapi/src/library_builder/gitea.md @@ -0,0 +1,33 @@ + + +install gitea with docker + +https://docs.gitea.com/zh-cn/installation/install-with-docker + + + +k8s 使用的端口 + +https://kubernetes.io/zh-cn/docs/reference/networking/ports-and-protocols/ + +不带选择器的服务 +Services without selectors +https://kubernetes.io/docs/concepts/services-networking/service/#services-without-selectors + + + +从主机到容器的 SSH 转发 + +```shell + +sudo -u git ssh-keygen -t rsa -b 4096 -C "Gitea Host Key" + + +ssh -p 2222 -o StrictHostKeyChecking=no git@127.0.0.1 "SSH_ORIGINAL_COMMAND=\"$SSH_ORIGINAL_COMMAND\" $0 $@" + + + +``` + +设置 Fail2ban +https://docs.gitea.com/zh-cn/administration/fail2ban-setup diff --git a/sapi/src/library_builder/kubevirt.md b/sapi/src/library_builder/kubevirt.md new file mode 100644 index 0000000000..2654862d4d --- /dev/null +++ b/sapi/src/library_builder/kubevirt.md @@ -0,0 +1,4 @@ + +https://kubevirt.io/ + +https://github.com/kubevirt/kubevirt.git diff --git a/sapi/src/library_builder/library_install_builder.php b/sapi/src/library_builder/library_install_builder.php new file mode 100644 index 0000000000..2064be33dd --- /dev/null +++ b/sapi/src/library_builder/library_install_builder.php @@ -0,0 +1,612 @@ +addLibrary( + (new Library('libxslt')) + ->withHomePage('https://gitlab.gnome.org/GNOME/libxslt/-/wikis/home') + ->withUrl('https://gitlab.gnome.org/GNOME/libxslt/-/archive/v1.1.34/libxslt-v1.1.34.tar.gz') + //https://download.gnome.org/sources/libxslt/1.1/ + ->withLicense('http://www.opensource.org/licenses/mit-license.html', Library::LICENSE_MIT) + ->withPrefix($libxslt_prefix) + ->withConfigure( + <<withPkgName('libexslt') + ->withPkgName('libxslt') + ->withBinPath($libxslt_prefix . '/bin/') + ->depends('libxml2', 'libiconv') + ); +} + + +function install_brotli(Preprocessor $p) +{ + /* + -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" \ + -DCMAKE_INSTALL_PREFIX="${PREFIX}" \ + -DCMAKE_INSTALL_LIBDIR="${LIBDIR}" \ + + -Wno-dev + */ +} + +function install_cares(Preprocessor $p) +{ +} + + +function install_gmp(Preprocessor $p) +{ +} + + +/* +// CFLAGS="-static -O2 -Wall" \ +// LDFLAGS="-Wl,R-lncurses" +// LDFLAGS="-lncurses" \ + */ +function install_ncurses(Preprocessor $p) +{ +} + + +function install_readline(Preprocessor $p) +{ +} + + +function install_libyaml(Preprocessor $p): void +{ +} + +function install_libsodium(Preprocessor $p) +{ +} + +function install_bzip2(Preprocessor $p) +{ +} + +function install_zlib(Preprocessor $p) +{ +} + + +function install_liblz4(Preprocessor $p) +{ + + //可以使用CMAKE 编译 也可以 + //不使用CMAKE,需要自己修改安装目录 + //->withMakeOptions('INSTALL_PROGRAM=/usr/liblz4/') + //->withMakeInstallOptions("DESTDIR=/usr/liblz4/") +} + + +function install_liblzma(Preprocessor $p) +{ +} + + +function install_libzstd(Preprocessor $p) +{ + /* + ' + mkdir -p build/cmake/builddir + cd build/cmake/builddir + # cmake -LH .. + cmake .. \ + -DCMAKE_INSTALL_PREFIX=/usr/libzstd/ \ + -DZSTD_BUILD_STATIC=ON \ + -DCMAKE_BUILD_TYPE=Release \ + -DZSTD_BUILD_CONTRIB=ON \ + -DZSTD_BUILD_PROGRAMS=OFF \ + -DZSTD_BUILD_SHARED=OFF \ + -DZSTD_BUILD_TESTS=OFF \ + -DZSTD_LEGACY_SUPPORT=ON \ + \ + -DZSTD_ZLIB_SUPPORT=ON \ + -DZLIB_INCLUDE_DIR=/usr/zlib/include \ + -DZLIB_LIBRARY=/usr/zlib/lib \ + \ + -DZSTD_LZ4_SUPPORT=ON \ + -DLIBLZ4_INCLUDE_DIR=/usr/liblz4/include \ + -DLIBLZ4_LIBRARY=/usr/liblz4/lib \ + \ + -DZSTD_LZMA_SUPPORT=ON \ + -DLIBLZMA_LIBRARY=/usr/liblzma/lib \ + -DLIBLZMA_INCLUDE_DIR=/usr/liblzma/include \ + -DLIBLZMA_HAS_AUTO_DECODER=ON\ + -DLIBLZMA_HAS_EASY_ENCODER=ON \ + -DLIBLZMA_HAS_LZMA_PRESET=ON + ' + */ +} + + +// MUST be in the /usr directory +function install_libzip(Preprocessor $p) +{ +} + + +function install_sqlite3(Preprocessor $p) +{ +} + + +function install_icu(Preprocessor $p) +{ + /* + --with-data-packaging specify how to package ICU data. Possible values: + + files raw files (.res, etc) + archive build a single icudtXX.dat file + library shared library (.dll/.so/etc.) + static static library (.a/.lib/etc.) + auto build shared if possible (default) + */ + //https://github.com/unicode-org/icu/ +} + +function install_oniguruma(Preprocessor $p) +{ +} + +function install_mimalloc(Preprocessor $p) +{ + $mimalloc_prefix = MIMALLOC_PREFIX; + $p->addLibrary( + (new Library('mimalloc')) + ->withUrl('https://github.com/microsoft/mimalloc/archive/refs/tags/v2.0.7.tar.gz') + ->withFile('mimalloc-2.0.7.tar.gz') + ->withPrefix($mimalloc_prefix) + ->withConfigure( + 'cmake . -DMI_BUILD_SHARED=OFF -DCMAKE_INSTALL_PREFIX=' . $mimalloc_prefix . ' -DMI_INSTALL_TOPLEVEL=ON -DMI_PADDING=OFF -DMI_SKIP_COLLECT_ON_EXIT=ON -DMI_BUILD_TESTS=OFF' + ) + ->withPkgName('libmimalloc') + ->withLicense('https://github.com/microsoft/mimalloc/blob/master/LICENSE', Library::LICENSE_MIT) + ->withHomePage('https://microsoft.github.io/mimalloc/') + ->withLdflags('-L' . $mimalloc_prefix . '/lib -lmimalloc') + ->disablePkgName() + ); +} + +function install_libidn2(Preprocessor $p) +{ +} + +function install_libssh2(Preprocessor $p) +{ +} + + +/** + * + * -lz 压缩库(Z) + * + * -lrt 实时库(real time):shm_open系列 + * + * -lm 数学库(math) + * + * -lc 标准C库(C lib) + * + * -dl ,是显式加载动态库的动态函数库 + * + */ +/** + * cur 交叉编译 + * + * https://curl.se/docs/install.html + * + * export PATH=$PATH:/opt/hardhat/devkit/ppc/405/bin + * export CPPFLAGS="-I/opt/hardhat/devkit/ppc/405/target/usr/include" + * export AR=ppc_405-ar + * export AS=ppc_405-as + * export LD=ppc_405-ld + * export RANLIB=ppc_405-ranlib + * export CC=ppc_405-gcc + * export NM=ppc_405-nm + * --with-random=/dev/urandom + * + * randlib + * strip + * + */ +function install_curl(Preprocessor $p) +{ + //http3 有多个实现 + //参考文档: https://curl.se/docs/http3.html + //https://curl.se/docs/protdocs.html + // curl 依赖库 https://curl.se/docs/libs.html + + $openssl_prefix = OPENSSL_PREFIX; + $zlib_prefix = ZLIB_PREFIX; + + $libidn2_prefix = LIBIDN2_PREFIX; + $libzstd_prefix = LIBZSTD_PREFIX; + $cares_prefix = CARES_PREFIX; + $brotli_prefix = BROTLI_PREFIX; + $gnutls_prefix = GNUTLS_PREFIX; + $libssh2_prefix = LIBSSH2_PREFIX; + $openssl_prefix = OPENSSL_PREFIX; + $zlib_prefix = ZLIB_PREFIX; + $cares_prefix = CARES_PREFIX; + + $curl_prefix = CURL_PREFIX; + $p->addLibrary( + (new Library('curl')) + ->withHomePage('https://curl.se/') + ->withUrl('https://curl.se/download/curl-7.88.0.tar.gz') + ->withManual('https://curl.se/docs/install.html') + ->withLicense('https://github.com/curl/curl/blob/master/COPYING', Library::LICENSE_SPEC) + ->withPrefix($curl_prefix) + ->withConfigure( + <<withPkgName('libcurl') + ->withBinPath($curl_prefix . '/bin/') + ->withDependentLibraries( + 'openssl', + 'cares', + 'zlib', + 'brotli', + 'libzstd', + 'libidn2', + 'nghttp2', + // 'nghttp3', + //'ngtcp2', + 'libssh2' + ) + ); + + #--with-gnutls=GNUTLS_PREFIX + #--with-nghttp3=NGHTTP3_PREFIX + #--with-ngtcp2=NGTCP2_PREFIX + #--with-nghttp2=NGHTTP2_PREFIX + #--without-brotli + #--disable-ares + #--with-ngtcp2=/usr/ngtcp2 \ + #--with-quiche=/usr/quiche + #--with-msh3=PATH + /** + * configure: pkg-config: SSL_LIBS: "-lssl -lcrypto" + * configure: pkg-config: SSL_LDFLAGS: "-L/usr/openssl/lib" + * configure: pkg-config: SSL_CPPFLAGS: "-I/usr/openssl/include" + * + * onfigure: pkg-config: IDN_LIBS: "-lidn2" + * configure: pkg-config: IDN_LDFLAGS: "-L/usr/libidn2/lib" + * configure: pkg-config: IDN_CPPFLAGS: "-I/usr/libidn2/include" + * configure: pkg-config: IDN_DIR: "/usr/libidn2/lib" + * + * configure: -l is -lnghttp2 + * configure: -I is -I/usr/nghttp2/include + * configure: -L is -L/usr/nghttp2/lib + * # search idn2_lookup_ul + * + * configure: pkg-config: ares LIBS: "-lcares" + * configure: pkg-config: ares LDFLAGS: "-L/usr/cares/lib" + * configure: pkg-config: ares CPPFLAGS: "-I/usr/cares/include" + * -lidn -lrt + */ +} + + +function install_pgsql(Preprocessor $p): void +{ +} + +function install_re2c(Preprocessor $p) +{ + $p->addLibrary( + (new Library('re2c')) + ->withHomePage('http://re2c.org/') + ->withUrl('https://github.com/skvadrik/re2c/releases/download/3.0/re2c-3.0.tar.xz') + ->withLicense('https://github.com/skvadrik/re2c/blob/master/LICENSE', Library::LICENSE_GPL) + ->withManual('https://re2c.org/build/build.html') + ->withLabel('build_env_bin') + + ->withConfigure( + " + autoreconf -i -W all + ./configure --help + ./configure --prefix=/usr/re2c + " + ) + ->withBinPath('/usr/re2c/bin/') + ->disableDefaultPkgConfig() + ->disableDefaultLdflags() + ->disablePkgName() + ); +} + +function install_libmcrypt(Preprocessor $p) +{ + $libmcrypt_prefix = LIBMCRYPT_PREFIX; + $lib = new Library('libmcrypt'); + $lib->withHomePage('https://sourceforge.net/projects/mcrypt/files/Libmcrypt/') + ->withLicense('https://gitlab.com/libtiff/libtiff/-/blob/master/LICENSE.md', Library::LICENSE_LGPL) + ->withUrl('https://github.com/winlibs/libmcrypt/archive/refs/tags/libmcrypt-2.5.8-3.4.tar.gz') + ->withManual('https://github.com/winlibs/libmcrypt/blob/master/INSTALL') + ->withPrefix($libmcrypt_prefix) + ->withConfigure( + <<withPkgName('libmcrypt'); + + $p->addLibrary($lib); +} + +function install_libxlsxwriter(Preprocessor $p) +{ + $libxlsxwriter_prefix = LIBXLSXWRITER_PREFIX; + $zlib_prefix = ZLIB_PREFIX; + $lib = new Library('libxlsxwriter'); + $lib->withHomePage('https://libxlsxwriter.github.io/') + ->withLicense('https://github.com/jmcnamara/libxlsxwriter/blob/main/License.txt', Library::LICENSE_BSD) + ->withLicense('https://libxlsxwriter.github.io/license.html', Library::LICENSE_BSD) + ->withUrl('https://github.com/jmcnamara/libxlsxwriter/archive/refs/tags/RELEASE_1.1.5.tar.gz') + ->withFile('libxlsxwriter-1.1.5.tar.gz') + ->withManual('http://libxlsxwriter.github.io/getting_started.html') + ->withPrefix($libxlsxwriter_prefix) + ->withBuildScript( + <<depends('zlib', 'openssl') + ->withPkgName('xlsxwriter'); + + $p->addLibrary($lib); +} + +function install_minizip(Preprocessor $p) +{ + $libminzip_prefix = LIBMINZIP_PREFIX; + $libzip2_prefix = BZIP2_PREFIX; + $openssl_prefix = OPENSSL_PREFIX; + $zlib_prefix = ZLIB_PREFIX; + $lib = new Library('libminizip'); + $lib->withHomePage('https://github.com/zlib-ng/minizip-ng') + ->withLicense('https://github.com/zlib-ng/minizip-ng/blob/master/LICENSE', Library::LICENSE_SPEC) + ->withUrl('https://github.com/zlib-ng/minizip-ng/archive/refs/tags/3.0.9.tar.gz') + ->withFile('minizip-ng-3.0.9.tar.gz') + ->withManual('https://github.com/zlib-ng/minizip-ng') + ->withPrefix($libminzip_prefix) + ->withBuildScript( + <<depends('zlib', 'bzip2', 'liblzma', 'libzstd', 'openssl', 'libiconv') + ->withBinPath($libminzip_prefix . '/bin/') + ->withPkgName('minizip'); + + $p->addLibrary($lib); +} + +function install_libxlsxio(Preprocessor $p) +{ + $libxlsxio_prefix = LIBXLSXIO_PREFIX; + $libminizip_prefix = LIBMINZIP_PREFIX; + $libzip_prefix = ZIP_PREFIX; + $zlib_prefix = ZLIB_PREFIX; + $libexpat_prefix = LIBEXPAT_PREFIX; + + $p->addLibrary( + (new Library('libxlsxio')) + ->withHomePage('https://github.com/brechtsanders/xlsxio.git') + ->withLicense('https://github.com/brechtsanders/xlsxio/blob/master/LICENSE.txt', Library::LICENSE_MIT) + ->withUrl('https://github.com/brechtsanders/xlsxio/archive/refs/tags/0.2.34.tar.gz') + ->withFile('libxlsxio-0.2.34.tar.gz') + ->withManual('https://brechtsanders.github.io/xlsxio/') + ->withPrefix($libxlsxio_prefix) + ->withConfigure( + <<depends('zlib', 'libzip') + ->withPkgName('libxlsxio_read') + ->withPkgName('libxlsxio_readw') + ->withPkgName('libxlsxio_write') + ); +} + + +function install_libevent($p) +{ +} diff --git a/sapi/src/library_builder/library_install_builder_extensions.php b/sapi/src/library_builder/library_install_builder_extensions.php new file mode 100644 index 0000000000..ddea719b67 --- /dev/null +++ b/sapi/src/library_builder/library_install_builder_extensions.php @@ -0,0 +1,66 @@ +getWorkDir(); + $p->addLibrary( + (new Library('php_parser')) + ->withHomePage('https://github.com/nikic/PHP-Parser.git') + ->withLicense('https://github.com/nikic/PHP-Parser/blob/4.x/LICENSE', Library::LICENSE_BSD) + ->withUrl('https://github.com/nikic/PHP-Parser/archive/refs/tags/v4.15.3.tar.gz') + ->withFile('php-8.1.12.tar.gz') + ->withManual('https://www.php.net/docs.php') + ->withLabel('php_internal_extension') + + ->withBuildScript('return 0') + ->disableDefaultPkgConfig() + ->disableDefaultLdflags() + ); +} + +function install_php_internal_extensions($p) +{ +} + +function install_php_extension_micro(Preprocessor $p) +{ +} + + +function install_php_extension_swow(Preprocessor $p) +{ +} + +function install_php_extension_wasm(Preprocessor $p) +{ + $workDir = $p->getWorkDir(); + $buildDir = $p->getBuildDir(); + $p->addLibrary( + (new Library('php_extension_wasm')) + ->withHomePage('https://github.com/wasmerio/wasmer-php.git') + ->withUrl('https://github.com/wasmerio/wasmer-php/archive/refs/tags/1.1.0.tar.gz') + ->withFile('wasmer-php-1.1.0.tar.gz') + ->withLicense('https://github.com/wasmerio/wasmer-php/blob/master/LICENSE', Library::LICENSE_MIT) + ->withManual('https://github.com/wasmerio/wasmer-php.git') + ->withLabel('php_extension') + + ->withBuildScript( + " + ls -lh ./ext + pwd + cp -rf ext {$workDir}/ext/wasm + " + ) + ->disableDefaultPkgConfig() + ->disableDefaultLdflags() + ->disablePkgName() + //->withSkipBuildInstall() + ); +} + +function install_php_extension_zookeeper(Preprocessor $p) +{ +} diff --git a/sapi/src/library_builder/library_install_builder_test.php b/sapi/src/library_builder/library_install_builder_test.php new file mode 100644 index 0000000000..79d676d9c6 --- /dev/null +++ b/sapi/src/library_builder/library_install_builder_test.php @@ -0,0 +1,1093 @@ +addLibrary( + (new Library('libgcrypt_error')) + ->withHomePage('https://www.gnupg.org/') + ->withUrl('https://www.gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-1.46.tar.bz2') + ->withLicense('https://www.gnu.org/licenses/gpl-3.0.html', Library::LICENSE_GPL) + ->withManual('https://www.gnupg.org/documentation/manuals.html') + ->withPrefix($libgcrypt_error_prefix) + ->withConfigure( + <<withBinPath($libgcrypt_error_prefix . '/bin') + ->withPkgName('gpg-error') + ); +} + +function install_libgcrypt(Preprocessor $p) +{ + $libgcrypt_prefix = LIBGCRYPT_PREFIX; + $p->addLibrary( + (new Library('libgcrypt')) + ->withHomePage('https://www.gnupg.org/') + ->withUrl('https://www.gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-1.10.1.tar.bz2') + ->withLicense('https://www.gnu.org/licenses/gpl-3.0.html', Library::LICENSE_GPL) + ->withManual('https://www.gnupg.org/documentation/manuals.html') + ->withPrefix($libgcrypt_prefix) + ->withConfigure( + <<withPkgName('libgcrypt') + ->withBinPath($libgcrypt_prefix . '/bin/') + ); +} + +/** + * libgcrypt是一个非常成熟的加密算法库,也是著名的开源加密软件GnuPG的底层库,支持多种对称、非对称加密算法,以及多种Hash算法。 + * @param Preprocessor $p + * @return void + */ +function install_gnupg(Preprocessor $p) +{ + $gnupg_prefix = GNUPG_PREFIX; + $p->addLibrary( + (new Library('gnupg')) + ->withHomePage('https://www.gnupg.org/') + ->withUrl('https://www.gnupg.org/ftp/gcrypt/gnupg/gnupg-2.4.0.tar.bz2') + ->withLicense('https://www.gnu.org/licenses/gpl-3.0.html', Library::LICENSE_GPL) + ->withManual('https://www.gnupg.org/documentation/manuals.html') + ->withPrefix($gnupg_prefix) + ->withBuildScript( + <<withPkgName('gnupg') + ); +} + +function install_libyuv(Preprocessor $p) +{ +} + + +function install_libraw(Preprocessor $p) +{ +} + +function install_dav1d(Preprocessor $p) +{ +} + +function install_libgav1(Preprocessor $p) +{ +} + +function install_libavif(Preprocessor $p): void +{ +} + +function install_nasm(Preprocessor $p) +{ + $nasm_prefix = NASM_PREFIX; + $p->addLibrary( + (new Library('nasm')) + ->withHomePage('https://www.nasm.us/') + ->withUrl('https://www.nasm.us/pub/nasm/releasebuilds/2.16.01/nasm-2.16.01.tar.gz') + ->withLicense('http://opensource.org/licenses/BSD-2-Clause', Library::LICENSE_BSD) + ->withManual('https://github.com/netwide-assembler/nasm.git') + ->withMd5sum('42c4948349d01662811c8641fad4494c') + ->withDownloadWithOriginURL() + ->withPrefix($nasm_prefix) + ->withConfigure( + <<withPkgName('') + ->withLdflags('') + ->withBinPath($nasm_prefix . '/bin/') + ); +} + + +function install_libde265(Preprocessor $p) +{ + +} + +function install_svt_av1(Preprocessor $p) +{ +} + +function install_libheif(Preprocessor $p) +{ + +} + + +function install_graphite2(Preprocessor $p) +{ + $graphite2_prefix = "/usr/graphite2"; + $p->addLibrary( + (new Library('graphite2')) + ->withLicense('https://github.com/silnrsi/graphite/blob/master/COPYING', Library::LICENSE_SPEC) + ->withHomePage('http://graphite.sil.org/') + ->withUrl('https://github.com/silnrsi/graphite/archive/refs/tags/1.3.14.tar.gz') + ->withManual('https://github.com/silnrsi/graphite.git') + ->withFile('graphite-1.3.14.tar.gz') + ->withLabel('library') + ->withPrefix($graphite2_prefix) + + ->withConfigure( + " + mkdir -p build + cd build + cmake .. \ + -DCMAKE_INSTALL_PREFIX={$graphite2_prefix} \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=OFF + " + ) + ->withPkgName('graphite2') + ); +} + +function install_libfribidi(Preprocessor $p) +{ +} + +function install_harfbuzz(Preprocessor $p) +{ +} + +function install_libgd2($p) +{ +} + +function install_librsvg($p) +{ + $librsvg_prefix = LIBRSVG_PREFIX; + + $lib = new Library('librsvg'); + $lib->withHomePage('https://gitlab.gnome.org/GNOME/librsvg') + ->withLicense('https://gitlab.gnome.org/GNOME/librsvg/-/blob/main/COPYING.LIB', Library::LICENSE_LGPL) + ->withUrl('https://gitlab.gnome.org/GNOME/librsvg') + ->withManual('https://gitlab.gnome.org/GNOME/librsvg') + ->withFile('librsvg-v2.56.0') + ->withDownloadScript( + 'librsvg', + <<withPrefix($librsvg_prefix) + ->withConfigure( + <<withPkgName('librsvg'); + + $p->addLibrary($lib); +} + +function install_GraphicsMagick($p) +{ + $libiconv_prefix = ICONV_PREFIX; + $GraphicsMagick_prefix = '/usr/GraphicsMagick'; + $lib = new Library('GraphicsMagick'); + $lib->withHomePage('http://www.graphicsmagick.org/index.html') + ->withLicense('https://github.com/libgd/libgd/blob/master/COPYING', Library::LICENSE_SPEC) + ->withUrl( + 'https://jaist.dl.sourceforge.net/project/graphicsmagick/graphicsmagick/1.3.40/GraphicsMagick-1.3.40.tar.gz' + ) + ->withManual('http://www.graphicsmagick.org/README.html') + ->withManual('http://www.graphicsmagick.org/INSTALL-unix.html') + ->withPrefix($GraphicsMagick_prefix) + ->withConfigure( + <<<'EOF' + # 下载依赖 + ./configure --help + # -lbrotlicommon-static -lbrotlidec-static -lbrotlienc-static + export CPPFLAGS="$(pkg-config --cflags-only-I --static zlib libpng freetype2 libjpeg libturbojpeg libwebp libwebpdecoder libwebpdemux libwebpmux libbrotlicommon libbrotlidec libbrotlienc ) " \ + export LDFLAGS="$(pkg-config --libs-only-L --static zlib libpng freetype2 libjpeg libturbojpeg libwebp libwebpdecoder libwebpdemux libwebpmux libbrotlicommon libbrotlidec libbrotlienc ) " \ + export LIBS="$(pkg-config --libs-only-l --static zlib libpng freetype2 libjpeg libturbojpeg libwebp libwebpdecoder libwebpdemux libwebpmux libbrotlicommon libbrotlidec libbrotlienc ) " \ + + echo $LIBS + +EOF. PHP_EOL . <<withMakeInstallCommand('') + ->withPkgName('GraphicsMagick'); + + $p->addLibrary($lib); +} + + +function install_libXpm(Preprocessor $p) +{ + $libXpm_prefix = LIBXPM_PREFIX; + $lib = new Library('libXpm'); + $lib->withHomePage('https://github.com/freedesktop/libXpm.git') + ->withLicense('https://github.com/freedesktop/libXpm/blob/master/COPYING', Library::LICENSE_SPEC) + ->withUrl('https://github.com/freedesktop/libXpm/archive/refs/tags/libXpm-3.5.11.tar.gz') + ->withFile('libXpm-3.5.11.tar.gz') + ->withPrefix($libXpm_prefix) + ->withConfigure( + <<withPkgName('libXpm'); + + $p->addLibrary($lib); +} + + +function install_libOpenEXR(Preprocessor $p) +{ +} + +/** + * @param Preprocessor $p + * @return void + * 并发编程:SIMD 介绍 https://zhuanlan.zhihu.com/p/416172020 + */ +function install_highway(Preprocessor $p) +{ + $highway_prefix = '/usr/highway'; + $lib = new Library('highway'); + $lib->withHomePage('https://github.com/google/highway.git') + ->withLicense('https://github.com/google/highway/blob/master/LICENSE', Library::LICENSE_APACHE2) + ->withUrl('https://github.com/google/highway/archive/refs/tags/1.0.3.tar.gz') + ->withFile('highway-1.0.3.tar.gz') + ->withManual('https://github.com/google/highway.git') + ->withPrefix($highway_prefix) + ->withConfigure( + <<withPkgName('libhwy-contrib.pc libhwy-test.pc libhwy'); + + $p->addLibrary($lib); +} + +function install_libjxl(Preprocessor $p) +{ +} + + +function install_libedit(Preprocessor $p) +{ +} + + +function install_libdeflate(Preprocessor $p) +{ +} + + +function install_bzip2_dev_latest(Preprocessor $p) +{ + $p->addLibrary( + (new Library('bzip2', '/usr/bzip2')) + ->withUrl('https://gitlab.com/bzip2/bzip2/-/archive/master/bzip2-master.tar.gz') + + ->withConfigure( + ' + cmake .. -DCMAKE_BUILD_TYPE="Release" \ + -DCMAKE_INSTALL_PREFIX=/usr/bzip2 \ + -DENABLE_STATIC_LIB=ON ; + cmake --build . --target install ; + cd - ; + :; # shell空语句 + pwd + return 0 ; # 返回本函数调用处,本函数后续代码不在执行 + ' + ) + ->withLdflags('-L/usr/bzip2/lib') + ->withHomePage('https://www.sourceware.org/bzip2/') + ->withLicense('https://www.sourceware.org/bzip2/', Library::LICENSE_BSD) + ); +} + + +function install_libev($p) +{ +} + +function install_libtasn1($p) +{ +} + +function install_libexpat($p) +{ +} + +function install_unbound($p) +{ +} + +function install_gnutls($p) +{ + $note = <<addLibrary( + (new Library('boringssl')) + ->withHomePage('https://boringssl.googlesource.com/boringssl/') + ->withLicense( + 'https://boringssl.googlesource.com/boringssl/+/refs/heads/master/LICENSE', + Library::LICENSE_BSD + ) + ->withUrl('https://github.com/google/boringssl/archive/refs/heads/master.zip') + ->withFile('boringssl-latest.tar.gz') + ->withDownloadWithOriginURL() + ->withDownloadScript( + 'boringssl', + <<withMirrorUrl('https://boringssl.googlesource.com/boringssl') + ->withManual('https://boringssl.googlesource.com/boringssl/+/refs/heads/master/BUILDING.md') + ->withPrefix($boringssl_prefix) + ->withBuildScript( + <<disableDefaultPkgConfig() + //->withSkipBuildInstall() + ); +} + +function install_wolfssl($p) +{ + $wolfssl_prefix = WOLFSSL_PREFIX; + $p->addLibrary( + (new Library('wolfssl')) + ->withHomePage('https://github.com/wolfSSL/wolfssl.git') + ->withLicense('https://github.com/wolfSSL/wolfssl/blob/master/COPYING', Library::LICENSE_GPL) + ->withUrl('https://github.com/wolfSSL/wolfssl/archive/refs/tags/v5.5.4-stable.tar.gz') + ->withFile('wolfssl-v5.5.4-stable.tar.gz') + ->withManual('https://wolfssl.com/wolfSSL/Docs.html') + ->withPrefix($wolfssl_prefix) + ->withBuildScript( + <<withPkgName('wolfssl') + //->withSkipBuildInstall() + ); +} + +function install_libressl($p) +{ + $libressl_prefix = '/usr/libressl'; + $p->addLibrary( + (new Library('libressl')) + ->withHomePage('https://www.libressl.org/') + ->withLicense('https://github.com/wolfSSL/wolfssl/blob/master/COPYING', Library::LICENSE_GPL) + ->withUrl('https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.5.4.tar.gz') + ->withFile('libressl-3.5.4.tar.gz') + ->withManual('https://github.com/libressl/portable.git') + ->withPrefix($libressl_prefix) + ->withConfigure( + <<withPkgName('libressl') + //->withSkipBuildInstall() + ); +} + +function install_nghttp3(Preprocessor $p) +{ +} + +function install_ngtcp2(Preprocessor $p) +{ +} + + +function install_quiche(Preprocessor $p) +{ + $p->addLibrary( + (new Library('quiche')) + ->withHomePage('https://github.com/cloudflare/quiche') + ->withManual('https://curl.se/docs/http3.html') + ->withUrl('https://github.com/cloudflare/quiche/archive/refs/heads/master.zip') + ->withFile('latest-quiche.zip') + + ->withUntarArchiveCommand('unzip') + ->withPrefix('/usr/quiche') + ->withBuildScript( + ' + test -d /usr/quiche && rm -rf /usr/quiche + # export RUSTUP_DIST_SERVER=https://mirrors.tuna.edu.cn/rustup + # export RUSTUP_UPDATE_ROOT=https://mirrors.tuna.edu.cn/rustup/rustup + export http_proxy=http://192.168.3.26:8015 + export https_proxy=http://192.168.3.26:8015 + source /root/.cargo/env + cp -rf /work/pool/lib/boringssl /work/thirdparty/quiche/ + export OPENSSL_DIR=/usr/openssl + export OPENSSL_STATIC=Yes + + ' + ) + ->withConfigure( + ' + cd quiche-master + cargo build --help + + export QUICHE_BSSL_PATH=/work/thirdparty/quiche/boringssl + cargo build --package quiche --release --features ffi,pkg-config-meta,qlog + mkdir -p quiche/deps/boringssl/src/lib + ln -vnf $(find target/release -name libcrypto.a -o -name libssl.a) quiche/deps/boringssl/src/lib/ + exit 0 + + ' + ) + ->withLicense('https://github.com/cloudflare/quiche/blob/master/COPYING', Library::LICENSE_BSD) + ->withPkgName('quiche') + ); +} + +function install_msh3(Preprocessor $p) +{ + $p->addLibrary( + (new Library('msh3')) + ->withHomePage('https://github.com/nibanks/msh3') + ->withManual('https://github.com/nibanks/msh3.git') + ->withUrl('https://github.com/nibanks/msh3/archive/refs/heads/main.zip') + ->withFile('latest-msh3.zip') + ->withFile('msh3') + ->withSkipDownload() + // + ->withUntarArchiveCommand('') + ->withPrefix('/usr/msh3') + ->withBuildScript( + ' + cp -rf /work/pool/lib/msh3 /work/thirdparty/msh3 + apk add bsd-compat-headers + ' + ) + ->withConfigure( + <<withLicense('https://github.com/ngtcp2/ngtcp2/blob/main/COPYING', Library::LICENSE_MIT) + ->withPkgName('msh3') + ); +} + +function install_nghttp2(Preprocessor $p): void +{ +} + + +function install_libunistring($p) +{ +} + +function install_libintl(Preprocessor $p) +{ +} + +function install_gettext(Preprocessor $p) +{ +} + +function install_coreutils($p): void +{ + /* + glibc是一个核心C运行时库.它提供了像printf(3)和的东西fopen(3). + + glib 是一个用C编写的基于对象的事件循环和实用程序库. + + gnulib 是一个库,提供从POSIX API到本机API的适配器. + + coreutils 包括常用的命令,如 cat、ls、rm、chmod、mkdir、wc、whoami 和许多其他命令 + + */ +} + +function install_gnulib($p) +{ + /* + glibc是一个核心C运行时库.它提供了像printf(3)和的东西fopen(3). + + glib 是一个用C编写的基于对象的事件循环和实用程序库. + + gnulib 是一个库,提供从POSIX API到本机API的适配器. + + gnulib,也称为GNU Portability Library,是 GNU 代码的集合,用于帮助编写可移植代码。 + + */ +} + + +function install_libunwind($p) +{ +} + + +function install_jemalloc($p) +{ +} + +function install_tcmalloc($p) +{ +} + + +function install_libelf(Preprocessor $p) +{ +} + +function install_libbpf(Preprocessor $p) +{ +} + +function install_capstone(Preprocessor $p) +{ + $capstone_prefix = CAPSTONE_PREFIX; + $p->addLibrary( + (new Library('capstone')) + ->withHomePage('http://www.capstone-engine.org/') + ->withLicense('https://github.com/capstone-engine/capstone/blob/master/LICENSE.TXT', Library::LICENSE_BSD) + ->withUrl('https://github.com/capstone-engine/capstone/archive/refs/tags/4.0.2.tar.gz') + ->withManual('http://www.capstone-engine.org/documentation.html') + ->withPrefix($capstone_prefix) + ->withConfigure( + <<withScriptAfterInstall( + <<withPkgName('capstone') + ->withBinPath($capstone_prefix . '/bin/') + ); +} + +function install_dynasm(Preprocessor $p) +{ + $dynasm_prefix = DYNASM_PREFIX; + $p->addLibrary( + (new Library('dynasm')) + ->withHomePage('https://luajit.org/dynasm.html') + ->withLicense('https://www.opensource.org/licenses/mit-license.php', Library::LICENSE_MIT) + ->withUrl('https://luajit.org/download/LuaJIT-2.0.5.tar.gz') + ->withManual('https://luajit.org/download.html') + ->withTutorial('https://corsix.github.io/dynasm-doc/tutorial.html') + ->withPrefix($dynasm_prefix) + + ->withMakeOptions('PREFIX=' . $dynasm_prefix) + ->withMakeInstallOptions('PREFIX=' . $dynasm_prefix) //DESTDIR=/tmp/buildroot + + ->withPkgName('dynasm') + ->withBinPath($dynasm_prefix . '/bin/') + ); +} + +function install_valgrind(Preprocessor $p) +{ + $valgrind_prefix = VALGRIND_PREFIX; + $p->addLibrary( + (new Library('valgrind')) + ->withHomePage('https://valgrind.org/') + ->withLicense('http://www.gnu.org/licenses/gpl-2.0.html', Library::LICENSE_LGPL) + ->withUrl('https://sourceware.org/pub/valgrind/valgrind-3.20.0.tar.bz2') + ->withManual('https://valgrind.org/docs/man') + ->withPrefix($valgrind_prefix) + + ->withConfigure( + <<withScriptAfterInstall( + <<withPkgName('valgrind') + ->withBinPath($valgrind_prefix . '/bin/') + ); +} + +function install_snappy(Preprocessor $p) +{ +} + +function install_kerberos(Preprocessor $p) +{ + $p->addLibrary( + (new Library('kerberos')) + ->withHomePage('https://web.mit.edu/kerberos/') + ->withLicense('https://github.com/google/snappy/blob/main/COPYING', Library::LICENSE_BSD) + ->withUrl('https://kerberos.org/dist/krb5/1.20/krb5-1.20.1.tar.gz') + ->withFile('krb5-1.20.1.tar.gz') + ->withManual('https://web.mit.edu/kerberos/krb5-1.20/README-1.20.1.txt') + //源码包: doc/html/admin/install.html + ->withPrefix('/usr/kerberos') + + ->withConfigure( + <<withPkgName('kerberos') + ->withBinPath('/usr/kerberos/bin/') + ); +} + +function install_fontconfig(Preprocessor $p) +{ + $p->addLibrary( + (new Library('fontconfig')) + ->withHomePage('https://www.freedesktop.org/wiki/Software/fontconfig/') + ->withLicense('https://www.freedesktop.org/software/fontconfig/webfonts/Licen.TXT', Library::LICENSE_SPEC) + //->withUrl('https://gitlab.freedesktop.org/fontconfig/fontconfig/-/archive/main/fontconfig-main.tar.gz') + ->withUrl('https://gitlab.freedesktop.org/fontconfig/fontconfig/-/tags/2.14.2') + //download font https://www.freedesktop.org/software/fontconfig/webfonts/webfonts.tar.gz + ->withFile('fontconfig-2.14.2.tar.gz') + ->withManual('https://gitlab.freedesktop.org/fontconfig/fontconfig') + ->withPrefix('/usr/fontconfig') + + ->withConfigure( + <<withPkgName('fontconfig') + ->withBinPath('/usr/fontconfig/bin/') + ); +} + + +function install_p11_kit(Preprocessor $p) +{ + $p->addLibrary( + (new Library('p11_kit')) + ->withHomePage('https://github.com/p11-glue/p11-kit.git') + ->withLicense('https://github.com/p11-glue/p11-kit/blob/master/COPYING', Library::LICENSE_BSD) + ->withManual('https://p11-glue.github.io/p11-glue/p11-kit.html') + ->withManual('https://p11-glue.github.io/p11-glue/p11-kit/manual/devel-building.html') + ->withUrl('https://github.com/p11-glue/p11-kit/archive/refs/tags/0.24.1.tar.gz') + //构建选项参参考文档: https://mesonbuild.com/Builtin-options.html + ->withFile('p11-kit-0.24.1.tar.gz') + + ->withPrefix('/usr/p11_kit/') + ->withBuildScript( + ' + + # apk add python3 py3-pip gettext coreutils + # pip3 install meson -i https://pypi.tuna.tsinghua.edu.cn/simple + + + # ./autogen.sh --prefix=/usr/p11_kit/ --disable-trust-module --disable-debug + # ./configure --help + # --with-libtasn1 --with-libffi + + # meson setup -Dprefix=/usr/p11_kit/ -Dsystemd=disabled -Dbash_completion=disabled --reconfigure _build + # run "ninja reconfigure" or "meson setup --reconfigure" + # ninja reconfigure -C _build + # meson setup --reconfigure _build + + meson setup \ + -Dprefix=/usr/p11_kit/ \ + -Dsystemd=disabled \ + -Dbash_completion=disabled \ + -Dbackend=ninja \ + -Dbuildtype=release \ + -Ddefault_library=static \ + -Db_staticpic=true \ + -Db_pie=true \ + -Dprefer_static=true \ + -Ddebug=false \ + -Dstrict=true \ + -Dunity=off \ + _build + + + # meson setup --wipe + + # DESTDIR=/usr/p11_kit/ meson install -C _build + # meson install -C _build + + ninja -C _build + ninja -C _build install + + ' + ) + ->withPkgName('p11_kit') + ); +} + + +function install_pgsql_test(Preprocessor $p) +{ +} + + +function install_fastdfs($p) +{ + $p->addLibrary( + (new Library('fastdfs')) + ->withHomePage('https://github.com/happyfish100/fastdfs.git') + ->withLicense('https://github.com/happyfish100/fastdfs/blob/master/COPYING-3_0.txt', Library::LICENSE_GPL) + ->withUrl('https://github.com/happyfish100/fastdfs/archive/refs/tags/V6.9.4.tar.gz') + ->withFile('fastdfs-V6.9.4.tar.gz') + ->withPrefix('/usr/fastdfs/') + ->withConfigure( + ' + export DESTDIR=/usr/libserverframe/ + ./make.sh clean && ./make.sh && ./make.sh install + ./setup.sh /etc/fdfs + ' + ) + ->withPkgName('') + ->withPkgConfig('/usr/fastdfs//lib/pkgconfig') + ->withLdflags('-L/usr/fastdfs/lib/') + ->withBinPath('/usr/fastdfs/bin/') + ->withSkipBuildInstall() + //->withSkipInstall() + //->disablePkgName() + //->disableDefaultPkgConfig() + //->disableDefaultLdflags() + ); +} + +function install_libserverframe($p) +{ + $p->addLibrary( + (new Library('libserverframe')) + ->withHomePage('https://github.com/happyfish100/libserverframe') + ->withLicense('https://github.com/happyfish100/libserverframe/blob/master/LICENSE', Library::LICENSE_GPL) + ->withUrl('https://github.com/happyfish100/libserverframe/archive/refs/tags/V1.1.25.tar.gz') + ->withFile('libserverframe-V1.1.25.tar.gz') + ->withPrefix('/usr/libserverframe/') + ->withConfigure( + ' + export DESTDIR=/usr/libserverframe/ + ./make.sh clean && ./make.sh && ./make.sh install + ' + ) + ->withPkgName('') + ->withSkipBuildInstall() + //->disablePkgName() + //->disableDefaultPkgConfig() + //->disableDefaultLdflags() + ); +} + +function install_libfastcommon($p) +{ + $p->addLibrary( + (new Library('libfastcommon')) + ->withHomePage('https://github.com/happyfish100/libfastcommon') + ->withLicense('https://github.com/happyfish100/libfastcommon/blob/master/LICENSE', Library::LICENSE_GPL) + ->withUrl('https://github.com/happyfish100/libfastcommon/archive/refs/tags/V1.0.66.tar.gz') + ->withFile('libfastcommon-V1.0.66.tar.gz') + ->withPrefix('/usr/libfastcommon/') + + ->withConfigure( + ' + export DESTDIR=/usr/libfastcommon + ./make.sh clean && ./make.sh && ./make.sh install + exit 0 + ' + ) + ->withPkgName('') + ->withPkgConfig('/usr/libfastcommon/usr/lib/pkgconfig') + ->withLdflags('-L/usr/libfastcommon/usr/lib -L/usr/libfastcommon/usr/lib64') + //->disablePkgName() + //->disableDefaultPkgConfig() + //->disableDefaultLdflags() + ); +} + + +function install_jansson(Preprocessor $p) +{ +} + + +function install_php_internal_extension_curl_patch(Preprocessor $p) +{ +} + + +function install_libgomp(Preprocessor $p) +{ +} + +function install_libzip_ng(Preprocessor $p) +{ + $zlib_ng_prefix = '/usr/zlib_ng'; + $lib = new Library('zlib_ng'); + $lib->withHomePage('https://github.com/zlib-ng/zlib-ng.git') + ->withLicense('https://github.com/zlib-ng/minizip-ng/blob/master/LICENSE', Library::LICENSE_SPEC) + ->withUrl('https://github.com/zlib-ng/zlib-ng/archive/refs/tags/2.0.6.tar.gz') + ->withManual('https://github.com/zlib-ng/zlib-ng.git') + ->withPrefix($zlib_ng_prefix) + ->withConfigure( + <<withPkgName('zlib_ng'); + + $p->addLibrary($lib); +} + + +function install_zookeeper_client($p) +{ +} + + +function install_unixodbc(Preprocessor $p) +{ +} + + +function install_xorg_macros(Preprocessor $p) +{ +} + +function install_xorgproto(Preprocessor $p) +{ + $xorgproto_prefix = XORGPROTO_PREFIX; + $lib = new Library('xorgproto'); + $lib->withHomePage('xorgproto') + ->withLicense('https://gitlab.freedesktop.org/xorg/proto/xorgproto', Library::LICENSE_SPEC) + ->withManual('https://gitlab.freedesktop.org/xorg/proto/xorgproto/-/blob/master/INSTALL') + ->withUrl('https://gitlab.freedesktop.org/xorg/proto/xorgproto/-/archive/master/xorgproto-master.tar.gz') + ->withFile('xorgproto-2022.2.tar.gz') + ->withDownloadScript( + 'xorgproto', + <<withPrefix($xorgproto_prefix) + ->withBuildScript( + <<withLdflags(''); + + $p->addLibrary($lib); +} + +function install_libX11(Preprocessor $p) +{ + $libX11_prefix = LIBX11_PREFIX; + $lib = new Library('libX11'); + $lib->withHomePage('http://www.x.org/releases/current/doc/libX11/libX11/libX11.html') + ->withLicense('https://github.com/mirror/libX11/blob/master/COPYING', Library::LICENSE_SPEC) + ->withManual('http://www.x.org/releases/current/doc/libX11/libX11/libX11.html') + ->withUrl('https://github.com/mirror/libX11/archive/refs/tags/libX11-1.8.4.tar.gz') + ->withFile('libX11-1.8.4.tar.gz') + ->withPrefix($libX11_prefix) + + ->withConfigure( + <<withLdflags(''); + + $p->addLibrary($lib); +} + + +function install_opencl(Preprocessor $p) +{ +} + +function install_boost(Preprocessor $p) +{ +} diff --git a/sapi/src/library_builder/library_install_builder_tools.php b/sapi/src/library_builder/library_install_builder_tools.php new file mode 100644 index 0000000000..274cc0958f --- /dev/null +++ b/sapi/src/library_builder/library_install_builder_tools.php @@ -0,0 +1,390 @@ +addLibrary( + $lib = (new Library('ninja')) + ->withHomePage('https://ninja-build.org/') + //->withUrl('https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-linux.zip') + ->withUrl('https://github.com/ninja-build/ninja/archive/refs/tags/v1.11.1.tar.gz') + ->withFile('ninja-build-v1.11.1.tar.gz') + ->withLicense('https://github.com/ninja-build/ninja/blob/master/COPYING', Library::LICENSE_APACHE2) + ->withManual('https://ninja-build.org/manual.html') + ->withManual('https://github.com/ninja-build/ninja/wiki') + ->withPrefix($ninja_prefix) + ->withLabel('build_env_bin') + + //->withUntarArchiveCommand('unzip') + ->withBuildScript( + " + # apk add ninja + + # ./configure.py --bootstrap + + cmake -Bbuild-cmake + cmake --build build-cmake + mkdir -p {$ninja_prefix}/bin/ + cp build-cmake/ninja {$ninja_prefix}/bin/ + return 0 ; + ./configure.py --bootstrap + mkdir -p /usr/ninja/bin/ + cp ninja /usr/ninja/bin/ + return 0 ; + " + ) + ->withBinPath($ninja_prefix . '/bin/') + ->disableDefaultPkgConfig() + ->disableDefaultLdflags() + ->disablePkgName() + ->withSkipBuildInstall() + ); + + if ($p->getOsType() == 'macos') { + $lib->withUrl('https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-mac.zip'); + } +} + + +function install_musl(Preprocessor $p): void +{ + $workDir = $p->getWorkDir(); + $musl_libc_prefix = MUSL_LIBC_PREFIX; + $p->addLibrary( + (new Library('musl_libc')) + ->withHomePage('https://musl.libc.org/') + ->withLicense('https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT', Library::LICENSE_MIT) + ->withManual('https://musl.libc.org/manual.html') + ->withUrl('https://musl.libc.org/releases/musl-1.2.3.tar.gz') + ->withDownloadWithOriginURL() + ->withPrefix($musl_libc_prefix) + + ->withBuildScript( + <<withBinPath('$HOME/.cargo/bin') + ->disableDefaultPkgConfig() + ->disableDefaultLdflags() + ->disablePkgName() + ); +} +function install_musl_cross_make(Preprocessor $p): void +{ + $workDir = $p->getWorkDir(); + $musl_cross_make_prefix = MUSL_CROSS_MAKE_PREFIX; + $p->addLibrary( + (new Library('musl_cross_make')) + ->withHomePage('https://musl.libc.org/') + ->withLicense('https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT', Library::LICENSE_MIT) + ->withManual('https://musl.libc.org/manual.html') + ->withUrl('https://github.com/richfelker/musl-cross-make/archive/refs/tags/v0.9.9.tar.gz') + ->withFile('musl-cross-make-v0.9.9.tar.gz') + ->withDownloadScript( + 'musl-cross-make', + <<withDownloadWithOriginURL() + ->withPrefix($musl_cross_make_prefix) + + ->withBuildScript( + <<> config.mak <<_EOF_ +TARGET = x86_64-linux-musl +GCC_VER = 11.2.0 +COMMON_CONFIG += CFLAGS="-g0 -O3" CXXFLAGS="-g0 -O3" LDFLAGS="-s" +GCC_CONFIG += --enable-default-pie --enable-static-pie +_EOF_ + + +EOF + ) + ->withBinPath($musl_cross_make_prefix . '/bin/') + ->disableDefaultPkgConfig() + ->disableDefaultLdflags() + ->disablePkgName() + ); +} + +function install_rust(Preprocessor $p): void +{ + $workDir = $p->getWorkDir(); + $p->addLibrary( + (new Library('rust_lang')) + ->withHomePage('https://www.rust-lang.org') + ->withLicense('https://github.com/rust-lang/rust/blob/master/LICENSE-APACHE', Library::LICENSE_APACHE2) + ->withUrl('https://sh.rustup.rs') + ->withManual('https://www.rust-lang.org/tools/install') + ->withFile('rustup.sh') + ->withDownloadWithOriginURL() + ->withUntarArchiveCommand('mv') + + ->withBuildScript( + <<withBinPath('$HOME/.cargo/bin') + ->disableDefaultPkgConfig() + ->disableDefaultLdflags() + ->disablePkgName() + ); +} + +function install_nodejs(Preprocessor $p): void +{ + $workDir = $p->getWorkDir(); + $nodejs_prefix = NODEJS_PREFIX; + $p->addLibrary( + (new Library('nodejs_lang')) + ->withHomePage('https://nodejs.org/') + ->withLicense('https://github.com/rust-lang/rust/blob/master/LICENSE-APACHE', Library::LICENSE_SPEC) + ->withUrl('https://nodejs.org/dist/v20.9.0/node-v20.9.0-linux-x64.tar.xz') + ->withManual('https://nodejs.org/en/docs') + ->withDownloadWithOriginURL() + ->withUntarArchiveCommand('xz') + ->withBuildScript( + <<withBinPath($nodejs_prefix . '/bin/') + ->disableDefaultPkgConfig() + ->disableDefaultLdflags() + ->disablePkgName() + ); +} + +function install_golang(Preprocessor $p): void +{ + $golang_prefix = GOLANG_PREFIX; + $workDir = $p->getWorkDir(); + $p->addLibrary( + (new Library('golang')) + ->withHomePage('https://golang.org') + ->withLicense('https://github.com/golang/go/blob/master/LICENSE', Library::LICENSE_BSD) + ->withUrl('https://golang.google.cn/dl/go1.20.2.linux-amd64.tar.gz') + ->withManual('https://golang.google.cn/doc/') + ->withFile('go1.20.2.linux-amd64.tar.gz') + ->withDownloadWithOriginURL() + + ->withBuildScript( + <<withBinPath($golang_prefix . '/bin/') + ->disableDefaultPkgConfig() + ->disableDefaultLdflags() + ->disablePkgName() + ); +} + +function install_depot_tools(Preprocessor $p): void +{ +} + +function install_gn_test(Preprocessor $p): void +{ + $file = ''; + if ($p->getOsType() == 'linux') { + $file = 'https://chrome-infra-packages.appspot.com/dl/gn/gn/linux-amd64/+/latest'; + } + if ($p->getOsType() == 'macos') { + $file = 'https:chrome-infra-packages.appspot.com/dl/gn/gn/mac-amd64/+/latest'; + } + + $gn_prefix = '/usr/gn'; + $p->addLibrary( + (new Library('gn')) + ->withHomePage('https://gn.googlesource.com/gn') + ->withLicense('https://gn.googlesource.com/gn/+/refs/heads/main/LICENSE', Library::LICENSE_SPEC) + ->withUrl($file) + ->withFile('gn-latest.zip') + ->withManual('https://gn.googlesource.com/gn/') + ->withUntarArchiveCommand('unzip') + + ->withBuildScript( + " + chmod a+x gn + mkdir -p $gn_prefix/bin/ + cp -rf gn $gn_prefix/bin/ + " + ) + ->withBinPath($gn_prefix . '/bin/') + ->disableDefaultPkgConfig() + ->disableDefaultLdflags() + ->disablePkgName() + ); +} + +function install_gn(Preprocessor $p): void +{ + +} + + +function install_bazel(Preprocessor $p) +{ + /** + * alpine 无法直接用 bazel ,原因: alpine 使用 musl , Bazel 使用 glibc + * + * 需要把alpine 切换到 test 版本 + * https://pkgs.alpinelinux.org/package/edge/testing/x86_64/bazel4 + */ + $bazel_prefix = '/usr/bazel'; + $p->addLibrary( + (new Library('bazel')) + ->withHomePage('https://bazel.build') + ->withLicense('https://github.com/bazelbuild/bazel/blob/master/LICENSE', Library::LICENSE_APACHE2) + //->withUrl('https://github.com/bazelbuild/bazel/releases/download/6.0.0/bazel-6.0.0-linux-x86_64') + //->withUrl('https://github.com/bazelbuild/bazel/archive/refs/tags/6.0.0.tar.gz') + //->withFile('bazel-6.0.0.tar.gz') + ->withUrl( + 'https://github.com/bazelbuild/bazel/releases/download/7.0.0-pre.20230215.2/bazel-7.0.0-pre.20230215.2-dist.zip' + ) + ->withUntarArchiveCommand('unzip') + ->withManual('https://bazel.build/install') + ->withManual('https://bazel.build/install/compile-source') + ->withPrefix($bazel_prefix) + + ->withBuildScript( + ' + # apk add openjdk13-jdk bash zip + + # 会自动安装 libx11 libtasn1 p11_kit gnutls + + env EXTRA_BAZEL_ARGS="--tool_java_runtime_version=local_jdk" bash ./compile.sh + + + exit 0 + export PATH=$SYSTEM_ORIGIN_PATH + export PKG_CONFIG_PATH=$SYSTEM_ORIGIN_PKG_CONFIG_PATH + # 执行构建前 + + # 执行构建 + + # 执行构建后 + export PATH=$SWOOLE_CLI_PATH + export PKG_CONFIG_PATH=$SWOOLE_CLI_PKG_CONFIG_PATH + + + mv bazel /usr/bazel/bin/ + chmod a+x /usr/bazel/bin/bazel + /usr/bazel/bin/bazel -h + + ' + ) + ->withBinPath($bazel_prefix . '/bin/') + ->disableDefaultPkgConfig() + ->disablePkgName() + ->disableDefaultLdflags() + ); +} + + +function install_apache_ant(Preprocessor $p): void +{ + $example_prefix = EXAMPLE_PREFIX; + ; + $p->addLibrary( + (new Library('apache_ant')) + ->withHomePage('http://ant.apache.org/') + ->withLicense('https://www.apache.org/licenses/', Library::LICENSE_APACHE2) + ->withPrefix($example_prefix) + ->withBuildScript( + <<withBinPath($example_prefix . '/bin/') + ); +} + + +function install_apache_maven(Preprocessor $p): void +{ + $example_prefix = EXAMPLE_PREFIX; + ; + $p->addLibrary( + (new Library('maven')) + ->withHomePage('https://maven.apache.org/') + ->withLicense('https://www.apache.org/licenses/', Library::LICENSE_APACHE2) + ->withPrefix($example_prefix) + ->withBuildScript( + <<withBinPath($example_prefix . '/bin/') + ); +} diff --git a/sapi/src/library_builder/library_install_builder_vision.php b/sapi/src/library_builder/library_install_builder_vision.php new file mode 100644 index 0000000000..bd5c67f03d --- /dev/null +++ b/sapi/src/library_builder/library_install_builder_vision.php @@ -0,0 +1,134 @@ +withHomePage('https://www.graphviz.org/about/') + ->withLicense( + 'https://git.ffmpeg.org/gitweb/ffmpeg.git/blob/refs/heads/master:/LICENSE.md', + Library::LICENSE_LGPL + ) + ->withUrl('https://gitlab.com/graphviz/graphviz/-/archive/main/graphviz-main.tar.gz') + ->withUrl( + 'https://gitlab.com/api/v4/projects/4207231/packages/generic/graphviz-releases/8.0.2/graphviz-8.0.2.tar.gz' + ) + ->withManual('https://www.graphviz.org/download/') + ->withManual('https://www.graphviz.org/documentation/') + ->withFile('graphviz-8.0.2.tar.gz') + ->withDownloadScript( + 'graphviz', + <<withPrefix($graphviz_prefix) + + ->withConfigure( + <<withPkgName('libcdt') + ->withPkgName('libcgraph') + ->withPkgName('libgvc') + ->withPkgName('libgvpr') + ->withPkgName('liblab_gamut') + ->withPkgName('libpathplan') + ->withPkgName('libxdot') + ->withBinPath($graphviz_prefix . '/bin/'); + + $p->addLibrary($lib); +} + + +# https://mirrors.tuna.tsinghua.edu.cn/help/CTAN/ +function install_TeX(Preprocessor $p) +{ + $TeX_prefix = '/usr/TeX'; + $lib = new Library('TeX'); + $lib->withHomePage('https://www.ctan.org/') + ->withLicense( + 'https://git.ffmpeg.org/gitweb/ffmpeg.git/blob/refs/heads/master:/LICENSE.md', + Library::LICENSE_SPEC + ) + ->withUrl('https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet/install-tl.zip') + ->withManual('https://www.graphviz.org/download/') + ->withManual('https://www.graphviz.org/documentation/') + ->withUntarArchiveCommand('unzip') + ->withPrefix($TeX_prefix) + + ->withBuildScript( + <<withPkgName('') + ->withBinPath($TeX_prefix . '/bin/'); + + $p->addLibrary($lib); +} diff --git a/sapi/src/library_builder/onvif.md b/sapi/src/library_builder/onvif.md new file mode 100644 index 0000000000..73bcc40323 --- /dev/null +++ b/sapi/src/library_builder/onvif.md @@ -0,0 +1,6 @@ +rtsp/onvif 天生只适合局域网。要外网,云端存储使用,只能想办法转换,中转 + +2p ,端口映射,将 rtsp 转换成 rtmp ,或者使用 GBT28181 协议 + +28181 是摄像机端主动向服务器推流,而 onvif/rtsp 是服务器主动向摄像机拉流 + diff --git a/sapi/src/library_builder/openwrt.md b/sapi/src/library_builder/openwrt.md new file mode 100644 index 0000000000..3ccf2dc397 --- /dev/null +++ b/sapi/src/library_builder/openwrt.md @@ -0,0 +1,37 @@ +## download openwrt x86 + + https://downloads.openwrt.org/releases/ + + https://downloads.openwrt.org/releases/23.05.4/targets/x86/64/ + +## OpenWrt on VirtualBox + https://openwrt.org/docs/guide-user/virtualization/virtualbox-vm + +## virtualbox img 文件转换为 vdi +```shell + +# img 文件转换为 vdi + +VBoxManage convertfromraw --format VDI ~/Downloads/openwrt/openwrt-23.05.4-x86-64-generic-ext4-combined.img ~/Downloads/openwrt/openwrt-23.05.4-x86-64-generic-ext4-combined.vdi + +# 修改磁盘大小 +VBoxManage modifyhd --resize 8096 ~/Downloads/openwrt/openwrt-23.05.4-x86-64-generic-ext4-combined.vdi + +``` + +把云服务器系统 dd 成 openwrt ,当云路由器用 + +VirtualBox 上的 OpenWrt 操作指南 +https://openwrt.org/docs/guide-user/virtualization/virtualbox-vm#troubleshooting + +https://openwrt.org/docs/guide-user/installation/openwrt_x86 + + +https://archive.openwrt.org/releases/ + + +openwrt Virtualization +https://openwrt.org/docs/guide-user/virtualization/start + +VirtualBox 上的 OpenWrt 网络配置 +https://openwrt.org/docs/guide-user/virtualization/virtualbox-vm diff --git a/sapi/src/library_builder/proxy.md b/sapi/src/library_builder/proxy.md new file mode 100644 index 0000000000..06fd3c84bd --- /dev/null +++ b/sapi/src/library_builder/proxy.md @@ -0,0 +1,106 @@ +:< ~/.gitconfig <<==EOF +[https] +proxy = 'socks5://127.0.0.1:8015' +[http] +proxy = 'socks5://127.0.0.1:8015' +==EOF + + + + +cat > ~/.ssh/config <<==EOF +Host github.com +Hostname github.com +ServerAliveInterval 55 +ForwardAgent yes +ProxyCommand nc -X 5 -x 127.0.0.1:1080 %h %p +ProxyCommand nc -X connect -x localhost:8015 %h %p +proxycommand socat - PROXY:your.proxy.ip:%h:%p,proxyport=8015,proxyauth=user:pwd +==EOF + + + +git config --global -l +git config --global --list + +git config --global core.gitproxy "git-proxy" +git config --global socks.proxy "localhost:1080" + + +git config --global --unset http.proxy +git config --global --unset https.proxy +git config --global --unset core.gitproxy +git config --global --unset safe.directory /work + +nc -X 5 -x 127.0.0.1:1080 "$@" + + + + +export GIT_SSH_COMMAND='ssh -o ProxyCommand="nc -X 5 -x 127.0.0.1:1080 %h %p"' + + +git config --get --global core.gitproxy + +git config --global core.gitproxy "" + +git config --global core.gitproxy "git-proxy" +# git config --global core.gitproxy "/usr/bin/git-proxy" + +git config --global core.gitproxy "/work/bin/runtime/git-proxy" + +sed 's@directory = /work@@g' ~/.gitconfig + + +sh sapi/quickstart/deploy-git-proxy.sh + +# 参考 +# https://bryanbrattlof.com/how-to-proxy-git-connections/ + +# https://elinux.org/Using_git_with_a_proxy + +# shwo git clone information + +export GIT_TRACE_PACKET=1 +export GIT_TRACE=1 +export GIT_CURL_VERBOSE=1 + + +git-proxy: https://www.cnblogs.com/jingjingxyk/p/17669295.html + +git config --global core.gitproxy "/work/bin/runtime/git-proxy" + +git clone --depth=1 git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git + +git config --global core.gitproxy "" + +git config --get --global core.gitproxy + +# or + +export GIT_PROXY_COMMAND="/work/sapi/quickstart/git-proxy.sh" +git clone --depth=1 git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git + + + +## 与socat 有同样功能 的工具 + https://github.com/esrrhs/spp.git + +## 代理自动配置文件(PAC)文件 + https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Proxy_servers_and_tunneling/Proxy_Auto-Configuration_PAC_file diff --git a/sapi/src/library_builder/sdn.md b/sapi/src/library_builder/sdn.md new file mode 100644 index 0000000000..8982c77f8a --- /dev/null +++ b/sapi/src/library_builder/sdn.md @@ -0,0 +1,9 @@ + + + +网络的虚拟化技术主要分为三类: 网络虚拟化(NV)、网络设备虚拟化(NDV)和网络功能虚拟化(NFV) +VRRP+FRR 跑 VRF BGP OSPF EVPN +nqa bfd + +VRRP(Virtual Router Redundancy Protocol)虚拟路由冗余协议 +M-LAG(Multichassis Link Aggregation Group):跨设备链路聚合组。 diff --git a/sapi/src/library_builder/ungoogled-chromium.md b/sapi/src/library_builder/ungoogled-chromium.md new file mode 100644 index 0000000000..c98ec241dd --- /dev/null +++ b/sapi/src/library_builder/ungoogled-chromium.md @@ -0,0 +1,4 @@ +## ungoogled-chromium + + https://github.com/ungoogled-software/ungoogled-chromium + https://ungoogled-software.github.io/ungoogled-chromium-binaries/ diff --git a/sapi/src/library_builder/virtualbox.md b/sapi/src/library_builder/virtualbox.md new file mode 100644 index 0000000000..14915bae3c --- /dev/null +++ b/sapi/src/library_builder/virtualbox.md @@ -0,0 +1,22 @@ +https://www.virtualbox.org/wiki/Downloads + +下载包 +https://download.virtualbox.org/virtualbox/ + +共享目录 加载USB +https://www.virtualbox.org/manual/ch04.html + +network modes +https://www.virtualbox.org/manual/ch06.html + + +RemoteBox 是一个开源 VirtualBox 客户端 ,不是基于浏览器的 +https://remotebox.knobgoblin.org.uk/?page=about + +phpvirtualbox 是一个开源 WEB VirtualBox 客户端 +https://github.com/phpvirtualbox/phpvirtualbox.git +https://github.com/studnitskiy/phpvirtualbox.git + + +proxmox vs virtualbox +https://www.diskinternals.com/vmfs-recovery/proxmox-vs-virtualbox/ diff --git a/sapi/src/template/extension-dependency-graph.php b/sapi/src/template/extension_dependency_graph.php similarity index 100% rename from sapi/src/template/extension-dependency-graph.php rename to sapi/src/template/extension_dependency_graph.php diff --git a/sapi/src/template/make-export-variables.php b/sapi/src/template/make-export-variables.php index 4214f81f34..9044386927 100644 --- a/sapi/src/template/make-export-variables.php +++ b/sapi/src/template/make-export-variables.php @@ -1,3 +1,4 @@ +#!/usr/bin/env bash buildType, ['dev', 'debug'])) : ?> set -x diff --git a/sapi/src/template/make.php b/sapi/src/template/make.php index ceb77f6696..58893ebfe9 100755 --- a/sapi/src/template/make.php +++ b/sapi/src/template/make.php @@ -36,12 +36,14 @@ # 参考: https://www.php.net/manual/en/install.pecl.static.php OPTIONS="--disable-all \ ---disable-cgi \ ---enable-shared=no \ ---enable-static=yes \ ---without-valgrind \ ---enable-cli \ ---disable-phpdbg \ + --enable-shared=no \ + --enable-static=yes \ + --without-valgrind \ + --disable-cgi \ + --enable-cli \ + --disable-phpdbg \ + --with-config-file-path=getGlobalPrefix() ?>/etc/ \ + --with-config-file-scan-dir=getGlobalPrefix() ?>/etc/conf.d/ \ extensionList as $item) : ?> options?> \ @@ -64,62 +66,54 @@ enableInstallCached) : ?> - if [ -f getGlobalPrefix() . '/'. $item->name ?>/.completed ] ;then - echo "[name?>] library cached , skip.." + if [ -f getGlobalPrefix() . '/' . $item->name ?>/.completed ] ;then + echo "[name ?>] library cached , skip.." return 0 fi - # 默认不需要,当需要构建中间库时需要 - enableCompiledCached) : ?> - if [ -f getBuildDir()?>/name?>/.completed ]; then - echo "[name?>] compiled, skip.." - cd workDir ?>/ - return 0 - fi - + # If the install directory exist, clean the install directory + test -d getGlobalPrefix() . '/' . $item->name ?>/ && rm -rf getGlobalPrefix() . '/' . $item->name ?>/ ; - cleanBuildDirectory || !$item->enableBuildCached) : ?> + enableBuildCached) : ?> if [ -d getBuildDir()?>/name?>/ ]; then rm -rf getBuildDir()?>/name?>/ fi # If the source code directory does not exist, create a directory and decompress the source code archive - if [ ! -d getBuildDir()?>/name?> ]; then - mkdir -p getBuildDir()?>/name . PHP_EOL?> + if [ ! -d getBuildDir() ?>/name ?> ]; then + mkdir -p getBuildDir() ?>/name . PHP_EOL ?> + untarArchiveCommand == 'tar') :?> + tar --strip-components=1 -C getBuildDir() ?>/name ?> -xf workDir ?>/pool/lib/file ?>; + untarArchiveCommand == 'unzip') :?> + unzip -d getBuildDir()?>/name?> workDir?>/pool/lib/file ?>; + untarArchiveCommand == 'tar-default') :?> + tar -C getBuildDir() ?>/name ?> -xf workDir ?>/pool/lib/file ?>; + untarArchiveCommand == 'xz') :?> + xz -f -d -k workDir?>/pool/lib/file ?>; + tar --strip-components=1 -C getBuildDir()?>/name?> -xf workDir . '/pool/lib/' . $item->file, '.xz') ?>; + untarArchiveCommand == 'cp') : ?> + cp -rfa workDir?>/pool/lib/file?>/* getBuildDir()?>/name?>/; + untarArchiveCommand == 'mv') : ?> + cp -rfa workDir?>/pool/lib/file?> getBuildDir()?>/name?>/; + + result_code=$? + if [ $result_code -ne 0 ]; then + echo "[name?>] [configure FAILURE]" + rm -rf getBuildDir()?>/name?>/ + exit $result_code + fi fi - untarArchiveCommand == 'tar') : ?> - tar --strip-components=1 -C getBuildDir()?>/name?> -xf workDir?>/pool/lib/file . PHP_EOL?> - result_code=$? - if [ $result_code -ne 0 ]; then - echo "[name?>] [configure FAILURE]" - rm -rf getBuildDir()?>/name?>/ - exit $result_code - fi - - - untarArchiveCommand == 'unzip') : ?> - unzip -d getBuildDir()?>/name?> workDir?>/pool/lib/file?> - - untarArchiveCommand == 'xz') :?> - xz -f -d -k workDir?>/pool/lib/file?> - tar --strip-components=1 -C getBuildDir()?>/name?> -xf workDir . '/pool/lib/' . $item->file, '.xz') . PHP_EOL?> - - untarArchiveCommand == 'cp') : ?> - cp -rfa workDir?>/pool/lib/file?>/* getBuildDir()?>/name?>/ - - untarArchiveCommand == 'mv') : ?> - cp -rfa workDir?>/pool/lib/file?> getBuildDir()?>/name?>/ - cleanPreInstallDirectory) : ?> # If the install directory exist, clean the install directory test -d preInstallDirectory?>/ && rm -rf preInstallDirectory?>/ ; - cd getBuildDir()?>/name . PHP_EOL?> + cd getBuildDir()?>/name?>/ + enableEnv) : ?> if [ -f getWorkDir() ?>/.env ] ; then @@ -391,6 +385,12 @@ exit 0 + PHP_VERSION= ; + if [ ! -f "phpSrcDir ?>/X-PHP-VERSION" ] ; then + bash make.sh php ; + fi + test "${PHP_VERSION}" = "$(cat 'phpSrcDir ?>/X-PHP-VERSION')" || bash make.sh php ; + cd phpSrcDir ?>/ buildType, ['dev'])) : ?> # dev 环境 过滤扩展,便于调试单个扩展编译 @@ -398,8 +398,9 @@ cd phpSrcDir ?>/ + set -x # 添加非内置扩展 - if [ ! -z "$(ls -A ${__PROJECT_DIR__}/ext/)" ] ;then + if [[ -d "${__PROJECT_DIR__}/ext/" ]] && [[ ! -z "$(ls -A ${__PROJECT_DIR__}/ext/)" ]] ;then cp -rf ${__PROJECT_DIR__}/ext/* phpSrcDir ?>/ext/ fi @@ -414,6 +415,15 @@ ./configure --help +getInputOption('with-swoole-cli-sfx')) : ?> + PHP_VERSION=$(cat main/php_version.h | grep 'PHP_VERSION_ID' | grep -E -o "[0-9]+") + if [[ $PHP_VERSION -lt 80000 ]] ; then + echo "only support PHP >= 8.0 " + else + # 请把这个做成 patch https://github.com/swoole/swoole-cli/pull/55/files + fi + + ./configure $OPTIONS :<<'_____EO_____' @@ -472,10 +482,19 @@ # ll /Library/Developer/CommandLineTools/ # /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk +isMacos()) : ?> + hasLibrary('pgsql')) : ?> + sed -i.backup "s/ac_cv_func_explicit_bzero\" = xyes/ac_cv_func_explicit_bzero\" = x_fake_yes/" ./configure + test -f ./configure.backup && rm -f ./configure.backup + + + export_variables - echo $LDFLAGS > getRootDir() ?>/ldflags.log - echo $CPPFLAGS > getRootDir() ?>/cppflags.log - echo $LIBS > getRootDir() ?>/libs.log + export LDFLAGS="$LDFLAGS extraLdflags ?>" + export EXTRA_CFLAGS='extraCflags ?>' + echo $LDFLAGS > getWorkDir() ?>/ldflags.log + echo $CPPFLAGS > getWorkDir() ?>/cppflags.log + echo $LIBS > getWorkDir() ?>/libs.log ./configure --help ./configure --help | grep -e '--enable' @@ -494,6 +513,11 @@ // -Wl,–whole-archive -Wl,–start-group a.o b.o c.o main.o -lf -ld -le -L./ -lc -Wl,–end-group -Wl,-no-whole-archive +isLinux()) : ?> + sed -i.backup 's/-export-dynamic/-all-static/g' Makefile + test -f Makefile.backup && rm -f Makefile.backup + + # LIBS=" $LIBS -Wl,--whole-archive -Wl,--start-group " # LIBS=" -Wl,--start-group " @@ -555,11 +579,13 @@ file phpSrcDir ?>/sapi/cli/php readelf -h phpSrcDir ?>/sapi/cli/php + # make install mkdir -p /bin/ cp -f phpSrcDir ?>/sapi/cli/php /bin/ echo "phpSrcDir ?>/sapi/cli/php -v" phpSrcDir ?>/sapi/cli/php -v + phpSrcDir ?>/sapi/cli/php -m echo "/bin/php -v" /bin/php -v @@ -580,6 +606,10 @@ PHP_CLI_FILE_DEBUG=php-cli-v${PHP_VERSION}-getOsType()?>-getSystemArch()?>-debug.tar.xz tar -cJvf ${PHP_CLI_FILE_DEBUG} php LICENSE + HASH=$(sha256sum ${PHP_CLI_FILE_DEBUG} | awk '{print $1}') + echo " ${PHP_CLI_FILE_DEBUG} sha256sum: ${HASH} " + echo -n ${HASH} > ${PHP_CLI_FILE_DEBUG}.sha256sum + mkdir -p /bin/dist cp -f php dist/ @@ -590,8 +620,15 @@ PHP_CLI_FILE=php-cli-v${PHP_VERSION}-getOsType()?>-getSystemArch()?>.tar.xz tar -cJvf ${PHP_CLI_FILE} php LICENSE + HASH=$(sha256sum ${PHP_CLI_FILE} | awk '{print $1}') + echo " ${PHP_CLI_FILE} sha256sum: ${HASH} " + echo -n ${HASH} > ${PHP_CLI_FILE}.sha256sum + + mv /bin/dist/${PHP_CLI_FILE} ${__PROJECT_DIR__}/ + mv /bin/dist/${PHP_CLI_FILE}.sha256sum ${__PROJECT_DIR__}/ mv /bin/${PHP_CLI_FILE_DEBUG} ${__PROJECT_DIR__}/ + mv /bin/${PHP_CLI_FILE_DEBUG}.sha256sum ${__PROJECT_DIR__}/ cd ${__PROJECT_DIR__}/ } @@ -639,7 +676,7 @@ if test -n "$1" ;then echo -e "[$1] dependent pkgs :\n\n${array_name[$1]} \n" else - for i in ${!array_name[@]} + for i in "${!array_name[@]}" do echo -e "[${i}] dependent pkgs :\n\n${array_name[$i]} \n" echo "==================================================" @@ -680,7 +717,6 @@ help() { - set +x echo "./make.sh docker-build [ china | ustc | tuna ]" echo "./make.sh docker-bash" echo "./make.sh docker-commit" @@ -715,15 +751,25 @@ if [ -n "$2" ]; then MIRROR=$2 case "$MIRROR" in - china | openatom | ustc | tuna) + china | openatom ) CONTAINER_BASE_IMAGE="hub.atomgit.com/library/alpine:3.18" ;; 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}" --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/sapi/tools/brew-python3-init.sh b/sapi/tools/brew-python3-init.sh new file mode 100644 index 0000000000..9173004095 --- /dev/null +++ b/sapi/tools/brew-python3-init.sh @@ -0,0 +1,78 @@ + +HOMEBREW_PREFIX=$(brew --prefix) + +brew install python3 + +export PATH=${HOMEBREW_PREFIX}/opt/python@3/bin:${HOMEBREW_PREFIX}/opt/python@3/libexec/bin:$PATH + +export PYTHONPATH=$(python -c "import site, os; print(os.path.join(site.USER_BASE, 'lib', 'python', 'site-packages'))"):$PYTHONPATH +X_PYTHON_BIN=$(python -c "import site, os; print(os.path.join(site.USER_BASE, 'bin'))") +export PATH=${X_PYTHON_BIN}:$PATH + + +case "$MIRROR" in +china | tuna | ustc) + pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple + test "$MIRROR" = "ustc" && pip3 config set global.index-url https://mirrors.ustc.edu.cn/pypi/web/simple + ;; +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 + + +which python +which pip +python --version +pip --version + +python -c "import site; print(site.USER_BASE)" +pip list +which meson +which ninja + +# python3 -m pip install --upgrade pip +# python3 -m pip install meson -i https://mirrors.ustc.edu.cn/pypi/web/simple +# curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py + + +exit 0 + +# for macos-12 + +python -m ensurepip --default-pip --upgrade --user + +python -m pip --version +python -m pip install meson --user +python -m pip install ninja --user +python -m pip list + + +# pip install meson +# pip3 install --user meson + + + +if [ ${WITH_UPDATE} -eq 1 ] ; then + case "$MIRROR" in + china|ustc) + brew tap --custom-remote --force-auto-update homebrew/cask https://mirrors.ustc.edu.cn/homebrew-cask.git + brew tap --custom-remote --force-auto-update homebrew/cask-versions https://mirrors.ustc.edu.cn/homebrew-cask-versions.git + brew tap --custom-remote --force-auto-update homebrew/services https://mirrors.ustc.edu.cn/homebrew-services.git + + # 参考文档: https://help.mirrors.cernet.edu.cn/homebrew/ + # reset + # brew tap --custom-remote --force-auto-update homebrew/cask https://github.com/Homebrew/homebrew-cask + # brew tap --custom-remote --force-auto-update homebrew/cask-versions https://github.com/Homebrew/homebrew-cask-versions + # brew tap --custom-remote --force-auto-update homebrew/services https://mirrors.ustc.edu.cn/homebrew-services.git + ;; + esac + + brew doctor + brew update + brew upgrade + + exit 0 + +fi diff --git a/sapi/tools/build-libpq.sh b/sapi/tools/build-libpq.sh new file mode 100644 index 0000000000..625e5fed51 --- /dev/null +++ b/sapi/tools/build-libpq.sh @@ -0,0 +1,7 @@ +make -C src/bin install +make -C src/include install +make -C src/interfaces install +make -C src/common install +make -C src/port install +make -C doc install + diff --git a/sapi/tools/build-swoole-cli-alpine-container.sh b/sapi/tools/build-swoole-cli-alpine-container.sh new file mode 100644 index 0000000000..5add653ae3 --- /dev/null +++ b/sapi/tools/build-swoole-cli-alpine-container.sh @@ -0,0 +1,116 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=$( + cd ${__DIR__}/../../ + pwd +) + +cd ${__DIR__} +cd ${__PROJECT__} + +test -d var/build-swoole-cli-container/ && rm -rf var/build-swoole-cli-container/ +mkdir -p var/build-swoole-cli-container/ +cd ${__PROJECT__}/var/build-swoole-cli-container/ + +cp ${__PROJECT__}/setup-swoole-cli-runtime.sh . +#bash setup-swoole-cli-runtime.sh --proxy socks5h://127.0.0.1:7890 +bash setup-swoole-cli-runtime.sh --proxy http://172.23.24.221:8010 --version v5.1.6.0 + +exit 0 + +cat >php.ini <<'EOF' +curl.cainfo="/usr/local/swoole-cli/etc/cacert.pem" +openssl.cafile="/usr/local/swoole-cli/etc/cacert.pem" +swoole.use_shortname=off +display_errors = On +error_reporting = E_ALL + +upload_max_filesize="128M" +post_max_size="128M" +memory_limit="1G" +date.timezone="UTC" + +opcache.enable=On +opcache.enable_cli=On +opcache.jit=1225 +opcache.jit_buffer_size=128M + +; jit 更多配置参考 https://mp.weixin.qq.com/s/Tm-6XVGQSlz0vDENLB3ylA + +expose_php=Off +apc.enable_cli=1 + +EOF + +cat >Dockerfile <<'EOF' +FROM alpine:3.20 + +ENV TZ=Etc/UTC +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +RUN mkdir -p /usr/local/swoole-cli/etc/conf.d/ +ADD ./bin/runtime/swoole-cli /usr/local/bin/ +ADD ./bin/runtime/composer /usr/local/bin/ +ADD ./bin/runtime/cacert.pem /usr/local/swoole-cli/etc/ +ADD ./php.ini /usr/local/swoole-cli/etc/ + +RUN chmod a+x /usr/local/bin/swoole-cli +RUN chmod a+x /usr/local/bin/composer +RUN ln -sf /usr/local/bin/swoole-cli /usr/local/bin/php + +ARG MIRROR="" +RUN test -f /etc/apk/repositories.save || 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 add ca-certificates tini + +RUN mkdir /work +WORKDIR /work +ENTRYPOINT ["tini", "--"] + +EOF + +PLATFORM='' +ARCH=$(uname -m) +case $ARCH in +'x86_64') + PLATFORM='linux/amd64' + ;; +'aarch64') + PLATFORM='linux/arm64' + ;; +esac + +while [ $# -gt 0 ]; do + case "$1" in + --platform) + PLATFORM="$2" + ;; + --*) + echo "Illegal option $1" + ;; + esac + shift $(($# > 0 ? 1 : 0)) +done + +TIME=$(date -u '+%Y%m%dT%H%M%SZ') +ARCH=$(uname -m) +VERSION="1.0.0" +TAG="alpine-3.20-v${VERSION}-${ARCH}-${TIME}" +IMAGE="docker.io/jingjingxyk/swoole-cli:${TAG}" + +MIRROR='china' +docker buildx build -t ${IMAGE} -f ./Dockerfile . --platform ${PLATFORM} --build-arg="MIRROR=${MIRROR}" + +echo ${IMAGE} +docker save -o "swoole-cli-image.tar" ${IMAGE} + +docker run --rm --name demo ${IMAGE} swoole-cli -v +docker run --rm --name demo ${IMAGE} swoole-cli -m +docker run --rm --name demo ${IMAGE} swoole-cli --ri swoole diff --git a/sapi/tools/download-phar.sh b/sapi/tools/download-phar.sh new file mode 100644 index 0000000000..8ff6849637 --- /dev/null +++ b/sapi/tools/download-phar.sh @@ -0,0 +1,79 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +cd ${__DIR__}/ + +__PROJECT__=$( + cd ${__DIR__}/../../ ; + pwd +) + + +mkdir -p ${__PROJECT__}/var/ +cd ${__PROJECT__}/var/ + +while [ $# -gt 0 ]; do + case "$1" in + --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" + 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" + ;; + esac + shift $(($# > 0 ? 1 : 0)) +done + +# box +# https://github.com/box-project/box/blob/main/doc/installation.md#installation + +# phive +# https://github.com/phar-io/phive + +# comopser +# https://getcomposer.org/ + +# PIE +# https://github.com/php/pie/blob/main/docs/usage.md +# https://packagist.org/extensions? + +test -f box.phar || curl -Lo box.phar "https://github.com/box-project/box/releases/latest/download/box.phar" +chmod +x box.phar + +test -f phive.phar || curl -Lo phive.phar "https://phar.io/releases/phive.phar" +chmod +x phive.phar + +test -f composer.phar || curl -Lo composer.phar https://getcomposer.org/download/latest-stable/composer.phar +chmod +x composer.phar + +test -f pie.phar || curl -Lo pie.phar https://github.com/php/pie/releases/latest/download/pie.phar +chmod +x pie.phar + +test -f captainhook.phar || curl -Lo https://github.com/captainhookphp/captainhook/releases/download/5.23.5/captainhook.phar +chmod +x captainhook.phar + +export PATH="${__PROJECT__}/bin/runtime:$PATH" +# shellcheck disable=SC2139 +#alias php="'php -d curl.cainfo=${__PROJECT__}/bin/runtime/cacert.pem -d openssl.cafile=${__PROJECT__}/bin/runtime/cacert.pem'" +alias php="'php -c ${__PROJECT__}/bin/runtime/php.ini'" +which php +php -v + + +./box.phar help +./box.phar list + +./phive.phar --help +./composer.phar --help +./pie.phar --help diff --git a/sapi/tools/download-xcode.md b/sapi/tools/download-xcode.md new file mode 100644 index 0000000000..fa56a6cbfa --- /dev/null +++ b/sapi/tools/download-xcode.md @@ -0,0 +1,43 @@ +# search xcode + + https://developer.apple.com/download/all/?q=xcode + +# download xcode + +> Xcode下载需要登录‌ + +```text + +https://developer.apple.com/documentation/xcode-release-notes/xcode-14_2-release-notes + +https://download.developer.apple.com/Developer_Tools/Xcode_14.2/Xcode_14.2.xip + + +https://download.developer.apple.com/Developer_Tools/Xcode_14.0.1/Xcode_14.0.1.xip + +https://download.developer.apple.com/Developer_Tools/Xcode_14.0.1_Release_Candidate/Xcode_14.0.1_Release_Candidate.xip + + + + +``` + +```shell + +# sudo rm -rf /Library/Developer/CommandLineTools + # 安装命令行工具 +# xcode-select --install + +# sudo xcode-select --reset +# sudo xcode-select -switch /Library/Developer/CommandLineTools +# sudo xcode-select --switch /Applications/Xcode.app +# xcode-select --install +# export SDKROOT=$(xcrun --show-sdk-path) +# export MACOSX_DEPLOYMENT_TARGET=12.6 + +# 查看可更新的软件 + +# softwareupdate --list --verbose +# softwareupdate --install --all + +``` diff --git a/sapi/tools/genereate-php-extension-example.sh b/sapi/tools/genereate-php-extension-example.sh new file mode 100644 index 0000000000..a0a0fe5f3d --- /dev/null +++ b/sapi/tools/genereate-php-extension-example.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + + +:<<'COMMENT' + +创建 PHP 扩展 辅助工具 + +COMMENT + +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +if [ -f ${__DIR__}/prepare.php ] ; then + __PROJECT__=$( + cd ${__DIR__}/ + pwd + ) +else + __PROJECT__=$( + cd ${__DIR__}/../../ + pwd + ) +fi + +cd ${__DIR__} + + +export PATH="${__PROJECT__}/bin/runtime:$PATH" + +alias php="'php -c ${__PROJECT__}/bin/runtime/php.ini'" + +php ${__PROJECT__}/sapi/scripts/download-php-src-archive.php + + +php ${__PROJECT__}/var/php-8.2.23/ext/ext_skel.php --help + +# 创建扩展 +# 使用 `--dir ${__PROJECT__}/../ ` # 指定生成扩展的目录 + +php ${__PROJECT__}/var/php-8.2.23/ext/ext_skel.php --ext example --author jingjingxyk --std + diff --git a/sapi/tools/gpg-verify.sh b/sapi/tools/gpg-verify.sh new file mode 100644 index 0000000000..272886e7a2 --- /dev/null +++ b/sapi/tools/gpg-verify.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=$( + cd ${__DIR__}/../../ + pwd +) +cd ${__PROJECT__} + +mkdir -p ${__PROJECT__}/var/gnupg-verify + +cd ${__PROJECT__}/var/gnupg-verify + +# curl https://www.gnu.org/usenet/usenet-gpg-key.txt +# https://ftp.gnu.org/gnu/gnu-keyring.gpg + +# test -f gnu-keyring.gpg || curl -Lo gnu-keyring.gpg https://ftp.gnu.org/gnu/gnu-keyring.gpg +test -f gnu-keyring.gpg || curl -Lo gnu-keyring.gpg https://ftpmirror.gnu.org/gnu/gnu-keyring.gpg +# test -f libiconv-1.17.tar.gz.sig || curl -Lo libiconv-1.17.tar.gz.sig https://ftp.gnu.org/gnu/libiconv/libiconv-1.17.tar.gz.sig +test -f libiconv-1.17.tar.gz.sig || curl -Lo libiconv-1.17.tar.gz.sig https://ftpmirror.gnu.org/gnu/libiconv/libiconv-1.17.tar.gz.sig + +{ + gpg --import gnu-keyring.gpg +} || { + echo $? +} + +# gpg --verify file.sig file +gpg --verify libiconv-1.17.tar.gz.sig ${__PROJECT__}/pool/lib/libiconv-1.17.tar.gz diff --git a/sapi/tools/openwrt-virtualbox.sh b/sapi/tools/openwrt-virtualbox.sh new file mode 100644 index 0000000000..685985757d --- /dev/null +++ b/sapi/tools/openwrt-virtualbox.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=$( + cd ${__DIR__}/../../ + pwd +) +cd ${__PROJECT__} + +while [ $# -gt 0 ]; do + case "$1" in + --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" + NO_PROXY="${NO_PROXY},127.0.0.1,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},.npmmirror.com" + export NO_PROXY="${NO_PROXY}" + ;; + + --*) + echo "Illegal option $1" + ;; + esac + shift $(($# > 0 ? 1 : 0)) +done + +mkdir -p ${__PROJECT__}/var/openwrt/ + +cd ${__PROJECT__}/var/openwrt/ + +# 参考 +# https://openwrt.org/docs/guide-user/virtualization/virtualbox-vm#troubleshooting + +test -f openwrt-23.05.5-x86-64-generic-ext4-combined.img.gz || curl -fSLo openwrt-23.05.5-x86-64-generic-ext4-combined.img.gz https://archive.openwrt.org/releases/23.05.5/targets/x86/64/openwrt-23.05.5-x86-64-generic-ext4-combined.img.gz + +test -f openwrt-23.05.5-x86-64-generic-ext4-combined.img || gunzip openwrt-*.img.gz +test -f openwrt.img && rm -f openwrt.img +dd if=openwrt-23.05.5-x86-64-generic-ext4-combined.img of=openwrt.img bs=128000 conv=sync + +test -f openwrt.vdi && rm -f openwrt.vdi +VBoxManage convertfromraw --format VDI openwrt.img openwrt.vdi +# VBoxManage modifymedium openwrt.vdi --resize 128 + + diff --git a/sapi/quickstart/setup-shm.sh b/sapi/tools/setup-shm.sh similarity index 73% rename from sapi/quickstart/setup-shm.sh rename to sapi/tools/setup-shm.sh index 7fff5b50ca..e0a52fb360 100644 --- a/sapi/quickstart/setup-shm.sh +++ b/sapi/tools/setup-shm.sh @@ -19,14 +19,9 @@ cd ${__PROJECT__} # du -h -d 1 /dev/shm # df -h /dev/shm - exit 0 -for dir in `ls -d ${__PROJECT__}` -do - for file in `ls -R $dir` - do - echo $file - done +for dir in $(ls -d ${__PROJECT__}); do + for file in $(ls -R $dir); do + echo $file + done done - - diff --git a/setup-aria2-runtime.sh b/setup-aria2-runtime.sh new file mode 100644 index 0000000000..f4dcc8dfcd --- /dev/null +++ b/setup-aria2-runtime.sh @@ -0,0 +1,137 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=${__DIR__} + +cd ${__PROJECT__} + +OS=$(uname -s) +ARCH=$(uname -m) + +case $OS in +'Linux') + OS="linux" + ;; +'Darwin') + OS="macos" + ;; +*) + case $OS in + 'MSYS_NT'* | 'CYGWIN_NT'* ) + OS="windows" + ;; + 'MINGW64_NT'*) + OS="windows" + ;; + *) + echo '暂未配置的 OS ' + exit 0 + ;; + esac + ;; +esac + +case $ARCH in +'x86_64') + ARCH="x64" + ;; +'aarch64' | 'arm64' ) + ARCH="arm64" + ;; +*) + echo '暂未配置的 ARCH ' + exit 0 + ;; +esac + +APP_VERSION='1.37.0' +APP_NAME='aria2c' +VERSION='v0.0.1' + +mkdir -p bin/runtime +mkdir -p var/runtime + +cd ${__PROJECT__}/var/runtime + +APP_DOWNLOAD_URL="https://github.com/jingjingxyk/build-static-aria2/releases/download/${VERSION}/${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}.tar.xz" +CACERT_DOWNLOAD_URL="https://curl.se/ca/cacert.pem" + +if [ $OS = 'windows' ]; then + APP_DOWNLOAD_URL="https://github.com/jingjingxyk/build-static-aria2/releases/download/${VERSION}/${APP_NAME}-${APP_VERSION}-vs2022-${ARCH}.zip" +fi + +MIRROR='' +while [ $# -gt 0 ]; do + case "$1" in + --mirror) + MIRROR="$2" + ;; + --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" + 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" + ;; + esac + shift $(($# > 0 ? 1 : 0)) +done + +case "$MIRROR" in +china) + APP_DOWNLOAD_URL="https://php-cli.jingjingxyk.com/${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}.tar.xz" + if [ $OS = 'windows' ]; then + APP_DOWNLOAD_URL="https://php-cli.jingjingxyk.com/${APP_NAME}-${APP_VERSION}-vs2022-${ARCH}.zip" + fi + ;; + +esac + +test -f cacert.pem || curl -LSo cacert.pem ${CACERT_DOWNLOAD_URL} + +APP_RUNTIME="${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}" + +if [ $OS = 'windows' ]; then + { + APP_RUNTIME="${APP_NAME}-${APP_VERSION}-vs2022-${ARCH}" + test -f ${APP_RUNTIME}.zip || curl -LSo ${APP_RUNTIME}.zip ${APP_DOWNLOAD_URL} + test -d ${APP_RUNTIME} && rm -rf ${APP_RUNTIME} + unzip "${APP_RUNTIME}.zip" + exit 0 + } +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 ${APP_RUNTIME} && rm -rf ${APP_RUNTIME} + tar -xvf ${APP_RUNTIME}.tar + chmod a+x ${APP_NAME} + cp -rf ${__PROJECT__}/var/runtime/${APP_NAME} ${__PROJECT__}/bin/runtime/${APP_NAME} +fi + +cd ${__PROJECT__}/var/runtime + +cp -f ${__PROJECT__}/var/runtime/cacert.pem ${__PROJECT__}/bin/runtime/cacert.pem + + +cd ${__PROJECT__}/ + +set +x + +echo " " +echo " USE aria2 RUNTIME :" +echo " " +echo " export PATH=\"${__PROJECT__}/bin/runtime:\$PATH\" " +echo " " +echo " aria2 docs : https://aria2.github.io/ " +echo " " +export PATH="${__PROJECT__}/bin/runtime:$PATH" diff --git a/setup-coturn-runtime.sh b/setup-coturn-runtime.sh new file mode 100644 index 0000000000..2d527bd51b --- /dev/null +++ b/setup-coturn-runtime.sh @@ -0,0 +1,140 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=${__DIR__} + +cd ${__PROJECT__} + +OS=$(uname -s) +ARCH=$(uname -m) + +case $OS in +'Linux') + OS="linux" + ;; +'Darwin') + OS="macos" + ;; +*) + case $OS in + 'MSYS_NT'* | 'CYGWIN_NT'* ) + OS="windows" + ;; + 'MINGW64_NT'*) + OS="windows" + ;; + *) + echo '暂未配置的 OS ' + exit 0 + ;; + esac + ;; +esac + +case $ARCH in +'x86_64') + ARCH="x64" + ;; +'aarch64' | 'arm64' ) + ARCH="arm64" + ;; +*) + echo '暂未配置的 ARCH ' + exit 0 + ;; +esac + +APP_VERSION='4.6.2' +APP_NAME='coturn' +VERSION='v1.2.0' + +mkdir -p bin/runtime +mkdir -p var/runtime + +cd ${__PROJECT__}/var/runtime + +APP_DOWNLOAD_URL="https://github.com/jingjingxyk/build-static-coturn/releases/download/${VERSION}/${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}.tar.xz" +CACERT_DOWNLOAD_URL="https://curl.se/ca/cacert.pem" + +if [ $OS = 'windows' ]; then + APP_DOWNLOAD_URL="https://github.com/jingjingxyk/build-static-coturn/releases/download/${VERSION}/${APP_NAME}-${APP_VERSION}-vs2022-${ARCH}.zip" +fi + +MIRROR='' +while [ $# -gt 0 ]; do + case "$1" in + --mirror) + MIRROR="$2" + ;; + --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" + 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" + ;; + esac + shift $(($# > 0 ? 1 : 0)) +done + +case "$MIRROR" in +china) + APP_DOWNLOAD_URL="https://php-cli.jingjingxyk.com/${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}.tar.xz" + if [ $OS = 'windows' ]; then + APP_DOWNLOAD_URL="https://php-cli.jingjingxyk.com/${APP_NAME}-${APP_VERSION}-vs2022-${ARCH}.zip" + fi + ;; + +esac + +test -f cacert.pem || curl -LSo cacert.pem ${CACERT_DOWNLOAD_URL} + +APP_RUNTIME="${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}" + +if [ $OS = 'windows' ]; then + { + APP_RUNTIME="${APP_NAME}-${APP_VERSION}-vs2022-${ARCH}" + test -f ${APP_RUNTIME}.zip || curl -LSo ${APP_RUNTIME}.zip ${APP_DOWNLOAD_URL} + test -d ${APP_RUNTIME} && rm -rf ${APP_RUNTIME} + unzip "${APP_RUNTIME}.zip" + exit 0 + } +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 -d ${APP_RUNTIME} && rm -rf ${APP_RUNTIME} + tar -xvf ${APP_RUNTIME}.tar + chmod a+x ${APP_NAME}/bin/turnserver + mkdir -p ${__PROJECT__}/bin/runtime/${APP_NAME} + cp -rf ${__PROJECT__}/var/runtime/${APP_NAME}/* ${__PROJECT__}/bin/runtime/${APP_NAME} +fi + +cd ${__PROJECT__}/var/runtime + +cp -f ${__PROJECT__}/var/runtime/cacert.pem ${__PROJECT__}/bin/runtime/cacert.pem + + +cd ${__PROJECT__}/ + +set +x + +echo " " +echo " USE COTURN RUNTIME :" +echo " " +echo " export PATH=\"${__PROJECT__}/bin/runtime/coturn/bin/:\$PATH\" " +echo " " +echo " ./bin/runtime/coturn/bin/turnserver -c ./bin/runtime/coturn/etc/turnserver.conf " +echo " " +echo " coturn docs : https://github.com/coturn/coturn " +echo " " +export PATH="${__PROJECT__}/bin/runtime:$PATH" diff --git a/setup-ffmpeg-runtime.sh b/setup-ffmpeg-runtime.sh new file mode 100644 index 0000000000..1b86c41252 --- /dev/null +++ b/setup-ffmpeg-runtime.sh @@ -0,0 +1,139 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=${__DIR__} + +cd ${__PROJECT__} + +OS=$(uname -s) +ARCH=$(uname -m) + +case $OS in +'Linux') + OS="linux" + ;; +'Darwin') + OS="macos" + ;; +*) + case $OS in + 'MSYS_NT'* | 'CYGWIN_NT'* ) + OS="windows" + ;; + 'MINGW64_NT'*) + OS="windows" + ;; + *) + echo '暂未配置的 OS ' + exit 0 + ;; + esac + ;; +esac + +case $ARCH in +'x86_64') + ARCH="x64" + ;; +'aarch64' | 'arm64' ) + ARCH="arm64" + ;; +*) + echo '暂未配置的 ARCH ' + exit 0 + ;; +esac + +APP_VERSION='git-2024-03-27-6b21317' +APP_NAME='ffmpeg' +VERSION='v1.0.0' + +mkdir -p bin/runtime +mkdir -p var/runtime + +cd ${__PROJECT__}/var/runtime + +APP_DOWNLOAD_URL="https://github.com/jingjingxyk/build-static-ffmpeg/releases/download/${VERSION}/${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}.tar.xz" +CACERT_DOWNLOAD_URL="https://curl.se/ca/cacert.pem" + +if [ $OS = 'windows' ]; then + APP_DOWNLOAD_URL="https://github.com/jingjingxyk/build-static-ffmpeg/releases/download/${VERSION}/${APP_NAME}-${APP_VERSION}-vs2022-${ARCH}.zip" +fi + +MIRROR='' +while [ $# -gt 0 ]; do + case "$1" in + --mirror) + MIRROR="$2" + ;; + --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" + 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" + ;; + esac + shift $(($# > 0 ? 1 : 0)) +done + +case "$MIRROR" in +china) + APP_DOWNLOAD_URL="https://php-cli.jingjingxyk.com/${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}.tar.xz" + if [ $OS = 'windows' ]; then + APP_DOWNLOAD_URL="https://php-cli.jingjingxyk.com/${APP_NAME}-${APP_VERSION}-vs2022-${ARCH}.zip" + fi + ;; + +esac + +test -f cacert.pem || curl -LSo cacert.pem ${CACERT_DOWNLOAD_URL} + +APP_RUNTIME="${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}" + +if [ $OS = 'windows' ]; then + { + APP_RUNTIME="${APP_NAME}-${APP_VERSION}-vs2022-${ARCH}" + test -f ${APP_RUNTIME}.zip || curl -LSo ${APP_RUNTIME}.zip ${APP_DOWNLOAD_URL} + test -d ${APP_RUNTIME} && rm -rf ${APP_RUNTIME} + unzip "${APP_RUNTIME}.zip" + exit 0 + } +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 -d ${APP_NAME} && rm -rf ${APP_NAME} + tar -xvf ${APP_RUNTIME}.tar + chmod a+x ${APP_NAME}/bin/ffmpeg + cp -rf ${__PROJECT__}/var/runtime/${APP_NAME} ${__PROJECT__}/bin/runtime/${APP_NAME} +fi + +cd ${__PROJECT__}/var/runtime + +cp -f ${__PROJECT__}/var/runtime/cacert.pem ${__PROJECT__}/bin/runtime/cacert.pem + + +cd ${__PROJECT__}/ + +set +x + +echo " " +echo " USE FFMPEG RUNTIME :" +echo " " +echo " export PATH=\"${__PROJECT__}/bin/runtime:\$PATH\" " +echo " " +echo " ./bin/runtime/ffmpeg/bin/ffmpeg -h " +echo " " +echo " ffmpeg docs : https://ffmpeg.org/documentation.html " +echo " " +export PATH="${__PROJECT__}/bin/runtime:$PATH" diff --git a/setup-go-runtime.sh b/setup-go-runtime.sh new file mode 100644 index 0000000000..7d62acfd98 --- /dev/null +++ b/setup-go-runtime.sh @@ -0,0 +1,137 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=${__DIR__} + +cd ${__PROJECT__} + +OS=$(uname -s) +ARCH=$(uname -m) + +case $OS in +'Linux') + OS="linux" + ;; +'Darwin') + OS="darwin" + ;; +*) + case $OS in + 'MSYS_NT'*) + OS="windows" + ;; + 'MINGW64_NT'*) + OS="windows" + ;; + *) + echo '暂未配置的 OS ' + exit 0 + ;; + esac + ;; +esac + +case $ARCH in +'x86_64') + ARCH="amd64" + ;; +'aarch64' | 'arm64') + ARCH="arm64" + ;; +*) + echo '暂未配置的 ARCH ' + exit 0 + ;; +esac + +APP_VERSION='1.22.5' +APP_NAME='go' +VERSION='1.22.5' + +mkdir -p bin/runtime +mkdir -p var/runtime + +cd ${__PROJECT__}/var/runtime + +: <<'EOF' + +https://go.dev/dl/go1.22.5.windows-amd64.msi + +https://go.dev/dl/go1.22.5.darwin-arm64.pkg + +https://go.dev/dl/go1.22.5.darwin-amd64.pkg +https://go.dev/dl/go1.22.5.linux-amd64.tar.gz +https://go.dev/dl/go1.21.12.linux-arm64.tar.gz +https://go.dev/dl/go1.21.12.windows-amd64.zip +https://go.dev/dl/go1.21.12.darwin-arm64.tar.gz +https://go.dev/dl/go1.21.12.darwin-amd64.tar.gz + +EOF + +APP_DOWNLOAD_URL="https://go.dev/dl/${APP_NAME}${APP_VERSION}.${OS}-${ARCH}.tar.gz" + +if [ $OS = 'windows' ]; then + APP_DOWNLOAD_URL="https://go.dev/dl/${APP_NAME}${APP_VERSION}.${OS}-${ARCH}.zip" +fi + +MIRROR='' +while [ $# -gt 0 ]; do + case "$1" in + --mirror) + MIRROR="$2" + ;; + --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" + 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" + ;; + esac + shift $(($# > 0 ? 1 : 0)) +done + +case "$MIRROR" in +china) + APP_DOWNLOAD_URL="https://golang.google.cn/dl/${APP_NAME}${APP_VERSION}.${OS}-${ARCH}.tar.gz" + if [ $OS = 'windows' ]; then + APP_DOWNLOAD_URL="https://golang.google.cn/dl/${APP_NAME}${APP_VERSION}.${OS}-${ARCH}.zip" + fi + ;; +esac + +APP_RUNTIME="${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}" +if [ $OS = 'windows' ]; then + test -f ${APP_RUNTIME}.zip || curl -LSo ${APP_RUNTIME}.zip ${APP_DOWNLOAD_URL} + test -d ${APP_RUNTIME} && rm -rf ${APP_RUNTIME} + unzip "${APP_RUNTIME}.zip" + exit 0 +else + test -f ${APP_RUNTIME}.tar.gz || curl -LSo ${APP_RUNTIME}.tar.gz ${APP_DOWNLOAD_URL} + test -d ${APP_RUNTIME} && rm -rf ${APP_RUNTIME} + tar -xvf ${APP_RUNTIME}.tar.gz + test -d ${__PROJECT__}/bin/runtime/go && rm -rf ${__PROJECT__}/bin/runtime/go + mv go ${__PROJECT__}/bin/runtime/go +fi + +cd ${__PROJECT__}/ + +set +x + +echo " " +echo " USE PHP RUNTIME :" +echo " " +echo " export PATH=\"${__PROJECT__}/bin/runtime/go/bin/:\$PATH\" " +echo " " +export PATH="${__PROJECT__}/bin/runtime/go/bin/:$PATH" +go version diff --git a/setup-nginx-runtime.sh b/setup-nginx-runtime.sh new file mode 100644 index 0000000000..297102fc32 --- /dev/null +++ b/setup-nginx-runtime.sh @@ -0,0 +1,141 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=${__DIR__} + +cd ${__PROJECT__} + +OS=$(uname -s) +ARCH=$(uname -m) + +case $OS in +'Linux') + OS="linux" + ;; +'Darwin') + OS="macos" + ;; +*) + case $OS in + 'MSYS_NT'*) + OS="windows" + ;; + 'MINGW64_NT'*) + OS="windows" + ;; + *) + echo '暂未配置的 OS ' + exit 0 + ;; + esac + ;; +esac + +case $ARCH in +'x86_64') + ARCH="x64" + ;; +'aarch64' | 'arm64' ) + ARCH="arm64" + ;; +*) + echo '暂未配置的 ARCH ' + exit 0 + ;; +esac + +APP_VERSION='1.27.0' +APP_NAME='nginx' +VERSION='v1.0.2' + +mkdir -p bin/runtime +mkdir -p var/runtime + +cd ${__PROJECT__}/var/runtime + +APP_DOWNLOAD_URL="https://github.com/jingjingxyk/build-static-nginx/releases/download/${VERSION}/${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}.tar.xz" +CACERT_DOWNLOAD_URL="https://curl.se/ca/cacert.pem" + +if [ $OS = 'windows' ]; then + APP_DOWNLOAD_URL="https://github.com/jingjingxyk/build-static-nginx/releases/download/${VERSION}/${APP_NAME}-${APP_VERSION}-cygwin-${ARCH}.zip" +fi + +MIRROR='' +while [ $# -gt 0 ]; do + case "$1" in + --mirror) + MIRROR="$2" + ;; + --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" + 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" + ;; + esac + shift $(($# > 0 ? 1 : 0)) +done + +case "$MIRROR" in +china) + APP_DOWNLOAD_URL="https://php-cli.jingjingxyk.com/${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}.tar.xz" + if [ $OS = 'windows' ]; then + APP_DOWNLOAD_URL="https://php-cli.jingjingxyk.com/${APP_NAME}-${APP_VERSION}-cygwin-${ARCH}.zip" + fi + ;; + +esac + +test -f cacert.pem || curl -LSo cacert.pem ${CACERT_DOWNLOAD_URL} + +APP_RUNTIME="${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}" + +if [ $OS = 'windows' ]; then + { + APP_RUNTIME="${APP_NAME}-${APP_VERSION}-cygwin-${ARCH}" + test -f ${APP_RUNTIME}.zip || curl -LSo ${APP_RUNTIME}.zip ${APP_DOWNLOAD_URL} + test -d ${APP_RUNTIME} && rm -rf ${APP_RUNTIME} + unzip "${APP_RUNTIME}.zip" + echo + exit 0 + } +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 -d nginx && rm -rf nginx + test -d nginx || tar -xvf ${APP_RUNTIME}.tar + chmod a+x nginx/sbin/nginx + cp -rf ${__PROJECT__}/var/runtime/nginx ${__PROJECT__}/bin/runtime/nginx +fi + +cd ${__PROJECT__}/var/runtime + +cp -f ${__PROJECT__}/var/runtime/cacert.pem ${__PROJECT__}/bin/runtime/cacert.pem + +cd ${__PROJECT__}/ + +set +x + +echo " " +echo " USE NGINX RUNTIME :" +echo " " +echo " export PATH=\"${__PROJECT__}/bin/runtime:\$PATH\" " +echo " " +echo " ./bin/runtime/nginx/sbin/nginx -p ./bin/runtime/nginx/ " +echo " " +echo " nginx.conf example : https://gitee.com/jingjingxyk/quickstart-nginx-php-fpm/blob/main/nginx.example.conf" +echo " " +echo " nginx docs : http://nginx.org/en/docs/configure.html" +echo " " +export PATH="${__PROJECT__}/bin/runtime:$PATH" diff --git a/setup-nodejs-runtime.sh b/setup-nodejs-runtime.sh new file mode 100644 index 0000000000..8cafda24d3 --- /dev/null +++ b/setup-nodejs-runtime.sh @@ -0,0 +1,169 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=$( + cd "${__DIR__}/" + pwd +) + +cd ${__PROJECT__} + +OS=$(uname -s) +ARCH=$(uname -m) + +case $OS in +'Linux') + OS="linux" + ;; +'Darwin') + OS="darwin" + ;; +*) + case $OS in + 'MSYS_NT'*) + OS="win" + ;; + 'MINGW64_NT'*) + OS="win" + ;; + *) + echo '暂未配置的 OS ' + exit 0 + ;; + esac + ;; +esac + +case $ARCH in +'x86_64') + ARCH="x64" + ;; +'aarch64' | 'arm64') + ARCH="arm64" + ;; +*) + echo '暂未配置的 ARCH ' + exit 0 + ;; +esac + +APP_VERSION='v20.15.1' +APP_NAME='node' +VERSION='v20.15.1' + +mkdir -p bin/runtime +mkdir -p var/runtime + +cd ${__PROJECT__}/var/runtime + +: <<'EOF' +https://nodejs.org/dist/v20.15.1/node-v20.15.1-darwin-x64.tar.gz +https://nodejs.org/dist/v20.15.1/node-v20.15.1-darwin-arm64.tar.gz +https://nodejs.org/dist/v20.15.1/node-v20.15.1-linux-arm64.tar.xz +https://nodejs.org/dist/v20.15.1/node-v20.15.1-linux-arm64.tar.xz +https://nodejs.org/dist/v20.15.1/node-v20.15.1-win-arm64.zip +https://nodejs.org/dist/v20.15.1/node-v20.15.1-win-x64.zip +https://registry.npmmirror.com/-/binary/node/v20.15.1/node-v20.15.1-win-x64.zip +EOF + +APP_DOWNLOAD_URL="https://nodejs.org/dist/${VERSION}/${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}.tar.xz" + +if [ $OS = 'win' ]; then + APP_DOWNLOAD_URL="https://nodejs.org/dist/${VERSION}/${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}.zip" +fi + +MIRROR='' +while [ $# -gt 0 ]; do + case "$1" in + --mirror) + MIRROR="$2" + ;; + --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" + NO_PROXY="${NO_PROXY},::1/128,fe80::/10,fd00::/8,ff00::/8" + NO_PROXY="${NO_PROXY},localhost" + export NO_PROXY="${NO_PROXY},.tsinghua.edu.cn,.ustc.edu.cn,.npmmirror.com" + ;; + --*) + echo "Illegal option $1" + ;; + esac + shift $(($# > 0 ? 1 : 0)) +done + +case "$MIRROR" in +china) + APP_DOWNLOAD_URL="https://registry.npmmirror.com/-/binary/node/${APP_VERSION}/${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}.tar.xz" + if [ $OS = 'windows' ]; then + APP_DOWNLOAD_URL="https://registry.npmmirror.com/-/binary/node/${APP_VERSION}/${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}.zip" + fi + ;; +esac + +APP_RUNTIME="${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}" +if [ $OS = 'win' ]; then + { + test -f ${APP_RUNTIME}.zip || curl -fSLo ${APP_RUNTIME}.zip ${APP_DOWNLOAD_URL} + test -d ${APP_RUNTIME} && rm -rf ${APP_RUNTIME} + unzip "${APP_RUNTIME}.zip" + exit 0 + } +else + if [ $OS = "darwin" ]; then + test -f ${APP_RUNTIME}.tar.gz || curl -fSLo ${APP_RUNTIME}.tar.gz ${APP_DOWNLOAD_URL} + test -d ${APP_RUNTIME} && rm -rf ${APP_RUNTIME} + tar -xvf ${APP_RUNTIME}.tar.gz + + else + test -f ${APP_RUNTIME}.tar.xz || curl -fSLo ${APP_RUNTIME}.tar.xz ${APP_DOWNLOAD_URL} + test -f ${APP_RUNTIME}.tar || xz -d -k ${APP_RUNTIME}.tar.xz + test -d ${APP_RUNTIME} || tar -xvf ${APP_RUNTIME}.tar + fi + test -d ${__PROJECT__}/bin/runtime/node && rm -rf ${__PROJECT__}/bin/runtime/node + mv ${APP_RUNTIME} ${__PROJECT__}/bin/runtime/node +fi + +cd ${__PROJECT__}/ + +set +x + +echo " " +echo " USE PHP RUNTIME :" +echo " " +echo " export PATH=\"${__PROJECT__}/bin/runtime/node/bin/:\$PATH\" " +echo " " +export PATH="${__PROJECT__}/bin/runtime/node/bin/:$PATH" +node -v +npm -v +npx -v + + + +# shellcheck disable=SC2217 +echo <<'EOF' + +# 指定 NPM 仓库下载源 + +npm install -g yarn --registry=https://registry.npmmirror.com + +npm install yarn --registry=https://registry.npmmirror.com + +yarn install --registry=https://registry.npmmirror.com + +npx yarn install --registry=https://registry.npmmirror.com + + +npm config set registry https://registry.npmmirror.com + +yarn config set registry https://registry.npmmirror.com + + + +EOF + diff --git a/setup-php-cli-runtime.sh b/setup-php-cli-runtime.sh new file mode 100644 index 0000000000..3b9b2c1709 --- /dev/null +++ b/setup-php-cli-runtime.sh @@ -0,0 +1,195 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=${__DIR__} + +cd ${__PROJECT__} + +OS=$(uname -s) +ARCH=$(uname -m) + +case $OS in +'Linux') + OS="linux" + ;; +'Darwin') + OS="macos" + ;; +*) + case $OS in + 'MSYS_NT'*) + OS="windows" + ;; + 'MINGW64_NT'*) + OS="windows" + ;; + *) + echo '暂未配置的 OS ' + exit 0 + ;; + esac + ;; +esac + +case $ARCH in +'x86_64') + ARCH="x64" + ;; +'aarch64' | 'arm64') + ARCH="arm64" + ;; +*) + echo '暂未配置的 ARCH ' + exit 0 + ;; +esac + +APP_VERSION='v8.2.25' +APP_NAME='php-cli' +VERSION='v1.6.0' + +mkdir -p bin/runtime +mkdir -p var/runtime + +MIRROR='' +while [ $# -gt 0 ]; do + case "$1" in + --mirror) + MIRROR="$2" + ;; + --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" + 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" + ;; + --version) + # 指定发布 TAG + if [ $OS = "macos" ]; then + X_VERSION=$(echo "$2" | grep -Eo '^v\d\.\d{1,2}\.\d{1,2}$') + elif [ $OS = "linux" ]; then + X_VERSION=$(echo "$2" | grep -Po '^v\d\.\d{1,2}\.\d{1,2}$') + else + X_VERSION='' + fi + if [[ -n $X_VERSION ]]; then + { + VERSION=$X_VERSION + } + fi + ;; + --php-version) + # 指定发布 TAG + if [ $OS = "macos" ]; then + X_APP_VERSION=$(echo "$2" | grep -Eo '^v\d\.\d{1,2}\.\d{1,2}$') + elif [ $OS = "linux" ]; then + X_APP_VERSION=$(echo "$2" | grep -Po '^v\d\.\d{1,2}\.\d{1,2}$') + else + X_VERSION='' + fi + if [[ -n $X_APP_VERSION ]]; then + { + APP_VERSION=$X_APP_VERSION + } + fi + ;; + --*) + echo "Illegal option $1" + ;; + esac + shift $(($# > 0 ? 1 : 0)) +done + +cd ${__PROJECT__}/var/runtime + +APP_DOWNLOAD_URL="https://github.com/swoole/build-static-php/releases/download/${VERSION}/${APP_NAME}-${APP_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 + APP_DOWNLOAD_URL="https://github.com/swoole/build-static-php/releases/download/${VERSION}/${APP_NAME}-${APP_VERSION}-cygwin-${ARCH}.zip" +fi + +case "$MIRROR" in +china) + APP_DOWNLOAD_URL="https://php-cli.jingjingxyk.com/${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}.tar.xz" + COMPOSER_DOWNLOAD_URL="https://mirrors.tencent.com/composer/composer.phar" + if [ $OS = 'windows' ]; then + APP_DOWNLOAD_URL="https://php-cli.jingjingxyk.com/${APP_NAME}-${APP_VERSION}-cygwin-${ARCH}.zip" + fi + ;; + +esac + +test -f composer.phar || curl -LSo composer.phar ${COMPOSER_DOWNLOAD_URL} +chmod a+x composer.phar + +test -f cacert.pem || curl -LSo cacert.pem ${CACERT_DOWNLOAD_URL} + +APP_RUNTIME="${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}" + +if [ $OS = 'windows' ]; then + { + APP_RUNTIME="${APP_NAME}-${APP_VERSION}-cygwin-${ARCH}" + test -f ${APP_RUNTIME}.zip || curl -LSo ${APP_RUNTIME}.zip ${APP_DOWNLOAD_URL} + test -d ${APP_RUNTIME} && rm -rf ${APP_RUNTIME} + unzip "${APP_RUNTIME}.zip" + echo + exit 0 + } +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 php || tar -xvf ${APP_RUNTIME}.tar + chmod a+x php + cp -f ${__PROJECT__}/var/runtime/php ${__PROJECT__}/bin/runtime/php +fi + +cd ${__PROJECT__}/var/runtime + +cp -f ${__PROJECT__}/var/runtime/composer.phar ${__PROJECT__}/bin/runtime/composer +cp -f ${__PROJECT__}/var/runtime/cacert.pem ${__PROJECT__}/bin/runtime/cacert.pem + +cat >${__PROJECT__}/bin/runtime/php.ini < 0 ? 1 : 0)) +done + +case "$MIRROR" in +china) + APP_DOWNLOAD_URL="https://php-cli.jingjingxyk.com/${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}.tar.xz" + COMPOSER_DOWNLOAD_URL="https://mirrors.tencent.com/composer/composer.phar" + if [ $OS = 'windows' ]; then + APP_DOWNLOAD_URL="https://php-cli.jingjingxyk.com/${APP_NAME}-${APP_VERSION}-cygwin-${ARCH}.zip" + fi + ;; + +esac + +test -f composer.phar || curl -LSo composer.phar ${COMPOSER_DOWNLOAD_URL} +chmod a+x composer.phar + +test -f cacert.pem || curl -LSo cacert.pem ${CACERT_DOWNLOAD_URL} + +APP_RUNTIME="${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}" + +if [ $OS = 'windows' ]; then + { + APP_RUNTIME="${APP_NAME}-${APP_VERSION}-vs2022-${ARCH}" + test -f ${APP_RUNTIME}.zip || curl -LSo ${APP_RUNTIME}.zip ${APP_DOWNLOAD_URL} + test -d ${APP_RUNTIME} && rm -rf ${APP_RUNTIME} + unzip "${APP_RUNTIME}.zip" + echo + exit 0 + } +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 php-fpm || tar -xvf ${APP_RUNTIME}.tar + chmod a+x php-fpm + cp -f ${__PROJECT__}/var/runtime/php-fpm ${__PROJECT__}/bin/runtime/php-fpm +fi + +cd ${__PROJECT__}/var/runtime + +cp -f ${__PROJECT__}/var/runtime/composer.phar ${__PROJECT__}/bin/runtime/composer +cp -f ${__PROJECT__}/var/runtime/cacert.pem ${__PROJECT__}/bin/runtime/cacert.pem + +cat >${__PROJECT__}/bin/runtime/php.ini <${__PROJECT__}/bin/runtime/php-fpm.conf <<'EOF' +; 更多配置参考 +; https://github.com/php/php-src/blob/master/sapi/fpm/www.conf.in +; https://github.com/php/php-src/blob/master/sapi/fpm/php-fpm.conf.in + +[global] +pid = run/php-fpm.pid +error_log = log/php-fpm.log +daemonize = yes + +[www] +user = nobody +group = nobody + +listen = 9001 +;listen = run/php-fpm.sock + +slowlog = log/$pool.log.slow +request_slowlog_timeout = 30s + + +pm = dynamic +pm.max_children = 5 +pm.start_servers = 2 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 + +; MAIN_PID=$(cat var/run/php-fpm.pid) +; 关闭 php-fpm +; kill -QUIT $MAIN_PID + +; 平滑重启 php-fpm +; kill -USR2 $MAIN_PID + +EOF + +cd ${__PROJECT__}/ + +set +x + +echo " " +echo " USE PHP-FPM :" +echo " " +echo " export PATH=\"${__PROJECT__}/runtime/:\$PATH\" " +echo " " +echo " php-fpm.conf example : https://gitee.com/jingjingxyk/quickstart-nginx-php-fpm/blob/main/php-fpm.example.conf" +echo " " +echo " enable start php-fpm ${APP_VERSION}" +echo " " +echo " ${__PROJECT__}/bin/runtime/php-fpm -c ${__PROJECT__}/bin/runtime/php.ini --fpm-config ${__PROJECT__}/runtime/php-fpm.conf " diff --git a/setup-php-fpm-runtime.sh b/setup-php-fpm-runtime.sh new file mode 100644 index 0000000000..c7d743ed43 --- /dev/null +++ b/setup-php-fpm-runtime.sh @@ -0,0 +1,230 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=${__DIR__} + +cd ${__PROJECT__} + +OS=$(uname -s) +ARCH=$(uname -m) + +case $OS in +'Linux') + OS="linux" + ;; +'Darwin') + OS="macos" + ;; +*) + case $OS in + 'MSYS_NT'*) + OS="windows" + ;; + 'MINGW64_NT'*) + OS="windows" + ;; + *) + echo '暂未配置的 OS ' + exit 0 + ;; + esac + ;; +esac + +case $ARCH in +'x86_64') + ARCH="x64" + ;; +'aarch64' | 'arm64') + ARCH="arm64" + ;; +*) + echo '暂未配置的 ARCH ' + exit 0 + ;; +esac + +APP_VERSION='v8.2.13' +APP_NAME='php-fpm' +VERSION='php-fpm-v0.0.2' + +mkdir -p bin/runtime +mkdir -p var/runtime + +MIRROR='' +while [ $# -gt 0 ]; do + case "$1" in + --mirror) + MIRROR="$2" + ;; + --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" + 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" + ;; + --version) + # 指定发布 TAG + if [ $OS = "macos" ]; then + X_VERSION=$(echo "$2" | grep -Eo '^v\d\.\d{1,2}\.\d{1,2}$') + elif [ $OS = "linux" ]; then + X_VERSION=$(echo "$2" | grep -Po '^v\d\.\d{1,2}\.\d{1,2}$') + else + X_VERSION='' + fi + if [[ -n $X_VERSION ]]; then + { + VERSION=$X_VERSION + } + fi + ;; + --php-version) + # 指定发布 TAG + if [ $OS = "macos" ]; then + X_APP_VERSION=$(echo "$2" | grep -Eo '^v\d\.\d{1,2}\.\d{1,2}$') + elif [ $OS = "linux" ]; then + X_APP_VERSION=$(echo "$2" | grep -Po '^v\d\.\d{1,2}\.\d{1,2}$') + else + X_VERSION='' + fi + if [[ -n $X_APP_VERSION ]]; then + { + APP_VERSION=$X_APP_VERSION + } + fi + ;; + --*) + echo "Illegal option $1" + ;; + esac + shift $(($# > 0 ? 1 : 0)) +done + +cd ${__PROJECT__}/var/runtime + +APP_DOWNLOAD_URL="https://github.com/swoole/build-static-php/releases/download/${VERSION}/${APP_NAME}-${APP_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 + APP_DOWNLOAD_URL="https://github.com/swoole/build-static-php/releases/download/${VERSION}/${APP_NAME}-${APP_VERSION}-vs2022-${ARCH}.zip" +fi + +case "$MIRROR" in +china) + APP_DOWNLOAD_URL="https://php-cli.jingjingxyk.com/${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}.tar.xz" + COMPOSER_DOWNLOAD_URL="https://mirrors.tencent.com/composer/composer.phar" + if [ $OS = 'windows' ]; then + APP_DOWNLOAD_URL="https://php-cli.jingjingxyk.com/${APP_NAME}-${APP_VERSION}-cygwin-${ARCH}.zip" + fi + ;; + +esac + +test -f composer.phar || curl -LSo composer.phar ${COMPOSER_DOWNLOAD_URL} +chmod a+x composer.phar + +test -f cacert.pem || curl -LSo cacert.pem ${CACERT_DOWNLOAD_URL} + +APP_RUNTIME="${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}" + +if [ $OS = 'windows' ]; then + { + APP_RUNTIME="${APP_NAME}-${APP_VERSION}-vs2022-${ARCH}" + test -f ${APP_RUNTIME}.zip || curl -LSo ${APP_RUNTIME}.zip ${APP_DOWNLOAD_URL} + test -d ${APP_RUNTIME} && rm -rf ${APP_RUNTIME} + unzip "${APP_RUNTIME}.zip" + echo + exit 0 + } +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 php-fpm || tar -xvf ${APP_RUNTIME}.tar + chmod a+x php-fpm + cp -f ${__PROJECT__}/var/runtime/php-fpm ${__PROJECT__}/bin/runtime/php-fpm +fi + +cd ${__PROJECT__}/var/runtime + +cp -f ${__PROJECT__}/var/runtime/composer.phar ${__PROJECT__}/bin/runtime/composer +cp -f ${__PROJECT__}/var/runtime/cacert.pem ${__PROJECT__}/bin/runtime/cacert.pem + +cat >${__PROJECT__}/bin/runtime/php.ini <${__PROJECT__}/bin/runtime/php-fpm.conf <<'EOF' +; 更多配置参考 +; https://github.com/php/php-src/blob/master/sapi/fpm/www.conf.in +; https://github.com/php/php-src/blob/master/sapi/fpm/php-fpm.conf.in + +[global] +pid = run/php-fpm.pid +error_log = log/php-fpm.log +daemonize = yes + +[www] +user = nobody +group = nobody + +listen = 9001 +;listen = run/php-fpm.sock + +slowlog = log/$pool.log.slow +request_slowlog_timeout = 30s + + +pm = dynamic +pm.max_children = 5 +pm.start_servers = 2 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 + +; MAIN_PID=$(cat var/run/php-fpm.pid) +; 关闭 php-fpm +; kill -QUIT $MAIN_PID + +; 平滑重启 php-fpm +; kill -USR2 $MAIN_PID + +EOF + +cd ${__PROJECT__}/ + +set +x + +echo " " +echo " USE PHP-FPM :" +echo " " +echo " export PATH=\"${__PROJECT__}/runtime/:\$PATH\" " +echo " " +echo " php-fpm.conf example : https://gitee.com/jingjingxyk/quickstart-nginx-php-fpm/blob/main/php-fpm.example.conf" +echo " " +echo " enable start php-fpm ${APP_VERSION}" +echo " " +echo " ${__PROJECT__}/bin/runtime/php-fpm -c ${__PROJECT__}/bin/runtime/php.ini --fpm-config ${__PROJECT__}/runtime/php-fpm.conf " diff --git a/setup-php-runtime.sh b/setup-php-runtime.sh index e97dc04bb5..17568a0af7 100644 --- a/setup-php-runtime.sh +++ b/setup-php-runtime.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -exu __DIR__=$( @@ -99,25 +99,26 @@ china) esac -test -f composer.phar || curl -LSo composer.phar ${COMPOSER_DOWNLOAD_URL} +test -f composer.phar || curl -fSLo composer.phar ${COMPOSER_DOWNLOAD_URL} chmod a+x composer.phar -test -f cacert.pem || curl -LSo cacert.pem ${CACERT_DOWNLOAD_URL} +test -f cacert.pem || curl -fSLo cacert.pem ${CACERT_DOWNLOAD_URL} APP_RUNTIME="${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}" if [ $OS = 'windows' ]; then { APP_RUNTIME="${APP_NAME}-${APP_VERSION}-cygwin-${ARCH}" - test -f ${APP_RUNTIME}.zip || curl -LSo ${APP_RUNTIME}.zip ${APP_DOWNLOAD_URL} + test -f ${APP_RUNTIME}.zip || curl -fSLo ${APP_RUNTIME}.zip ${APP_DOWNLOAD_URL} test -d ${APP_RUNTIME} && rm -rf ${APP_RUNTIME} unzip "${APP_RUNTIME}.zip" exit 0 } else - test -f ${APP_RUNTIME}.tar.xz || curl -LSo ${APP_RUNTIME}.tar.xz ${APP_DOWNLOAD_URL} + test -f ${APP_RUNTIME}.tar.xz || curl -fSLo ${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 @@ -139,13 +140,15 @@ post_max_size="128M" memory_limit="1G" date.timezone="UTC" -opcache.enable_cli=1 -opcache.jit=1254 -opcache.jit_buffer_size=480M +opcache.enable=On +opcache.enable_cli=On +opcache.jit=1225 +opcache.jit_buffer_size=128M expose_php=Off phar.readonly=0 + EOF cd ${__PROJECT__}/ @@ -161,4 +164,7 @@ 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-privoxy-runtime.sh b/setup-privoxy-runtime.sh new file mode 100644 index 0000000000..0bba738908 --- /dev/null +++ b/setup-privoxy-runtime.sh @@ -0,0 +1,168 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=${__DIR__} + +cd ${__PROJECT__} + +OS=$(uname -s) +ARCH=$(uname -m) + +case $OS in +'Linux') + OS="linux" + ;; +'Darwin') + OS="macos" + ;; +*) + case $OS in + 'MSYS_NT'* | 'CYGWIN_NT'* ) + OS="windows" + ;; + 'MINGW64_NT'*) + OS="windows" + ;; + *) + echo '暂未配置的 OS ' + exit 0 + ;; + esac + ;; +esac + +case $ARCH in +'x86_64') + ARCH="x64" + ;; +'aarch64' | 'arm64' ) + ARCH="arm64" + ;; +*) + echo '暂未配置的 ARCH ' + exit 0 + ;; +esac + +APP_VERSION='3.0.34' +APP_NAME='privoxy' +VERSION='v1.0.0' + +mkdir -p bin/runtime +mkdir -p var/runtime + +cd ${__PROJECT__}/var/runtime + +APP_DOWNLOAD_URL="https://github.com/jingjingxyk/build-static-privoxy/releases/download/${VERSION}/${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}.tar.xz" +CACERT_DOWNLOAD_URL="https://curl.se/ca/cacert.pem" + +if [ $OS = 'windows' ]; then + APP_DOWNLOAD_URL="https://github.com/jingjingxyk/build-static-privoxy/releases/download/${VERSION}/${APP_NAME}-${APP_VERSION}-vs2022-${ARCH}.zip" +fi + +MIRROR='' +while [ $# -gt 0 ]; do + case "$1" in + --mirror) + MIRROR="$2" + ;; + --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" + 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" + ;; + esac + shift $(($# > 0 ? 1 : 0)) +done + +case "$MIRROR" in +china) + APP_DOWNLOAD_URL="https://php-cli.jingjingxyk.com/${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}.tar.xz" + if [ $OS = 'windows' ]; then + APP_DOWNLOAD_URL="https://php-cli.jingjingxyk.com/${APP_NAME}-${APP_VERSION}-vs2022-${ARCH}.zip" + fi + ;; + +esac + +test -f cacert.pem || curl -LSo cacert.pem ${CACERT_DOWNLOAD_URL} + +APP_RUNTIME="${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}" + +if [ $OS = 'windows' ]; then + { + APP_RUNTIME="${APP_NAME}-${APP_VERSION}-vs2022-${ARCH}" + test -f ${APP_RUNTIME}.zip || curl -LSo ${APP_RUNTIME}.zip ${APP_DOWNLOAD_URL} + test -d ${APP_RUNTIME} && rm -rf ${APP_RUNTIME} + unzip "${APP_RUNTIME}.zip" + exit 0 + } +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 -d ${APP_RUNTIME} && rm -rf ${APP_RUNTIME} + tar -xvf ${APP_RUNTIME}.tar + chmod a+x privoxy/sbin/privoxy + mkdir -p ${__PROJECT__}/bin/runtime/${APP_NAME} + test -d ${__PROJECT__}/bin/runtime/${APP_NAME} && rm -rf ${__PROJECT__}/bin/runtime/${APP_NAME} + cp -rf ${__PROJECT__}/var/runtime/${APP_NAME}/. ${__PROJECT__}/bin/runtime/${APP_NAME} +fi + +cd ${__PROJECT__}/var/runtime + +cp -f ${__PROJECT__}/var/runtime/cacert.pem ${__PROJECT__}/bin/runtime/cacert.pem + + +cd ${__PROJECT__}/ + + +tee ${__PROJECT__}/bin/runtime/privoxy/privoxy-start.sh <<'EOF' +#!/usr/bin/env bash +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) + +cd ${__DIR__}/ + ./sbin/privoxy --no-daemon etc/config +EOF + + +set +x + +echo " " +echo " USE PRIVOXY RUNTIME :" +echo " " +echo " change file ./bin/runtime/privoxy/etc/config " +echo '' +echo ' listen-address 0.0.0.0:8118' +echo ' #forward-socks5 / user:pass@socks-gw.example.com:1080 . ' +echo ' forward-socks5 / 127.0.0.1:2000 . ' +echo " confdir ${__PROJECT__}/bin/runtime/privoxy/etc" +echo " logdir ${__PROJECT__}/bin/runtime/privoxy/var/log/privoxy" +echo '# debug 1' +echo '# debug 512' +echo '# debug 1024' +echo '' +echo " cd ./bin/runtime/privoxy " +echo " ./sbin/privoxy --no-daemon etc/config " +echo '' +echo ' OR ' +echo '' +echo ' bash bin/runtime/privoxy/privoxy-start.sh' +echo " " + +export PATH="${__PROJECT__}/bin/runtime:$PATH" diff --git a/setup-runtime.md b/setup-runtime.md new file mode 100644 index 0000000000..adea692de1 --- /dev/null +++ b/setup-runtime.md @@ -0,0 +1,52 @@ +# setup runtime + +```bash +curl -fSLo cacert.pem https://curl.se/ca/cacert.pem + +curl -fSL https://github.com/jingjingxyk/swoole-cli/blob/new_dev/setup-coturn-runtime.sh?raw=true | bash +curl -fSL https://gitee.com/jingjingxyk/swoole-cli/raw/new_dev/setup-coturn-runtime.sh | bash -s -- --mirror china + + +curl -fSL https://github.com/jingjingxyk/swoole-cli/blob/new_dev/setup-socat-runtime.sh?raw=true | bash +curl -fSL https://gitee.com/jingjingxyk/swoole-cli/raw/new_dev/setup-socat-runtime.sh | bash -s -- --mirror china +curl -fSL https://github.com/jingjingxyk/swoole-cli/blob/new_dev/setup-socat-runtime.sh?raw=true | bash -s -- --version v2.2.1 --socat-version v1.8.0.1 + +curl -fSL https://github.com/jingjingxyk/swoole-cli/blob/new_dev/setup-nginx-runtime.sh?raw=true | bash +curl -fSL https://gitee.com/jingjingxyk/swoole-cli/raw/new_dev/setup-nginx-runtime.sh | bash -s -- --mirror china + + +curl -fSL https://github.com/jingjingxyk/swoole-cli/blob/new_dev/setup-php-runtime.sh?raw=true | bash +curl -fSL https://gitee.com/jingjingxyk/swoole-cli/raw/new_dev/setup-php-runtime.sh | bash -s -- --mirror china + +curl -fSL https://github.com/jingjingxyk/swoole-cli/blob/new_dev/setup-privoxy-runtime.sh?raw=true | bash +curl -fSL https://gitee.com/jingjingxyk/swoole-cli/raw/new_dev/setup-privoxy-runtime.sh | bash -s -- --mirror china + + +curl -fSL https://github.com/swoole/swoole-cli/blob/main/setup-php-runtime.sh?raw=true | bash -s -- --mirror china +curl -fSL https://gitee.com/jingjingxyk/swoole-cli/raw/new_dev/setup-php-runtime.sh | bash -s -- --mirror china + + +curl -fSL https://github.com/docker/docker-install/blob/master/install.sh?raw=true | bash +curl -fSL https://gitee.com/jingjingxyk/docker-install/raw/master/install.sh | bash -s -- --mirror AzureChinaCloud + + +curl -fSL https://github.com/jingjingxyk/swoole-cli/blob/new_dev/setup-supervisord.sh?raw=true | bash +curl -fSL https://gitee.com/jingjingxyk/swoole-cli/raw/new_dev/setup-supervisord.sh | bash -s -- --mirror china + +curl -fSL https://kubernetes-tools.dengxiaci.com/proxy/supervisord-setup.sh | bash + +curl -fSL https://github.com/jingjingxyk/swoole-cli/blob/new_dev/setup-aria2-runtime.sh?raw=true | bash +curl -fSL https://gitee.com/jingjingxyk/swoole-cli/raw/new_dev/setup-aria2-runtime.sh | bash -s -- --mirror china + + +curl -fSL https://swoole-cli.jingjingxyk.com/setup-swoole-cli-pre-runtime.sh | bash + +curl -fSL https://swoole-cli.jingjingxyk.com/setup-swoole-cli-pre-runtime.sh | bash -s -- --proxy socks5h://127.0.0.1:2000 + + +curl -fsSL https://github.com/swoole/installers/blob/main/install.sh?raw=true | bash -s -- --mirror china --latest +curl -fsSL https://gitee.com/jingjingxyk/swoole-install/raw/main/install.sh | bash -s -- --mirror china --latest + + + +``` diff --git a/setup-socat-runtime.sh b/setup-socat-runtime.sh new file mode 100644 index 0000000000..8b6c2b9f0b --- /dev/null +++ b/setup-socat-runtime.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=${__DIR__} + +cd ${__PROJECT__} + +OS=$(uname -s) +ARCH=$(uname -m) + +case $OS in +'Linux') + OS="linux" + ;; +'Darwin') + OS="macos" + ;; +*) + case $OS in + 'MSYS_NT'* | 'CYGWIN_NT'*) + OS="windows" + ;; + 'MINGW64_NT'*) + OS="windows" + ;; + *) + echo '暂未配置的 OS ' + exit 0 + ;; + esac + ;; +esac + +case $ARCH in +'x86_64') + ARCH="x64" + ;; +'aarch64' | 'arm64') + ARCH="arm64" + ;; +*) + echo '暂未配置的 ARCH ' + exit 0 + ;; +esac + +APP_VERSION='v1.8.0.1' +APP_NAME='socat' +VERSION='v2.2.1' + +MIRROR='' +while [ $# -gt 0 ]; do + case "$1" in + --mirror) + MIRROR="$2" + ;; + --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" + 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" + ;; + --version) + # 指定发布 TAG + X_VERSION=$(echo "$2" | grep -Eo '^v\d\.\d{1,2}\.\d{1,2}$') + if [[ -n $X_VERSION ]]; then + { + VERSION=$X_VERSION + } + fi + ;; + --socat-version) + # 指定发布 TAG + X_APP_VERSION=$(echo "$2" | grep -Eo '^v\d\.\d{1,2}\.\d{1,2}.\d{1,2}$') + if [[ -n $X_APP_VERSION ]]; then + { + APP_VERSION=$X_APP_VERSION + } + fi + ;; + --*) + echo "Illegal option $1" + ;; + esac + shift $(($# > 0 ? 1 : 0)) +done + +mkdir -p bin/runtime +mkdir -p var/runtime + +cd ${__PROJECT__}/var/runtime + +APP_DOWNLOAD_URL="https://github.com/jingjingxyk/build-static-socat/releases/download/${VERSION}/${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}.tar.xz" +CACERT_DOWNLOAD_URL="https://curl.se/ca/cacert.pem" + +if [ $OS = 'windows' ]; then + APP_DOWNLOAD_URL="https://github.com/jingjingxyk/build-static-socat/releases/download/${VERSION}/${APP_NAME}-${APP_VERSION}-cygwin-${ARCH}.zip" +fi + +case "$MIRROR" in +china) + APP_DOWNLOAD_URL="https://php-cli.jingjingxyk.com/${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}.tar.xz" + if [ $OS = 'windows' ]; then + APP_DOWNLOAD_URL="https://php-cli.jingjingxyk.com/${APP_NAME}-${APP_VERSION}-cygwin-${ARCH}.zip" + fi + ;; + +esac + +test -f cacert.pem || curl -LSo cacert.pem ${CACERT_DOWNLOAD_URL} + +APP_RUNTIME="${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}" + +if [ $OS = 'windows' ]; then + { + APP_RUNTIME="${APP_NAME}-${APP_VERSION}-vs2022-${ARCH}" + test -f ${APP_RUNTIME}.zip || curl -LSo ${APP_RUNTIME}.zip ${APP_DOWNLOAD_URL} + test -d ${APP_RUNTIME} && rm -rf ${APP_RUNTIME} + unzip "${APP_RUNTIME}.zip" + exit 0 + } +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 socat || tar -xvf ${APP_RUNTIME}.tar + chmod a+x socat + cp -f ${__PROJECT__}/var/runtime/socat ${__PROJECT__}/bin/runtime/socat +fi + +cd ${__PROJECT__}/var/runtime + +cp -f ${__PROJECT__}/var/runtime/cacert.pem ${__PROJECT__}/bin/runtime/cacert.pem + +cd ${__PROJECT__}/ + +set +x + +echo " " +echo " USE SOCAT RUNTIME :" +echo " " +echo " export PATH=\"${__PROJECT__}/bin/runtime:\$PATH\" " +echo " " +echo " socat [options]
" +echo " socat docs : http://www.dest-unreach.org/socat/" +echo " socat example : https://www.redhat.com/sysadmin/getting-started-socat" +echo " " +export PATH="${__PROJECT__}/bin/runtime:$PATH" diff --git a/setup-supervisord.sh b/setup-supervisord.sh new file mode 100644 index 0000000000..eab6b40efd --- /dev/null +++ b/setup-supervisord.sh @@ -0,0 +1,91 @@ +#!/usr/bin/env bash + +set -exu +__CURRENT__=`pwd` +__DIR__=$(cd "$(dirname "$0")";pwd) +cd ${__DIR__}/ + +# apt install -y socat tini +# pip3 install --upgrade supervisor +# pip3 更新所有包 +# pip3 list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip3 install -U + + +# sed -i "s@deb.debian.org@mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list +# sed -i "s@security.debian.org@mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list + +#优先使用 +#sed -i "s@deb.debian.org@mirrors.aliyun.com@g" /etc/apt/sources.list +#sed -i "s@security.debian.org@mirrors.aliyun.com@g" /etc/apt/sources.list + + + +apt update -y +apt install -y python3 python3-pip + +# apt install -y python3 python3-pip socat tini uuid uuid-runtime wget curl procps sudo +# apt install -y gettext procps lsof dnsutils iproute2 net-tools vim iputils-ping +# apt install -y privoxy proxychains + +pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple +pip3 install supervisor + +# 生成 supervisor 默认配置文件 +test -d /etc/supervisord.d/user-custom/ || mkdir -p /etc/supervisord.d/user-custom/ +# 创建supervisord配置文件 + +if test ! -f /etc/supervisord.conf +then +{ + echo_supervisord_conf > /etc/supervisord.conf + cat >> /etc/supervisord.conf < /etc/supervisord.d/user-custom/example.conf.bak <<'EOF' +[program:example] +command=bash /tmp/example.sh +;process_name=%(program_name)s ; process_name expr (default %(program_name)s) +process_name=example ; process_name expr (default %(program_name)s) +numprocs=1 ; number of processes copies to start (def 1) +directory=/ ; directory to cwd to before exec (def no cwd) +autostart=true ; start at supervisord start (default: true) +startsecs=1 ; # of secs prog must stay up to be running (def. 1) +startretries=3 ; max # of serial start failures when starting (default 3) +autorestart=unexpected ; when to restart if exited after running (def: unexpected) +exitcodes=0 ; 'expected' exit codes used with autorestart (default 0) +stopsignal=QUIT ; signal used to kill process (default TERM) +stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10) +stdout_logfile=/tmp/supervisord-example.log ; stdout log path, NONE for none; default AUTO +stdout_syslog=false ; send stdout to syslog with process name (default false) +stderr_logfile=/tmp/supervisord-example.log ; stderr log path, NONE for none; default AUTO + + +EOF diff --git a/setup-swoole-cli-pre-runtime.sh b/setup-swoole-cli-pre-runtime.sh new file mode 100644 index 0000000000..9150e7ce0e --- /dev/null +++ b/setup-swoole-cli-pre-runtime.sh @@ -0,0 +1,201 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=${__DIR__} + +cd ${__PROJECT__} + +OS=$(uname -s) +ARCH=$(uname -m) + +case $OS in +'Linux') + OS="linux" + ;; +'Darwin') + OS="macos" + ;; +*) + case $OS in + 'MSYS_NT'* | 'CYGWIN_NT'*) + OS="windows" + ;; + 'MINGW64_NT'*) + OS="windows" + ;; + *) + echo '暂未配置的 OS ' + exit 0 + ;; + esac + ;; +esac + +case $ARCH in +'x86_64') + ARCH="x64" + ;; +'aarch64' | 'arm64') + ARCH="arm64" + ;; +*) + echo '暂未配置的 ARCH ' + exit 0 + ;; +esac + +APP_VERSION='v6.0.0-dev' +APP_NAME='swoole-cli' +VERSION='swoole-cli-v0.0.9' + +mkdir -p bin/runtime +mkdir -p var/runtime + +cd ${__PROJECT__}/var/runtime + +APP_DOWNLOAD_URL="https://github.com/jingjingxyk/swoole-cli/releases/download/${VERSION}/${APP_NAME}-${APP_VERSION}-zts-${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 + APP_DOWNLOAD_URL="https://github.com/jingjingxyk/swoole-cli/releases/download/${VERSION}/${APP_NAME}-${APP_VERSION}-zts-cygwin-${ARCH}.zip" +fi + +MIRROR='' +while [ $# -gt 0 ]; do + case "$1" in + --mirror) + MIRROR="$2" + # dev beta alpha 不支持 镜像 + MIRROR="" + ;; + --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" + 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" + ;; + esac + shift $(($# > 0 ? 1 : 0)) +done + +case "$MIRROR" in +china) + APP_DOWNLOAD_URL="https://wenda-1252906962.file.myqcloud.com/dist/${APP_NAME}-${APP_VERSION}-zts-${OS}-${ARCH}.tar.xz" + COMPOSER_DOWNLOAD_URL="https://mirrors.tencent.com/composer/composer.phar" + if [ $OS = 'windows' ]; then + APP_DOWNLOAD_URL="https://wenda-1252906962.file.myqcloud.com/dist/${APP_NAME}-${APP_VERSION}-zts-cygwin-${ARCH}.zip" + fi + ;; + +esac + +test -f composer.phar || curl -LSo composer.phar ${COMPOSER_DOWNLOAD_URL} +chmod a+x composer.phar + +test -f cacert.pem || curl -LSo cacert.pem ${CACERT_DOWNLOAD_URL} + +APP_RUNTIME="${APP_NAME}-${APP_VERSION}-zts-${OS}-${ARCH}" + +if [ $OS = 'windows' ]; then + { + APP_RUNTIME="${APP_NAME}-${APP_VERSION}-zts-cygwin-${ARCH}" + test -f ${APP_RUNTIME}.zip || curl -LSo ${APP_RUNTIME}.zip ${APP_DOWNLOAD_URL} + test -d ${APP_RUNTIME} && rm -rf ${APP_RUNTIME} + unzip "${APP_RUNTIME}.zip" + exit 0 + } +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 + chmod a+x swoole-cli + cp -f ${__PROJECT__}/var/runtime/swoole-cli ${__PROJECT__}/bin/runtime/swoole-cli +fi + +cd ${__PROJECT__}/var/runtime + +cp -f ${__PROJECT__}/var/runtime/composer.phar ${__PROJECT__}/bin/runtime/composer +cp -f ${__PROJECT__}/var/runtime/cacert.pem ${__PROJECT__}/bin/runtime/cacert.pem + +cat >${__PROJECT__}/bin/runtime/php.ini <${__PROJECT__}/bin/runtime/php-fpm.conf <<'EOF' +; 更多配置参考 +; https://github.com/php/php-src/blob/master/sapi/fpm/www.conf.in +; https://github.com/php/php-src/blob/master/sapi/fpm/php-fpm.conf.in + +[global] +pid = run/php-fpm.pid +error_log = log/php-fpm.log +daemonize = yes + +[www] +user = nobody +group = nobody + +listen = 9001 +;listen = run/php-fpm.sock + +slowlog = log/$pool.log.slow +request_slowlog_timeout = 30s + + +pm = dynamic +pm.max_children = 5 +pm.start_servers = 2 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 + +; MAIN_PID=$(cat var/run/php-fpm.pid) +; 关闭 php-fpm +; kill -QUIT $MAIN_PID + +; 平滑重启 php-fpm +; kill -USR2 $MAIN_PID + +EOF + +cd ${__PROJECT__}/ + +set +x + +echo " " +echo " USE PHP RUNTIME :" +echo " " +echo " export PATH=\"${__PROJECT__}/bin/runtime:\$PATH\" " +echo " " +echo " alias swoole-cli='swoole-cli -d curl.cainfo=${__PROJECT__}/bin/runtime/cacert.pem -d openssl.cafile=${__PROJECT__}/bin/runtime/cacert.pem' " +echo " OR " +echo " alias swoole-cli='swoole-cli -c ${__PROJECT__}/bin/runtime/php.ini' " +echo " " +export PATH="${__PROJECT__}/bin/runtime:$PATH" diff --git a/setup-swoole-cli-runtime.sh b/setup-swoole-cli-runtime.sh new file mode 100644 index 0000000000..d4785cf1b6 --- /dev/null +++ b/setup-swoole-cli-runtime.sh @@ -0,0 +1,239 @@ +#!/usr/bin/env bash + +set -xu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=${__DIR__} + +cd ${__PROJECT__} + +OS=$(uname -s) +ARCH=$(uname -m) + +case $OS in +'Linux') + OS="linux" + ;; +'Darwin') + OS="macos" + ;; +*) + case $OS in + 'MSYS_NT'*) + OS="windows" + ;; + 'MINGW64_NT'*) + OS="windows" + ;; + *) + echo '暂未配置的 OS ' + exit 0 + ;; + esac + ;; +esac + +case $ARCH in +'x86_64') + ARCH="x64" + ;; +'aarch64' | 'arm64') + ARCH="arm64" + ;; +*) + echo '暂未配置的 ARCH ' + exit 0 + ;; +esac + +APP_VERSION='v6.0.0' +APP_NAME='swoole-cli' +VERSION='v6.0.0.0' + +MIRROR='' +while [ $# -gt 0 ]; do + case "$1" in + --mirror) + MIRROR="$2" + ;; + --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" + 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" + ;; + --version) + # 指定发布 TAG + if [ $OS = "macos" ]; then + X_VERSION=$(echo "$2" | grep -E '^v\d\.\d{1,2}\.\d{1,2}\.\d{1,2}$') + X_APP_VERSION=$(echo "$2" | grep -Eo '^v\d\.\d{1,2}\.\d{1,2}') + elif [ $OS = "linux" ]; then + OS_RELEASE=$(awk -F= '/^ID=/{print $2}' /etc/os-release | tr -d '\n' | tr -d '\"') + if [ "$OS_RELEASE" = 'alpine' ]; then + X_VERSION=$(echo "$2" | grep -E '^v\d\.\d{1,2}\.\d{1,2}\.\d{1,2}$') + X_APP_VERSION=$(echo "$2" | grep -Eo '^v\d\.\d{1,2}\.\d{1,2}') + else + X_VERSION=$(echo "$2" | grep -P '^v\d\.\d{1,2}\.\d{1,2}\.\d{1,2}$') + X_APP_VERSION=$(echo "$2" | grep -Po '^v\d\.\d{1,2}\.\d{1,2}') + fi + else + X_VERSION='' + X_APP_VERSION='' + fi + + if [[ -n $X_VERSION ]] && [[ -n $X_APP_VERSION ]]; then + { + VERSION=$X_VERSION + APP_VERSION=$X_APP_VERSION + } + fi + ;; + --*) + echo "Illegal option $1" + ;; + esac + shift $(($# > 0 ? 1 : 0)) +done + +mkdir -p bin/runtime +mkdir -p var/runtime + +cd ${__PROJECT__}/var/runtime + +APP_DOWNLOAD_URL="https://github.com/swoole/swoole-cli/releases/download/${VERSION}/${APP_NAME}-${APP_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 + APP_DOWNLOAD_URL="https://github.com/swoole/swoole-cli/releases/download/${VERSION}/${APP_NAME}-${APP_VERSION}-cygwin-${ARCH}.zip" +fi + +case "$MIRROR" in +china) + APP_DOWNLOAD_URL="https://wenda-1252906962.file.myqcloud.com/dist/${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}.tar.xz" + COMPOSER_DOWNLOAD_URL="https://mirrors.tencent.com/composer/composer.phar" + if [ $OS = 'windows' ]; then + APP_DOWNLOAD_URL="https://wenda-1252906962.file.myqcloud.com/dist/${APP_NAME}-${APP_VERSION}-cygwin-${ARCH}.zip" + fi + ;; + +esac + +test -f composer.phar || curl -fSLo composer.phar ${COMPOSER_DOWNLOAD_URL} +chmod a+x composer.phar + +test -f cacert.pem || curl -fSLo cacert.pem ${CACERT_DOWNLOAD_URL} + +APP_RUNTIME="${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}" + +if [ $OS = 'windows' ]; then + { + APP_RUNTIME="${APP_NAME}-${APP_VERSION}-cygwin-${ARCH}" + test -f ${APP_RUNTIME}.zip || curl -fSLo ${APP_RUNTIME}.zip ${APP_DOWNLOAD_URL} + test -d ${APP_RUNTIME} && rm -rf ${APP_RUNTIME} + unzip "${APP_RUNTIME}.zip" + echo + exit 0 + } +else + test -f ${APP_RUNTIME}.tar.xz || curl -fSLo ${APP_RUNTIME}.tar.xz ${APP_DOWNLOAD_URL} + test -f ${APP_RUNTIME}.tar || xz -d -k ${APP_RUNTIME}.tar.xz + 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 + +cd ${__PROJECT__}/var/runtime + +cp -f ${__PROJECT__}/var/runtime/composer.phar ${__PROJECT__}/bin/runtime/composer +cp -f ${__PROJECT__}/var/runtime/cacert.pem ${__PROJECT__}/bin/runtime/cacert.pem + +cat >${__PROJECT__}/bin/runtime/php.ini <${__PROJECT__}/bin/runtime/php-fpm.conf <<'EOF' +; 更多配置参考 +; https://github.com/php/php-src/blob/master/sapi/fpm/www.conf.in +; https://github.com/php/php-src/blob/master/sapi/fpm/php-fpm.conf.in + +[global] +pid = run/php-fpm.pid +error_log = log/php-fpm.log +daemonize = yes + +[www] +user = nobody +group = nobody + +listen = 9001 +;listen = run/php-fpm.sock + +slowlog = log/$pool.log.slow +request_slowlog_timeout = 30s + + +pm = dynamic +pm.max_children = 5 +pm.start_servers = 2 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 + +; MAIN_PID=$(cat var/run/php-fpm.pid) +; 关闭 php-fpm +; kill -QUIT $MAIN_PID + +; 平滑重启 php-fpm +; kill -USR2 $MAIN_PID + +EOF + +cd ${__PROJECT__}/ + +set +x + +echo " " +echo " USE PHP-FPM RUNTIME :" +echo " " +echo "${__PROJECT__}/bin/runtime/swoole-cli -c ${__PROJECT__}/bin/runtime/php.ini -P --fpm-config ${__PROJECT__}/bin/runtime/php-fpm.conf -p ${__PROJECT__}/runtime/var " +echo " " +echo " USE PHP-CLI RUNTIME :" +echo " " +echo " export PATH=\"${__PROJECT__}/bin/runtime:\$PATH\" " +echo " " +echo " alias swoole-cli='swoole-cli -d curl.cainfo=${__PROJECT__}/bin/runtime/cacert.pem -d openssl.cafile=${__PROJECT__}/bin/runtime/cacert.pem' " +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/setup-swow-cli-runtime.sh b/setup-swow-cli-runtime.sh new file mode 100644 index 0000000000..10e28741fd --- /dev/null +++ b/setup-swow-cli-runtime.sh @@ -0,0 +1,167 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=${__DIR__} + +cd ${__PROJECT__} + +OS=$(uname -s) +ARCH=$(uname -m) + +case $OS in +'Linux') + OS="linux" + ;; +'Darwin') + OS="macos" + ;; +*) + case $OS in + 'MSYS_NT'*) + OS="windows" + ;; + 'MINGW64_NT'*) + OS="windows" + ;; + *) + echo '暂未配置的 OS ' + exit 0 + ;; + esac + ;; +esac + +case $ARCH in +'x86_64') + ARCH="x64" + ;; +'aarch64' | 'arm64') + ARCH="arm64" + ;; +*) + echo '暂未配置的 ARCH ' + exit 0 + ;; +esac + +APP_VERSION='v8.2.13' +APP_NAME='php-cli' +VERSION='v1.2.0' + +mkdir -p bin/runtime +mkdir -p var/runtime + +cd ${__PROJECT__}/var/runtime + +APP_DOWNLOAD_URL="https://github.com/jingjingxyk/build-swow-cli/releases/download/${VERSION}/${APP_NAME}-${APP_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 + APP_DOWNLOAD_URL="https://github.com/jingjingxyk/build-swow-cli/releases/download/${VERSION}/${APP_NAME}-${APP_VERSION}-cygwin-${ARCH}.zip" +fi + +MIRROR='' +while [ $# -gt 0 ]; do + case "$1" in + --mirror) + MIRROR="$2" + MIRROR="" # 暂无镜像 + ;; + --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" + 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" + ;; + esac + shift $(($# > 0 ? 1 : 0)) +done + +case "$MIRROR" in +china) + APP_DOWNLOAD_URL="https://php-cli.jingjingxyk.com/${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}.tar.xz" + COMPOSER_DOWNLOAD_URL="https://mirrors.tencent.com/composer/composer.phar" + if [ $OS = 'windows' ]; then + APP_DOWNLOAD_URL="https://php-cli.jingjingxyk.com/${APP_NAME}-${APP_VERSION}-cygwin-${ARCH}.zip" + fi + ;; + +esac + +test -f composer.phar || curl -LSo composer.phar ${COMPOSER_DOWNLOAD_URL} +chmod a+x composer.phar + +test -f cacert.pem || curl -LSo cacert.pem ${CACERT_DOWNLOAD_URL} + +APP_RUNTIME="${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}" + +if [ $OS = 'windows' ]; then + { + APP_RUNTIME="${APP_NAME}-${APP_VERSION}-cygwin-${ARCH}" + test -f ${APP_RUNTIME}.zip || curl -LSo ${APP_RUNTIME}.zip ${APP_DOWNLOAD_URL} + test -d ${APP_RUNTIME} && rm -rf ${APP_RUNTIME} + unzip "${APP_RUNTIME}.zip" + echo + exit 0 + } +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 php || tar -xvf ${APP_RUNTIME}.tar + chmod a+x php + cp -f ${__PROJECT__}/var/runtime/php ${__PROJECT__}/bin/runtime/php +fi + +cd ${__PROJECT__}/var/runtime + +cp -f ${__PROJECT__}/var/runtime/composer.phar ${__PROJECT__}/bin/runtime/composer +cp -f ${__PROJECT__}/var/runtime/cacert.pem ${__PROJECT__}/bin/runtime/cacert.pem + +cat >${__PROJECT__}/bin/runtime/php.ini < 0 ? 1 : 0)) +done + + + + +APP_RUNTIME="${APP_NAME}_${OS}_${ARCH}" + +if [ $OS = 'windows' ]; then + { + APP_RUNTIME="${APP_NAME}_${OS}_${ARCH}.exe" + exit 0 + } +else + test -f ${APP_RUNTIME} || curl -LSo ${APP_RUNTIME} ${APP_DOWNLOAD_URL} + + chmod a+x ${APP_RUNTIME} + cp -rf ${__PROJECT__}/var/runtime/${APP_RUNTIME} ${__PROJECT__}/bin/runtime/${APP_RUNTIME} +fi + +cd ${__PROJECT__}/var/runtime + +cd ${__PROJECT__}/ + +set +x + +echo " 测网速工具 " +echo " USE webBenchmark RUNTIME :" +echo " " +echo " export PATH=\"${__PROJECT__}/bin/runtime:\$PATH\" " +echo " " +echo " docs : https://github.com/maintell/webBenchmark" +echo " " +echo " example : webBenchmark_linux_x64 -c 32 -s https://target.url" +echo " " +export PATH="${__PROJECT__}/bin/runtime:$PATH" diff --git a/sync-source-code.php b/sync-source-code.php index 0433ab6fa6..942704c023 100644 --- a/sync-source-code.php +++ b/sync-source-code.php @@ -3,8 +3,7 @@ declare(strict_types=1); $project_dir = __DIR__; -require_once __DIR__ . '/sapi/scripts/DownloadPHPSourceCode.php'; -$php_source_folder = PHP_SRC_DIR; +$php_source_folder = require_once __DIR__ . '/sapi/scripts/download-php-src-archive.php'; $sync_dest_dir = $project_dir . '/var/sync-source-code-tmp'; $scanned_directory_source = array_diff(scandir($php_source_folder . '/ext/'), array('..', '.')); @@ -68,34 +67,35 @@ echo "sync" # ZendVM - cp -rf $SRC/Zend/ ./Zend + cp -rf $SRC/Zend/. ./Zend # Extension - cp -rf $SRC/ext/bcmath/ ./ext/bcmath - cp -rf $SRC/ext/bz2/ ./ext/bz2 - cp -rf $SRC/ext/calendar/ ./ext/calendar - cp -rf $SRC/ext/ctype/ ./ext/ctype - cp -rf $SRC/ext/curl/ ./ext/curl - cp -rf $SRC/ext/date/ ./ext/date - cp -rf $SRC/ext/dom/ ./ext/dom - cp -rf $SRC/ext/exif/ ./ext/exif - cp -rf $SRC/ext/fileinfo/ ./ext/fileinfo - cp -rf $SRC/ext/filter/ ./ext/filter - cp -rf $SRC/ext/gd/ ./ext/gd - cp -rf $SRC/ext/gettext/ ./ext/gettext - cp -rf $SRC/ext/gmp/ ./ext/gmp - cp -rf $SRC/ext/hash/ ./ext/hash - cp -rf $SRC/ext/iconv/ ./ext/iconv - cp -rf $SRC/ext/intl/ ./ext/intl - cp -rf $SRC/ext/json/ ./ext/json - cp -rf $SRC/ext/libxml/ ./ext/libxml - cp -rf $SRC/ext/mbstring/ ./ext/mbstring - cp -rf $SRC/ext/mysqli/ ./ext/mysqli - cp -rf $SRC/ext/mysqlnd/ ./ext/mysqlnd - cp -rf $SRC/ext/opcache/ ./ext/opcache + cp -rf $SRC/ext/bcmath/. ./ext/bcmath + cp -rf $SRC/ext/bz2/. ./ext/bz2 + cp -rf $SRC/ext/calendar/. ./ext/calendar + cp -rf $SRC/ext/ctype/. ./ext/ctype + cp -rf $SRC/ext/curl/. ./ext/curl + cp -rf $SRC/ext/date/. ./ext/date + cp -rf $SRC/ext/dom/. ./ext/dom + cp -rf $SRC/ext/exif/. ./ext/exif + cp -rf $SRC/ext/fileinfo/. ./ext/fileinfo + cp -rf $SRC/ext/filter/. ./ext/filter + cp -rf $SRC/ext/gd/. ./ext/gd + cp -rf $SRC/ext/gettext/. ./ext/gettext + cp -rf $SRC/ext/gmp/. ./ext/gmp + cp -rf $SRC/ext/hash/. ./ext/hash + cp -rf $SRC/ext/iconv/. ./ext/iconv + cp -rf $SRC/ext/intl/. ./ext/intl + cp -rf $SRC/ext/json/. ./ext/json + cp -rf $SRC/ext/libxml/. ./ext/libxml + cp -rf $SRC/ext/mbstring/. ./ext/mbstring + cp -rf $SRC/ext/mysqli/. ./ext/mysqli + cp -rf $SRC/ext/mysqlnd/. ./ext/mysqlnd + cp -rf $SRC/ext/opcache/. ./ext/opcache sed -i.backup 's/ext_shared=yes/ext_shared=no/g' ext/opcache/config.m4 sed -i.backup 's/shared,,/$ext_shared,,/g' ext/opcache/config.m4 + # sed -i 's/-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1/-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -DPHP_ENABLE_OPCACHE/g' ext/opcache/config.m4 # echo '#include "php.h"\n\nextern zend_module_entry opcache_module_entry;\n#define phpext_opcache_ptr &opcache_module_entry\n' > ext/opcache/php_opcache.h cat > ext/opcache/php_opcache.h <> ext/phar/phar_internal.h - cp -rf $SRC/ext/posix/ ./ext/posix - cp -rf $SRC/ext/readline/ ./ext/readline - cp -rf $SRC/ext/reflection/ ./ext/reflection - cp -rf $SRC/ext/session/ ./ext/session - cp -rf $SRC/ext/simplexml/ ./ext/simplexml - cp -rf $SRC/ext/soap/ ./ext/soap - cp -rf $SRC/ext/sockets/ ./ext/sockets - cp -rf $SRC/ext/sodium/ ./ext/sodium - cp -rf $SRC/ext/spl/ ./ext/spl - cp -rf $SRC/ext/sqlite3/ ./ext/sqlite3 - cp -rf $SRC/ext/standard/ ./ext/standard - cp -rf $SRC/ext/sysvshm/ ./ext/sysvshm - cp -rf $SRC/ext/tokenizer/ ./ext/tokenizer - cp -rf $SRC/ext/xml/ ./ext/xml - cp -rf $SRC/ext/xmlreader/ ./ext/xmlreader - cp -rf $SRC/ext/xmlwriter/ ./ext/xmlwriter - cp -rf $SRC/ext/xsl/ ./ext/xsl - cp -rf $SRC/ext/zip/ ./ext/zip - cp -rf $SRC/ext/zlib/ ./ext/zlib + cp -rf $SRC/ext/posix/. ./ext/posix + cp -rf $SRC/ext/readline/. ./ext/readline + cp -rf $SRC/ext/reflection/. ./ext/reflection + cp -rf $SRC/ext/session/. ./ext/session + cp -rf $SRC/ext/simplexml/. ./ext/simplexml + cp -rf $SRC/ext/soap/. ./ext/soap + cp -rf $SRC/ext/sockets/. ./ext/sockets + cp -rf $SRC/ext/sodium/. ./ext/sodium + cp -rf $SRC/ext/spl/. ./ext/spl + cp -rf $SRC/ext/sqlite3/. ./ext/sqlite3 + cp -rf $SRC/ext/standard/. ./ext/standard + cp -rf $SRC/ext/sysvshm/. ./ext/sysvshm + cp -rf $SRC/ext/tokenizer/. ./ext/tokenizer + cp -rf $SRC/ext/xml/. ./ext/xml + cp -rf $SRC/ext/xmlreader/. ./ext/xmlreader + cp -rf $SRC/ext/xmlwriter/. ./ext/xmlwriter + cp -rf $SRC/ext/xsl/. ./ext/xsl + cp -rf $SRC/ext/zip/. ./ext/zip + cp -rf $SRC/ext/zlib/. ./ext/zlib # main - cp -rf $SRC/main/ ./main + cp -rf $SRC/main/. ./main sed -i.backup 's/\/\* start Zend extensions \*\//\/\* start Zend extensions \*\/\n#ifdef PHP_ENABLE_OPCACHE\n\textern zend_extension zend_extension_entry;\n\tzend_register_extension(\&zend_extension_entry, NULL);\n#endif/g' main/main.c # build - cp -rf $SRC/build/ ./build + cp -rf $SRC/build/. ./build - # TSRM - cp -rf $SRC/TSRM/ ./TSRM - cp -rf $SRC/TSRM/TSRM.h main/TSRM.h + # TSRM (more info: https://github.com/swoole/swoole-cli/commit/172c76445a631abb1b32fc2a721a2dd9d5a5fc0d) + # (https://github.com/php/php-src/pull/16568) + # cp -rf $SRC/TSRM/. ./TSRM cp -f $SRC/configure.ac ./configure.ac cp -f $SRC/buildconf ./buildconf cp -f $SRC/run-tests.php ./run-tests.php # scripts - cp -rf $SRC/scripts/ ./scripts + cp -rf $SRC/scripts/. ./scripts - # 在sed命令中,常见的需要转义的字符有:\、/、$、&、.、*、[、]等 + # 在sed命令中,常见的需要转义的字符有:\、 /、 $、 &、 .、 *、 [、]等 # 反斜杠、正斜杠、美元符号、引用符号、点号、星号、方括号等 - 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/ + # fpm [Need to manually compare fpm_main.c] + cp -rf $SRC/sapi/fpm/fpm/. ./sapi/cli/fpm + sed -i.backup '/#include "ext\/standard\/php_standard\.h"/a \ +\ +#include "ext/swoole/include/swoole_version.h"\ +extern void show_swoole_version(void);\ +' ./sapi/cli/fpm/fpm_main.c + + sed -i.backup 's/prog = "php";/prog = "swoole-cli";/' ./sapi/cli/fpm/fpm_main.c + sed -i.backup 's/Usage: %s \[-n\]/Usage: %s (fpm) [-n]/' ./sapi/cli/fpm/fpm_main.c + sed -i.backup "/force_stderr = 1;/a \\ + break;\\ +\\ + case 'P': /* enable fpm */\\ +" ./sapi/cli/fpm/fpm_main.c + sed -i.backup 's/int main(int argc, char \*argv\[\])/int fpm_main(int argc, char \*argv\[\])/g' ./sapi/cli/fpm/fpm_main.c - sed -i.backup 's/{'-', 0, NULL}/{'P', 0, "fpm"},\n {'-', 0, NULL}/g' ./sapi/cli/fpm/fpm_main.c + sed -i.backup "s/{'-', 0, NULL}/{'P', 0, \"fpm\"},\n {'-', 0, NULL}/g" ./sapi/cli/fpm/fpm_main.c + X_FPM_MATCH_LINE_NUM=$(sed -n '/__TIME__, get_zend_version());/=' ./sapi/cli/fpm/fpm_main.c) + X_FPM_REPLACE_LINE_NUM=$(($X_FPM_MATCH_LINE_NUM-2)) + X_FPM_DELETE_START_LINE_NUM=$(($X_FPM_MATCH_LINE_NUM-1)) + X_FPM_DELETE_END_LINE_NUM=$(($X_FPM_MATCH_LINE_NUM+3)) + + sed -i.backup "${X_FPM_REPLACE_LINE_NUM} s/.*/ show_swoole_version();/" ./sapi/cli/fpm/fpm_main.c + sed -i.backup "${X_FPM_DELETE_START_LINE_NUM},${X_FPM_DELETE_END_LINE_NUM}d" ./sapi/cli/fpm/fpm_main.c + + # show changed + # git diff ./sapi/cli/fpm/fpm_main.c | cat + # diff $SRC/sapi/fpm/fpm/fpm_main.c ./sapi/cli/fpm/fpm_main.c - # exit 0 # cli + # 【执行本命令,影响 swoole-cli 特性,请手动确认功能变更】 + # cp -rf $SRC/sapi/cli/. ./sapi/cli cp -rf $SRC/sapi/cli/ps_title.c ./sapi/cli cp -rf $SRC/sapi/cli/generate_mime_type_map.php ./sapi/cli cp -rf $SRC/sapi/cli/php.1.in ./sapi/cli + # clean file + 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 + test -f sapi/cli/fpm/fpm_main.c.backup && rm -f sapi/cli/fpm/fpm_main.c.backup + + # patch for readline cli + FOUND_DL_READLINE=$(grep -c '#ifdef COMPILE_DL_READLINE' ext/readline/readline_cli.c) + if test $[FOUND_DL_READLINE] -gt 0 ; then + # 获得待删除 区间 + START_LINE_NUM=$(sed -n "/#ifdef COMPILE_DL_READLINE/=" ext/readline/readline_cli.c) + START_LINE_NUM=$(($START_LINE_NUM - 1)) + END_LINE_NUM=$(sed -n "/PHP_MINIT_FUNCTION(cli_readline)/=" ext/readline/readline_cli.c) + END_LINE_NUM=$(($END_LINE_NUM - 5)) + sed -i.backup "${START_LINE_NUM},${END_LINE_NUM}d" ext/readline/readline_cli.c + REPLACE_LINE_NUM=$(sed -n "/#define GET_SHELL_CB(cb) (cb) = php_cli_get_shell_callbacks()/=" ext/readline/readline_cli.c) + REPLACE_LINE_NUM=$(($REPLACE_LINE_NUM + 1)) + sed -i.backup "${REPLACE_LINE_NUM} s/.*/ /" ext/readline/readline_cli.c + fi EOF; echo PHP_EOL;