summaryrefslogtreecommitdiffstats
path: root/php-pecl-mysqlnd-qc.spec
blob: 80b8822a459251e7eda97c1b4f53c34d3b0ec0b8 (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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
%{!?__pecl:   %{expand: %%global __pecl     %{_bindir}/pecl}}

%global pecl_name mysqlnd_qc
%global prever    alpha

%if 0%{?fedora} >= 9 || 0%{?rhel} >= 6
%global withsqlite 1
%else
%global withsqlite 0
%endif

Summary:      A query cache plugin for mysqlnd
Name:         php-pecl-mysqlnd-qc
Version:      1.1.1
Release:      3%{?dist}.1
Source0:      http://pecl.php.net/get/%{pecl_name}-%{version}.tgz
License:      PHP
Group:        Development/Languages
URL:          http://pecl.php.net/package/mysqlnd_qc


# From http://www.php.net/manual/en/mysqlnd-qc.configuration.php
Source1:      mysqlnd_qc.ini

BuildRoot:     %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: php-devel >= 5.3.4
BuildRequires: php-mysqlnd
BuildRequires: php-pear
BuildRequires: libmemcached-devel >= 0.38
%if %{withsqlite}
BuildRequires: sqlite-devel >= 3.5.9
%endif

Requires(post): %{__pecl}
Requires(postun): %{__pecl}

Requires:     php-mysqlnd%{?_isa}
Requires:     php-sqlite3%{?_isa}
Requires:     php(zend-abi) = %{php_zend_api}
Requires:     php(api) = %{php_core_api}

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-mysqlnd-qc
Obsoletes:     php53u-pecl-mysqlnd-qc
%if "%{php_version}" > "5.4"
Obsoletes:     php54-pecl-mysqlnd-qc
%endif

# Filter private shared
%{?filter_provides_in: %filter_provides_in %{_libdir}/.*\.so$}
%{?filter_setup}


%description
The mysqlnd query result cache plugin is a mysqlnd plugin. 
It adds basic client side result set caching to all PHP MySQL extensions
(ext/mysql, ext/mysqli, PDO_MySQL). if they are compiled to use mysqlnd.
It does not change the API of the MySQL extensions and thus it operates
virtually transparent for applications.

Documentation : http://www.php.net/mysqlnd_qc

%package devel
Summary:       Mysqlnd_qc developer files (header)
Group:         Development/Libraries
Requires:      php-pecl-mysqlnd-qc%{?_isa} = %{version}-%{release}
Requires:      php-devel

%description devel
These are the files needed to compile programs using mysqlnd_qc extension.


%prep 
%setup -c -q

# Fix version
sed -i -e '/MYSQLND_QC_VERSION_STR/s/1.1.0/1.1.1/' %{pecl_name}-*/php_mysqlnd_qc.h

# Check version (often broken)
extver=$(sed -n '/#define MYSQLND_QC_VERSION_STR/{s/.* "//;s/".*$//;p}' %{pecl_name}-*/php_mysqlnd_qc.h)
if test "x${extver}" != "x%{version}%{?prever:-}%{?prever}"; then
   : Error: Upstream %{pecl_name} version is now ${extver}, expecting %{version}%{?prever}.
   : Update the pdover macro and rebuild.
   exit 1
fi

cp %{SOURCE1} %{pecl_name}.ini

cp -r %{pecl_name}-%{version} %{pecl_name}-zts


%build
cd %{pecl_name}-%{version}

#LDFLAGS="$(pkg-config libmemcached --libs) -lpthread %{__global_ldflags}"
#export LDFLAGS
%{_bindir}/phpize

# don't use --enable-mysqlnd-qc-apc because:
# APC is onlysupported if both APC and MySQL Query Cache are compiled statically
%configure \
    --with-libdir=%{_lib} \
    --enable-mysqlnd-qc \
    --enable-mysqlnd-qc-memcache \
    --with-libmemcached-dir=%{_prefix} \
%if %{withsqlite}
    --enable-mysqlnd-qc-sqlite \
    --with-sqlite-dir=%{_prefix} \
%endif
    --with-php-config=%{_bindir}/php-config
make %{?_smp_mflags}

%if 0%{?__ztsphp:1}
cd ../%{pecl_name}-zts
%{_bindir}/zts-phpize
%configure \
    --with-libdir=%{_lib} \
    --enable-mysqlnd-qc \
    --enable-mysqlnd-qc-memcache \
    --with-libmemcached-dir=%{_prefix} \
%if %{withsqlite}
    --enable-mysqlnd-qc-sqlite \
    --with-sqlite-dir=%{_prefix} \
%endif
    --with-php-config=%{_bindir}/zts-php-config
make %{?_smp_mflags}
%endif


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

make install -C %{pecl_name}-%{version} INSTALL_ROOT=%{buildroot}
# Drop in the bit of configuration
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

%if 0%{?__ztsphp:1}
make install -C %{pecl_name}-zts        INSTALL_ROOT=%{buildroot}
install -D -m 644 %{pecl_name}.ini %{buildroot}%{php_ztsinidir}/%{pecl_name}.ini
%endif



%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}
ln -s %{php_extdir}/mysqlnd.so modules/
%if %{withsqlite}
ln -s %{php_extdir}/sqlite3.so modules/
%endif

# only check if build extension can be loaded
php -n -q \
    -d extension_dir=modules \
    -d extension=mysqlnd.so \
%if %{withsqlite}
    -d extension=sqlite3.so \
%endif
    -d extension=%{pecl_name}.so \
    --modules | grep %{pecl_name}

%if 0%{?__ztsphp:1}
cd ../%{pecl_name}-zts
ln -s %{php_ztsextdir}/mysqlnd.so modules/
%if %{withsqlite}
ln -s %{php_ztsextdir}/sqlite3.so modules/
%endif

# only check if build extension can be loaded
zts-php -n -q \
    -d extension_dir=modules \
    -d extension=mysqlnd.so \
%if %{withsqlite}
    -d extension=sqlite3.so \
%endif
    -d extension=%{pecl_name}.so \
    --modules | grep %{pecl_name}
%endif


%files
%defattr(-, root, root, -)
%doc %{pecl_name}-%{version}/{CHANGES,CREDITS,LICENSE,README}
%doc %{pecl_name}-%{version}/web
%config(noreplace) %{_sysconfdir}/php.d/%{pecl_name}.ini
%{php_extdir}/%{pecl_name}.so
%{pecl_xmldir}/%{name}.xml

%if 0%{?__ztsphp:1}
%config(noreplace) %{php_ztsinidir}/%{pecl_name}.ini
%{php_ztsextdir}/%{pecl_name}.so
%endif

%files devel
%defattr(-,root,root,-)
%{_includedir}/php/ext/%{pecl_name}

%if 0%{?__ztsphp:1}
%{php_ztsincldir}/ext/%{pecl_name}
%endif


%changelog
* Fri Nov 30 2012 Remi Collet <remi@fedoraproject.org> - 1.1.1-3.1
- also provides php-mysqlnd_qc

* Sat Sep 22 2012 Remi Collet <remi@fedoraproject.org> - 1.1.1-3
- rebuild for new libmemcached
- Obsoletes php53*, php54*

* Mon Apr 30 2012 Remi Collet <remi@fedoraproject.org> - 1.1.1-2
- rebuild for EL and PHP 5.4

* Mon Apr 30 2012  Remi Collet <remi@fedoraproject.org> - 1.1.1-1
- update to 1.1.1-alpha
- add devel sub-package
- update configuration file provided
  add collect_statistics-log-file and ignore_sql_comments
  remove apc_prefix (not supported in this build)

* Mon Jan 30 2012  Remi Collet <remi@fedoraproject.org> - 1.1.0-0.1.svn322926
- new snapshot, update to 1.1.0-alpha

* Mon Nov 21 2011  Remi Collet <remi@fedoraproject.org> - 1.0.1-3.svn322926
- fix from svn, build against php 5.4

* Sun Sep 18 2011  Remi Collet <remi@fedoraproject.org> - 1.0.1-2
- build zts extension

* Sun Sep 18 2011  Remi Collet <remi@fedoraproject.org> - 1.0.1-1
- Initial RPM