diff --git a/.github/workflows/linux-aarch64.yml b/.github/workflows/linux-aarch64.yml index d25111e95b..03b2e2327b 100644 --- a/.github/workflows/linux-aarch64.yml +++ b/.github/workflows/linux-aarch64.yml @@ -95,7 +95,7 @@ jobs: mkdir -p bin/ mkdir -p runtime/ test -f runtime/php && rm -f runtime/php - if [ ! -f runtime/php/php ] ; then + if [ ! -f runtime/php/pie ] ; then bash setup-php-runtime.sh fi bash sapi/download-box/download-box-get-archive-from-server.sh diff --git a/.github/workflows/linux-glibc.yml b/.github/workflows/linux-glibc.yml index 28e9b59f78..3580cfe5a6 100644 --- a/.github/workflows/linux-glibc.yml +++ b/.github/workflows/linux-glibc.yml @@ -85,7 +85,7 @@ jobs: mkdir -p bin/ mkdir -p runtime/ test -f runtime/php && rm -f runtime/php - if [ ! -f runtime/php/php ] ; then + if [ ! -f runtime/php/pie ] ; then bash setup-php-runtime.sh fi bash sapi/download-box/download-box-get-archive-from-server.sh @@ -99,7 +99,7 @@ jobs: composer install --no-interaction --no-autoloader --no-scripts --profile composer dump-autoload --optimize --profile - php prepare.php --with-libavif + php prepare.php --with-libavif --without-docker sudo apt update bash ./sapi/scripts/install-deps-on-ubuntu.sh diff --git a/.github/workflows/linux-x86_64.yml b/.github/workflows/linux-x86_64.yml index b0034b33f0..0e4ab704f7 100644 --- a/.github/workflows/linux-x86_64.yml +++ b/.github/workflows/linux-x86_64.yml @@ -95,7 +95,7 @@ jobs: mkdir -p bin/ mkdir -p runtime/ test -f runtime/php && rm -f runtime/php - if [ ! -f runtime/php/php ] ; then + if [ ! -f runtime/php/pie ] ; then bash setup-php-runtime.sh fi bash sapi/download-box/download-box-get-archive-from-server.sh diff --git a/.github/workflows/macos-aarch64.yml b/.github/workflows/macos-aarch64.yml index 61226e828b..31b3cefb40 100644 --- a/.github/workflows/macos-aarch64.yml +++ b/.github/workflows/macos-aarch64.yml @@ -90,7 +90,7 @@ jobs: mkdir -p bin/ mkdir -p runtime/ test -f runtime/php && rm -f runtime/php - if [ ! -f runtime/php/php ] ; then + if [ ! -f runtime/php/pie ] ; then bash setup-php-runtime.sh fi bash sapi/download-box/download-box-get-archive-from-server.sh diff --git a/.github/workflows/macos-x86_64.yml b/.github/workflows/macos-x86_64.yml index 625dc09231..75d442a37d 100644 --- a/.github/workflows/macos-x86_64.yml +++ b/.github/workflows/macos-x86_64.yml @@ -90,7 +90,7 @@ jobs: mkdir -p bin/ mkdir -p runtime/ test -f runtime/php && rm -f runtime/php - if [ ! -f runtime/php/php ] ; then + if [ ! -f runtime/php/pie ] ; then bash setup-php-runtime.sh fi bash sapi/download-box/download-box-get-archive-from-server.sh diff --git a/.github/workflows/windows-msys2.yml b/.github/workflows/windows-msys2.yml index 82bbdb0118..5b8116bdae 100644 --- a/.github/workflows/windows-msys2.yml +++ b/.github/workflows/windows-msys2.yml @@ -47,7 +47,8 @@ jobs: - name: prepare build environment shell: msys2 {0} run: | - bash ./sapi/quickstart/windows/msys2-build/install-msys2.sh + bash sapi/quickstart/windows/msys2-build/install-msys2.sh + bash sapi/download-box/download-box-get-archive-from-server.sh - name: install deps lib with source code shell: msys2 {0} diff --git a/prepare.php b/prepare.php index af37e96761..1d1707bbc6 100755 --- a/prepare.php +++ b/prepare.php @@ -27,7 +27,7 @@ // Download swoole-src if (!is_dir(__DIR__ . '/ext/swoole')) { - shell_exec(__DIR__ . '/sapi/scripts/download-swoole-src-archive.sh'); + //shell_exec(__DIR__ . '/sapi/scripts/download-swoole-src-archive.sh'); } // Compile directly on the host machine, not in the docker container diff --git a/sapi/SWOOLE-VERSION.conf b/sapi/SWOOLE-VERSION.conf index b2c63a1c1b..4871c222ec 100644 --- a/sapi/SWOOLE-VERSION.conf +++ b/sapi/SWOOLE-VERSION.conf @@ -1 +1 @@ -v6.1.3 +v6.1.6 diff --git a/sapi/src/Extension.php b/sapi/src/Extension.php index fc9d681898..c056cc3f8b 100644 --- a/sapi/src/Extension.php +++ b/sapi/src/Extension.php @@ -7,6 +7,9 @@ class Extension extends Project public string $options = ''; public string $peclVersion = ''; + public string $pieVersion = ''; + public string $pieName = ''; + public array $dependentExtensions = []; public function withOptions(string $options): static @@ -26,4 +29,17 @@ public function withDependentExtensions(string ...$extensions): static $this->dependentExtensions += $extensions; return $this; } + + public function withPieVersion(string $pieVersion): static + { + $this->pieVersion = $pieVersion; + return $this; + } + + public function withPieName(string $pieName): static + { + $this->pieName = $pieName; + return $this; + } + } diff --git a/sapi/src/Preprocessor.php b/sapi/src/Preprocessor.php index 3da0fd4d0a..60f4f33840 100644 --- a/sapi/src/Preprocessor.php +++ b/sapi/src/Preprocessor.php @@ -309,8 +309,10 @@ public function doNotInstallLibrary(): void * @param string $file * @param object|null $project [ $lib or $ext ] */ - protected function downloadFile(string $url, string $file, ?object $project = null) + protected function downloadFile(?object $project = null) { + $url = $project->url; + $file = $project->path; $retry_number = DOWNLOAD_FILE_RETRY_NUMBE; $wait_retry = DOWNLOAD_FILE_WAIT_RETRY; $connect_timeout = DOWNLOAD_FILE_CONNECTION_TIMEOUT; @@ -324,19 +326,39 @@ protected function downloadFile(string $url, string $file, ?object $project = nu echo PHP_EOL; echo `$cmd`; echo PHP_EOL; - if (is_file($file) && (filesize($file) == 0)) { - unlink($file); - } - // 下载失败 - if (!is_file($file) or filesize($file) == 0) { - throw new Exception("Downloading file[" . basename($file) . "] from url[$url] failed"); - } - // 下载文件的 hash 不一致 - if (!$this->skipHashVerify and $project->enableHashVerify) { - if (!$project->hashVerify($file)) { - throw new Exception("The {$project->hashAlgo} of downloaded file[$file] is inconsistent with the configuration"); - } - } + } + + public function downloadFileWithPie(?object $project = null): void + { + $pieName = $project->pieName; + $pieVersion = $project->pieVersion; + $file = $project->file; + $path = $project->path; + $workdir = $this->getWorkDir(); + $cmd = << \${TEMP_FILE} 2>&1 +cat \${TEMP_FILE} +SOURCE_CODE_DIR=\$(cat \${TEMP_FILE} | grep 'source to: ' | awk -F 'source to: ' '{ print $2 }') +rm -f \${TEMP_FILE} +echo "{$pieName}:{$pieVersion} source code: \${SOURCE_CODE_DIR}" +pie info {$pieName}:{$pieVersion}; +cd \${SOURCE_CODE_DIR} +tar -czf "{$workdir}/var/ext/{$file}" . +cp -f {$workdir}/var/ext/{$file} {$path} +cd {$workdir} +EOF; + echo $cmd; + echo PHP_EOL; + echo '------------RUNNING START-------------'; + echo PHP_EOL; + echo `$cmd`; + echo '------------RUNNING END-------------'; + echo PHP_EOL; } /** @@ -363,7 +385,18 @@ public function addLibrary(Library $lib): void if (!$skip_download) { if (!is_file($lib->path) or filesize($lib->path) === 0) { echo "[Library] {$lib->file} not found, downloading: " . $lib->url . PHP_EOL; - $this->downloadFile($lib->url, $lib->path, $lib); + $this->downloadFile($lib); + $file = $lib->path; + // 下载失败 + if (!is_file($file) or filesize($file) == 0) { + throw new Exception("with Downloading file[" . basename($file) . "] from failed"); + } + // 下载文件的 hash 不一致 + if (!$this->skipHashVerify and $lib->enableHashVerify) { + if (!$lib->hashVerify($file)) { + throw new Exception("The {$lib->hashAlgo} of downloaded file[$file] is inconsistent with the configuration"); + } + } } else { echo "[Library] file cached: " . $lib->file . PHP_EOL; } @@ -396,8 +429,10 @@ public function addLibrary(Library $lib): void public function addExtension(Extension $ext): void { - if ($ext->peclVersion) { - $ext->file = $ext->name . '-' . $ext->peclVersion . '.tgz'; + if ($ext->peclVersion || $ext->pieVersion) { + $extensionVersion = !empty($ext->peclVersion) ? $ext->peclVersion : $ext->pieVersion; + $downloadType = $ext->peclVersion ? 'pecl' : 'pie'; + $ext->file = $ext->name . '-' . $extensionVersion . '.tgz'; $ext->path = $this->extensionDir . '/' . $ext->file; $ext->url = "https://pecl.php.net/get/{$ext->file}"; @@ -411,8 +446,24 @@ public function addExtension(Extension $ext): void } if (!$this->getInputOption('skip-download')) { if (!is_file($ext->path) or filesize($ext->path) === 0) { - echo "[Extension] {$ext->file} not found, downloading: " . $ext->url . PHP_EOL; - $this->downloadFile($ext->url, $ext->path, $ext); + if ($downloadType === 'pecl') { + echo "[Extension] {$ext->file} not found, downloading: " . $ext->url . PHP_EOL; + $this->downloadFile($ext); + } else { + echo "[Extension] {$ext->file} not found, downloading with pie.phar https://packagist.org/packages/" . $ext->pieName . PHP_EOL; + $this->downloadFileWithPie($ext); + } + $file = $ext->path; + // 下载失败 + if (!is_file($file) or filesize($file) == 0) { + throw new Exception("with Downloading file[" . basename($file) . "] from failed"); + } + // 下载文件的 hash 不一致 + if (!$this->skipHashVerify and $ext->enableHashVerify) { + if (!$ext->hashVerify($file)) { + throw new Exception("The {$ext->hashAlgo} of downloaded file[$file] is inconsistent with the configuration"); + } + } } else { echo "[Extension] file cached: " . $ext->file . PHP_EOL; } diff --git a/sapi/src/builder/extension/swoole.php b/sapi/src/builder/extension/swoole.php index 6213b213f4..100c049e01 100644 --- a/sapi/src/builder/extension/swoole.php +++ b/sapi/src/builder/extension/swoole.php @@ -30,15 +30,19 @@ $p->withExportVariable('URING_CFLAGS', '$(pkg-config --cflags --static liburing)'); $p->withExportVariable('URING_LIBS', '$(pkg-config --libs --static liburing)'); } - - $p->addExtension((new Extension('swoole')) - ->withHomePage('https://github.com/swoole/swoole-src') - ->withLicense('https://github.com/swoole/swoole-src/blob/master/LICENSE', Extension::LICENSE_APACHE2) - ->withManual('https://wiki.swoole.com/#/') - ->withOptions(implode(' ', $options)) - ->withBuildCached(false) - ->withDependentLibraries(...$dependentLibraries) - ->withDependentExtensions(...$dependentExtensions)); + $swoole_version = trim(file_get_contents(__DIR__ . '/../../../SWOOLE-VERSION.conf')); + $p->addExtension( + (new Extension('swoole')) + ->withHomePage('https://github.com/swoole/swoole-src') + ->withLicense('https://github.com/swoole/swoole-src/blob/master/LICENSE', Extension::LICENSE_APACHE2) + ->withManual('https://wiki.swoole.com/#/') + ->withOptions(implode(' ', $options)) + ->withBuildCached(false) + ->withDependentLibraries(...$dependentLibraries) + ->withDependentExtensions(...$dependentExtensions) + ->withPieName('swoole/swoole') + ->withPieVersion($swoole_version) + ); $p->withVariable('LIBS', '$LIBS ' . ($p->isMacos() ? '-lc++' : '-lstdc++')); $p->withExportVariable('CARES_CFLAGS', '$(pkg-config --cflags --static libcares)'); diff --git a/setup-php-runtime.sh b/setup-php-runtime.sh index 17931779a1..0621068ff8 100644 --- a/setup-php-runtime.sh +++ b/setup-php-runtime.sh @@ -51,7 +51,7 @@ esac APP_VERSION='v5.1.3' APP_NAME='swoole-cli' VERSION='v5.1.3.0' -PIE_VERSION="1.2.1" +PIE_VERSION="1.3.5" # 查看pie最新版本 https://github.com/php/pie/releases/latest cd ${__PROJECT__}