diff --git a/config/ext.json b/config/ext.json index 2df512391..8a75b5022 100644 --- a/config/ext.json +++ b/config/ext.json @@ -242,6 +242,13 @@ "zlib" ] }, + "password-argon2": { + "type": "builtin", + "arg-type": "with-prefix", + "lib-depends": [ + "libargon2" + ] + }, "pcntl": { "type": "builtin", "unix-only": true diff --git a/config/lib.json b/config/lib.json index 318afe166..14d66130c 100644 --- a/config/lib.json +++ b/config/lib.json @@ -163,6 +163,12 @@ "libsodium" ] }, + "libargon2": { + "source": "libargon2", + "static-libs-unix": [ + "libargon2.a" + ] + }, "libavif": { "source": "libavif", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index fb29e410d..09cd20647 100644 --- a/config/source.json +++ b/config/source.json @@ -172,6 +172,15 @@ "path": "LICENSE" } }, + "libargon2": { + "type": "git", + "rev": "master", + "url": "https://github.com/mpociot/phc-winner-argon2", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "libavif": { "type": "ghtar", "repo": "AOMediaCodec/libavif", @@ -376,9 +385,8 @@ } }, "pkg-config": { - "type": "filelist", - "url": "https://pkgconfig.freedesktop.org/releases/", - "regex": "/href=\"(?pkg-config-(?[^\"]+)\\.tar\\.gz)\"/", + "type": "url", + "url": "https://dl.static-php.dev/static-php-cli/deps/pkg-config/pkg-config-0.29.2.tar.gz", "license": { "type": "file", "path": "COPYING" diff --git a/src/SPC/builder/extension/password_argon2.php b/src/SPC/builder/extension/password_argon2.php new file mode 100644 index 000000000..fb3c4b044 --- /dev/null +++ b/src/SPC/builder/extension/password_argon2.php @@ -0,0 +1,21 @@ +execWithResult(BUILD_ROOT_PATH . '/bin/php -r "assert(defined(\'PASSWORD_ARGON2I\'));"'); + if ($ret !== 0) { + throw new RuntimeException('extension ' . $this->getName() . ' failed sanity check'); + } + } +} diff --git a/src/SPC/builder/linux/library/libargon2.php b/src/SPC/builder/linux/library/libargon2.php new file mode 100644 index 000000000..ca4a72acd --- /dev/null +++ b/src/SPC/builder/linux/library/libargon2.php @@ -0,0 +1,25 @@ +builder->getLib('libsodium') !== null) { + throw new WrongUsageException('libargon2 (required by password-argon2) conflicts with the libsodium library !'); + } + FileSystem::replaceFileStr($this->source_dir . '/Makefile', 'LIBRARY_REL ?= lib/x86_64-linux-gnu', 'LIBRARY_REL ?= lib'); + return true; + } +} diff --git a/src/SPC/builder/macos/library/libargon2.php b/src/SPC/builder/macos/library/libargon2.php new file mode 100644 index 000000000..f39afa4fe --- /dev/null +++ b/src/SPC/builder/macos/library/libargon2.php @@ -0,0 +1,12 @@ +cd($this->source_dir) + ->exec("make PREFIX='' clean") + ->exec("make -j{$this->builder->concurrency} PREFIX=''") + ->exec("make install PREFIX='' DESTDIR=" . BUILD_ROOT_PATH); + + $this->patchPkgconfPrefix(['libargon2.pc']); + + foreach (FileSystem::scanDirFiles(BUILD_ROOT_PATH . '/lib/', false, true) as $filename) { + if (str_starts_with($filename, 'libargon2') && (str_contains($filename, '.so') || str_ends_with($filename, '.dylib'))) { + unlink(BUILD_ROOT_PATH . '/lib/' . $filename); + } + } + } +} diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index a80c9a781..f047e2493 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -3,6 +3,10 @@ declare(strict_types=1); # If you want to test new extensions here, just modify it. -$extensions = 'apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,event,exif,fileinfo,filter,ftp,gd,gmp,iconv,imagick,imap,intl,ldap,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sodium,sqlite3,swoole,sysvmsg,sysvsem,sysvshm,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib'; +$extensions = 'password-argon2,apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,event,exif,fileinfo,filter,ftp,gd,gmp,iconv,imagick,imap,intl,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sqlite3,swoole,sysvmsg,sysvsem,sysvshm,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib'; + +if (PHP_OS_FAMILY === 'Darwin') { + $extensions .= ',sodium'; +} echo $extensions;