From 269860bee39fde0acce8f543b18f8ec64bb61cc0 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 8 Aug 2013 15:01:12 +0200 Subject: php-pecl-zip: upstream patch --- php-pecl-zip.spec | 11 ++- zip-git.patch | 204 +++++++++++++++++++++++++++++++++++++++++++++++++ zip-systemlibzip.patch | 109 ++------------------------ 3 files changed, 220 insertions(+), 104 deletions(-) create mode 100644 zip-git.patch diff --git a/php-pecl-zip.spec b/php-pecl-zip.spec index 2573c3e..1237d93 100644 --- a/php-pecl-zip.spec +++ b/php-pecl-zip.spec @@ -21,8 +21,11 @@ URL: http://pecl.php.net/package/zip Source: http://pecl.php.net/get/%{pecl_name}-%{version}.tgz +# https://github.com/pierrejoye/php_zip/pull/3 (merged) +# Cleanups and fix build warnings +Patch0: zip-git.patch # use system libzip 0.11 instead of bundled copy -Patch0: zip-systemlibzip.patch +Patch1: zip-systemlibzip.patch BuildRequires: php-devel %if %{with_libzip} @@ -60,8 +63,10 @@ Zip est une extension pour créer et lire les archives au format ZIP. cd %{pecl_name}-%{version} %if %{with_libzip} -%patch0 -p1 -b .systemlibzip -rm -rf lib +%patch0 -p1 -b .git +%patch1 -p1 -b .systemlibzip +# delete bundled libzip to ensure it is not used (except zipint.h) +rm lib/*.c %endif cd .. diff --git a/zip-git.patch b/zip-git.patch new file mode 100644 index 0000000..89a557b --- /dev/null +++ b/zip-git.patch @@ -0,0 +1,204 @@ +From 739f7ace12455b589f464f3d72eb809be950f0a1 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Thu, 8 Aug 2013 14:03:25 +0200 +Subject: [PATCH 1/6] drop PCRE test (not used, php_zip_pcre is unconditionaly + defined) + +--- + config.m4 | 24 ------------------------ + 1 file changed, 24 deletions(-) + +diff --git a/config.m4 b/config.m4 +index edf0d2a..aade73d 100755 +--- a/config.m4 ++++ b/config.m4 +@@ -47,30 +47,6 @@ if test "$PHP_ZIP" != "no"; then + PHP_ADD_INCLUDE($PHP_ZLIB_INCDIR) + fi + +- dnl This is PECL build, check if bundled PCRE library is used +- old_CPPFLAGS=$CPPFLAGS +- CPPFLAGS=$INCLUDES +- AC_EGREP_CPP(yes,[ +-#include
+-#if defined(HAVE_BUNDLED_PCRE) && !defined(COMPILE_DL_PCRE) +-yes +-#endif +- ],[ +- PHP_PCRE_REGEX=yes +- ],[ +- AC_EGREP_CPP(yes,[ +-#include
+-#if defined(HAVE_PCRE) && !defined(COMPILE_DL_PCRE) +-yes +-#endif +- ],[ +- PHP_PCRE_REGEX=pecl +- ],[ +- PHP_PCRE_REGEX=no +- ]) +- ]) +- CPPFLAGS=$old_CPPFLAGS +- + PHP_ZIP_SOURCES="$PHP_ZIP_SOURCES lib/zip_add.c lib/zip_add_dir.c lib/zip_add_entry.c\ + lib/zip_close.c lib/zip_delete.c lib/zip_dir_add.c lib/zip_dirent.c lib/zip_discard.c lib/zip_entry.c\ + lib/zip_err_str.c lib/zip_error.c lib/zip_error_clear.c lib/zip_error_get.c lib/zip_error_get_sys_type.c\ +-- +1.8.1.6 + + +From 09986e947ff8452affb1ae709d0e93dbd112f078 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Thu, 8 Aug 2013 14:04:23 +0200 +Subject: [PATCH 2/6] drop duplicate include (already in php_zip.h) + +--- + zip_stream.c | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/zip_stream.c b/zip_stream.c +index 400edd6..dde5c0b 100755 +--- a/zip_stream.c ++++ b/zip_stream.c +@@ -6,8 +6,6 @@ + #if HAVE_ZIP + #ifdef ZEND_ENGINE_2 + +-#include "lib/zip.h" +- + #include "php_streams.h" + #include "ext/standard/file.h" + #include "ext/standard/php_string.h" +-- +1.8.1.6 + + +From b06d3de0b7b8e2ea09d55c24b7661f894b70eba2 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Thu, 8 Aug 2013 14:05:00 +0200 +Subject: [PATCH 3/6] drop duplicate include (already in php_zip.h) + +--- + php_zip.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/php_zip.c b/php_zip.c +index 8969397..42e9dd1 100755 +--- a/php_zip.c ++++ b/php_zip.c +@@ -30,7 +30,6 @@ + #include "ext/standard/php_string.h" + #include "ext/pcre/php_pcre.h" + #include "php_zip.h" +-#include "lib/zip.h" + #include "lib/zipint.h" + + /* zip_open is a macro for renaming libzip zipopen, so we need to use PHP_NAMED_FUNCTION */ +-- +1.8.1.6 + + +From 600220bc9a4e1f4488612b47ec26cbe99c7d88dc Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Thu, 8 Aug 2013 14:06:08 +0200 +Subject: [PATCH 4/6] fix warning: variable 'file' set but not used + [-Wunused-but-set-variable] + +--- + php_zip.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/php_zip.c b/php_zip.c +index 42e9dd1..36bf8cc 100755 +--- a/php_zip.c ++++ b/php_zip.c +@@ -1727,13 +1727,12 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /* + zval **zval_file = NULL; + + for (i = 0; i < found; i++) { +- char *file, *file_stripped, *entry_name; ++ char *file_stripped, *entry_name; + size_t entry_name_len, file_stripped_len; + char entry_name_buf[MAXPATHLEN]; + char *basename = NULL; + + if (zend_hash_index_find(Z_ARRVAL_P(return_value), i, (void **) &zval_file) == SUCCESS) { +- file = Z_STRVAL_PP(zval_file); + if (remove_all_path) { + php_basename(Z_STRVAL_PP(zval_file), Z_STRLEN_PP(zval_file), NULL, 0, + &basename, (size_t *)&file_stripped_len TSRMLS_CC); +-- +1.8.1.6 + + +From 3ceb0cc1e76338721634b07638c472d4e32f0fc8 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Thu, 8 Aug 2013 14:08:00 +0200 +Subject: [PATCH 5/6] warning: 'remove_path_len' may be used uninitialized in + this function [-Wmaybe-uninitialized] (just to make gcc happy) + +--- + php_zip.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/php_zip.c b/php_zip.c +index 36bf8cc..43bd062 100755 +--- a/php_zip.c ++++ b/php_zip.c +@@ -1678,7 +1678,7 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /* + char *path = NULL; + char *remove_path = NULL; + char *add_path = NULL; +- int pattern_len, add_path_len, remove_path_len, path_len = 0; ++ int pattern_len, add_path_len, remove_path_len = 0, path_len = 0; + long remove_all_path = 0; + long flags = 0; + zval *options = NULL; +-- +1.8.1.6 + + +From fe8c5bbddbb60c346474cabcdaa375df781000d0 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Thu, 8 Aug 2013 14:22:03 +0200 +Subject: [PATCH 6/6] use public zip_error_clear instead of private + _zip_error_clear + +--- + php_zip.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/php_zip.c b/php_zip.c +index 43bd062..2e97e84 100755 +--- a/php_zip.c ++++ b/php_zip.c +@@ -322,7 +322,7 @@ static int php_zip_add_file(struct zip *za, const char *filename, size_t filenam + if (zip_file_add(za, entry_name, zs, ZIP_FL_OVERWRITE) < 0) { + return -1; + } else { +- _zip_error_clear(&za->error); ++ zip_error_clear(za); + return 1; + } + } +@@ -1660,7 +1660,7 @@ static ZIPARCHIVE_METHOD(addEmptyDir) + if (zip_add_dir(intern, (const char *)s) == -1) { + RETVAL_FALSE; + } +- _zip_error_clear(&intern->error); ++ zip_error_clear(intern); + RETVAL_TRUE; + } + +@@ -1886,7 +1886,7 @@ static ZIPARCHIVE_METHOD(addFromString) + if (zip_add(intern, name, zs) == -1) { + RETURN_FALSE; + } else { +- _zip_error_clear(&intern->error); ++ zip_error_clear(intern); + RETURN_TRUE; + } + } +-- +1.8.1.6 + diff --git a/zip-systemlibzip.patch b/zip-systemlibzip.patch index b6d76b1..0c9d7d1 100644 --- a/zip-systemlibzip.patch +++ b/zip-systemlibzip.patch @@ -1,6 +1,6 @@ -diff -up zip-1.12.1/config.m4.old zip-1.12.1/config.m4 ---- zip-1.12.1/config.m4.old 2013-04-29 11:18:17.000000000 +0200 -+++ zip-1.12.1/config.m4 2013-08-08 13:09:18.000000000 +0200 +diff -up zip-1.12.1/config.m4.systemlibzip zip-1.12.1/config.m4 +--- zip-1.12.1/config.m4.systemlibzip 2013-08-08 14:55:44.864556155 +0200 ++++ zip-1.12.1/config.m4 2013-08-08 14:55:44.868556168 +0200 @@ -13,8 +13,60 @@ fi PHP_ARG_WITH(pcre-dir, pcre install prefix, [ --with-pcre-dir ZIP: pcre install prefix], no, no) @@ -62,7 +62,7 @@ diff -up zip-1.12.1/config.m4.old zip-1.12.1/config.m4 if test "$PHP_ZLIB_DIR" != "no" && test "$PHP_ZLIB_DIR" != "yes"; then if test -f "$PHP_ZLIB_DIR/include/zlib/zlib.h"; then PHP_ZLIB_DIR="$PHP_ZLIB_DIR" -@@ -94,6 +146,7 @@ yes +@@ -70,6 +122,7 @@ if test "$PHP_ZIP" != "no"; then PHP_NEW_EXTENSION(zip, php_zip.c zip_stream.c $PHP_ZIP_SOURCES, $ext_shared) PHP_ADD_BUILD_DIR($ext_builddir/lib, 1) PHP_SUBST(ZIP_SHARED_LIBADD) @@ -70,91 +70,10 @@ diff -up zip-1.12.1/config.m4.old zip-1.12.1/config.m4 AC_CHECK_TYPES([int8_t]) -diff -up zip-1.12.1/libzip-missing.h.old zip-1.12.1/libzip-missing.h ---- zip-1.12.1/libzip-missing.h.old 2013-08-08 13:31:19.000000000 +0200 -+++ zip-1.12.1/libzip-missing.h 2013-08-08 13:29:24.000000000 +0200 -@@ -0,0 +1,60 @@ -+/*** Private API copied from lib/zipint.h ***/ -+ -+/* error information */ -+ -+struct zip_error { -+ int zip_err; /* libzip error code (ZIP_ER_*) */ -+ int sys_err; /* copy of errno (E*) or zlib error code */ -+ char *str; /* string representation or NULL */ -+}; -+ -+ -+/* zip archive, part of API */ -+ -+struct zip { -+ char *zn; /* file name */ -+ FILE *zp; /* file */ -+ unsigned int open_flags; /* flags passed to zip_open */ -+ struct zip_error error; /* error information */ -+ -+ unsigned int flags; /* archive global flags */ -+ unsigned int ch_flags; /* changed archive global flags */ -+ -+ char *default_password; /* password used when no other supplied */ -+ -+ struct zip_string *comment_orig; /* archive comment */ -+ struct zip_string *comment_changes; /* changed archive comment */ -+ int comment_changed; /* whether archive comment was changed */ -+ -+ zip_uint64_t nentry; /* number of entries */ -+ zip_uint64_t nentry_alloc; /* number of entries allocated */ -+ struct zip_entry *entry; /* entries */ -+ -+ unsigned int nfile; /* number of opened files within archive */ -+ unsigned int nfile_alloc; /* number of files allocated */ -+ struct zip_file **file; /* opened files within archive */ -+ -+ char *tempdir; /* custom temp dir (needed e.g. for OS X sandboxing) */ -+}; -+ -+/* file in zip archive, part of API */ -+ -+struct zip_file { -+ struct zip *za; /* zip archive containing this file */ -+ struct zip_error error; /* error information */ -+ int eof; -+ struct zip_source *src; /* data source */ -+}; -+ -+/*** Private API copied from lib/zip_error.c ***/ -+ -+void -+_zip_error_clear(struct zip_error *err) -+{ -+ if (err == NULL) -+ return; -+ -+ err->zip_err = ZIP_ER_OK; -+ err->sys_err = 0; -+} -+ -diff -up zip-1.12.1/php_zip.c.old zip-1.12.1/php_zip.c ---- zip-1.12.1/php_zip.c.old 2013-08-08 13:24:00.000000000 +0200 -+++ zip-1.12.1/php_zip.c 2013-08-08 13:26:43.000000000 +0200 -@@ -29,8 +29,14 @@ - #include "ext/standard/php_string.h" - #include "ext/pcre/php_pcre.h" - #include "php_zip.h" -+ -+#if defined(HAVE_LIBZIP) -+#include -+#include "libzip-missing.h" -+#else - #include "lib/zip.h" - #include "lib/zipint.h" -+#endif - - /* zip_open is a macro for renaming libzip zipopen, so we need to use PHP_NAMED_FUNCTION */ - static PHP_NAMED_FUNCTION(zif_zip_open); -diff -up zip-1.12.1/php_zip.h.old zip-1.12.1/php_zip.h ---- zip-1.12.1/php_zip.h.old 2013-08-08 13:33:03.000000000 +0200 -+++ zip-1.12.1/php_zip.h 2013-08-08 13:33:34.000000000 +0200 +diff -up zip-1.12.1/php_zip.c.systemlibzip zip-1.12.1/php_zip.c +diff -up zip-1.12.1/php_zip.h.systemlibzip zip-1.12.1/php_zip.h +--- zip-1.12.1/php_zip.h.systemlibzip 2013-04-29 11:18:17.000000000 +0200 ++++ zip-1.12.1/php_zip.h 2013-08-08 14:55:44.871556178 +0200 @@ -28,7 +28,11 @@ extern zend_module_entry zip_module_entr #include "TSRM.h" #endif @@ -167,15 +86,3 @@ diff -up zip-1.12.1/php_zip.h.old zip-1.12.1/php_zip.h #define PHP_ZIP_VERSION_STRING "1.12.1" -diff -up zip-1.12.1/zip_stream.c.old zip-1.12.1/zip_stream.c ---- zip-1.12.1/zip_stream.c.old 2013-08-08 13:35:24.000000000 +0200 -+++ zip-1.12.1/zip_stream.c 2013-08-08 13:35:39.000000000 +0200 -@@ -6,8 +6,6 @@ - #if HAVE_ZIP - #ifdef ZEND_ENGINE_2 - --#include "lib/zip.h" -- - #include "php_streams.h" - #include "ext/standard/file.h" - #include "ext/standard/php_string.h" -- cgit