fix gmssl and event properly..

This commit is contained in:
henderkes
2026-07-09 19:27:41 +07:00
parent 8f557aae8a
commit 6b6a099a47
4 changed files with 22 additions and 5 deletions

View File

@@ -10,3 +10,5 @@ ext-gmssl:
license: PHP-3.01 license: PHP-3.01
depends: depends:
- gmssl - gmssl
php-extension:
arg-type: with-path

View File

@@ -2,8 +2,9 @@ gmssl:
type: library type: library
artifact: artifact:
source: source:
type: ghtar type: git
repo: guanzhi/GmSSL url: 'https://github.com/guanzhi/GmSSL.git'
rev: master
metadata: metadata:
license-files: [LICENSE] license-files: [LICENSE]
license: Apache-2.0 license: Apache-2.0

View File

@@ -17,4 +17,11 @@ class gmssl
FileSystem::replaceFileStr($target_path . '/src/hex.c', 'unsigned char *OPENSSL_hexstr2buf(const char *str, size_t *len)', 'unsigned char *GMSSL_hexstr2buf(const char *str, size_t *len)'); FileSystem::replaceFileStr($target_path . '/src/hex.c', 'unsigned char *OPENSSL_hexstr2buf(const char *str, size_t *len)', 'unsigned char *GMSSL_hexstr2buf(const char *str, size_t *len)');
FileSystem::replaceFileStr($target_path . '/src/hex.c', 'OPENSSL_hexchar2int', 'GMSSL_hexchar2int'); FileSystem::replaceFileStr($target_path . '/src/hex.c', 'OPENSSL_hexchar2int', 'GMSSL_hexchar2int');
} }
#[AfterSourceExtract('ext-gmssl')]
#[PatchDescription('Rename pbkdf2_hmac_sm3_genkey() to sm3_pbkdf2() (renamed upstream in GmSSL 3.2+; identical signature)')]
public function patchExt(string $target_path): void
{
FileSystem::replaceFileStr($target_path . '/gmssl.c', 'pbkdf2_hmac_sm3_genkey(', 'sm3_pbkdf2(');
}
} }

View File

@@ -56,9 +56,16 @@ class event extends PhpExtensionPackage
private function patchLibeventConstPeer(string $event_source_dir): bool private function patchLibeventConstPeer(string $event_source_dir): bool
{ {
$file = "{$event_source_dir}/php8/classes/http_connection.c"; $file = "{$event_source_dir}/php8/classes/http_connection.c";
if (is_file($file) && FileSystem::replaceFileRegex($file, '/^\tchar \*address;$/m', "\tconst char *address;")) { if (!is_file($file)) {
return true; return false;
} }
return false; // libevent >= 2.2 changed evhttp_connection_get_peer()'s
// address arg to `const char **`
$header = $this->getBuilder()->getBuildRootPath() . '/include/event2/http.h';
$isConst = is_file($header)
&& preg_match('/evhttp_connection_get_peer\s*\([^;]*\bconst\s+char\s*\*\*\s*address/s', file_get_contents($header)) === 1;
return (bool) ($isConst
? FileSystem::replaceFileRegex($file, '/^\tchar \*address;$/m', "\tconst char *address;")
: FileSystem::replaceFileRegex($file, '/^\tconst char \*address;$/m', "\tchar *address;"));
} }
} }