Add ext-maxminddb

This commit is contained in:
crazywhalecc 2026-03-11 08:18:25 +08:00
parent fa7de0642a
commit f414bd289c
No known key found for this signature in database
GPG Key ID: 1F4BDD59391F2680
2 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,13 @@
ext-maxminddb:
type: php-extension
artifact:
source:
type: pecl
name: maxminddb
metadata:
license-files: [LICENSE]
license: Apache-2.0
depends:
- libmaxminddb
php-extension:
arg-type: with

View File

@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
namespace Package\Extension;
use Package\Target\php;
use StaticPHP\Attribute\Package\BeforeStage;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Attribute\PatchDescription;
use StaticPHP\Package\PhpExtensionPackage;
use StaticPHP\Util\FileSystem;
#[Extension('maxminddb')]
class maxminddb extends PhpExtensionPackage
{
#[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-maxminddb')]
#[PatchDescription('Patch maxminddb extension for buildconf to support new source structure')]
public function patchBeforeBuildconf(): void
{
if (file_exists("{$this->getSourceDir()}/config.m4")) {
return;
}
// move ext/maxminddb/ext/* to ext/maxminddb/
$files = FileSystem::scanDirFiles("{$this->getSourceDir()}/ext", false, true);
foreach ($files as $file) {
rename("{$this->getSourceDir()}/ext/{$file}", "{$this->getSourceDir()}/{$file}");
}
}
}