]>
Commit | Line | Data |
---|---|---|
9ce6e03e ER |
1 | %define buildver %(pkg-config --silence-errors --modversion libsodium 2>/dev/null || echo 65536) |
2 | ||
3 | # | |
4 | # Conditional build: | |
5 | %bcond_without tests # build without tests | |
6 | ||
7 | %define php_name php%{?php_suffix} | |
8 | %define modname libsodium | |
9 | Summary: Wrapper for the Sodium cryptographic library | |
10 | Name: php-pecl-%{modname} | |
11 | Version: 1.0.2 | |
12 | Release: 1 | |
13 | License: BSD | |
14 | Group: Development/Languages | |
15 | Source0: http://pecl.php.net/get/%{modname}-%{version}.tgz | |
16 | # Source0-md5: b4083271f4fe0a94b8ae69320878a5e8 | |
17 | URL: http://pecl.php.net/package/libsodium | |
18 | # See https://github.com/jedisct1/libsodium-php/pull/70 | |
19 | Patch0: %{modname}-pr70.patch | |
20 | BuildRequires: %{php_name}-devel >= 4:5.3 | |
21 | BuildRequires: libsodium-devel >= 0.6.0 | |
22 | BuildRequires: pkgconfig | |
23 | BuildRequires: rpmbuild(macros) >= 1.666 | |
24 | %if %{with tests} | |
25 | BuildRequires: %{php_name}-cli | |
26 | BuildRequires: %{php_name}-json | |
27 | %endif | |
28 | Requires: libsodium >= %{buildver} | |
29 | %{?requires_php_extension} | |
30 | Provides: php(libsodium) = %{version} | |
31 | BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) | |
32 | ||
33 | %description | |
34 | A simple, low-level PHP extension for libsodium. | |
35 | ||
36 | Documentation: https://paragonie.com/book/pecl-libsodium | |
37 | ||
38 | %prep | |
39 | %setup -qc | |
40 | mv %{modname}-%{version}/* . | |
41 | ||
42 | %patch0 -p1 | |
43 | ||
44 | # Sanity check, really often broken | |
45 | extver=$(sed -n '/#define PHP_LIBSODIUM_VERSION/{s/.* "//;s/".*$//;p}' php_libsodium.h) | |
46 | if test "x${extver}" != "x%{version}"; then | |
47 | : Error: Upstream extension version is ${extver}, expecting %{version}. | |
48 | exit 1 | |
49 | fi | |
50 | ||
51 | %build | |
52 | phpize | |
53 | %configure | |
54 | %{__make} | |
55 | ||
56 | %if %{with tests} | |
57 | : Minimal load test | |
58 | %{__php} -n \ | |
59 | -d extension_dir=modules \ | |
60 | -d extension=%{modname}.so \ | |
61 | -m > modules.log | |
62 | grep %{modname} modules.log | |
63 | ||
64 | : Upstream test suite | |
65 | export NO_INTERACTION=1 REPORT_EXIT_STATUS=1 MALLOC_CHECK_=2 | |
66 | %{__make} test \ | |
67 | PHP_EXECUTABLE=%{__php} \ | |
68 | PHP_TEST_SHARED_SYSTEM_EXTENSIONS="json" \ | |
69 | %endif | |
70 | ||
71 | %install | |
72 | rm -rf $RPM_BUILD_ROOT | |
73 | %{__make} install \ | |
74 | EXTENSION_DIR=%{php_extensiondir} \ | |
75 | INSTALL_ROOT=$RPM_BUILD_ROOT | |
76 | ||
77 | install -d $RPM_BUILD_ROOT%{php_sysconfdir}/conf.d | |
78 | cat <<'EOF' > $RPM_BUILD_ROOT%{php_sysconfdir}/conf.d/%{modname}.ini | |
79 | ; Enable %{modname} extension module | |
80 | extension=%{modname}.so | |
81 | EOF | |
82 | ||
83 | %clean | |
84 | rm -rf $RPM_BUILD_ROOT | |
85 | ||
86 | %post | |
87 | %php_webserver_restart | |
88 | ||
89 | %postun | |
90 | if [ "$1" = 0 ]; then | |
91 | %php_webserver_restart | |
92 | fi | |
93 | ||
94 | %files | |
95 | %defattr(644,root,root,755) | |
96 | %doc README.md LICENSE | |
97 | %config(noreplace) %verify(not md5 mtime size) %{php_sysconfdir}/conf.d/%{modname}.ini | |
98 | %attr(755,root,root) %{php_extensiondir}/%{modname}.so |