summaryrefslogtreecommitdiff
path: root/php-pecl-mysql.spec
blob: aec2d695ee1c6cbe5a5718409f558693d5224c3a (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
#
# Conditional build:
%bcond_without	tests		# build without tests
%bcond_without	mysqlnd		# without mysqlnd support in mysql related extensions

%define		rel		6
%define		commit	580d46c
%define		php_name	php%{?php_suffix}
%define		modname	mysql
Summary:	Legacy MySQL extension
Summary(pl.UTF-8):	Moduł bazy danych MySQL dla PHP
Summary(pt_BR.UTF-8):	Um módulo para aplicações PHP que usam bancos de dados MySQL
Name:		%{php_name}-pecl-%{modname}
Version:	1.0.0
Release:	%{rel}.%{commit}
License:	PHP 3.01
Group:		Development/Languages/PHP
# https://github.com/php/pecl-database-mysql
# https://git.php.net/?p=pecl/database/mysql.git;a=summary
Source0:	https://github.com/php/pecl-database-mysql/archive/%{commit}/php-pecl-%{modname}-%{version}-%{commit}.tar.gz
# Source0-md5:	3ecc43430bf97c6e8c125adb5853a5cf
Patch0:		revert-deprecate-ext-mysql.patch
URL:		https://secure.php.net/manual/en/book.mysql.php
%{?with_tests:BuildRequires:    %{php_name}-cli}
BuildRequires:	%{php_name}-devel >= 4:7.0.0
BuildRequires:	rpmbuild(macros) >= 1.666
%if %{with tests}
BuildRequires:	%{php_name}-cli
%{?with_mysqlnd:BuildRequires:	%{php_name}-mysqlnd}
BuildRequires:	%{php_name}-pcre
%endif
%{?with_mysqlnd:Requires:	%{php_name}-mysqlnd}
%{?requires_php_extension}
Provides:	php(mysql) = %{version}
BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)

%description
This is a dynamic shared object (DSO) for PHP that will add MySQL
database support.

This extension provides the mysql family of functions that were
provided with PHP 3-5. These functions have been superseded by MySQLi
and PDO_MySQL, which continue to be bundled with PHP 7.

You are strongly encouraged to port your code to use either MySQLi or
PDO_MySQL, as this extension is not maintained and is available for
historical reasons only.

%prep
%setup -qc
mv pecl-database-%{modname}-*/* .
%patch0 -p1

cat <<'EOF' > run-tests.sh
#!/bin/sh
export NO_INTERACTION=1 REPORT_EXIT_STATUS=1 MALLOC_CHECK_=2
exec %{__make} test \
	PHP_EXECUTABLE=%{__php} \
	PHP_TEST_SHARED_SYSTEM_EXTENSIONS="%{?with_mysqlnd:mysqlnd}" \
	RUN_TESTS_SETTINGS="-q $*"
EOF
chmod +x run-tests.sh

xfail() {
	local t=$1
	test -f $t
	cat >> $t <<-EOF

	--XFAIL--
	Skip
	EOF
}

while read line; do
	t=${line##*\[}; t=${t%\]}
	xfail $t
done << 'EOF'
mysql_escape_string() [tests/mysql_escape_string.phpt]
mysql_get_client_info() [tests/mysql_get_client_info.phpt]
ReflectionFunction to check API [tests/mysql_reflection_functions.phpt]
EOF

%build
phpize
%configure \
	--with-mysql=shared,%{!?with_mysqlnd:/usr}%{?with_mysqlnd:mysqlnd} \
	--with-mysql-sock=/var/lib/mysql/mysql.sock \
	--with-zlib-dir=shared,/usr \

%{__make}

# simple module load test
%{__php} -n -q \
	-d extension_dir=modules \
%if %{with mysqlnd}
	-d extension=%{php_extensiondir}/mysqlnd.so \
%endif
	-d extension=%{modname}.so \
	-m > modules.log
grep %{modname} modules.log

%if %{with tests}
./run-tests.sh --show-diff
%endif

%install
rm -rf $RPM_BUILD_ROOT
%{__make} install \
	EXTENSION_DIR=%{php_extensiondir} \
	INSTALL_ROOT=$RPM_BUILD_ROOT

install -d $RPM_BUILD_ROOT%{php_sysconfdir}/conf.d
cat <<'EOF' > $RPM_BUILD_ROOT%{php_sysconfdir}/conf.d/%{modname}.ini
; Enable %{modname} extension module
extension=%{modname}.so
EOF

%clean
rm -rf $RPM_BUILD_ROOT

%post
%php_webserver_restart

%postun
if [ "$1" = 0 ]; then
	%php_webserver_restart
fi

%files
%defattr(644,root,root,755)
%doc README.md CREDITS LICENSE
%config(noreplace) %verify(not md5 mtime size) %{php_sysconfdir}/conf.d/%{modname}.ini
%attr(755,root,root) %{php_extensiondir}/%{modname}.so