Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phpExtensions.couchbase: fix builds on PHP 5.6 #285

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ jobs:
run: |
nix eval --json --impure --expr 'builtins.attrNames (import ./.).packages.${{ matrix.archs.arch }}.${{ steps.params.outputs.attr }}.extensions'

- name: Build Couchbase extension
run: nix-build -A outputs.checks.${{ matrix.archs.arch }}.${{ steps.params.outputs.attr }}-couchbase

- name: Build Imagick extension
run: nix-build -A outputs.checks.${{ matrix.archs.arch }}.${{ steps.params.outputs.attr }}-imagick

Expand Down
5 changes: 5 additions & 0 deletions checks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ let
drv = { php, ... }: php.extensions.tidy;
};

couchbase = {
description = "Build Couchbase extension";
drv = { php, ... }: php.extensions.couchbase;
};

composer-phar = {
description = "Check that composer PHAR works";
drv =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
From 58237e64fa77ec5cdec658b3295f71ec899175fa Mon Sep 17 00:00:00 2001
From: Maximilian Bosch <maximilian@mbosch.me>
Date: Sat, 5 Oct 2019 13:47:59 +0200
Subject: [PATCH] Fix timeouts in libcouchbase testsuite

Nix-specific patch. Basically
https://github.com/couchbase/libcouchbase/commit/b272f6ab88be523bbcf9d5c4252d07fccb023fe5, but
rebased onto 2.10.4.
---
src/ssl/ssl_e.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/src/ssl/ssl_e.c b/src/ssl/ssl_e.c
index f4506cf..734a3e6 100644
--- a/src/ssl/ssl_e.c
+++ b/src/ssl/ssl_e.c
@@ -210,10 +210,16 @@ flush_ssl_data(lcbio_ESSL *es)
* calls. While we could have done this inline with the send() call this
* would make future optimization more difficult. */
GT_WRITE_DONE:
+#if !LCB_CAN_OPTIMIZE_SSL_BIO
+ BIO_get_mem_ptr(es->wbio, &wmb);
+#endif
while (wmb->length > (size_t)tmp_len) {
char dummy[4096];
unsigned to_read = MINIMUM(wmb->length-tmp_len, sizeof dummy);
BIO_read(es->wbio, dummy, to_read);
+#if !LCB_CAN_OPTIMIZE_SSL_BIO
+ BIO_get_mem_ptr(es->wbio, &wmb);
+#endif
}
BIO_clear_retry_flags(es->wbio);
return 0;
--
2.23.0
34 changes: 34 additions & 0 deletions pkgs/extensions/couchbase/0001-fix-config.m4.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
From 81b20d6b5ced850a4b173b26499a3ed3266bdaa4 Mon Sep 17 00:00:00 2001
From: Pol Dellaiera <pol.dellaiera@protonmail.com>
Date: Mon, 24 Jul 2023 05:23:09 +0200
Subject: [PATCH] fix config.m4

---
config.m4 | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/config.m4 b/config.m4
index 8033193..3327a53 100644
--- a/config.m4
+++ b/config.m4
@@ -9,7 +9,7 @@ if test "$PHP_COUCHBASE" != "no"; then
LIBCOUCHBASE_DIR=$PHP_COUCHBASE
else
AC_MSG_CHECKING(for libcouchbase in default path)
- for i in /usr/local /usr; do
+ for i in @libcouchbase@; do
if test -r $i/include/libcouchbase/couchbase.h; then
LIBCOUCHBASE_DIR=$i
AC_MSG_RESULT(found in $i)
@@ -163,6 +163,8 @@ COUCHBASE_FILES=" \
igbinary_inc_path="$phpincludedir"
elif test -f "$phpincludedir/ext/igbinary/igbinary.h"; then
igbinary_inc_path="$phpincludedir"
+ elif test -f "@igbinary@/include/ext/igbinary/igbinary.h"; then
+ igbinary_inc_path="@igbinary@/include"
fi
if test "$igbinary_inc_path" = ""; then
AC_MSG_WARN([Cannot find igbinary.h])
--
2.41.0

28 changes: 28 additions & 0 deletions pkgs/extensions/couchbase/0001-fix-libcouchbase.pc.in.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
From e3343d8392b68f7a432a5d45dbcb09df41e264da Mon Sep 17 00:00:00 2001
From: Pol Dellaiera <pol.dellaiera@protonmail.com>
Date: Mon, 24 Jul 2023 05:43:59 +0200
Subject: [PATCH] fix libcouchbase.pc.in

Nix related patch
---
packaging/libcouchbase.pc.in | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/packaging/libcouchbase.pc.in b/packaging/libcouchbase.pc.in
index 94820a65..95360f43 100644
--- a/packaging/libcouchbase.pc.in
+++ b/packaging/libcouchbase.pc.in
@@ -1,7 +1,7 @@
prefix=@CMAKE_INSTALL_PREFIX@
-exec_prefix=${prefix}/@CMAKE_INSTALL_BINDIR@
-includedir=${prefix}/include
-libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
+exec_prefix=@CMAKE_INSTALL_FULL_LIBDIR@
+includedir=@CMAKE_INSTALL_FULL_LIBDIR@/include
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@

Name: libcouchbase @LCB_VERSION@
Description: Couchbase client library
--
2.41.0

45 changes: 45 additions & 0 deletions pkgs/extensions/couchbase/couchbase-2.6.2.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{ lib
, libcouchbase
, buildPecl
, fetchFromGitHub
, substituteAll
, zlib
, prev
}:

let
pname = "couchbase";
version = "2.6.2";
in
buildPecl {
inherit pname version;

src = fetchFromGitHub {
owner = "couchbase";
repo = "php-couchbase";
rev = "v${version}";
hash = "sha256-Q1WSt5CsrNAvF4D0Dp1rxTBuyMOEAG3FSg+H9G31uXo=";
};

configureFlags = [ "--with-couchbase" ];

buildInputs = [ libcouchbase zlib ];
internalDeps = [ prev.php.extensions.json ];
peclDeps = [ prev.php.extensions.igbinary ];

patches = [
(substituteAll {
# Patch backported from https://github.com/NixOS/nixpkgs/blob/e76ccc6b2798e50ef959a8cf830035d76a92106b/pkgs/development/php-packages/couchbase/default.nix#L23
src = ./0001-fix-config.m4.patch;
inherit libcouchbase;
igbinary = prev.php.extensions.igbinary.dev;
})
];

meta = {
description = "Couchbase Server PHP extension";
license = lib.licenses.asl20;
homepage = "https://docs.couchbase.com/php-sdk/current/project-docs/sdk-release-notes.html";
maintainers = lib.teams.php.members;
};
}
32 changes: 32 additions & 0 deletions pkgs/extensions/couchbase/libcouchbase-2.10.4.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{ lib, stdenv, fetchFromGitHub, cmake, pkg-config, libevent, openssl}:

stdenv.mkDerivation (finalAttrs: {
pname = "libcouchbase";
version = "2.10.4";

src = fetchFromGitHub {
owner = "couchbase";
repo = "libcouchbase";
rev = finalAttrs.version;
hash = "sha256-hy8TnRzaBO2wgeC9EVlBFg0tap1GQaYPoqVhVUxn1fk=";
};

cmakeFlags = [ "-DLCB_NO_MOCK=ON" ];

nativeBuildInputs = [ cmake pkg-config ];
buildInputs = [ libevent openssl ];

patches = [
# Patch from https://github.com/NixOS/nixpkgs/commit/fd41a333d806b9d4ac4a5f39775b650edc5756f6
./0001-Fix-timeouts-in-libcouchbase-testsuite.patch
# Custom patch to fix the .pc file
./0001-fix-libcouchbase.pc.in.patch
];

meta = {
description = "C client library for Couchbase";
homepage = "https://github.com/couchbase/libcouchbase";
license = lib.licenses.asl20;
platforms = lib.platforms.unix;
};
})
25 changes: 16 additions & 9 deletions pkgs/package-overrides.nix
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,22 @@ in
else
final.callPackage ./extensions/blackfire/1.50.0.nix { inherit prev; };

couchbase = prev.extensions.couchbase.overrideAttrs (attrs: {
preConfigure =
let
deps = lib.optionals (lib.versionOlder prev.php.version "8.0") [
final.extensions.json
];
in
attrs.preConfigure or "" + linkInternalDeps deps;
});
couchbase =
if lib.versionOlder prev.php.version "7.0" then
final.callPackage ./extensions/couchbase/couchbase-2.6.2.nix {
inherit prev;
libcouchbase = final.callPackage ./extensions/couchbase/libcouchbase-2.10.4.nix { };
}
else
prev.extensions.couchbase.overrideAttrs (attrs: {
preConfigure =
let
deps = lib.optionals (lib.versionOlder prev.php.version "8.0") [
final.extensions.json
];
in
attrs.preConfigure or "" + linkInternalDeps deps;
});

datadog_trace =
if lib.versionAtLeast prev.php.version "8.3" then
Expand Down
Loading