summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--gnupg-gpg1.patch13
-rw-r--r--gnupg-php54.patch113
-rw-r--r--gnupg-tests.patch28
-rw-r--r--info.c36
-rw-r--r--php-pecl-gnupg.spec195
-rw-r--r--vars.inc38
7 files changed, 427 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..1e65467
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,4 @@
+SRCDIR := $(shell pwd)
+NAME := $(shell basename $(SRCDIR))
+include ../common/Makefile
+
diff --git a/gnupg-gpg1.patch b/gnupg-gpg1.patch
new file mode 100644
index 0000000..8b079bc
--- /dev/null
+++ b/gnupg-gpg1.patch
@@ -0,0 +1,13 @@
+diff -up gnupg-1.3.2/gnupg.c.orig gnupg-1.3.2/gnupg.c
+--- gnupg-1.3.2/gnupg.c.orig 2012-01-28 10:24:09.763192106 +0100
++++ gnupg-1.3.2/gnupg.c 2012-01-28 10:25:36.644195977 +0100
+@@ -137,6 +137,9 @@ static void gnupg_res_init(gnupg_object
+ gpgme_ctx_t ctx;
+ gpgme_check_version (NULL);
+ gpgme_new (&ctx);
++#ifdef GNUPG_PATH
++ gpgme_ctx_set_engine_info(ctx, GPGME_PROTOCOL_OpenPGP, GNUPG_PATH, NULL);
++#endif
+ gpgme_set_armor (ctx,1);
+ intern->ctx = ctx;
+ intern->encryptkeys = NULL;
diff --git a/gnupg-php54.patch b/gnupg-php54.patch
new file mode 100644
index 0000000..47f7e95
--- /dev/null
+++ b/gnupg-php54.patch
@@ -0,0 +1,113 @@
+diff -up gnupg-1.3.2/gnupg.c.php54 gnupg-1.3.2/gnupg.c
+--- gnupg-1.3.2/gnupg.c.php54 1970-01-01 10:13:08.000000000 +0100
++++ gnupg-1.3.2/gnupg.c 2012-05-06 09:36:28.377935185 +0200
+@@ -18,6 +18,7 @@
+
+ #include "php.h"
+ #include "php_ini.h"
++#include "zend_exceptions.h"
+ #include "ext/standard/info.h"
+ #include "php_gnupg.h"
+
+@@ -53,7 +54,7 @@ static zend_object_handlers gnupg_object
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, (char*)error); \
+ break; \
+ case 2: \
+- zend_throw_exception(zend_exception_get_default(), (char*) error, 0 TSRMLS_CC); \
++ zend_throw_exception(zend_exception_get_default(TSRMLS_C), (char*) error, 0 TSRMLS_CC); \
+ break; \
+ default: \
+ intern->errortxt = (char*)error; \
+@@ -170,7 +171,9 @@ static void gnupg_obj_dtor(gnupg_object
+ /* {{{ objects_new */
+ zend_object_value gnupg_obj_new(zend_class_entry *class_type TSRMLS_DC){
+ gnupg_object *intern;
++#if PHP_VERSION_ID < 50400
+ zval *tmp;
++#endif
+ zend_object_value retval;
+
+ intern = emalloc(sizeof(gnupg_object));
+@@ -179,7 +182,12 @@ zend_object_value gnupg_obj_new(zend_cla
+
+ ALLOC_HASHTABLE (intern->zo.properties);
+ zend_hash_init (intern->zo.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
++
++#if PHP_VERSION_ID < 50400
+ zend_hash_copy (intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
++#else
++ object_properties_init( (zend_object*)intern, class_type );
++#endif
+
+ retval.handle = zend_objects_store_put(intern,NULL,(zend_objects_free_object_storage_t) gnupg_obj_dtor,NULL TSRMLS_CC);
+ retval.handlers = (zend_object_handlers *) & gnupg_object_handlers;
+@@ -379,7 +387,7 @@ PHP_MINFO_FUNCTION(gnupg)
+ /* {{{ callback func for setting the passphrase */
+
+ gpgme_error_t passphrase_cb (gnupg_object *intern, const char *uid_hint, const char *passphrase_info,int last_was_bad, int fd TSRMLS_DC){
+- char uid[16];
++ char uid[17];
+ int idx;
+ char *passphrase = NULL;
+ zval *return_value = NULL;
+@@ -407,7 +415,7 @@ gpgme_error_t passphrase_cb (gnupg_objec
+ }
+
+ gpgme_error_t passphrase_decrypt_cb (gnupg_object *intern, const char *uid_hint, const char *passphrase_info,int last_was_bad, int fd TSRMLS_DC){
+- char uid[16];
++ char uid[17];
+ int idx;
+ char *passphrase = NULL;
+ zval *return_value = NULL;
+@@ -1244,7 +1252,6 @@ PHP_FUNCTION(gnupg_decryptverify){
+ gpgme_data_t in, out;
+ gpgme_decrypt_result_t decrypt_result;
+ gpgme_verify_result_t verify_result;
+- gpgme_signature_t gpg_signatures;
+
+ GNUPG_GETOBJ();
+
+@@ -1472,13 +1479,12 @@ PHP_FUNCTION(gnupg_gettrustlist){
+ /* {{{ proto array gnupg_listsignatures(string keyid) */
+ PHP_FUNCTION(gnupg_listsignatures){
+ char *keyid;
+- char keyid_len;
++ int keyid_len;
+
+ zval *sub_arr;
+ zval *sig_arr;
+
+ gpgme_key_t gpgme_key;
+- gpgme_subkey_t gpgme_subkey;
+ gpgme_user_id_t gpgme_userid;
+ gpgme_key_sig_t gpgme_signature;
+
+diff -up gnupg-1.3.2/gnupg_keylistiterator.c.php54 gnupg-1.3.2/gnupg_keylistiterator.c
+--- gnupg-1.3.2/gnupg_keylistiterator.c.php54 1970-01-01 10:13:08.000000000 +0100
++++ gnupg-1.3.2/gnupg_keylistiterator.c 2012-05-06 09:35:59.584823512 +0200
+@@ -23,6 +23,7 @@
+ #include "php_ini.h"
+ #include "ext/standard/info.h"
+ #include "zend_interfaces.h"
++#include "zend_exceptions.h"
+ #include "php_gnupg.h"
+ #include "php_gnupg_keylistiterator.h"
+
+@@ -148,7 +149,7 @@ PHP_METHOD(gnupg_keylistiterator,next){
+ gpgme_key_release(intern->gpgkey);
+ }
+
+- if(intern->err = gpgme_op_keylist_next(intern->ctx, &intern->gpgkey)){
++ if((intern->err = gpgme_op_keylist_next(intern->ctx, &intern->gpgkey))){
+ gpgme_key_release(intern->gpgkey);
+ intern->gpgkey = NULL;
+ }
+@@ -159,7 +160,7 @@ PHP_METHOD(gnupg_keylistiterator,rewind)
+ GNUPG_GET_ITERATOR();
+
+ if((intern->err = gpgme_op_keylist_start(intern->ctx, Z_STRVAL(intern->pattern), 0)) != GPG_ERR_NO_ERROR){
+- zend_throw_exception(zend_exception_get_default(),gpg_strerror(intern->err),1 TSRMLS_CC);
++ zend_throw_exception(zend_exception_get_default(TSRMLS_C),gpg_strerror(intern->err),1 TSRMLS_CC);
+ }
+ if((intern->err = gpgme_op_keylist_next(intern->ctx, &intern->gpgkey))!=GPG_ERR_NO_ERROR){
+ RETURN_FALSE;
diff --git a/gnupg-tests.patch b/gnupg-tests.patch
new file mode 100644
index 0000000..f26b53e
--- /dev/null
+++ b/gnupg-tests.patch
@@ -0,0 +1,28 @@
+diff -up gnupg-1.3.2/tests/gnupg_oo_export.phpt.orig gnupg-1.3.2/tests/gnupg_oo_export.phpt
+--- gnupg-1.3.2/tests/gnupg_oo_export.phpt.orig 2012-01-28 08:43:44.138922329 +0100
++++ gnupg-1.3.2/tests/gnupg_oo_export.phpt 2012-01-28 08:44:44.152924641 +0100
+@@ -11,8 +11,8 @@ $ret = $gpg -> export($fingerprint);
+ var_dump($ret);
+ ?>
+ --EXPECTF--
+-string(1336) "-----BEGIN PGP PUBLIC KEY BLOCK-----
+-Version: GnuPG v1.4.3 (GNU/Linux)
++string(%d) "-----BEGIN PGP PUBLIC KEY BLOCK-----
++Version: GnuPG v%d.%d.%d (GNU/Linux)
+
+ mQGiBENQAKwRBADpy828KU+0SuoetJTrJ5dR86PiO3CsH8K6QRP7wY82Eh/9NTJ3
+ afRj0FNPaVSP0NciPeM4G4uFoQ3lsIf+FBEPXH1D97/XigWObU8K6ha2/s8wU98z
+diff -up gnupg-1.3.2/tests/gnupg_res_export.phpt.orig gnupg-1.3.2/tests/gnupg_res_export.phpt
+--- gnupg-1.3.2/tests/gnupg_res_export.phpt.orig 2012-01-28 08:43:54.576921963 +0100
++++ gnupg-1.3.2/tests/gnupg_res_export.phpt 2012-01-28 08:44:40.582924190 +0100
+@@ -9,8 +9,8 @@ $ret = gnupg_export($gpg, $fingerprint);
+ var_dump($ret);
+ ?>
+ --EXPECTF--
+-string(1336) "-----BEGIN PGP PUBLIC KEY BLOCK-----
+-Version: GnuPG v1.4.3 (GNU/Linux)
++string(%d) "-----BEGIN PGP PUBLIC KEY BLOCK-----
++Version: GnuPG v%d.%d.%d (GNU/Linux)
+
+ mQGiBENQAKwRBADpy828KU+0SuoetJTrJ5dR86PiO3CsH8K6QRP7wY82Eh/9NTJ3
+ afRj0FNPaVSP0NciPeM4G4uFoQ3lsIf+FBEPXH1D97/XigWObU8K6ha2/s8wU98z
diff --git a/info.c b/info.c
new file mode 100644
index 0000000..edcc53a
--- /dev/null
+++ b/info.c
@@ -0,0 +1,36 @@
+#include <stdio.h>
+#include <gpgme.h>
+
+int main (int argc, char *argv[]) {
+
+ gpgme_ctx_t ctx;
+ gpgme_error_t err;
+ const char *ver;
+ gpgme_engine_info_t info;
+
+ ver = gpgme_check_version(NULL);
+ printf("gpgme version: %s\n", ver);
+
+ err = gpgme_new(&ctx);
+ if (err != GPG_ERR_NO_ERROR) {
+ printf("** gpgme_new return %d\n", err);
+ }
+
+ info = gpgme_ctx_get_engine_info(ctx);
+ while(info) {
+ printf("protocol:%d, file_name:%s\n", info->protocol, info->file_name);
+ info = info->next;
+ }
+
+ err = gpgme_ctx_set_engine_info(ctx, GPGME_PROTOCOL_OpenPGP, "/usr/bin/gpg", NULL);
+ if (err != GPG_ERR_NO_ERROR) {
+ printf("** gpgme_ctx_set_engine_info return %d\n", err);
+ }
+
+ info = gpgme_ctx_get_engine_info(ctx);
+ while(info) {
+ printf("protocol:%d, file_name:%s\n", info->protocol, info->file_name);
+ info = info->next;
+ }
+ return 0;
+}
diff --git a/php-pecl-gnupg.spec b/php-pecl-gnupg.spec
new file mode 100644
index 0000000..1373f87
--- /dev/null
+++ b/php-pecl-gnupg.spec
@@ -0,0 +1,195 @@
+%{!?__pecl: %{expand: %%global __pecl %{_bindir}/pecl}}
+%global pecl_name gnupg
+
+Summary: Wrapper around the gpgme library
+Name: php-pecl-gnupg
+Version: 1.3.2
+Release: 3%{?dist}
+
+License: BSD
+Group: Development/Languages
+URL: http://pecl.php.net/package/gnupg
+Source0: http://pecl.php.net/get/%{pecl_name}-%{version}.tgz
+
+# http://svn.php.net/viewvc/pecl/gnupg/trunk/tests/vars.inc?view=co
+Source1: vars.inc
+# https://bugs.php.net/60915 PHP 5.4 build
+Patch0: gnupg-php54.patch
+# https://bugs.php.net/60913 Fix test suite
+Patch1: gnupg-tests.patch
+# https://bugs.php.net/60916 Force use of /usr/bin/gpg
+Patch2: gnupg-gpg1.patch
+
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+BuildRequires: php-devel
+BuildRequires: gpgme-devel
+BuildRequires: php-pear
+BuildRequires: gnupg
+
+Requires(post): %{__pecl}
+Requires(postun): %{__pecl}
+
+Requires: php(zend-abi) = %{php_zend_api}
+Requires: php(api) = %{php_core_api}
+# We force use of /usr/bin/gpg as gpg2 is unusable in non-interactive mode
+Requires: gnupg
+
+Provides: php-pecl(%{pecl_name}) = %{version}-%{release}
+Provides: php-pecl(%{pecl_name})%{?_isa} = %{version}-%{release}
+
+%{?filter_setup}
+
+
+%description
+This module allows you to interact with gnupg.
+
+Documentation : http://www.php.net/gnupg
+
+
+%prep
+%setup -c -q
+
+cp %{SOURCE1} %{pecl_name}-%{version}/tests
+%patch0 -p0 -b .php54
+%patch1 -p0 -b .tests
+%patch2 -p0 -b .gpg1
+
+# Create configuration file
+cat >%{pecl_name}.ini << 'EOF'
+; Enable %{pecl_name} extension module
+extension=%{pecl_name}.so
+EOF
+
+%if 0%{?rhel} == 5
+# GnuPG seems to old
+rm -f %{pecl_name}-%{version}/tests/gnupg_{oo,res}_listsignatures.phpt
+%endif
+
+# Fix version for phpinfo()
+# https://bugs.php.net/60914
+sed -i -e /PHP_GNUPG_VERSION/s/1.3.2-dev/1.3.2/ %{pecl_name}-%{version}/php_gnupg.h
+
+# Check extension version
+extver=$(sed -n '/#define PHP_GNUPG_VERSION/{s/.* "//;s/".*$//;p}' %{pecl_name}-%{version}/php_gnupg.h)
+if test "x${extver}" != "x%{version}"; then
+ : Error: Upstream extension version is ${extver}, expecting %{version}.
+ exit 1
+fi
+
+
+%if 0%{?__ztsphp:1}
+# Build ZTS extension if ZTS devel available (fedora >= 17)
+cp -r %{pecl_name}-%{version} %{pecl_name}-zts
+%endif
+
+
+%build
+export PHP_RPATH=no
+export CFLAGS="$RPM_OPT_FLAGS -D_FILE_OFFSET_BITS=64 -DGNUPG_PATH='\"/usr/bin/gpg\"'"
+
+cd %{pecl_name}-%{version}
+%{_bindir}/phpize
+%configure \
+ --with-libdir=%{_lib} \
+ --with-php-config=%{_bindir}/php-config
+make %{?_smp_mflags}
+
+%if 0%{?__ztsphp:1}
+cd ../%{pecl_name}-zts
+%{_bindir}/zts-phpize
+%configure \
+ --with-libdir=%{_lib} \
+ --with-php-config=%{_bindir}/zts-php-config
+make %{?_smp_mflags}
+%endif
+
+%install
+rm -rf %{buildroot}
+# for short-circuit
+rm -rf %{pecl_name}-*/modules/{json,mysqlnd}.so
+
+make install -C %{pecl_name}-%{version} \
+ INSTALL_ROOT=%{buildroot}
+
+%if 0%{?__ztsphp:1}
+make install -C %{pecl_name}-zts \
+ INSTALL_ROOT=%{buildroot}
+
+# Drop in the bit of configuration
+install -D -m 644 %{pecl_name}.ini %{buildroot}%{php_ztsinidir}/%{pecl_name}.ini
+%endif
+install -D -m 644 %{pecl_name}.ini %{buildroot}%{_sysconfdir}/php.d/%{pecl_name}.ini
+
+# Install XML package description
+install -D -m 644 package.xml %{buildroot}%{pecl_xmldir}/%{name}.xml
+
+
+%clean
+rm -rf %{buildroot}
+
+
+%post
+%{pecl_install} %{pecl_xmldir}/%{name}.xml >/dev/null || :
+
+
+%postun
+if [ $1 -eq 0 ] ; then
+ %{pecl_uninstall} %{pecl_name} >/dev/null || :
+fi
+
+
+%check
+cd %{pecl_name}-%{version}
+
+# run full test suite
+TEST_PHP_EXECUTABLE=%{_bindir}/php \
+REPORT_EXIT_STATUS=1 \
+NO_INTERACTION=1 \
+php run-tests.php \
+ -n -q \
+ -d extension_dir=modules \
+ -d extension=%{pecl_name}.so
+
+%if 0%{?__ztsphp:1}
+cd ../%{pecl_name}-zts
+
+# run full test suite
+TEST_PHP_EXECUTABLE=%{__ztsphp} \
+REPORT_EXIT_STATUS=1 \
+NO_INTERACTION=1 \
+%{__ztsphp} run-tests.php \
+ -n -q \
+ -d extension_dir=modules \
+ -d extension=%{pecl_name}.so
+%endif
+
+
+%files
+%defattr(-, root, root, -)
+%doc %{pecl_name}-%{version}/{LICENSE,README}
+%{pecl_xmldir}/%{name}.xml
+
+%config(noreplace) %{_sysconfdir}/php.d/%{pecl_name}.ini
+%{php_extdir}/%{pecl_name}.so
+
+%if 0%{?__ztsphp:1}
+%config(noreplace) %{php_ztsinidir}/%{pecl_name}.ini
+%{php_ztsextdir}/%{pecl_name}.so
+%endif
+
+
+%changelog
+* Sun May 06 2012 Remi Collet <remi@fedoraproject.org> - 1.3.2-3
+- improve patch
+
+* Sat Jan 28 2012 Remi Collet <remi@fedoraproject.org> - 1.3.2-2
+- build against PHP 5.4
+
+* Sat Jan 28 2012 Remi Collet <remi@fedoraproject.org> - 1.3.2-1
+- Initial RPM
+- open upstream bugs
+ https://bugs.php.net/60913 - test suite fails
+ https://bugs.php.net/60914 - bad version
+ https://bugs.php.net/60915 - php 5.4 build fails
+ https://bugs.php.net/60916 - force use of /usr/bin/gpg
+
diff --git a/vars.inc b/vars.inc
new file mode 100644
index 0000000..1d4de35
--- /dev/null
+++ b/vars.inc
@@ -0,0 +1,38 @@
+<?php
+putenv("GNUPGHOME=".dirname(__FILE__));
+error_reporting (E_ALL);
+$fingerprint = "64DF06E42FCF2094590CDEEE2E96F141B3DD2B2E";
+$passphrase = "blabla";
+
+$plaintext = "foo bar";
+
+$testkey =<<<EOF
+-----BEGIN PGP PRIVATE KEY BLOCK-----
+Version: GnuPG v1.4.3 (GNU/Linux)
+
+lQHhBENQAKwRBADpy828KU+0SuoetJTrJ5dR86PiO3CsH8K6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