From 460699c48cb9e323708738a509bfe82273e9f1c1 Mon Sep 17 00:00:00 2001 From: Marc Henderkes Date: Wed, 5 Mar 2025 11:35:03 +0100 Subject: [PATCH] add (lib)attr and libacl as optional libraries when libacl is built and --enable-fpm is used, also enable --with-fpm-acl --- config/lib.json | 15 ++++++++++++ config/source.json | 20 ++++++++++++++++ src/SPC/builder/linux/LinuxBuilder.php | 11 +++++++-- src/SPC/builder/linux/library/attr.php | 12 ++++++++++ src/SPC/builder/linux/library/libacl.php | 12 ++++++++++ src/SPC/builder/unix/library/attr.php | 26 ++++++++++++++++++++ src/SPC/builder/unix/library/libacl.php | 30 ++++++++++++++++++++++++ 7 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 src/SPC/builder/linux/library/attr.php create mode 100644 src/SPC/builder/linux/library/libacl.php create mode 100644 src/SPC/builder/unix/library/attr.php create mode 100644 src/SPC/builder/unix/library/libacl.php diff --git a/config/lib.json b/config/lib.json index cfe41927..32d9a770 100644 --- a/config/lib.json +++ b/config/lib.json @@ -24,6 +24,12 @@ "pkg-config" ] }, + "attr": { + "source": "attr", + "static-libs-unix": [ + "libattr.a" + ] + }, "brotli": { "source": "brotli", "static-libs-unix": [ @@ -234,6 +240,15 @@ "libsodium" ] }, + "libacl": { + "source": "libacl", + "static-libs-unix": [ + "libacl.a" + ], + "lib-depends": [ + "attr" + ] + }, "libaom": { "source": "libaom", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index b97ab139..81204229 100644 --- a/config/source.json +++ b/config/source.json @@ -36,6 +36,16 @@ "path": "LICENSE" } }, + "attr": { + "type": "git", + "rev": "v2.5.2", + "url": "https://git.savannah.nongnu.org/git/attr.git", + "provide-pre-built": false, + "license": { + "type": "file", + "path": "doc/COPYING" + } + }, "brotli": { "type": "ghtar", "repo": "google/brotli", @@ -323,6 +333,16 @@ "path": "LICENSE" } }, + "libacl": { + "type": "git", + "rev": "v2.3.2", + "url": "https://git.savannah.nongnu.org/git/acl.git", + "provide-pre-built": false, + "license": { + "type": "file", + "path": "doc/COPYING" + } + }, "libaom": { "type": "git", "rev": "main", diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index b809a005..2012ae3a 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -174,7 +174,7 @@ class LinuxBuilder extends UnixBuilderBase ->exec( getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' . ($enable_cli ? '--enable-cli ' : '--disable-cli ') . - ($enable_fpm ? '--enable-fpm ' : '--disable-fpm ') . + ($enable_fpm ? '--enable-fpm ' . ($this->getLib('libacl') !== null ? '--with-fpm-acl ' : '') : '--disable-fpm ') . ($enable_embed ? "--enable-embed={$embed_type} " : '--disable-embed ') . ($enable_micro ? '--enable-micro=all-static ' : '--disable-micro ') . $config_file_path . @@ -287,7 +287,14 @@ class LinuxBuilder extends UnixBuilderBase */ protected function buildFpm(): void { - $vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars()); + $vars = $this->getMakeExtraVars(); + if ($this->getLib('libacl') !== null) { + $ldflags_program = $vars['EXTRA_LDFLAGS_PROGRAM'] ?? ''; + if (!str_contains($ldflags_program, '-L' . BUILD_LIB_PATH)) { + $vars['EXTRA_LDFLAGS_PROGRAM'] = trim('-L' . BUILD_LIB_PATH . ' ' . $ldflags_program); + } + } + $vars = $this->getEnvString($vars); shell()->cd(SOURCE_PATH . '/php-src') ->exec('sed -i "s|//lib|/lib|g" Makefile') ->exec("\$SPC_CMD_PREFIX_PHP_MAKE {$vars} fpm"); diff --git a/src/SPC/builder/linux/library/attr.php b/src/SPC/builder/linux/library/attr.php new file mode 100644 index 00000000..da29d48f --- /dev/null +++ b/src/SPC/builder/linux/library/attr.php @@ -0,0 +1,12 @@ +cd($this->source_dir) + ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) + ->execWithEnv('./autogen.sh') + ->execWithEnv('./configure --prefix= --enable-static --disable-shared --disable-tests') + ->execWithEnv("make -j {$this->builder->concurrency}") + ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + + $this->patchPkgconfPrefix(['libattr.pc'], PKGCONF_PATCH_PREFIX); + $this->cleanLaFiles(); + } +} diff --git a/src/SPC/builder/unix/library/libacl.php b/src/SPC/builder/unix/library/libacl.php new file mode 100644 index 00000000..9d6ebc82 --- /dev/null +++ b/src/SPC/builder/unix/library/libacl.php @@ -0,0 +1,30 @@ +cd($this->source_dir) + ->setEnv([ + 'CFLAGS' => trim('-I' . BUILD_INCLUDE_PATH . ' ' . $this->getLibExtraCFlags()), + 'LDFLAGS' => trim('-L' . BUILD_LIB_PATH . ' ' . $this->getLibExtraLdFlags()), + 'LIBS' => $this->getLibExtraLibs(), + ]) + ->execWithEnv('./autogen.sh') + ->execWithEnv('./configure --prefix= --enable-static --disable-shared --disable-tests --disable-nls') + ->execWithEnv("make -j {$this->builder->concurrency}") + ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + + $this->patchPkgconfPrefix(['libacl.pc'], PKGCONF_PATCH_PREFIX); + $this->cleanLaFiles(); + } +}