feat: new channel
This commit is contained in:
@@ -412,17 +412,19 @@ class ChannelProjectService
|
||||
: 'coruna.channel_builder.python';
|
||||
$configured = trim((string) config($configKey, ''));
|
||||
if ($configured !== '') {
|
||||
// Trust .env: do not is_file() — venv python is usually a symlink to
|
||||
// /usr/bin/python*, which fatals under panel open_basedir.
|
||||
return $configured;
|
||||
}
|
||||
|
||||
$venv = $this->builderCwd($builderType).'/.venv/bin/python';
|
||||
if (is_file($venv)) {
|
||||
if ($this->venvPythonExists($venv)) {
|
||||
return $venv;
|
||||
}
|
||||
|
||||
if ($builderType === self::BUILDER_NEW) {
|
||||
$fallback = base_path('channel-builder/.venv/bin/python');
|
||||
if (is_file($fallback)) {
|
||||
if ($this->venvPythonExists($fallback)) {
|
||||
return $fallback;
|
||||
}
|
||||
}
|
||||
@@ -430,6 +432,22 @@ class ChannelProjectService
|
||||
return 'python3';
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect .venv/bin/python without following the symlink into /usr/bin
|
||||
* (open_basedir typically allows the project root only).
|
||||
*/
|
||||
private function venvPythonExists(string $path): bool
|
||||
{
|
||||
clearstatcache(true, $path);
|
||||
|
||||
// is_link() checks the link inode inside the project; does not resolve target.
|
||||
if (@is_link($path)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return @is_file($path);
|
||||
}
|
||||
|
||||
private function builderScript(string $name, string $builderType): string
|
||||
{
|
||||
$path = $this->builderCwd($builderType).'/tools/'.$name;
|
||||
|
||||
Reference in New Issue
Block a user