support for php-src switching by downloading different php version (like it was before, essentially)

This commit is contained in:
henderkes 2026-01-01 15:38:35 +01:00
parent 51ef5e61be
commit ce7829fd13
3 changed files with 8 additions and 7 deletions

View File

@ -134,10 +134,6 @@ class BuildPHPCommand extends BuildCommand
// Use version-specific php-src
f_putenv("SPC_PHP_SRC_NAME={$version_specific_name}");
logger()->info("Building with PHP {$php_version} (using {$version_specific_name})");
} elseif (isset($lock_content['php-src'])) {
// Fall back to regular php-src
f_putenv('SPC_PHP_SRC_NAME=php-src');
logger()->warning("php-src-{$php_version} not found, using default php-src");
} else {
logger()->error('No php-src found in downloads. Please run download command first.');
return static::FAILURE;
@ -147,7 +143,6 @@ class BuildPHPCommand extends BuildCommand
return static::FAILURE;
}
} else {
// No version specified, use default php-src
f_putenv('SPC_PHP_SRC_NAME=php-src');
}

View File

@ -280,8 +280,9 @@ class DownloadCommand extends BaseCommand
logger()->warning("Pre-built content not found for {$source}, fallback to source download");
}
logger()->info("[{$ni}/{$cnt}] Downloading source {$source}");
$force_download = $force_all || in_array($source, $force_list) || str_starts_with($source, 'php-src-') && in_array('php-src', $force_list);
try {
Downloader::downloadSource($source, $config, $force_all || in_array($source, $force_list));
Downloader::downloadSource($source, $config, $force_download);
} catch (SPCException $e) {
// if `--no-alt` option is set, we will not download alternative sources
if ($this->getOption('no-alt')) {
@ -299,7 +300,7 @@ class DownloadCommand extends BaseCommand
logger()->notice("Trying to download alternative sources for {$source}");
$alt_config = array_merge($config, $alt_sources);
}
Downloader::downloadSource($source, $alt_config, $force_all || in_array($source, $force_list));
Downloader::downloadSource($source, $alt_config, $force_download);
}
}
}

View File

@ -7,6 +7,7 @@ namespace SPC\store\source;
use JetBrains\PhpStorm\ArrayShape;
use SPC\exception\DownloaderException;
use SPC\store\Downloader;
use SPC\store\LockFile;
class PhpSource extends CustomSourceBase
{
@ -28,6 +29,10 @@ class PhpSource extends CustomSourceBase
} else {
Downloader::downloadSource($source_name, $this->getLatestPHPInfo($major), $force);
}
if ($source_name !== 'php-src') {
LockFile::put('php-src', LockFile::get($source_name));
}
}
public function update(array $lock, ?array $config = null): ?array