diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..6a441788 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,12 @@ +## What does this PR do? + + + +## Checklist before merging + +> If your PR involves the changes mentioned below and completed the action, please tick the corresponding option. +> If a modification is not involved, please skip it directly. + +- [ ] If it's a extension or dependency update, make sure adding related extensions in `src/global/test-extensions.php`. +- [ ] If you changed the behavior of static-php-cli, add docs in [static-php/static-php-cli-docs](https://github.com/static-php/static-php-cli-docs) . +- [ ] If you updated `config/xxxx.json` content, run `bin/spc dev:sort-config xxx`. diff --git a/.github/workflows/build-linux-arm.yml b/.github/workflows/build-linux-arm.yml index d36321e4..3fc6d5e5 100644 --- a/.github/workflows/build-linux-arm.yml +++ b/.github/workflows/build-linux-arm.yml @@ -51,7 +51,7 @@ jobs: uses: actions/cache@v3 with: path: downloads - key: php-${{ inputs.version }}-dependencies + key: php-${{ inputs.version }}-dependencies-${{ inputs.extensions }} # With or without debug - if: inputs.debug == true @@ -67,7 +67,7 @@ jobs: # If there's no dependencies cache, fetch sources, with or without debug - if: steps.cache-download.outputs.cache-hit != 'true' - run: SPC_USE_ARCH=${{ inputs.operating-system }} ./bin/spc-alpine-docker download --with-php=${{ inputs.version }} --all ${{ env.SPC_BUILD_DEBUG }} + run: SPC_USE_ARCH=${{ inputs.operating-system }} ./bin/spc-alpine-docker download --with-php=${{ inputs.version }} --for-extensions=${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} # Run build command - run: SPC_USE_ARCH=${{ inputs.operating-system }} ./bin/spc-alpine-docker build ${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }} diff --git a/.github/workflows/build-linux-x86_64.yml b/.github/workflows/build-linux-x86_64.yml index 90705f33..4251f9e2 100644 --- a/.github/workflows/build-linux-x86_64.yml +++ b/.github/workflows/build-linux-x86_64.yml @@ -56,7 +56,7 @@ jobs: uses: actions/cache@v3 with: path: downloads - key: php-${{ inputs.version }}-dependencies + key: php-${{ inputs.version }}-dependencies-${{ inputs.extensions }} # With or without debug - if: inputs.debug == true @@ -72,7 +72,7 @@ jobs: # If there's no dependencies cache, fetch sources, with or without debug - if: steps.cache-download.outputs.cache-hit != 'true' - run: CACHE_API_EXEC=yes ./bin/spc-alpine-docker download --with-php=${{ inputs.version }} --all ${{ env.SPC_BUILD_DEBUG }} + run: CACHE_API_EXEC=yes ./bin/spc-alpine-docker download --with-php=${{ inputs.version }} --for-extensions=${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} # Run build command - run: ./bin/spc-alpine-docker build ${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }} diff --git a/.github/workflows/build-macos-x86_64.yml b/.github/workflows/build-macos-x86_64.yml index 6727fcbd..7ef31bb7 100644 --- a/.github/workflows/build-macos-x86_64.yml +++ b/.github/workflows/build-macos-x86_64.yml @@ -61,7 +61,7 @@ jobs: uses: actions/cache@v3 with: path: downloads - key: php-${{ inputs.version }}-dependencies + key: php-${{ inputs.version }}-dependencies-${{ inputs.extensions }} # With or without debug - if: inputs.debug == true @@ -77,7 +77,7 @@ jobs: # If there's no dependencies cache, fetch sources, with or without debug - if: steps.cache-download.outputs.cache-hit != 'true' - run: ./bin/spc download --with-php=${{ inputs.version }} --all ${{ env.SPC_BUILD_DEBUG }} + run: ./bin/spc download --with-php=${{ inputs.version }} --for-extensions=${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} # Run build command - run: ./bin/spc build ${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d7223f64..8370a0c3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,98 +1,145 @@ name: Tests on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] permissions: - contents: read + contents: read jobs: - php-cs-fixer: - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - - name: Checkout - uses: actions/checkout@v4 + php-cs-fixer: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: "Checkout" + uses: actions/checkout@v4 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - extensions: curl, openssl, mbstring - ini-values: memory_limit=-1 - tools: pecl, composer, php-cs-fixer + - name: "Setup PHP" + uses: shivammathur/setup-php@v2 + with: + php-version: '8.1' + extensions: curl, openssl, mbstring + ini-values: memory_limit=-1 + tools: pecl, composer, php-cs-fixer - - name: Run PHP-CS-Fixer fix - run: php-cs-fixer fix --dry-run --diff --ansi + - name: Run PHP-CS-Fixer fix + run: php-cs-fixer fix --dry-run --diff --ansi - phpstan: - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - - name: Checkout - uses: actions/checkout@v4 + phpstan: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: "Checkout" + uses: actions/checkout@v4 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - extensions: curl, openssl, mbstring - ini-values: memory_limit=-1 - tools: composer + - name: "Setup PHP" + uses: shivammathur/setup-php@v2 + with: + php-version: '8.1' + extensions: curl, openssl, mbstring + ini-values: memory_limit=-1 + tools: composer - - name: Cache Composer packages - id: composer-cache - uses: actions/cache@v3 - with: - path: vendor - key: ${{ runner.os }}-phpstan-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-phpstan- + - name: "Cache Composer packages" + id: composer-cache + uses: actions/cache@v3 + with: + path: vendor + key: ${{ runner.os }}-phpstan-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-phpstan- - - name: Install Dependencies - run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist + - name: "Install Dependencies" + run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist - - name: Run phpstan - run: vendor/bin/phpstan analyse + - name: "Run phpstan" + run: vendor/bin/phpstan analyse - phpunit: - name: PHPUnit (PHP ${{ matrix.php }}) - runs-on: ubuntu-latest - timeout-minutes: 10 - strategy: - matrix: - include: - - php: '8.1' - - php: '8.2' - fail-fast: false + phpunit: + name: "PHPUnit (PHP ${{ matrix.php }})" + runs-on: ubuntu-latest + timeout-minutes: 10 + strategy: + matrix: + include: + - php: '8.1' + - php: '8.2' + fail-fast: false - steps: - - name: Checkout - uses: actions/checkout@v4 + steps: + - name: "Checkout" + uses: actions/checkout@v4 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: "${{ matrix.php }}" - tools: pecl, composer - extensions: curl, openssl, mbstring - ini-values: memory_limit=-1 + - name: "Setup PHP" + uses: shivammathur/setup-php@v2 + with: + php-version: "${{ matrix.php }}" + tools: pecl, composer + extensions: curl, openssl, mbstring + ini-values: memory_limit=-1 - - name: Cache Composer packages - id: composer-cache - uses: actions/cache@v3 - with: - path: vendor - key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-php- + - name: "Cache Composer packages" + id: composer-cache + uses: actions/cache@v3 + with: + path: vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php- - - name: Install Dependencies - run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist + - name: "Install Dependencies" + run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist - - name: Run PHPUnit tests - run: | - vendor/bin/phpunit tests/ --no-coverage + - name: "Run PHPUnit Tests" + run: | + vendor/bin/phpunit tests/ --no-coverage + + build: + name: "Build PHP Test (PHP ${{ matrix.php }})" + runs-on: ${{ matrix.os }} + timeout-minutes: 120 + strategy: + matrix: + php: + - 8.0 + - 8.1 + - 8.2 + os: + - ubuntu-latest + - macos-latest + fail-fast: false + steps: + - name: "Checkout" + uses: actions/checkout@v4 + + - name: "Setup PHP" + uses: shivammathur/setup-php@v2 + with: + php-version: "${{ matrix.php }}" + tools: pecl, composer + extensions: curl, openssl, mbstring + ini-values: memory_limit=-1 + + - name: "Cache Composer packages" + id: composer-cache + uses: actions/cache@v3 + with: + path: vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php- + + - name: "Install Dependencies" + run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist + + - name: "Run Build Tests (doctor)" + run: bin/spc doctor --auto-fix + + - name: "Run Build Tests (download)" + run: bin/spc download --for-extensions="$(php src/globals/test-extensions.php)" --with-php=${{ matrix.php }} --debug + + - name: "Run Build Tests (build)" + run: bin/spc build "$(php src/globals/test-extensions.php)" --build-cli --build-micro --build-fpm --debug diff --git a/config/ext.json b/config/ext.json index ab3f18d2..19125296 100644 --- a/config/ext.json +++ b/config/ext.json @@ -118,7 +118,7 @@ "iconv": { "type": "builtin", "arg-type": "with-prefix", - "lib-depends-windows": [ + "lib-depends": [ "libiconv" ] }, @@ -132,12 +132,12 @@ }, "imap": { "type": "builtin", - "arg-type": "with", + "arg-type": "custom", "lib-depends": [ "imap" ], "lib-suggests": [ - "kerberos" + "openssl" ] }, "inotify": { @@ -234,7 +234,8 @@ "type": "builtin", "arg-type": "custom", "lib-depends": [ - "openssl" + "openssl", + "zlib" ], "ext-depends": [ "zlib" diff --git a/config/lib.json b/config/lib.json index 6a602d16..a36afebd 100644 --- a/config/lib.json +++ b/config/lib.json @@ -141,6 +141,15 @@ "libxml2" ] }, + "imap": { + "source": "imap", + "static-libs-unix": [ + "libc-client.a" + ], + "lib-suggests": [ + "openssl" + ] + }, "ldap": { "source": "ldap", "static-libs-unix": [ @@ -302,8 +311,7 @@ ], "lib-suggests-windows": [ "icu", - "xz", - "pthreads4w" + "xz" ] }, "libxslt": { @@ -441,18 +449,6 @@ "zstd" ] }, - "pthreads4w": { - "source": "pthreads4w", - "static-libs-windows": [ - "libpthreadVC3.lib" - ], - "headers-windows": [ - "_ptw32.h", - "pthread.h", - "sched.h", - "semaphore.h" - ] - }, "readline": { "source": "readline", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index 7d35661e..cca1284f 100644 --- a/config/source.json +++ b/config/source.json @@ -121,9 +121,9 @@ } }, "freetype": { - "type": "filelist", - "url": "https://download-mirror.savannah.gnu.org/releases/freetype/", - "regex": "/href=\"(?freetype-(?[^\"]+)\\.tar\\.xz)\"/", + "type": "git", + "rev": "VER-2-13-2", + "url": "https://github.com/freetype/freetype", "license": { "type": "file", "path": "LICENSE.TXT" @@ -154,6 +154,15 @@ "path": "LICENSE" } }, + "imap": { + "type": "git", + "url": "https://github.com/static-php/imap.git", + "rev": "master", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "inotify": { "type": "url", "url": "https://pecl.php.net/get/inotify", @@ -218,7 +227,7 @@ }, "libmcrypt": { "type": "url", - "url": "https://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz", + "url": "https://downloads.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz", "license": { "type": "file", "path": "COPYING" @@ -235,7 +244,7 @@ }, "libpng": { "type": "git", - "url": "https://git.code.sf.net/p/libpng/code", + "url": "https://github.com/glennrp/libpng.git", "rev": "libpng16", "license": { "type": "file", @@ -304,7 +313,7 @@ }, "mcrypt": { "type": "url", - "url": "https://jaist.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz", + "url": "https://downloads.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz", "license": { "type": "file", "path": "COPYING" @@ -403,15 +412,6 @@ "path": "LICENSE" } }, - "pthreads4w": { - "type": "git", - "rev": "master", - "url": "https://git.code.sf.net/p/pthreads4w/code", - "license": { - "type": "file", - "path": "LICENSE" - } - }, "readline": { "type": "filelist", "url": "https://ftp.gnu.org/pub/gnu/readline/", diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 6e46886f..d214b859 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -69,7 +69,7 @@ abstract class BuilderBase foreach ($libraries as $library) { // if some libs are not supported (but in config "lib.json", throw exception) if (!isset($support_lib_list[$library])) { - throw new RuntimeException('library [' . $library . '] is in the lib.json list but not supported to compile, but in the future I will support it!'); + throw new WrongUsageException('library [' . $library . '] is in the lib.json list but not supported to compile, but in the future I will support it!'); } $lib = new ($support_lib_list[$library])($this); $this->addLib($lib); diff --git a/src/SPC/builder/extension/imap.php b/src/SPC/builder/extension/imap.php new file mode 100644 index 00000000..389223ec --- /dev/null +++ b/src/SPC/builder/extension/imap.php @@ -0,0 +1,28 @@ +builder->getOption('enable-zts')) { + throw new WrongUsageException('ext-imap is not thread safe, do not build it with ZTS builds'); + } + $arg = '--with-imap=' . BUILD_ROOT_PATH; + if ($this->builder->getLib('openssl') !== null) { + $arg .= ' --with-imap-ssl=' . BUILD_ROOT_PATH; + } + return $arg; + } +} diff --git a/src/SPC/builder/extension/swoole.php b/src/SPC/builder/extension/swoole.php index 987a0cab..a9c1199f 100644 --- a/src/SPC/builder/extension/swoole.php +++ b/src/SPC/builder/extension/swoole.php @@ -16,7 +16,7 @@ class swoole extends Extension // pgsql hook is buggy for static php $arg .= ' --disable-swoole-pgsql'; $arg .= $this->builder->getLib('openssl') ? ' --enable-openssl' : ' --disable-openssl --without-openssl'; - $arg .= $this->builder->getLib('brotli') ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : ''; + $arg .= $this->builder->getLib('brotli') ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : ' --disable-brotli'; $arg .= $this->builder->getExt('curl') ? ' --enable-swoole-curl' : ' --disable-swoole-curl'; return $arg; } diff --git a/src/SPC/builder/linux/library/imap.php b/src/SPC/builder/linux/library/imap.php new file mode 100644 index 00000000..60b02203 --- /dev/null +++ b/src/SPC/builder/linux/library/imap.php @@ -0,0 +1,63 @@ +source_dir . '/Makefile', '-DMAC_OSX_KLUDGE=1', ''); + FileSystem::replaceFileStr($this->source_dir . '/src/osdep/unix/Makefile', 'CC=cc', "CC={$cc}"); + /* FileSystem::replaceFileStr($this->source_dir . '/src/osdep/unix/Makefile', '-lcrypto -lz', '-lcrypto'); + FileSystem::replaceFileStr($this->source_dir . '/src/osdep/unix/Makefile', '-lcrypto', '-lcrypto -lz'); + FileSystem::replaceFileStr( + $this->source_dir . '/src/osdep/unix/ssl_unix.c', + "#include \n#include ", + "#include \n#include " + ); + // SourcePatcher::patchFile('1006_openssl1.1_autoverify.patch', $this->source_dir); + SourcePatcher::patchFile('2014_openssl1.1.1_sni.patch', $this->source_dir); */ + FileSystem::replaceFileStr($this->source_dir . '/Makefile', 'SSLINCLUDE=/usr/include/openssl', 'SSLINCLUDE=' . BUILD_INCLUDE_PATH); + FileSystem::replaceFileStr($this->source_dir . '/Makefile', 'SSLLIB=/usr/lib', 'SSLLIB=' . BUILD_LIB_PATH); + return true; + } + + /** + * @throws RuntimeException + */ + protected function build(): void + { + if ($this->builder->getLib('openssl')) { + $ssl_options = 'SPECIALAUTHENTICATORS=ssl SSLTYPE=unix.nopwd SSLINCLUDE=' . BUILD_INCLUDE_PATH . ' SSLLIB=' . BUILD_LIB_PATH; + } else { + $ssl_options = 'SSLTYPE=none'; + } + shell()->cd($this->source_dir) + ->exec('make clean') + ->exec('touch ip6') + ->exec( + "yes | make slx {$ssl_options}" + ); + try { + shell() + ->exec("cp -rf {$this->source_dir}/c-client/c-client.a " . BUILD_LIB_PATH . '/libc-client.a') + ->exec("cp -rf {$this->source_dir}/c-client/*.c " . BUILD_LIB_PATH . '/') + ->exec("cp -rf {$this->source_dir}/c-client/*.h " . BUILD_INCLUDE_PATH . '/') + ->exec("cp -rf {$this->source_dir}/src/osdep/unix/*.h " . BUILD_INCLUDE_PATH . '/'); + } catch (\Throwable) { + // last command throws an exception, no idea why since it works + } + } +} diff --git a/src/SPC/builder/macos/library/imap.php b/src/SPC/builder/macos/library/imap.php new file mode 100644 index 00000000..ab489ee6 --- /dev/null +++ b/src/SPC/builder/macos/library/imap.php @@ -0,0 +1,66 @@ +source_dir); + // FileSystem::replaceFileStr($this->source_dir . '/Makefile', '-DMAC_OSX_KLUDGE=1', ''); + FileSystem::replaceFileStr($this->source_dir . '/src/osdep/unix/Makefile', 'CC=cc', "CC={$cc}"); + /* FileSystem::replaceFileStr($this->source_dir . '/src/osdep/unix/Makefile', '-lcrypto -lz', '-lcrypto'); + FileSystem::replaceFileStr($this->source_dir . '/src/osdep/unix/Makefile', '-lcrypto', '-lcrypto -lz'); + FileSystem::replaceFileStr( + $this->source_dir . '/src/osdep/unix/ssl_unix.c', + "#include \n#include ", + "#include \n#include " + ); + // SourcePatcher::patchFile('1006_openssl1.1_autoverify.patch', $this->source_dir); + SourcePatcher::patchFile('2014_openssl1.1.1_sni.patch', $this->source_dir); */ + FileSystem::replaceFileStr($this->source_dir . '/Makefile', 'SSLINCLUDE=/usr/include/openssl', 'SSLINCLUDE=' . BUILD_INCLUDE_PATH); + FileSystem::replaceFileStr($this->source_dir . '/Makefile', 'SSLLIB=/usr/lib', 'SSLLIB=' . BUILD_LIB_PATH); + return true; + } + + /** + * @throws RuntimeException + */ + protected function build(): void + { + if ($this->builder->getLib('openssl')) { + $ssl_options = 'SPECIALAUTHENTICATORS=ssl SSLTYPE=unix.nopwd SSLINCLUDE=' . BUILD_INCLUDE_PATH . ' SSLLIB=' . BUILD_LIB_PATH; + } else { + $ssl_options = 'SSLTYPE=none'; + } + shell()->cd($this->source_dir) + ->exec('make clean') + ->exec('touch ip6') + ->exec( + "yes | EXTRACFLAGS='-Wimplicit-function-declaration -include $(xcrun --show-sdk-path)/usr/include/poll.h -include $(xcrun --show-sdk-path)/usr/include/time.h -include $(xcrun --show-sdk-path)/usr/include/utime.h' make osx {$ssl_options}" + ); + try { + shell() + ->exec("cp -rf {$this->source_dir}/c-client/c-client.a " . BUILD_LIB_PATH . '/libc-client.a') + ->exec("cp -rf {$this->source_dir}/c-client/*.c " . BUILD_LIB_PATH . '/') + ->exec("cp -rf {$this->source_dir}/c-client/*.h " . BUILD_INCLUDE_PATH . '/') + ->exec("cp -rf {$this->source_dir}/src/osdep/unix/*.h " . BUILD_INCLUDE_PATH . '/'); + } catch (\Throwable) { + // last command throws an exception, no idea why since it works + } + } +} diff --git a/src/SPC/builder/unix/library/freetype.php b/src/SPC/builder/unix/library/freetype.php index 8ef3368f..3158d828 100644 --- a/src/SPC/builder/unix/library/freetype.php +++ b/src/SPC/builder/unix/library/freetype.php @@ -26,6 +26,7 @@ trait freetype $suggested .= ' '; shell()->cd($this->source_dir) + ->exec('sh autogen.sh') ->exec( './configure ' . '--enable-static --disable-shared --without-harfbuzz --prefix= ' . diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 38be1bf2..5769c106 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -24,7 +24,6 @@ trait postgresql $optional_packages = [ 'zstd' => 'libzstd', 'ldap' => 'ldap', - 'libpam' => 'libpam', 'libxslt' => 'libxslt', 'icu' => 'icu-i18n', ]; @@ -74,12 +73,12 @@ trait postgresql '--with-libxml ' . ($this->builder->getLib('icu') ? '--with-icu ' : '--without-icu ') . ($this->builder->getLib('ldap') ? '--with-ldap ' : '--without-ldap ') . - ($this->builder->getLib('libpam') ? '--with-pam ' : '--without-pam ') . ($this->builder->getLib('libxslt') ? '--with-libxslt ' : '--without-libxslt ') . ($this->builder->getLib('zstd') ? '--with-zstd ' : '--without-zstd ') . '--without-lz4 ' . '--without-perl ' . '--without-python ' . + '--without-pam ' . '--without-bonjour ' . '--without-tcl ' ); diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index ee9394f3..40d17956 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -36,7 +36,7 @@ class LinuxToolCheckList 'git', 'autoconf', 'automake', 'tar', 'unzip', 'gzip', 'gcc', 'bzip2', 'cmake', 'patch', - 'xz', 'wget', // to get musl + 'xz', ]; /** @noinspection PhpUnused */ @@ -47,8 +47,7 @@ class LinuxToolCheckList $required = match ($distro['dist']) { 'alpine' => self::TOOLS_ALPINE, - 'almalinux' => self::TOOLS_RHEL, - 'rhel' => self::TOOLS_RHEL, + 'redhat' => self::TOOLS_RHEL, default => self::TOOLS_DEBIAN, }; $missing = []; @@ -61,8 +60,7 @@ class LinuxToolCheckList return match ($distro['dist']) { 'ubuntu', 'alpine', - 'rhel', - 'almalinux', + 'redhat', 'debian' => CheckResult::fail(implode(', ', $missing) . ' not installed on your system', 'install-linux-tools', [$distro, $missing]), default => CheckResult::fail(implode(', ', $missing) . ' not installed on your system'), }; @@ -74,11 +72,10 @@ class LinuxToolCheckList #[AsCheckItem('if necessary packages are installed', limit_os: 'Linux')] public function checkSystemOSPackages(): ?CheckResult { - $distro = SystemUtil::getOSRelease(); - if ($distro['dist'] === 'alpine') { + if (SystemUtil::isMuslDist()) { // check linux-headers installation if (!file_exists('/usr/include/linux/mman.h')) { - return CheckResult::fail('linux-headers not installed on your system', 'install-linux-tools', [$distro, ['linux-headers']]); + return CheckResult::fail('linux-headers not installed on your system', 'install-linux-tools', [SystemUtil::getOSRelease(), ['linux-headers']]); } } return CheckResult::ok(); @@ -94,8 +91,7 @@ class LinuxToolCheckList $install_cmd = match ($distro['dist']) { 'ubuntu', 'debian' => 'apt-get install -y', 'alpine' => 'apk add', - 'rhel' => 'dnf install -y', - 'almalinux' => 'dnf install -y', + 'redhat' => 'dnf install -y', default => throw new RuntimeException('Current linux distro does not have an auto-install script for musl packages yet.'), }; $prefix = ''; @@ -104,8 +100,8 @@ class LinuxToolCheckList logger()->warning('Current user is not root, using sudo for running command'); } try { - $is_rhel = in_array($distro['dist'], ['rhel', 'almalinux']); - $to_install = $is_rhel ? $missing : str_replace('xz', 'xz-utils', $missing); + $is_debian = in_array($distro['dist'], ['debian', 'ubuntu']); + $to_install = $is_debian ? str_replace('xz', 'xz-utils', $missing) : $missing; shell(true)->exec($prefix . $install_cmd . ' ' . implode(' ', $to_install)); } catch (RuntimeException) { return false; diff --git a/src/globals/patch/0001_imap_macos.patch b/src/globals/patch/0001_imap_macos.patch new file mode 100644 index 00000000..c977de6a --- /dev/null +++ b/src/globals/patch/0001_imap_macos.patch @@ -0,0 +1,220 @@ +From 5ab3bd7fa858eec0626a9dd0117ca3b050ef4660 Mon Sep 17 00:00:00 2001 +From: crazywhalecc +Date: Mon, 13 Nov 2023 00:00:52 +0800 +Subject: [PATCH] make macOS static compile happy + +--- + src/c-client/netmsg.c | 1 + + src/c-client/nntp.c | 1 + + src/osdep/amiga/dummy.c | 1 + + src/osdep/amiga/mbx.c | 1 + + src/osdep/amiga/mh.c | 1 + + src/osdep/amiga/mtx.c | 1 + + src/osdep/amiga/unix.c | 1 + + src/osdep/unix/dummy.c | 1 + + src/osdep/unix/mbx.c | 1 + + src/osdep/unix/mh.c | 1 + + src/osdep/unix/mmdf.c | 1 + + src/osdep/unix/mtx.c | 1 + + src/osdep/unix/mx.c | 1 + + src/osdep/unix/tcp_unix.c | 1 + + src/osdep/unix/tenex.c | 2 ++ + src/osdep/unix/unix.c | 1 + + 16 files changed, 17 insertions(+) + +diff --git a/src/c-client/netmsg.c b/src/c-client/netmsg.c +index 187e4eb..f316d0b 100644 +--- a/src/c-client/netmsg.c ++++ b/src/c-client/netmsg.c +@@ -29,6 +29,7 @@ + + #include + #include ++#include + extern int errno; /* just in case */ + #include "c-client.h" + #include "netmsg.h" +diff --git a/src/c-client/nntp.c b/src/c-client/nntp.c +index fe90edb..b2f7536 100644 +--- a/src/c-client/nntp.c ++++ b/src/c-client/nntp.c +@@ -29,6 +29,7 @@ + + #include + #include ++#include + #include "c-client.h" + #include "newsrc.h" + #include "netmsg.h" +diff --git a/src/osdep/amiga/dummy.c b/src/osdep/amiga/dummy.c +index b003a0b..2c65824 100644 +--- a/src/osdep/amiga/dummy.c ++++ b/src/osdep/amiga/dummy.c +@@ -35,6 +35,7 @@ extern int errno; /* just in case */ + #include "osdep.h" + #include + #include ++#include + #include "dummy.h" + #include "misc.h" + +diff --git a/src/osdep/amiga/mbx.c b/src/osdep/amiga/mbx.c +index 1ece5d8..2495965 100644 +--- a/src/osdep/amiga/mbx.c ++++ b/src/osdep/amiga/mbx.c +@@ -43,6 +43,7 @@ extern int errno; /* just in case */ + #include + #include + #include ++#include + #include "misc.h" + #include "dummy.h" + #include "fdstring.h" +diff --git a/src/osdep/amiga/mh.c b/src/osdep/amiga/mh.c +index 0226b7a..e7c907a 100644 +--- a/src/osdep/amiga/mh.c ++++ b/src/osdep/amiga/mh.c +@@ -36,6 +36,7 @@ extern int errno; /* just in case */ + #include + #include + #include ++#include + #include "misc.h" + #include "dummy.h" + #include "fdstring.h" +diff --git a/src/osdep/amiga/mtx.c b/src/osdep/amiga/mtx.c +index 8e6f76e..ca7b368 100644 +--- a/src/osdep/amiga/mtx.c ++++ b/src/osdep/amiga/mtx.c +@@ -43,6 +43,7 @@ extern int errno; /* just in case */ + #include + #include + #include ++#include + #include "misc.h" + #include "dummy.h" + #include "fdstring.h" +diff --git a/src/osdep/amiga/unix.c b/src/osdep/amiga/unix.c +index be3c437..c755fe7 100644 +--- a/src/osdep/amiga/unix.c ++++ b/src/osdep/amiga/unix.c +@@ -46,6 +46,7 @@ extern int errno; /* just in case */ + #include "osdep.h" + #include + #include ++#include + #include "unix.h" + #include "pseudo.h" + #include "fdstring.h" +diff --git a/src/osdep/unix/dummy.c b/src/osdep/unix/dummy.c +index b003a0b..2c65824 100644 +--- a/src/osdep/unix/dummy.c ++++ b/src/osdep/unix/dummy.c +@@ -35,6 +35,7 @@ extern int errno; /* just in case */ + #include "osdep.h" + #include + #include ++#include + #include "dummy.h" + #include "misc.h" + +diff --git a/src/osdep/unix/mbx.c b/src/osdep/unix/mbx.c +index 1ece5d8..2495965 100644 +--- a/src/osdep/unix/mbx.c ++++ b/src/osdep/unix/mbx.c +@@ -43,6 +43,7 @@ extern int errno; /* just in case */ + #include + #include + #include ++#include + #include "misc.h" + #include "dummy.h" + #include "fdstring.h" +diff --git a/src/osdep/unix/mh.c b/src/osdep/unix/mh.c +index 0226b7a..e7c907a 100644 +--- a/src/osdep/unix/mh.c ++++ b/src/osdep/unix/mh.c +@@ -36,6 +36,7 @@ extern int errno; /* just in case */ + #include + #include + #include ++#include + #include "misc.h" + #include "dummy.h" + #include "fdstring.h" +diff --git a/src/osdep/unix/mmdf.c b/src/osdep/unix/mmdf.c +index e962434..8cc9fae 100644 +--- a/src/osdep/unix/mmdf.c ++++ b/src/osdep/unix/mmdf.c +@@ -34,6 +34,7 @@ extern int errno; /* just in case */ + #include "osdep.h" + #include + #include ++#include + #include "pseudo.h" + #include "fdstring.h" + #include "misc.h" +diff --git a/src/osdep/unix/mtx.c b/src/osdep/unix/mtx.c +index 8e6f76e..ca7b368 100644 +--- a/src/osdep/unix/mtx.c ++++ b/src/osdep/unix/mtx.c +@@ -43,6 +43,7 @@ extern int errno; /* just in case */ + #include + #include + #include ++#include + #include "misc.h" + #include "dummy.h" + #include "fdstring.h" +diff --git a/src/osdep/unix/mx.c b/src/osdep/unix/mx.c +index 4549527..9d444c9 100644 +--- a/src/osdep/unix/mx.c ++++ b/src/osdep/unix/mx.c +@@ -36,6 +36,7 @@ extern int errno; /* just in case */ + #include + #include + #include ++#include + #include "misc.h" + #include "dummy.h" + #include "fdstring.h" +diff --git a/src/osdep/unix/tcp_unix.c b/src/osdep/unix/tcp_unix.c +index 5bad706..5d6cd03 100644 +--- a/src/osdep/unix/tcp_unix.c ++++ b/src/osdep/unix/tcp_unix.c +@@ -27,6 +27,7 @@ + */ + + #include "ip_unix.c" ++#include + + #undef write /* don't use redefined write() */ + +diff --git a/src/osdep/unix/tenex.c b/src/osdep/unix/tenex.c +index eee61fb..61760f0 100644 +--- a/src/osdep/unix/tenex.c ++++ b/src/osdep/unix/tenex.c +@@ -46,6 +46,8 @@ extern int errno; /* just in case */ + #include "mail.h" + #include "osdep.h" + #include ++#include ++#include + #include "misc.h" + #include "dummy.h" + +diff --git a/src/osdep/unix/unix.c b/src/osdep/unix/unix.c +index be3c437..c755fe7 100644 +--- a/src/osdep/unix/unix.c ++++ b/src/osdep/unix/unix.c +@@ -46,6 +46,7 @@ extern int errno; /* just in case */ + #include "osdep.h" + #include + #include ++#include + #include "unix.h" + #include "pseudo.h" + #include "fdstring.h" +-- +2.39.3 (Apple Git-145) + diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php new file mode 100644 index 00000000..3a2548d3 --- /dev/null +++ b/src/globals/test-extensions.php @@ -0,0 +1,8 @@ +