From 07ddfc5c1dd87ac0e9b406966d2aeee0281102fd Mon Sep 17 00:00:00 2001 From: muhme Date: Wed, 28 May 2025 10:44:38 +0200 Subject: [PATCH 1/2] Fix build.php to create zstd packages on macOS and stop on error. --- build/build.php | 94 ++++++++++++++++++++++++++++++------------------- 1 file changed, 57 insertions(+), 37 deletions(-) diff --git a/build/build.php b/build/build.php index bf84fc6008d13..c606b59ce5231 100644 --- a/build/build.php +++ b/build/build.php @@ -211,6 +211,39 @@ function clean_composer(string $dir) chdir($cwd); } +/** + * Executes a system command to build a package file. + * Shows a start and a finish message and terminates if an error occurs. + * Captures all outputs (stdout+stderr) and only displays them if an error has occurred. + * + * @param string $packageName Name of the package file to be created. + * @param string $command The full system command to execute. + * + * @return void + */ +function build_and_check(string $packageName, string $command): void +{ + echo "Building {$packageName} ... "; + + // Redirect stderr to stdout + $fullCommand = $command . ' 2>&1'; + $output = []; + $exitCode = 0; + + exec($fullCommand, $output, $exitCode); + + if ($exitCode !== 0) { + echo "failed.\n"; + fwrite(STDERR, "ERROR: Command failed ($exitCode): $command\n"); + if (!empty($output)) { + fwrite(STDERR, "Output:\n" . implode("\n", $output) . "\n"); + } + exit($exitCode); + } + + echo "done.\n"; +} + $time = time(); // Set path to git binary (e.g., /usr/local/git/bin/git or /usr/bin/git) @@ -563,34 +596,29 @@ function clean_composer(string $dir) if (!$excludeZip) { $packageName = 'Joomla_' . $version . '.' . $fromName . '_to_' . $fullVersion . '-' . $packageStability . '-Patch_Package.zip'; echo "Building " . $packageName . "... "; - chdir($time); - system('zip ../packages/' . $packageName . ' -@ < ../diffconvert/' . $version . '.' . $num . '> /dev/null'); - chdir('..'); - echo "done.\n"; + $command = "cd {$time} && zip ../packages/{$packageName} -@ < ../diffconvert/{$version}.{$num}"; + build_and_check($packageName, $command); $checksums[$packageName] = []; } if (!$excludeGzip) { $packageName = 'Joomla_' . $version . '.' . $fromName . '_to_' . $fullVersion . '-' . $packageStability . '-Patch_Package.tar.gz'; - echo "Building " . $packageName . "... "; - system('tar --create --gzip --no-recursion --directory ' . $time . ' --file packages/' . $packageName . ' --files-from diffconvert/' . $version . '.' . $num . '> /dev/null'); - echo "done.\n"; + $command = "tar --create --gzip --no-recursion --directory {$time} --file packages/{$packageName} --files-from diffconvert/{$version}.{$num}"; + build_and_check($packageName, $command); $checksums[$packageName] = []; } if (!$excludeBzip2) { $packageName = 'Joomla_' . $version . '.' . $fromName . '_to_' . $fullVersion . '-' . $packageStability . '-Patch_Package.tar.bz2'; - echo "Building " . $packageName . "... "; - system('tar --create --bzip2 --no-recursion --directory ' . $time . ' --file packages/' . $packageName . ' --files-from diffconvert/' . $version . '.' . $num . '> /dev/null'); - echo "done.\n"; + $command = "tar --create --bzip2 --no-recursion --directory {$time} --file packages/{$packageName} --files-from diffconvert/{$version}.{$num}"; + build_and_check($packageName, $command); $checksums[$packageName] = []; } if (!$excludeZstd) { $packageName = 'Joomla_' . $version . '.' . $fromName . '_to_' . $fullVersion . '-' . $packageStability . '-Patch_Package.tar.zst'; - echo "Building " . $packageName . "... "; - system('tar "-I zstd --ultra -22" --create --no-recursion --directory ' . $time . ' --file packages/' . $packageName . ' --files-from diffconvert/' . $version . '.' . $num . '> /dev/null'); - echo "done.\n"; + $command = "tar --create --no-recursion --directory {$time} --files-from diffconvert/{$version}.{$num} | zstd --ultra -22 -o packages/{$packageName}"; + build_and_check($packageName, $command); $checksums[$packageName] = []; } } @@ -601,33 +629,29 @@ function clean_composer(string $dir) // Create full archive packages. if (!$excludeZip) { $packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Full_Package.zip'; - echo "Building " . $packageName . "... "; - system('zip -r ../packages/' . $packageName . ' * > /dev/null'); - echo "done.\n"; + $command = "zip -r ../packages/{$packageName} *"; + build_and_check($packageName, $command); $checksums[$packageName] = []; } if (!$excludeGzip) { $packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Full_Package.tar.gz'; - echo "Building " . $packageName . "... "; - system('tar --create --gzip --file ../packages/' . $packageName . ' * > /dev/null'); - echo "done.\n"; + $command = "tar --create --gzip --file ../packages/{$packageName} *"; + build_and_check($packageName, $command); $checksums[$packageName] = []; } if (!$excludeBzip2) { $packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Full_Package.tar.bz2'; - echo "Building " . $packageName . "... "; - system('tar --create --bzip2 --file ../packages/' . $packageName . ' * > /dev/null'); - echo "done.\n"; + $command = "tar --create --bzip2 --file ../packages/{$packageName} *"; + build_and_check($packageName, $command); $checksums[$packageName] = []; } if (!$excludeZstd) { $packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Full_Package.tar.zst'; - echo "Building " . $packageName . "... "; - system('tar "-I zstd --ultra -22" --create --file ../packages/' . $packageName . ' * > /dev/null'); - echo "done.\n"; + $command = "tar --create * | zstd --ultra -22 -o ../packages/{$packageName}"; + build_and_check($packageName, $command); $checksums[$packageName] = []; } @@ -644,33 +668,29 @@ function clean_composer(string $dir) if (!$excludeZip) { $packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Update_Package.zip'; - echo "Building " . $packageName . "... "; - system('zip -r ../packages/' . $packageName . ' * > /dev/null'); - echo "done.\n"; + $command = "zip -r ../packages/{$packageName} *"; + build_and_check($packageName, $command); $checksums[$packageName] = []; } if (!$excludeGzip) { $packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Update_Package.tar.gz'; - echo "Building " . $packageName . "... "; - system('tar --create --gzip --file ../packages/' . $packageName . ' * > /dev/null'); - echo "done.\n"; + $command = "tar --create --gzip --file ../packages/{$packageName} *"; + build_and_check($packageName, $command); $checksums[$packageName] = []; } if (!$excludeBzip2) { $packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Update_Package.tar.bz2'; - echo "Building " . $packageName . "... "; - system('tar --create --bzip2 --file ../packages/' . $packageName . ' * > /dev/null'); - echo "done.\n"; + $command = "tar --create --bzip2 --file ../packages/{$packageName} *"; + build_and_check($packageName, $command); $checksums[$packageName] = []; } if (!$excludeZstd) { $packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Update_Package.tar.zst'; - echo "Building " . $packageName . "... "; - system('tar "-I zstd --ultra -22" --create --file ../packages/' . $packageName . ' * > /dev/null'); - echo "done.\n"; + $command = "tar --create * | zstd --ultra -22 -o ../packages/{$packageName}"; + build_and_check($packageName, $command); $checksums[$packageName] = []; } } From 37327e34afcaf29b3cd11573e1fa30a2842ffb22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Heiko=20L=C3=BCbbe?= Date: Wed, 28 May 2025 15:11:22 +0200 Subject: [PATCH 2/2] php-cs-fixer --- build/build.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/build/build.php b/build/build.php index c606b59ce5231..03d22c4042a50 100644 --- a/build/build.php +++ b/build/build.php @@ -227,8 +227,8 @@ function build_and_check(string $packageName, string $command): void // Redirect stderr to stdout $fullCommand = $command . ' 2>&1'; - $output = []; - $exitCode = 0; + $output = []; + $exitCode = 0; exec($fullCommand, $output, $exitCode); @@ -603,21 +603,21 @@ function build_and_check(string $packageName, string $command): void if (!$excludeGzip) { $packageName = 'Joomla_' . $version . '.' . $fromName . '_to_' . $fullVersion . '-' . $packageStability . '-Patch_Package.tar.gz'; - $command = "tar --create --gzip --no-recursion --directory {$time} --file packages/{$packageName} --files-from diffconvert/{$version}.{$num}"; + $command = "tar --create --gzip --no-recursion --directory {$time} --file packages/{$packageName} --files-from diffconvert/{$version}.{$num}"; build_and_check($packageName, $command); $checksums[$packageName] = []; } if (!$excludeBzip2) { $packageName = 'Joomla_' . $version . '.' . $fromName . '_to_' . $fullVersion . '-' . $packageStability . '-Patch_Package.tar.bz2'; - $command = "tar --create --bzip2 --no-recursion --directory {$time} --file packages/{$packageName} --files-from diffconvert/{$version}.{$num}"; + $command = "tar --create --bzip2 --no-recursion --directory {$time} --file packages/{$packageName} --files-from diffconvert/{$version}.{$num}"; build_and_check($packageName, $command); $checksums[$packageName] = []; } if (!$excludeZstd) { $packageName = 'Joomla_' . $version . '.' . $fromName . '_to_' . $fullVersion . '-' . $packageStability . '-Patch_Package.tar.zst'; - $command = "tar --create --no-recursion --directory {$time} --files-from diffconvert/{$version}.{$num} | zstd --ultra -22 -o packages/{$packageName}"; + $command = "tar --create --no-recursion --directory {$time} --files-from diffconvert/{$version}.{$num} | zstd --ultra -22 -o packages/{$packageName}"; build_and_check($packageName, $command); $checksums[$packageName] = []; } @@ -629,28 +629,28 @@ function build_and_check(string $packageName, string $command): void // Create full archive packages. if (!$excludeZip) { $packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Full_Package.zip'; - $command = "zip -r ../packages/{$packageName} *"; + $command = "zip -r ../packages/{$packageName} *"; build_and_check($packageName, $command); $checksums[$packageName] = []; } if (!$excludeGzip) { $packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Full_Package.tar.gz'; - $command = "tar --create --gzip --file ../packages/{$packageName} *"; + $command = "tar --create --gzip --file ../packages/{$packageName} *"; build_and_check($packageName, $command); $checksums[$packageName] = []; } if (!$excludeBzip2) { $packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Full_Package.tar.bz2'; - $command = "tar --create --bzip2 --file ../packages/{$packageName} *"; + $command = "tar --create --bzip2 --file ../packages/{$packageName} *"; build_and_check($packageName, $command); $checksums[$packageName] = []; } if (!$excludeZstd) { $packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Full_Package.tar.zst'; - $command = "tar --create * | zstd --ultra -22 -o ../packages/{$packageName}"; + $command = "tar --create * | zstd --ultra -22 -o ../packages/{$packageName}"; build_and_check($packageName, $command); $checksums[$packageName] = []; } @@ -668,28 +668,28 @@ function build_and_check(string $packageName, string $command): void if (!$excludeZip) { $packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Update_Package.zip'; - $command = "zip -r ../packages/{$packageName} *"; + $command = "zip -r ../packages/{$packageName} *"; build_and_check($packageName, $command); $checksums[$packageName] = []; } if (!$excludeGzip) { $packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Update_Package.tar.gz'; - $command = "tar --create --gzip --file ../packages/{$packageName} *"; + $command = "tar --create --gzip --file ../packages/{$packageName} *"; build_and_check($packageName, $command); $checksums[$packageName] = []; } if (!$excludeBzip2) { $packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Update_Package.tar.bz2'; - $command = "tar --create --bzip2 --file ../packages/{$packageName} *"; + $command = "tar --create --bzip2 --file ../packages/{$packageName} *"; build_and_check($packageName, $command); $checksums[$packageName] = []; } if (!$excludeZstd) { $packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Update_Package.tar.zst'; - $command = "tar --create * | zstd --ultra -22 -o ../packages/{$packageName}"; + $command = "tar --create * | zstd --ultra -22 -o ../packages/{$packageName}"; build_and_check($packageName, $command); $checksums[$packageName] = []; }