From be3d68cebe76d385aad8c21641ff2ce91c21c470 Mon Sep 17 00:00:00 2001 From: Marc Henderkes Date: Mon, 10 Mar 2025 11:25:38 +0100 Subject: [PATCH] patch the makefile before make (remove -lacl from FPM_EXTRA_LIBS) --- src/SPC/builder/LibraryBase.php | 5 +++++ src/SPC/builder/unix/library/libacl.php | 13 +++++++++++-- src/SPC/store/SourcePatcher.php | 7 ++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/SPC/builder/LibraryBase.php b/src/SPC/builder/LibraryBase.php index 4cb62811..08ff3d84 100644 --- a/src/SPC/builder/LibraryBase.php +++ b/src/SPC/builder/LibraryBase.php @@ -299,6 +299,11 @@ abstract class LibraryBase return false; } + public function patchBeforeMake(): bool + { + return false; + } + /** * Build this library. * diff --git a/src/SPC/builder/unix/library/libacl.php b/src/SPC/builder/unix/library/libacl.php index 8fbe1610..9727e17c 100644 --- a/src/SPC/builder/unix/library/libacl.php +++ b/src/SPC/builder/unix/library/libacl.php @@ -5,14 +5,23 @@ declare(strict_types=1); namespace SPC\builder\unix\library; use SPC\builder\linux\library\LinuxLibraryBase; +use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\store\FileSystem; trait libacl { - public function patchBeforeConfigure(): bool + /** + * @throws FileSystemException + */ + public function patchBeforeMake(): bool { - FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/sapi/fpm/config.m4', '[AS_VAR_APPEND([FPM_EXTRA_LIBS],', ','); + $file_path = SOURCE_PATH . '/php-src/Makefile'; + $file_content = FileSystem::readFile($file_path); + if (!preg_match('/FPM_EXTRA_LIBS =(.*)-lacl/', $file_content)) { + return false; + } + FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/Makefile', '/FPM_EXTRA_LIBS =(.*)-lacl ?(.*)/', 'FPM_EXTRA_LIBS =$1$2'); return true; } diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 047c33cf..3c90e3ec 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -252,6 +252,11 @@ class SourcePatcher logger()->info('Extension [' . $ext->getName() . '] patched before make'); } } + foreach ($builder->getLibs() as $lib) { + if ($lib->patchBeforeMake() === true) { + logger()->info('Library [' . $lib->getName() . '] patched before make'); + } + } } /** @@ -415,7 +420,7 @@ class SourcePatcher public static function patchAttrForAlpine(): bool { - if (PHP_OS_FAMILY === 'Linux' && SystemUtil::isMuslDist()) { + if (PHP_OS_FAMILY === 'Linux' && SystemUtil::isMuslDist() || PHP_OS_FAMILY === 'Darwin') { SourcePatcher::patchFile('attr_alpine_gethostname.patch', SOURCE_PATH . '/attr'); return true; }