mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-15 12:55:36 +08:00
Add snmp support
This commit is contained in:
@@ -756,6 +756,14 @@
|
|||||||
"apcu"
|
"apcu"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"snmp": {
|
||||||
|
"type": "builtin",
|
||||||
|
"arg-type-unix": "with",
|
||||||
|
"arg-type-windows": "with",
|
||||||
|
"lib-depends": [
|
||||||
|
"net-snmp"
|
||||||
|
]
|
||||||
|
},
|
||||||
"soap": {
|
"soap": {
|
||||||
"support": {
|
"support": {
|
||||||
"BSD": "wip"
|
"BSD": "wip"
|
||||||
|
|||||||
@@ -697,6 +697,17 @@
|
|||||||
"libncurses.a"
|
"libncurses.a"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"net-snmp": {
|
||||||
|
"source": "net-snmp",
|
||||||
|
"pkg-configs": [
|
||||||
|
"netsnmp",
|
||||||
|
"netsnmp-agent"
|
||||||
|
],
|
||||||
|
"lib-depends": [
|
||||||
|
"openssl",
|
||||||
|
"zlib"
|
||||||
|
]
|
||||||
|
},
|
||||||
"nghttp2": {
|
"nghttp2": {
|
||||||
"source": "nghttp2",
|
"source": "nghttp2",
|
||||||
"static-libs-unix": [
|
"static-libs-unix": [
|
||||||
|
|||||||
@@ -810,6 +810,14 @@
|
|||||||
"path": "COPYING"
|
"path": "COPYING"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"net-snmp": {
|
||||||
|
"type": "ghtagtar",
|
||||||
|
"repo": "net-snmp/net-snmp",
|
||||||
|
"license": {
|
||||||
|
"type": "file",
|
||||||
|
"path": "COPYING"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nghttp2": {
|
"nghttp2": {
|
||||||
"type": "ghrel",
|
"type": "ghrel",
|
||||||
"repo": "nghttp2/nghttp2",
|
"repo": "nghttp2/nghttp2",
|
||||||
|
|||||||
25
src/SPC/builder/extension/snmp.php
Normal file
25
src/SPC/builder/extension/snmp.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\extension;
|
||||||
|
|
||||||
|
use SPC\builder\Extension;
|
||||||
|
use SPC\store\FileSystem;
|
||||||
|
use SPC\util\CustomExt;
|
||||||
|
use SPC\util\PkgConfigUtil;
|
||||||
|
|
||||||
|
#[CustomExt('snmp')]
|
||||||
|
class snmp extends Extension
|
||||||
|
{
|
||||||
|
public function patchBeforeBuildconf(): bool
|
||||||
|
{
|
||||||
|
$libs = implode(' ', PkgConfigUtil::getLibsArray('netsnmp'));
|
||||||
|
FileSystem::replaceFileStr(
|
||||||
|
"{$this->source_dir}/config.m4",
|
||||||
|
'PHP_EVAL_LIBLINE([$SNMP_LIBS], [SNMP_SHARED_LIBADD])',
|
||||||
|
"SNMP_LIBS=\"{$libs}\"\nPHP_EVAL_LIBLINE([\$SNMP_LIBS], [SNMP_SHARED_LIBADD])"
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
12
src/SPC/builder/linux/library/net_snmp.php
Normal file
12
src/SPC/builder/linux/library/net_snmp.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\linux\library;
|
||||||
|
|
||||||
|
class net_snmp extends LinuxLibraryBase
|
||||||
|
{
|
||||||
|
use \SPC\builder\unix\library\net_snmp;
|
||||||
|
|
||||||
|
public const NAME = 'net-snmp';
|
||||||
|
}
|
||||||
@@ -78,7 +78,7 @@ class openssl extends LinuxLibraryBase
|
|||||||
if (!str_contains($file = FileSystem::readFile(BUILD_LIB_PATH . '/pkgconfig/libcrypto.pc'), 'prefix=')) {
|
if (!str_contains($file = FileSystem::readFile(BUILD_LIB_PATH . '/pkgconfig/libcrypto.pc'), 'prefix=')) {
|
||||||
FileSystem::writeFile(BUILD_LIB_PATH . '/pkgconfig/libcrypto.pc', 'prefix=' . BUILD_ROOT_PATH . "\n" . $file);
|
FileSystem::writeFile(BUILD_LIB_PATH . '/pkgconfig/libcrypto.pc', 'prefix=' . BUILD_ROOT_PATH . "\n" . $file);
|
||||||
}
|
}
|
||||||
FileSystem::replaceFileRegex(BUILD_LIB_PATH . '/pkgconfig/libcrypto.pc', '/Libs.private:.*/m', 'Libs.private: ${libdir}/libz.a');
|
FileSystem::replaceFileRegex(BUILD_LIB_PATH . '/pkgconfig/libcrypto.pc', '/Libs.private:.*/m', 'Requires.private: zlib');
|
||||||
FileSystem::replaceFileRegex(BUILD_LIB_PATH . '/cmake/OpenSSL/OpenSSLConfig.cmake', '/set\(OPENSSL_LIBCRYPTO_DEPENDENCIES .*\)/m', 'set(OPENSSL_LIBCRYPTO_DEPENDENCIES "${OPENSSL_LIBRARY_DIR}/libz.a")');
|
FileSystem::replaceFileRegex(BUILD_LIB_PATH . '/cmake/OpenSSL/OpenSSLConfig.cmake', '/set\(OPENSSL_LIBCRYPTO_DEPENDENCIES .*\)/m', 'set(OPENSSL_LIBCRYPTO_DEPENDENCIES "${OPENSSL_LIBRARY_DIR}/libz.a")');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
src/SPC/builder/macos/library/net_snmp.php
Normal file
12
src/SPC/builder/macos/library/net_snmp.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\macos\library;
|
||||||
|
|
||||||
|
class net_snmp extends MacOSLibraryBase
|
||||||
|
{
|
||||||
|
use \SPC\builder\unix\library\net_snmp;
|
||||||
|
|
||||||
|
public const NAME = 'net-snmp';
|
||||||
|
}
|
||||||
@@ -63,7 +63,7 @@ class openssl extends MacOSLibraryBase
|
|||||||
if (!str_contains($file = FileSystem::readFile(BUILD_LIB_PATH . '/pkgconfig/libcrypto.pc'), 'prefix=')) {
|
if (!str_contains($file = FileSystem::readFile(BUILD_LIB_PATH . '/pkgconfig/libcrypto.pc'), 'prefix=')) {
|
||||||
FileSystem::writeFile(BUILD_LIB_PATH . '/pkgconfig/libcrypto.pc', 'prefix=' . BUILD_ROOT_PATH . "\n" . $file);
|
FileSystem::writeFile(BUILD_LIB_PATH . '/pkgconfig/libcrypto.pc', 'prefix=' . BUILD_ROOT_PATH . "\n" . $file);
|
||||||
}
|
}
|
||||||
FileSystem::replaceFileRegex(BUILD_LIB_PATH . '/pkgconfig/libcrypto.pc', '/Libs.private:.*/m', 'Libs.private: ${libdir}/libz.a');
|
FileSystem::replaceFileRegex(BUILD_LIB_PATH . '/pkgconfig/libcrypto.pc', '/Libs.private:.*/m', 'Requires.private: zlib');
|
||||||
FileSystem::replaceFileRegex(BUILD_LIB_PATH . '/cmake/OpenSSL/OpenSSLConfig.cmake', '/set\(OPENSSL_LIBCRYPTO_DEPENDENCIES .*\)/m', 'set(OPENSSL_LIBCRYPTO_DEPENDENCIES "${OPENSSL_LIBRARY_DIR}/libz.a")');
|
FileSystem::replaceFileRegex(BUILD_LIB_PATH . '/cmake/OpenSSL/OpenSSLConfig.cmake', '/set\(OPENSSL_LIBCRYPTO_DEPENDENCIES .*\)/m', 'set(OPENSSL_LIBCRYPTO_DEPENDENCIES "${OPENSSL_LIBRARY_DIR}/libz.a")');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
28
src/SPC/builder/unix/library/net_snmp.php
Normal file
28
src/SPC/builder/unix/library/net_snmp.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\unix\library;
|
||||||
|
|
||||||
|
use SPC\util\executor\UnixAutoconfExecutor;
|
||||||
|
|
||||||
|
trait net_snmp
|
||||||
|
{
|
||||||
|
protected function build(): void
|
||||||
|
{
|
||||||
|
// use --static for PKG_CONFIG
|
||||||
|
UnixAutoconfExecutor::create($this)
|
||||||
|
->setEnv(['PKG_CONFIG' => getenv('PKG_CONFIG') . ' --static'])
|
||||||
|
->configure(
|
||||||
|
'--disable-mibs',
|
||||||
|
'--with-default-snmp-version="3"',
|
||||||
|
'--with-sys-contact="@@no.where"',
|
||||||
|
'--with-sys-location="Unknown"',
|
||||||
|
'--with-logfile="/var/log/snmpd.log"',
|
||||||
|
'--with-persistent-directory="/var/net-snmp"',
|
||||||
|
'--with-openssl=' . BUILD_ROOT_PATH,
|
||||||
|
'--with-zlib=' . BUILD_ROOT_PATH,
|
||||||
|
)->make(with_install: 'installheaders installlibs install_pkgconfig');
|
||||||
|
$this->patchPkgconfPrefix();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -115,6 +115,12 @@ class UnixAutoconfExecutor extends Executor
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setEnv(array $env): static
|
||||||
|
{
|
||||||
|
$this->shell->setEnv($env);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function appendEnv(array $env): static
|
public function appendEnv(array $env): static
|
||||||
{
|
{
|
||||||
$this->shell->appendEnv($env);
|
$this->shell->appendEnv($env);
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ declare(strict_types=1);
|
|||||||
// test php version (8.1 ~ 8.4 available, multiple for matrix)
|
// test php version (8.1 ~ 8.4 available, multiple for matrix)
|
||||||
$test_php_version = [
|
$test_php_version = [
|
||||||
'8.1',
|
'8.1',
|
||||||
// '8.2',
|
'8.2',
|
||||||
// '8.3',
|
'8.3',
|
||||||
// '8.4',
|
'8.4',
|
||||||
'8.5',
|
'8.5',
|
||||||
// 'git',
|
// 'git',
|
||||||
];
|
];
|
||||||
@@ -49,8 +49,8 @@ $prefer_pre_built = false;
|
|||||||
|
|
||||||
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
|
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
|
||||||
$extensions = match (PHP_OS_FAMILY) {
|
$extensions = match (PHP_OS_FAMILY) {
|
||||||
'Linux', 'Darwin' => 'gettext',
|
'Linux', 'Darwin' => 'snmp',
|
||||||
'Windows' => 'bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pdo,pdo_mysql,pdo_sqlite,phar,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip',
|
'Windows' => 'snmp',
|
||||||
};
|
};
|
||||||
|
|
||||||
// If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`).
|
// If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`).
|
||||||
|
|||||||
Reference in New Issue
Block a user