@@ -227,6 +227,23 @@ private static function createRpmPackage(string $name, array $config, string $ph
227227 '--url ' , 'rpms.henderkes.com ' ,
228228 ], ...$ extraArgs ];
229229
230+ // Ensure non-CLI packages depend on the same PHP major.minor as php-zts-cli (ignore iteration/patch)
231+ if ($ name !== self ::getPrefix () . '-cli ' ) {
232+ [$ fullPhpVersion ] = self ::getPhpVersionAndArchitecture ();
233+ if (preg_match ('/^(\d+)\.(\d+)/ ' , $ fullPhpVersion , $ m )) {
234+ $ maj = (int )$ m [1 ];
235+ $ min = (int )$ m [2 ];
236+ $ nextMin = $ min + 1 ;
237+ $ lowerBound = sprintf ('%d.%d ' , $ maj , $ min );
238+ $ upperBound = sprintf ('%d.%d ' , $ maj , $ nextMin );
239+ // RPM range: >= X.Y and < X.(Y+1)
240+ $ fpmArgs [] = '--depends ' ;
241+ $ fpmArgs [] = self ::getPrefix () . "-cli >= {$ lowerBound }" ;
242+ $ fpmArgs [] = '--depends ' ;
243+ $ fpmArgs [] = self ::getPrefix () . "-cli < {$ upperBound }" ;
244+ }
245+ }
246+
230247 if (isset ($ config ['provides ' ]) && is_array ($ config ['provides ' ])) {
231248 foreach ($ config ['provides ' ] as $ provide ) {
232249 $ fpmArgs [] = '--provides ' ;
@@ -346,6 +363,22 @@ private static function createDebPackage(
346363 '--url ' , 'debs.henderkes.com ' ,
347364 ], ...$ extraArgs ];
348365
366+ // Ensure non-CLI packages depend on the same PHP major.minor as php-zts-cli (ignore iteration/patch)
367+ if ($ name !== self ::getPrefix () . '-cli ' ) {
368+ if (preg_match ('/^(\d+)\.(\d+)/ ' , $ phpVersion , $ m )) {
369+ $ maj = (int )$ m [1 ];
370+ $ min = (int )$ m [2 ];
371+ $ nextMin = $ min + 1 ;
372+ $ lowerBound = sprintf ('%d.%d ' , $ maj , $ min );
373+ // For Debian, use an upper bound with tilde to exclude the next minor and its pre-releases
374+ $ upperBound = sprintf ('%d.%d~ ' , $ maj , $ nextMin );
375+ $ fpmArgs [] = '--depends ' ;
376+ $ fpmArgs [] = self ::getPrefix () . "-cli (>= {$ lowerBound }) " ;
377+ $ fpmArgs [] = '--depends ' ;
378+ $ fpmArgs [] = self ::getPrefix () . "-cli (<< {$ upperBound }) " ;
379+ }
380+ }
381+
349382 if (isset ($ config ['provides ' ]) && is_array ($ config ['provides ' ])) {
350383 foreach ($ config ['provides ' ] as $ provide ) {
351384 $ fpmArgs [] = '--provides ' ;
0 commit comments