1{
2 buildPecl,
3 lib,
4 gpgme,
5 file,
6 gnupg,
7 php,
8 fetchFromGitHub,
9}:
10
11let
12 version = "1.5.4";
13in
14buildPecl {
15 inherit version;
16 pname = "gnupg";
17
18 src = fetchFromGitHub {
19 owner = "php-gnupg";
20 repo = "php-gnupg";
21 rev = "gnupg-${version}";
22 fetchSubmodules = true;
23 hash = "sha256-g9w0v9qc/Q5qjB9/ekZyheQ1ClIEqMEoBc32nGWhXYA=";
24 };
25
26 buildInputs = [ gpgme ];
27 nativeCheckInputs = [ gnupg ];
28
29 postPhpize = ''
30 substituteInPlace configure \
31 --replace-fail '/usr/bin/file' '${file}/bin/file' \
32 --replace-fail 'SEARCH_PATH="/usr/local /usr /opt /opt/homebrew"' 'SEARCH_PATH="${gpgme.dev}"'
33 '';
34
35 postConfigure = ''
36 substituteInPlace Makefile \
37 --replace-fail 'run-tests.php' 'run-tests.php -q --offline'
38 substituteInPlace tests/gnupg_res_init_file_name.phpt \
39 --replace-fail '/usr/bin/gpg' '${gnupg}/bin/gpg' \
40 --replace-fail 'string(12)' 'string(${toString (lib.stringLength "${gnupg}/bin/gpg")})'
41 substituteInPlace tests/gnupg_oo_init_file_name.phpt \
42 --replace-fail '/usr/bin/gpg' '${gnupg}/bin/gpg' \
43 --replace-fail 'string(12)' 'string(${toString (lib.stringLength "${gnupg}/bin/gpg")})'
44 '';
45
46 patches = [
47 # https://github.com/php-gnupg/php-gnupg/issues/62
48 ./missing-new-line-test.patch
49 ];
50
51 doCheck = true;
52
53 meta = {
54 changelog = "https://github.com/php-gnupg/php-gnupg/releases/tag/gnupg-${version}";
55 broken = lib.versionOlder php.version "8.1"; # Broken on PHP older than 8.1.
56 description = "PHP wrapper for GpgME library that provides access to GnuPG";
57 license = lib.licenses.bsd3;
58 homepage = "https://pecl.php.net/package/gnupg";
59 maintainers = with lib.maintainers; [ taikx4 ];
60 teams = [ lib.teams.php ];
61 };
62}