@@ -311,21 +311,32 @@ private static function createRpmPackage(string $name, array $config, string $ph
311311 }
312312 }
313313
314- private static function createDebPackage (string $ name , array $ config , string $ phpVersion , string $ architecture , string $ iteration , array $ extraArgs = []): void
315- {
314+ private static function createDebPackage (
315+ string $ name ,
316+ array $ config ,
317+ string $ phpVersion ,
318+ string $ architecture ,
319+ string $ iteration ,
320+ array $ extraArgs = [],
321+ ): void {
316322 echo "Creating DEB package for {$ name }... \n" ;
317323
318324 $ phpVersion = preg_replace ('/_\d+$/ ' , '' , $ phpVersion );
319325
326+ $ osRelease = parse_ini_file ('/etc/os-release ' );
327+ $ distroCodename = $ osRelease ['VERSION_CODENAME ' ] ?? null ;
328+ $ debIteration = $ distroCodename !== '' ? "{$ iteration }~ {$ distroCodename }" : $ iteration ;
329+ $ fullVersion = "{$ phpVersion }- {$ debIteration }" ;
330+
320331 $ fpmArgs = [
321332 'fpm ' ,
322333 '-s ' , 'dir ' ,
323334 '-t ' , 'deb ' ,
324335 '-p ' , DIST_DEB_PATH ,
325336 '--name ' , $ name ,
326- '--version ' , $ phpVersion ,
337+ '--version ' , $ phpVersion , // upstream version
327338 '--architecture ' , $ architecture ,
328- '--iteration ' , $ iteration ,
339+ '--iteration ' , $ debIteration , // Debian revision (includes distro)
329340 '--description ' , "Static PHP Package for {$ name }" ,
330341 '--license ' , 'MIT ' ,
331342 '--maintainer ' , 'Static PHP <info@static-php.dev> '
@@ -334,14 +345,14 @@ private static function createDebPackage(string $name, array $config, string $ph
334345 if (isset ($ config ['provides ' ]) && is_array ($ config ['provides ' ])) {
335346 foreach ($ config ['provides ' ] as $ provide ) {
336347 $ fpmArgs [] = '--provides ' ;
337- $ fpmArgs [] = "$ provide (= $ phpVersion ) " ;
348+ $ fpmArgs [] = "{ $ provide} (= { $ fullVersion } ) " ;
338349 }
339350 }
340351
341352 if (isset ($ config ['replaces ' ]) && is_array ($ config ['replaces ' ])) {
342353 foreach ($ config ['replaces ' ] as $ replace ) {
343354 $ fpmArgs [] = '--replaces ' ;
344- $ fpmArgs [] = "$ replace < {$ phpVersion } - { $ iteration }) " ;
355+ $ fpmArgs [] = "{ $ replace} ( < {$ fullVersion }) " ;
345356 }
346357 }
347358
@@ -350,7 +361,7 @@ private static function createDebPackage(string $name, array $config, string $ph
350361 $ lib = preg_replace ('/_\D+/ ' , '' , $ lib );
351362 $ numericVersion = preg_replace ('/[^0-9.]/ ' , '' , $ version );
352363 $ fpmArgs [] = '--depends ' ;
353- $ fpmArgs [] = "$ lib (>= {$ numericVersion }) " ;
364+ $ fpmArgs [] = "{ $ lib} (>= {$ numericVersion }) " ;
354365 }
355366 if (isset ($ config ['depends ' ]) && is_array ($ config ['depends ' ])) {
356367 foreach ($ config ['depends ' ] as $ depend ) {
@@ -378,16 +389,15 @@ private static function createDebPackage(string $name, array $config, string $ph
378389 foreach ($ config ['files ' ] as $ source => $ dest ) {
379390 if (file_exists ($ source )) {
380391 $ fpmArgs [] = $ source . '= ' . $ dest ;
381- }
382- else {
392+ } else {
383393 echo "Warning: Source file not found: {$ source }\n" ;
384394 }
385395 }
386396 }
387397
388398 if (isset ($ config ['empty_directories ' ]) && is_array ($ config ['empty_directories ' ])) {
389399 $ emptyDir = TEMP_DIR . '/spp_empty ' ;
390- if (!file_exists ($ emptyDir ) && !mkdir ($ emptyDir , 0755 ,true ) && !is_dir ($ emptyDir )) {
400+ if (!file_exists ($ emptyDir ) && !mkdir ($ emptyDir , 0755 , true ) && !is_dir ($ emptyDir )) {
391401 throw new \RuntimeException (sprintf ('Directory "%s" was not created ' , $ emptyDir ));
392402 }
393403 if (is_dir ($ emptyDir )) {
@@ -407,7 +417,7 @@ private static function createDebPackage(string $name, array $config, string $ph
407417 echo $ buffer ;
408418 });
409419
410- echo "DEB package created: " . DIST_DEB_PATH . "/ {$ name }_ {$ phpVersion }- {$ iteration }_ {$ architecture }.deb \n" ;
420+ echo "DEB package created: " . DIST_DEB_PATH . "/ {$ name }_ {$ phpVersion }- {$ debIteration }_ {$ architecture }.deb \n" ;
411421 }
412422
413423 private static function getPhpVersionAndArchitecture (): array
@@ -417,7 +427,6 @@ private static function getPhpVersionAndArchitecture(): array
417427 }
418428 $ basePhpVersion = SPP_PHP_VERSION ;
419429 $ phpBinary = BUILD_BIN_PATH . '/php ' ;
420- $ fullPhpVersion = null ; // Default to base version if binary check fails
421430
422431 if (!file_exists ($ phpBinary )) {
423432 throw new RuntimeException ("Warning: PHP binary not found at {$ phpBinary }, using base PHP version: {$ basePhpVersion }" );
0 commit comments