Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2d550a8
Add simple output handling to exception classes
crazywhalecc Feb 28, 2026
ed5a516
Implement check-update functionality for artifacts and enhance downlo…
crazywhalecc Feb 28, 2026
40e3698
Add custom binary check-update support for artifacts
crazywhalecc Feb 28, 2026
550f6ca
Replace RuntimeException with DownloaderException for Go version retr…
crazywhalecc Feb 28, 2026
0a07f6b
cs fix
crazywhalecc Feb 28, 2026
a7b04d9
Update src/StaticPHP/Artifact/Downloader/Type/Git.php
crazywhalecc Feb 28, 2026
64b0e72
Update src/StaticPHP/Artifact/Downloader/Type/PIE.php
crazywhalecc Feb 28, 2026
6ef5e9e
Update src/StaticPHP/Artifact/Downloader/Type/CheckUpdateInterface.php
crazywhalecc Feb 28, 2026
28f4a5c
Add support for custom source check-update callbacks in artifacts
crazywhalecc Feb 28, 2026
7cedd45
Merge remote-tracking branch 'origin/v3-feat/check-update' into v3-fe…
crazywhalecc Feb 28, 2026
029f8ef
Avoid empty output
crazywhalecc Feb 28, 2026
4f2ca17
cs fix
crazywhalecc Feb 28, 2026
174ef3d
Refactor ReturnCode constants for clarity and consistency
crazywhalecc Feb 28, 2026
dc0a809
Add PECL download type and support for PECL artifacts
crazywhalecc Feb 28, 2026
12d4009
Update PHP release handling to use configurable mirror and improve UR…
crazywhalecc Mar 4, 2026
671ebd2
Use gmp mirror site
crazywhalecc Mar 4, 2026
00c08e0
Use no optional libs for libxml2
crazywhalecc Mar 5, 2026
f7277cc
Improve output formatting for update checks in CheckUpdateCommand
crazywhalecc Mar 5, 2026
715f33a
Add log filtering to prevent sensitive data leakage
crazywhalecc Mar 5, 2026
94fb7a6
Merge remote-tracking branch 'origin/v3-feat/check-update' into v3-fe…
crazywhalecc Mar 5, 2026
5298ee4
Use constant back due to config validation problem
crazywhalecc Mar 5, 2026
abdaaab
Refactor CheckUpdateResult logic to simplify version comparison
crazywhalecc Mar 5, 2026
84f6dab
Add parallel update checking and improve artifact update handling
crazywhalecc Mar 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config/artifact/php-src.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ php-src:
license: PHP-3.01
source:
type: php-release
domain: 'https://www.php.net'
source-mirror:
type: php-release
domain: 'https://phpmirror.static-php.dev'
30 changes: 0 additions & 30 deletions config/downloader.php

This file was deleted.

29 changes: 29 additions & 0 deletions config/pkg/ext/builtin-extensions.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
ext-bcmath:
type: php-extension
ext-mbregex:
type: php-extension
depends:
- onig
- ext-mbstring
php-extension:
arg-type: custom
build-shared: false
build-static: true
display-name: mbstring
ext-mbstring:
type: php-extension
php-extension:
arg-type: custom
ext-openssl:
type: php-extension
depends:
Expand All @@ -10,6 +24,21 @@ ext-openssl:
arg-type: custom
arg-type@windows: with
build-with-php: true
ext-phar:
type: php-extension
depends:
- zlib
ext-readline:
type: php-extension
depends:
- libedit
php-extension:
support:
Windows: wip
BSD: wip
arg-type: with-path
build-shared: false
build-static: true
ext-zlib:
type: php-extension
depends:
Expand Down
6 changes: 2 additions & 4 deletions config/pkg/ext/ext-amqp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ ext-amqp:
type: php-extension
artifact:
source:
type: url
url: 'https://pecl.php.net/get/amqp'
extract: php-src/ext/amqp
filename: amqp.tgz
type: pecl
name: amqp
metadata:
license-files: [LICENSE]
license: PHP-3.01
Expand Down
6 changes: 2 additions & 4 deletions config/pkg/ext/ext-apcu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ ext-apcu:
type: php-extension
artifact:
source:
type: url
url: 'https://pecl.php.net/get/APCu'
extract: php-src/ext/apcu
filename: apcu.tgz
type: pecl
name: APCu
metadata:
license-files: [LICENSE]
license: PHP-3.01
6 changes: 6 additions & 0 deletions config/pkg/ext/ext-ast.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ext-ast:
type: php-extension
artifact:
source:
type: pecl
name: ast
10 changes: 0 additions & 10 deletions config/pkg/ext/ext-mbregex.yml

This file was deleted.

4 changes: 0 additions & 4 deletions config/pkg/ext/ext-mbstring.yml

This file was deleted.

4 changes: 0 additions & 4 deletions config/pkg/ext/ext-phar.yml

This file was deleted.

11 changes: 0 additions & 11 deletions config/pkg/ext/ext-readline.yml

This file was deleted.

2 changes: 1 addition & 1 deletion config/pkg/lib/gmp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ gmp:
artifact:
source:
type: filelist
url: 'https://gmplib.org/download/gmp/'
url: 'https://ftp.gnu.org/gnu/gmp/'
regex: '/href="(?<file>gmp-(?<version>[^"]+)\.tar\.xz)"/'
source-mirror:
type: url
Expand Down
3 changes: 1 addition & 2 deletions config/pkg/lib/libxml2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ libxml2:
license: MIT
depends@unix:
- libiconv
suggests@unix:
- xz
- zlib
- xz
headers:
- libxml2
pkg-configs:
Expand Down
21 changes: 21 additions & 0 deletions src/Package/Artifact/go_xcaddy.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

use StaticPHP\Artifact\ArtifactDownloader;
use StaticPHP\Artifact\Downloader\DownloadResult;
use StaticPHP\Artifact\Downloader\Type\CheckUpdateResult;
use StaticPHP\Attribute\Artifact\AfterBinaryExtract;
use StaticPHP\Attribute\Artifact\CustomBinary;
use StaticPHP\Attribute\Artifact\CustomBinaryCheckUpdate;
use StaticPHP\Exception\DownloaderException;
use StaticPHP\Runtime\SystemTarget;
use StaticPHP\Util\GlobalEnvManager;
Expand Down Expand Up @@ -65,6 +67,25 @@ public function downBinary(ArtifactDownloader $downloader): DownloadResult
return DownloadResult::archive(basename($path), ['url' => $url, 'version' => $version], extract: "{$pkgroot}/go-xcaddy", verified: true, version: $version);
}

#[CustomBinaryCheckUpdate('go-xcaddy', [
'linux-x86_64',
'linux-aarch64',
'macos-x86_64',
'macos-aarch64',
])]
public function checkUpdateBinary(?string $old_version, ArtifactDownloader $downloader): CheckUpdateResult
{
[$version] = explode("\n", default_shell()->executeCurl('https://go.dev/VERSION?m=text') ?: '');
if ($version === '') {
throw new DownloaderException('Failed to get latest Go version from https://go.dev/VERSION?m=text');
}
return new CheckUpdateResult(
old: $old_version,
new: $version,
needUpdate: $old_version === null || $version !== $old_version,
);
}

#[AfterBinaryExtract('go-xcaddy', [
'linux-x86_64',
'linux-aarch64',
Expand Down
32 changes: 32 additions & 0 deletions src/Package/Artifact/zig.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

use StaticPHP\Artifact\ArtifactDownloader;
use StaticPHP\Artifact\Downloader\DownloadResult;
use StaticPHP\Artifact\Downloader\Type\CheckUpdateResult;
use StaticPHP\Attribute\Artifact\AfterBinaryExtract;
use StaticPHP\Attribute\Artifact\CustomBinary;
use StaticPHP\Attribute\Artifact\CustomBinaryCheckUpdate;
use StaticPHP\Exception\DownloaderException;
use StaticPHP\Runtime\SystemTarget;

Expand Down Expand Up @@ -59,6 +61,36 @@ public function downBinary(ArtifactDownloader $downloader): DownloadResult
return DownloadResult::archive(basename($path), ['url' => $url, 'version' => $latest_version], extract: PKG_ROOT_PATH . '/zig', verified: true, version: $latest_version);
}

#[CustomBinaryCheckUpdate('zig', [
'linux-x86_64',
'linux-aarch64',
'macos-x86_64',
'macos-aarch64',
])]
public function checkUpdateBinary(?string $old_version, ArtifactDownloader $downloader): CheckUpdateResult
{
$index_json = default_shell()->executeCurl('https://ziglang.org/download/index.json', retries: $downloader->getRetry());
$index_json = json_decode($index_json ?: '', true);
$latest_version = null;
if (!is_array($index_json)) {
throw new DownloaderException('Failed to fetch Zig version index for update check');
}
foreach ($index_json as $version => $data) {
if ($version !== 'master') {
$latest_version = $version;
break;
}
}
if (!$latest_version) {
throw new DownloaderException('Could not determine latest Zig version');
}
return new CheckUpdateResult(
old: $old_version,
new: $latest_version,
needUpdate: $old_version === null || $latest_version !== $old_version,
);
}

#[AfterBinaryExtract('zig', [
'linux-x86_64',
'linux-aarch64',
Expand Down
12 changes: 4 additions & 8 deletions src/Package/Library/libxml2.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,13 @@ class libxml2
public function buildForLinux(LibraryPackage $lib): void
{
UnixCMakeExecutor::create($lib)
->optionalPackage(
'zlib',
'-DLIBXML2_WITH_ZLIB=ON ' .
"-DZLIB_LIBRARY={$lib->getLibDir()}/libz.a " .
"-DZLIB_INCLUDE_DIR={$lib->getIncludeDir()}",
'-DLIBXML2_WITH_ZLIB=OFF',
)
->optionalPackage('xz', ...cmake_boolean_args('LIBXML2_WITH_LZMA'))
->addConfigureArgs(
'-DLIBXML2_WITH_ICONV=ON',
'-DIconv_IS_BUILT_IN=OFF',
'-DLIBXML2_WITH_ZLIB=ON',
"-DZLIB_LIBRARY={$lib->getLibDir()}/libz.a",
"-DZLIB_INCLUDE_DIR={$lib->getIncludeDir()}",
'-DLIBXML2_WITH_LZMA=ON',
'-DLIBXML2_WITH_ICU=OFF', // optional, but discouraged: https://gitlab.gnome.org/GNOME/libxml2/-/blob/master/README.md
'-DLIBXML2_WITH_PYTHON=OFF',
'-DLIBXML2_WITH_PROGRAMS=OFF',
Expand Down
37 changes: 37 additions & 0 deletions src/StaticPHP/Artifact/Artifact.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,15 @@ class Artifact
/** @var null|callable Bind custom source fetcher callback */
protected mixed $custom_source_callback = null;

/** @var null|callable Bind custom source check-update callback */
protected mixed $custom_source_check_update_callback = null;

/** @var array<string, callable> Bind custom binary fetcher callbacks */
protected mixed $custom_binary_callbacks = [];

/** @var array<string, callable> Bind custom binary check-update callbacks */
protected array $custom_binary_check_update_callbacks = [];

/** @var null|callable Bind custom source extract callback (completely takes over extraction) */
protected mixed $source_extract_callback = null;

Expand Down Expand Up @@ -405,6 +411,19 @@ public function getCustomSourceCallback(): ?callable
return $this->custom_source_callback ?? null;
}

/**
* Set custom source check-update callback.
*/
public function setCustomSourceCheckUpdateCallback(callable $callback): void
{
$this->custom_source_check_update_callback = $callback;
}

public function getCustomSourceCheckUpdateCallback(): ?callable
{
return $this->custom_source_check_update_callback ?? null;
}

public function getCustomBinaryCallback(): ?callable
{
$current_platform = SystemTarget::getCurrentPlatformString();
Expand Down Expand Up @@ -433,6 +452,24 @@ public function setCustomBinaryCallback(string $target_os, callable $callback):
$this->custom_binary_callbacks[$target_os] = $callback;
}

/**
* Set custom binary check-update callback for a specific target OS.
*
* @param string $target_os Target OS platform string (e.g. linux-x86_64)
* @param callable $callback Custom binary check-update callback
*/
public function setCustomBinaryCheckUpdateCallback(string $target_os, callable $callback): void
{
ConfigValidator::validatePlatformString($target_os);
$this->custom_binary_check_update_callbacks[$target_os] = $callback;
}

public function getCustomBinaryCheckUpdateCallback(): ?callable
{
$current_platform = SystemTarget::getCurrentPlatformString();
return $this->custom_binary_check_update_callbacks[$current_platform] ?? null;
}

// ==================== Extraction Callbacks ====================

/**
Expand Down
Loading