summaryrefslogtreecommitdiffstats
path: root/php-sentry.spec
blob: d4de11bfd1d094ce905d2272a8e18d5b33d857ef (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
# remirepo spec file for php-sentry, from
#
# Fedora spec file for php-sentry
#
# Copyright (c) 2016-2020 Shawn Iwinski <shawn@iwin.ski>
#
# License: MIT
# http://opensource.org/licenses/MIT
#
# Please preserve the changelog entries
#

%global github_owner     getsentry
%global github_name      sentry-php
%global github_version   0.22.0
%global github_commit    49d4c0c4f2c298c9f15a07416debb5352a209b79

%global composer_vendor  sentry
%global composer_project sentry

# "php": ">=5.2.4"
%global php_min_ver      5.2.4
# "monolog/monolog": "*"
#     NOTE: Min version because autoloader required
#     NOTE: Adding max version to force v1
%global monolog_min_ver  1.15.0
%global monolog_max_ver  2

# Build using "--without tests" to disable tests
%global with_tests 0%{!?_without_tests:1}

# Range dependencies supported?
%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8
%global with_range_dependencies 1
%else
%global with_range_dependencies 0
%endif

%{!?phpdir:  %global phpdir  %{_datadir}/php}

Name:          php-%{composer_project}
Version:       %{github_version}
Release:       11%{?github_release}%{?dist}
Summary:       PHP client for Sentry

# ASL 2.0:
#     - lib/Raven/Serializer.php
# BSD:
#     - Everything else
License:       BSD and ASL 2.0
URL:           https://github.com/%{github_owner}/%{github_name}

# GitHub export does not include tests.
# Run php-sentry-get-source.sh to create full source.
Source0:       %{name}-%{github_version}-%{github_commit}.tar.gz
Source1:       %{name}-get-source.sh

BuildArch:     noarch
# Library version value check
BuildRequires: php-cli
# Tests
%if %{with_tests}
## composer.json
BuildRequires: php(language) >= %{php_min_ver}
BuildRequires: php-composer(phpunit/phpunit)
BuildRequires: php-curl
%if %{with_range_dependencies}
BuildRequires: (php-composer(monolog/monolog) >= %{monolog_min_ver} with php-composer(monolog/monolog) < %{monolog_max_ver})
%else
BuildRequires: php-Monolog >= %{monolog_min_ver}
%endif
## phpcompatinfo (computed from version 0.22.0)
BuildRequires: php-date
BuildRequires: php-hash
BuildRequires: php-mbstring
BuildRequires: php-pcre
BuildRequires: php-reflection
BuildRequires: php-session
BuildRequires: php-spl
BuildRequires: php-zlib
# Conflict because Monolog will load obsoleted package's autoloader and classes.
BuildConflicts: php-Raven
%endif

Requires:      php-cli
Requires:      ca-certificates
# composer.json
Requires:      php(language) >= %{php_min_ver}
Requires:      php-curl
%if %{with_range_dependencies}
Requires:      (php-composer(monolog/monolog) >= %{monolog_min_ver} with php-composer(monolog/monolog) < %{monolog_max_ver})
%else
Requires:      php-Monolog >= %{monolog_min_ver}
%endif
# phpcompatinfo (computed from version 0.22.0)
Requires:      php-date
Requires:      php-hash
Requires:      php-mbstring
Requires:      php-pcre
Requires:      php-reflection
Requires:      php-session
Requires:      php-spl
Requires:      php-zlib

# Standard "php-{COMPOSER_VENDOR}-{COMPOSER_PROJECT}" naming
Provides:      php-%{composer_vendor}-%{composer_project} = %{version}-%{release}
# Composer
Provides:      php-composer(%{composer_vendor}/%{composer_project}) = %{version}

# Rename
Obsoletes:     php-Raven < %{version}
Provides:      php-Raven = %{version}-%{release}
Provides:      php-composer(raven/raven) = %{version}


%description
%{summary} (http://getsentry.com).

Autoloader: %{phpdir}/Raven/autoload.php


%prep
%setup -qn %{github_name}-%{github_commit}

: Remove bundled cert
rm -rf lib/Raven/data
sed "/return.*cacert\.pem/s#.*#        return '%{_sysconfdir}/pki/tls/cert.pem';#" \
    -i lib/Raven/Client.php

: Update autoloader require in bin
sed "/require.*Autoloader/s#.*#require_once '%{phpdir}/Raven/Autoloader.php';#" \
    -i bin/sentry


%build
: Create autoloader
cat <<'AUTOLOAD' | tee lib/Raven/autoload.php
<?php
/**
 * Autoloader for %{name} and its' dependencies
 * (created by %{name}-%{version}-%{release}).
 */

require_once dirname(__FILE__).'/Autoloader.php';
Raven_Autoloader::register();

// Required dependency
require_once '%{phpdir}/Monolog/autoload.php';
AUTOLOAD


%install
mkdir -p %{buildroot}%{phpdir}
cp -rp lib/* %{buildroot}%{phpdir}/

mkdir -p %{buildroot}%{_bindir}
install -pm 0755 bin/sentry %{buildroot}%{_bindir}/
: Compat bin
ln -s sentry %{buildroot}%{_bindir}/raven


%check
: Library version value check
%{_bindir}/php -r '
    require_once "%{buildroot}%{phpdir}/Raven/Client.php";
    $version = Raven_Client::VERSION;
    echo "Version $version (expected %{version})\n";
    exit(version_compare("%{version}", "$version", "=") ? 0 : 1);
'

%if %{with_tests}
: Create tests bootstrap
cat <<'BOOTSTRAP' | tee bootstrap.php
<?php
session_start();
require_once '%{buildroot}%{phpdir}/Raven/autoload.php';
BOOTSTRAP

: Run tests
ret=0
for cmd in php php70 php71 php72 php73; do
  if which $cmd; then
    $cmd %{_bindir}/phpunit \
      --filter '^((?!(testCanTraceParamContext|testDoesFixFrameInfo)).)*$' \
      --verbose --bootstrap bootstrap.php || ret=1
  fi
done
exit $ret
%else
: Tests skipped
%endif


%files
%{!?_licensedir:%global license %%doc}
%license LICENSE
%doc *.rst
%doc AUTHORS
%doc CHANGES
%doc composer.json
%{phpdir}/Raven
%{_bindir}/raven
%{_bindir}/sentry


%changelog
* Fri Sep 04 2020 Shawn Iwinski <shawn@iwin.ski> - 0.22.0-11
- Add max Monolog version

* Thu Dec  6 2018 Remi Collet <remi@remirepo.net> - 0.22.0-6
- skip test relying on uopz extension

* Sun Nov  6 2016 Remi Collet <remi@remirepo.net> - 0.22.0-1
- add backport stuff for remi repo.

* Thu Nov 03 2016 Shawn Iwinski <shawn@iwin.ski> - 0.22.0-1
- Initial package