summaryrefslogtreecommitdiffstats
path: root/php-pecl-gnupg.spec
blob: 98a8448be8a3dd1532b82e365af701d8e108a063 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
%{!?__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}.3

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_name} = %{version}
Provides:     php-%{pecl_name}%{?_isa} = %{version}
Provides:     php-pecl(%{pecl_name}) = %{version}
Provides:     php-pecl(%{pecl_name})%{?_isa} = %{version}

# Other third party repo stuff
Obsoletes:    php53-pecl-%{pecl_name}
Obsoletes:    php53u-pecl-%{pecl_name}
%if "%{php_version}" > "5.4"
Obsoletes:    php54-pecl-%{pecl_name}
%endif
%if "%{php_version}" > "5.5"
Obsoletes:    php55-pecl-%{pecl_name}
%endif

# Filter private shared
%{?filter_provides_in: %filter_provides_in %{_libdir}/.*\.so$}
%{?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

# Build ZTS extension if ZTS devel available (fedora >= 17)
cp -r %{pecl_name}-%{version} %{pecl_name}-zts


%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}

cd ../%{pecl_name}-zts
%{_bindir}/zts-phpize
%configure \
    --with-libdir=%{_lib} \
    --with-php-config=%{_bindir}/zts-php-config
make %{?_smp_mflags}


%install
rm -rf %{buildroot}
# for short-circuit
rm -rf %{pecl_name}-*/modules/{json,mysqlnd}.so

make install -C %{pecl_name}-%{version} \
     INSTALL_ROOT=%{buildroot}

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
install -D -m 644 %{pecl_name}.ini %{buildroot}%{php_inidir}/%{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}

unset GPG_AGENT_INFO

# 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

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


%files
%defattr(-, root, root, -)
%doc %{pecl_name}-%{version}/{LICENSE,README}
%{pecl_xmldir}/%{name}.xml

%config(noreplace) %{php_inidir}/%{pecl_name}.ini
%{php_extdir}/%{pecl_name}.so

%config(noreplace) %{php_ztsinidir}/%{pecl_name}.ini
%{php_ztsextdir}/%{pecl_name}.so


%changelog
* Fri Nov 30 2012 Remi Collet <remi@fedoraproject.org> - 1.3.2-3.1
- also provides php-gnupg + cleanups

* 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