fix custompackage handling

This commit is contained in:
henderkes
2025-09-09 12:10:06 +07:00
parent c330d02e78
commit 5c1194ea92
7 changed files with 29 additions and 43 deletions

View File

@@ -30,10 +30,14 @@ abstract class CustomPackage
/**
* Get the environment variables this package needs to be usable.
* PATH needs to be appended, rather than replaced.
*/
abstract public static function getEnvironment(): array;
/**
* Get the PATH required to use this package.
*/
abstract public static function getPath(): ?string;
abstract public static function isInstalled(): bool;
/**

View File

@@ -90,22 +90,17 @@ class GoXcaddy extends CustomPackage
public static function getEnvironment(): array
{
$arch = arch2gnu(php_uname('m'));
$os = match (PHP_OS_FAMILY) {
'Windows' => 'win',
'Darwin' => 'macos',
'BSD' => 'freebsd',
default => 'linux',
};
$packageName = "go-xcaddy-{$arch}-{$os}";
$packageName = 'go-xcaddy';
$pkgroot = PKG_ROOT_PATH;
return [
'PATH' => "{$pkgroot}/{$packageName}/bin",
'GOROOT' => "{$pkgroot}/{$packageName}",
'GOBIN' => "{$pkgroot}/{$packageName}/bin",
'GOPATH' => "{$pkgroot}/go",
];
}
public static function getPath(): ?string
{
return PKG_ROOT_PATH . '/go-xcaddy/bin';
}
}

View File

@@ -129,23 +129,10 @@ class Zig extends CustomPackage
public static function getEnvironment(): array
{
$arch = arch2gnu(php_uname('m'));
$os = match (PHP_OS_FAMILY) {
'Windows' => 'win',
'Darwin' => 'macos',
'BSD' => 'freebsd',
default => 'linux',
};
$packageName = "zig-{$arch}-{$os}";
$path = PKG_ROOT_PATH . "/{$packageName}";
return [
'PATH' => $path,
];
return [];
}
private static function getPath(): string
public static function getPath(): ?string
{
return PKG_ROOT_PATH . '/zig';
}