diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index 9871eeb4..0294f350 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -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'); } diff --git a/src/SPC/command/DownloadCommand.php b/src/SPC/command/DownloadCommand.php index fb1179e3..84fa5753 100644 --- a/src/SPC/command/DownloadCommand.php +++ b/src/SPC/command/DownloadCommand.php @@ -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); } } } diff --git a/src/SPC/store/source/PhpSource.php b/src/SPC/store/source/PhpSource.php index 079d5287..f5c9063f 100644 --- a/src/SPC/store/source/PhpSource.php +++ b/src/SPC/store/source/PhpSource.php @@ -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