From 16192a25a02e72eee26009f47bf85e0644ac3daf Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 12 Oct 2023 14:12:40 +0200 Subject: stream require librpm 4.13 --- config.m4 | 1 + rpminfo.c | 13 +++++++++++++ tests/014-stream.phpt | 5 ++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/config.m4 b/config.m4 index 49f6f1d..fa16010 100644 --- a/config.m4 +++ b/config.m4 @@ -16,6 +16,7 @@ if test "$PHP_RPMINFO" != "no"; then LIBRPM_VERSON=`$PKG_CONFIG rpm --modversion` AC_MSG_RESULT(from pkgconfig: version $LIBRPM_VERSON) if $PKG_CONFIG rpm --atleast-version 4.13; then + AC_DEFINE(HAVE_ARCHIVE, 1, [ Archive reader since RPM 4.13 ]) AC_DEFINE(HAVE_WEAKDEP, 1, [ Indexes on weak dependency field since RPM 4.13 ]) fi else diff --git a/rpminfo.c b/rpminfo.c index ab2182d..88868d5 100644 --- a/rpminfo.c +++ b/rpminfo.c @@ -35,6 +35,7 @@ #include "rpminfo_arginfo.h" +#ifdef HAVE_ARCHIVE struct php_rpm_stream_data_t { FD_t gzdi; Header h; @@ -45,6 +46,7 @@ struct php_rpm_stream_data_t { #define STREAM_DATA_FROM_STREAM() \ struct php_rpm_stream_data_t *self = (struct php_rpm_stream_data_t *) stream->abstract; +#endif ZEND_DECLARE_MODULE_GLOBALS(rpminfo) @@ -573,6 +575,7 @@ PHP_FUNCTION(rpmaddtag) } /* }}} */ +#ifdef HAVE_ARCHIVE static ssize_t php_rpm_ops_read(php_stream *stream, char *buf, size_t count) { ssize_t n = -1; @@ -736,6 +739,9 @@ const php_stream_wrapper php_stream_rpm_wrapper = { NULL, 0 /* is_url */ }; +#endif + + /* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(rpminfo) @@ -781,7 +787,9 @@ PHP_MINIT_FUNCTION(rpminfo) } rpmtdFree(names); +#ifdef HAVE_ARCHIVE php_register_url_stream_wrapper("rpm", &php_stream_rpm_wrapper); +#endif return SUCCESS; } @@ -835,6 +843,11 @@ PHP_MINFO_FUNCTION(rpminfo) php_info_print_table_header(2, "rpminfo support", "enabled"); php_info_print_table_row(2, "Extension version", PHP_RPMINFO_VERSION); php_info_print_table_row(2, "RPM library version", RPMVERSION); +#ifdef HAVE_ARCHIVE + php_info_print_table_row(2, "RPM stream wrapper", "yes"); +#else + php_info_print_table_row(2, "RPM stream wrapper", "no"); +#endif php_info_print_table_end(); /* Remove comments if you have entries in php.ini diff --git a/tests/014-stream.phpt b/tests/014-stream.phpt index 5a4fefa..e8650f7 100644 --- a/tests/014-stream.phpt +++ b/tests/014-stream.phpt @@ -1,7 +1,10 @@ --TEST-- Check for stream --SKIPIF-- - + --FILE--