[Buildroot] [PATCH 1/1] package/pecl-dbus: new package

Herve Codina herve.codina at bootlin.com
Tue Oct 5 13:11:21 UTC 2021


The pecl-dbus package provides a PHP extension for interaction
with D-Bus busses.

https://github.com/derickr/pecl-dbus

Based on initial work from Nicolas Carrier <nicolas.carrier at orolia.com>

Signed-off-by: Herve Codina <herve.codina at bootlin.com>
---
 DEVELOPERS                                    |   6 +
 package/Config.in                             |   1 +
 package/pecl-dbus/0001-php8-compat.patch      | 161 ++++++++++++++++++
 ...lity-with-php8-call_user_function_ex.patch |  31 ++++
 package/pecl-dbus/Config.in                   |  15 ++
 package/pecl-dbus/pecl-dbus.hash              |   3 +
 package/pecl-dbus/pecl-dbus.mk                |  25 +++
 .../testing/tests/package/test_pecl_dbus.py   |  32 ++++
 8 files changed, 274 insertions(+)
 create mode 100644 package/pecl-dbus/0001-php8-compat.patch
 create mode 100644 package/pecl-dbus/0002-Fix-compatibility-with-php8-call_user_function_ex.patch
 create mode 100644 package/pecl-dbus/Config.in
 create mode 100644 package/pecl-dbus/pecl-dbus.hash
 create mode 100644 package/pecl-dbus/pecl-dbus.mk
 create mode 100644 support/testing/tests/package/test_pecl_dbus.py

diff --git a/DEVELOPERS b/DEVELOPERS
index 1f977190ab..30120b2eeb 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1148,6 +1148,10 @@ F:	package/sysrepo/
 N:	Henrique Camargo <henrique at henriquecamargo.com>
 F:	package/json-glib/
 
+N:	Hervé Codina <herve.codina at bootlin.com>
+F:	package/pecl-dbus/
+F:	support/testing/tests/package/test_pecl_dbus.py
+
 N:	Hiroshi Kawashima <kei-k at ca2.so-net.ne.jp>
 F:	package/gauche/
 F:	package/gmrender-resurrect/
@@ -1980,6 +1984,7 @@ F:	configs/galileo_defconfig
 
 N:	Nicolas Carrier <nicolas.carrier at orolia.com>
 F:	package/bmap-tools/
+F:	package/pecl-dbus/
 F:	package/php-xdebug/
 F:	package/python-augeas/
 F:	package/python-flask-expects-json/
@@ -1989,6 +1994,7 @@ F:	support/testing/tests/package/sample_python_augeas.py
 F:	support/testing/tests/package/sample_python_flask_expects_json.py
 F:	support/testing/tests/package/sample_python_git.py
 F:	support/testing/tests/package/test_bmap_tools.py
+F:	support/testing/tests/package/test_pecl_dbus.py
 F:	support/testing/tests/package/test_python_augeas.py
 F:	support/testing/tests/package/test_python_flask_expects_json.py
 F:	support/testing/tests/package/test_python_git.py
diff --git a/package/Config.in b/package/Config.in
index 2f83c87582..0ca1c39a64 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -861,6 +861,7 @@ endif
 if BR2_PACKAGE_PHP
 if !BR2_STATIC_LIBS
 menu "External php extensions"
+	source "package/pecl-dbus/Config.in"
 	source "package/php-amqp/Config.in"
 	source "package/php-geoip/Config.in"
 	source "package/php-gnupg/Config.in"
diff --git a/package/pecl-dbus/0001-php8-compat.patch b/package/pecl-dbus/0001-php8-compat.patch
new file mode 100644
index 0000000000..bef9a1fa05
--- /dev/null
+++ b/package/pecl-dbus/0001-php8-compat.patch
@@ -0,0 +1,161 @@
+From 7fde4dd4d26d2a4b7957a1010c6ea9e4b940fc62 Mon Sep 17 00:00:00 2001
+From: Stefan Saraev <stefan at saraev.ca>
+Date: Mon, 18 Jan 2021 23:22:52 +0200
+Subject: [PATCH] php8 compat
+
+This patch was retrieved from the pending upstream pull request
+done by Stefan Saraev.
+https://github.com/derickr/pecl-dbus/pull/8
+
+Signed-off-by: Herve Codina <herve.codina at bootlin.com>
+---
+ dbus.c     | 55 ++++++++++++++++++++++++++++++------------------------
+ php_dbus.h | 10 ++++++++++
+ 2 files changed, 41 insertions(+), 24 deletions(-)
+
+diff --git a/dbus.c b/dbus.c
+index 9fde647..a98e2ea 100644
+--- a/dbus.c
++++ b/dbus.c
+@@ -38,6 +38,9 @@
+ #define Z_ADDREF_P(z) ((z)->refcount++)
+ #endif
+ 
++ZEND_BEGIN_ARG_INFO_EX(arginfo_void, 0, 0, 0)
++ZEND_END_ARG_INFO()
++
+ /* {{{ arginfo */
+ ZEND_BEGIN_ARG_INFO_EX(arginfo_dbus_object___call, 0, 0, 2)
+ 	ZEND_ARG_INFO(0, function_name)
+@@ -46,44 +49,44 @@ ZEND_END_ARG_INFO()
+ /* }}} */
+ 
+ const zend_function_entry dbus_funcs_dbus[] = {
+-	PHP_ME(Dbus, __construct, NULL, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
+-	PHP_ME(Dbus, addWatch,    NULL, ZEND_ACC_PUBLIC)
+-	PHP_ME(Dbus, waitLoop,    NULL, ZEND_ACC_PUBLIC)
+-	PHP_ME(Dbus, requestName, NULL, ZEND_ACC_PUBLIC)
+-	PHP_ME(Dbus, registerObject, NULL, ZEND_ACC_PUBLIC)
+-	PHP_ME(Dbus, createProxy, NULL, ZEND_ACC_PUBLIC)
++	PHP_ME(Dbus, __construct, arginfo_void, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
++	PHP_ME(Dbus, addWatch,    arginfo_void, ZEND_ACC_PUBLIC)
++	PHP_ME(Dbus, waitLoop,    arginfo_void, ZEND_ACC_PUBLIC)
++	PHP_ME(Dbus, requestName, arginfo_void, ZEND_ACC_PUBLIC)
++	PHP_ME(Dbus, registerObject, arginfo_void, ZEND_ACC_PUBLIC)
++	PHP_ME(Dbus, createProxy, arginfo_void, ZEND_ACC_PUBLIC)
+ 	PHP_FE_END
+ };
+ 
+ const zend_function_entry dbus_funcs_dbus_object[] = {
+-	PHP_ME(DbusObject, __construct, NULL, ZEND_ACC_CTOR|ZEND_ACC_PRIVATE)
++	PHP_ME(DbusObject, __construct, arginfo_void, ZEND_ACC_CTOR|ZEND_ACC_PRIVATE)
+ 	PHP_ME(DbusObject, __call,      arginfo_dbus_object___call, ZEND_ACC_PUBLIC)
+ 	PHP_FE_END
+ };
+ 
+ const zend_function_entry dbus_funcs_dbus_signal[] = {
+-	PHP_ME(DbusSignal, __construct, NULL, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
+-	PHP_ME(DbusSignal, matches,     NULL, ZEND_ACC_PUBLIC)
+-	PHP_ME(DbusSignal, getData,     NULL, ZEND_ACC_PUBLIC)
+-	PHP_ME(DbusSignal, send,        NULL, ZEND_ACC_PUBLIC)
++	PHP_ME(DbusSignal, __construct, arginfo_void, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
++	PHP_ME(DbusSignal, matches,     arginfo_void, ZEND_ACC_PUBLIC)
++	PHP_ME(DbusSignal, getData,     arginfo_void, ZEND_ACC_PUBLIC)
++	PHP_ME(DbusSignal, send,        arginfo_void, ZEND_ACC_PUBLIC)
+ 	PHP_FE_END
+ };
+ 
+ const zend_function_entry dbus_funcs_dbus_array[] = {
+-	PHP_ME(DbusArray, __construct, NULL, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
+-	PHP_ME(DbusArray, getData,     NULL, ZEND_ACC_PUBLIC)
++	PHP_ME(DbusArray, __construct, arginfo_void, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
++	PHP_ME(DbusArray, getData,     arginfo_void, ZEND_ACC_PUBLIC)
+ 	PHP_FE_END
+ };
+ 
+ const zend_function_entry dbus_funcs_dbus_dict[] = {
+-	PHP_ME(DbusDict, __construct, NULL, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
+-	PHP_ME(DbusDict, getData,     NULL, ZEND_ACC_PUBLIC)
++	PHP_ME(DbusDict, __construct, arginfo_void, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
++	PHP_ME(DbusDict, getData,     arginfo_void, ZEND_ACC_PUBLIC)
+ 	PHP_FE_END
+ };
+ 
+ #define PHP_DBUS_INT_WRAPPER_DEF(s,t) \
+ 	const zend_function_entry dbus_funcs_dbus_##s[] = { \
+-		PHP_ME(Dbus##t, __construct, NULL, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) \
++		PHP_ME(Dbus##t, __construct, arginfo_void, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) \
+ 		PHP_FE_END \
+ 	};
+ 
+@@ -98,26 +101,26 @@ PHP_DBUS_INT_WRAPPER_DEF(uint64,UInt64);
+ PHP_DBUS_INT_WRAPPER_DEF(double, Double);
+ 
+ const zend_function_entry dbus_funcs_dbus_variant[] = {
+-	PHP_ME(DbusVariant, __construct, NULL, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
+-	PHP_ME(DbusVariant, getData,     NULL, ZEND_ACC_PUBLIC)
++	PHP_ME(DbusVariant, __construct, arginfo_void, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
++	PHP_ME(DbusVariant, getData,     arginfo_void, ZEND_ACC_PUBLIC)
+ 	PHP_FE_END
+ };
+ 
+ const zend_function_entry dbus_funcs_dbus_set[] = {
+-	PHP_ME(DbusSet, __construct, NULL, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
+-	PHP_ME(DbusSet, getData,     NULL, ZEND_ACC_PUBLIC)
++	PHP_ME(DbusSet, __construct, arginfo_void, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
++	PHP_ME(DbusSet, getData,     arginfo_void, ZEND_ACC_PUBLIC)
+ 	PHP_FE_END
+ };
+ 
+ const zend_function_entry dbus_funcs_dbus_struct[] = {
+-	PHP_ME(DbusStruct, __construct, NULL, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
+-	PHP_ME(DbusStruct, getData,     NULL, ZEND_ACC_PUBLIC)
++	PHP_ME(DbusStruct, __construct, arginfo_void, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
++	PHP_ME(DbusStruct, getData,     arginfo_void, ZEND_ACC_PUBLIC)
+ 	PHP_FE_END
+ };
+ 
+ const zend_function_entry dbus_funcs_dbus_object_path[] = {
+-	PHP_ME(DbusObjectPath, __construct, NULL, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
+-	PHP_ME(DbusObjectPath, getData,     NULL, ZEND_ACC_PUBLIC)
++	PHP_ME(DbusObjectPath, __construct, arginfo_void, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
++	PHP_ME(DbusObjectPath, getData,     arginfo_void, ZEND_ACC_PUBLIC)
+ 	PHP_FE_END
+ };
+ 
+@@ -405,7 +408,11 @@ static void dbus_register_classes(TSRMLS_D)
+ 	dbus_ce_dbus = zend_register_internal_class_ex(&ce_dbus, NULL);
+ 	memcpy(&dbus_object_handlers_dbus, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ 	dbus_object_handlers_dbus.clone_obj = dbus_object_clone_dbus;
++#if PHP_VERSION_ID < 80000
+ 	dbus_object_handlers_dbus.compare_objects = dbus_object_compare_dbus;
++#else
++	dbus_object_handlers_dbus.compare = dbus_object_compare_dbus;
++#endif
+ 
+ 	zend_declare_class_constant_long(dbus_ce_dbus, "BYTE", sizeof("BYTE")-1, DBUS_TYPE_BYTE TSRMLS_CC);
+ 	zend_declare_class_constant_long(dbus_ce_dbus, "BOOLEAN", sizeof("BOOLEAN")-1, DBUS_TYPE_BOOLEAN TSRMLS_CC);
+diff --git a/php_dbus.h b/php_dbus.h
+index 8817544..1f0f551 100644
+--- a/php_dbus.h
++++ b/php_dbus.h
+@@ -25,6 +25,16 @@
+ #include "config.h"
+ #endif
+ 
++#if PHP_VERSION_ID >= 80000
++#ifndef TSRMLS_D
++#define TSRMLS_D void
++#define TSRMLS_DC
++#define TSRMLS_C
++#define TSRMLS_CC
++#define TSRMLS_FETCH()
++#endif
++#endif /* PHP_VERSION_ID >= 80000 */
++
+ #include "Zend/zend_hash.h"
+ 
+ #define PHP_DBUS_VERSION "0.2.0"
+-- 
+2.31.1
+
diff --git a/package/pecl-dbus/0002-Fix-compatibility-with-php8-call_user_function_ex.patch b/package/pecl-dbus/0002-Fix-compatibility-with-php8-call_user_function_ex.patch
new file mode 100644
index 0000000000..1e579e4272
--- /dev/null
+++ b/package/pecl-dbus/0002-Fix-compatibility-with-php8-call_user_function_ex.patch
@@ -0,0 +1,31 @@
+From 8cf66c4b5dd657ca14552b27a42901db0a5e9280 Mon Sep 17 00:00:00 2001
+From: Herve Codina <herve.codina at bootlin.com>
+Date: Mon, 4 Oct 2021 17:13:45 +0200
+Subject: [PATCH] Fix compatibility with php8 - call_user_function_ex
+
+This patch fix compatibility with php8 replacing
+call_user_function_ex by call_user_function.
+
+Signed-off-by: Herve Codina <herve.codina at bootlin.com>
+---
+ dbus.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/dbus.c b/dbus.c
+index a98e2ea..6fa9897 100644
+--- a/dbus.c
++++ b/dbus.c
+@@ -1015,8 +1015,8 @@ php_dbus_do_method_call(php_dbus_obj *dbus,
+ 		method_args = safe_emalloc(sizeof(zval *), num_elems, 0);
+ 	}
+ 
+-	if (call_user_function_ex(EG(function_table), object, &callback, &retval,
+-				              num_elems, method_args, 0, NULL) == SUCCESS) {
++	if (call_user_function(EG(function_table), object, &callback, &retval,
++				              num_elems, method_args) == SUCCESS) {
+ 		if (!Z_ISUNDEF(retval)) {
+ 			reply = dbus_message_new_method_return(msg);
+ 			php_dbus_append_parameters(reply, &retval, NULL,
+-- 
+2.31.1
+
diff --git a/package/pecl-dbus/Config.in b/package/pecl-dbus/Config.in
new file mode 100644
index 0000000000..a531397754
--- /dev/null
+++ b/package/pecl-dbus/Config.in
@@ -0,0 +1,15 @@
+config BR2_PACKAGE_PECL_DBUS
+	bool "pecl-dbus"
+	depends on BR2_TOOLCHAIN_HAS_THREADS # dbus
+	depends on BR2_USE_MMU # dbus
+	select BR2_PACKAGE_DBUS
+	select BR2_PACKAGE_LIBXML2
+	select BR2_PACKAGE_PHP_EXT_LIBXML2 # Runtime dependency
+	help
+	  PHP extension for interaction with D-Bus busses.
+
+	  https://github.com/derickr/pecl-dbus
+
+comment "pecl-dbus needs a toolchain w/ threads"
+	depends on BR2_USE_MMU
+	depends on !BR2_TOOLCHAIN_HAS_THREADS
diff --git a/package/pecl-dbus/pecl-dbus.hash b/package/pecl-dbus/pecl-dbus.hash
new file mode 100644
index 0000000000..5fe656ba40
--- /dev/null
+++ b/package/pecl-dbus/pecl-dbus.hash
@@ -0,0 +1,3 @@
+# Locally calculated:
+sha256 c48761c645c6fa42b57af0e65d893217dc69bcd8d879ace74d6abbf1c5f73a8f  pecl-dbus-315d17558c7614d02e923d898231e51c86a25789.tar.gz
+sha256 ecc8b74820c32fb82ddee80446205408585d75d1632ac959fb3cdf8eaf3877b5  LICENSE
diff --git a/package/pecl-dbus/pecl-dbus.mk b/package/pecl-dbus/pecl-dbus.mk
new file mode 100644
index 0000000000..704ced911e
--- /dev/null
+++ b/package/pecl-dbus/pecl-dbus.mk
@@ -0,0 +1,25 @@
+################################################################################
+#
+# pecl-dbus
+#
+################################################################################
+
+PECL_DBUS_VERSION = 315d17558c7614d02e923d898231e51c86a25789
+PECL_DBUS_SITE = $(call github,derickr,pecl-dbus,$(PECL_DBUS_VERSION))
+PECL_DBUS_LICENSE = PHP-3.01
+PECL_DBUS_LICENSE_FILES = LICENSE
+PECL_DBUS_DEPENDENCIES = php dbus libxml2 host-autoconf host-pkgconf
+
+PECL_DBUS_CONF_OPTS = \
+	--with-php-config=$(STAGING_DIR)/usr/bin/php-config \
+	--enable-dbus
+
+define PECL_DBUS_PHPIZE
+	(cd $(@D); \
+		PHP_AUTOCONF=$(HOST_DIR)/usr/bin/autoconf \
+		PHP_AUTOHEADER=$(HOST_DIR)/usr/bin/autoheader \
+		$(STAGING_DIR)/usr/bin/phpize)
+endef
+PECL_DBUS_PRE_CONFIGURE_HOOKS += PECL_DBUS_PHPIZE
+
+$(eval $(autotools-package))
diff --git a/support/testing/tests/package/test_pecl_dbus.py b/support/testing/tests/package/test_pecl_dbus.py
new file mode 100644
index 0000000000..a9570658b7
--- /dev/null
+++ b/support/testing/tests/package/test_pecl_dbus.py
@@ -0,0 +1,32 @@
+import os
+
+import infra.basetest
+
+
+class TestPeclDbus(infra.basetest.BRTest):
+    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
+        """
+        BR2_PACKAGE_PHP=y
+        BR2_PACKAGE_PHP_SAPI_CLI=y
+        BR2_PACKAGE_PECL_DBUS=y
+        BR2_TARGET_ROOTFS_CPIO=y
+        # BR2_TARGET_ROOTFS_TAR is not set
+        """
+
+    def test_run(self):
+        img = os.path.join(self.builddir, "images", "rootfs.cpio")
+        self.emulator.boot(arch="armv5",
+                           kernel="builtin",
+                           options=["-initrd", img])
+        self.emulator.login()
+
+        self.assertRunOk("mkdir /etc/php.d")
+        self.assertRunOk("echo 'extension=dbus.so'> /etc/php.d/dbus.ini")
+
+        output, exit_code = self.emulator.run("php --ri dbus | sed '/^$/d'")
+        self.assertEqual(exit_code, 0)
+        self.assertEqual(output[0], "dbus")
+        self.assertEqual(output[1], "Dbus support => enabled")
+        # Do not check the version value in order to avoid test failure when
+        # bumping package version
+        self.assertEqual(output[2][0:11], "Version => ")
-- 
2.31.1



More information about the buildroot mailing list