summaryrefslogtreecommitdiffstats
path: root/php-williamdes-mariadb-mysql-kbs.spec
blob: 25ec517746861f59d46079a3cb4c74883b32e720 (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
# remirepo/fedora spec file for php-williamdes-mariadb-mysql-kbs
#
# Copyright (c) 2019-2021 Remi Collet
# License: CC-BY-SA
# http://creativecommons.org/licenses/by-sa/4.0/
#
# Please, preserve the changelog entries
#

%bcond_without       tests

# Github
%global gh_commit    b5d4b498ba3d24ab7ad7dd0b79384542e37286a1
%global gh_short     %(c=%{gh_commit}; echo ${c:0:7})
%global gh_owner     williamdes
%global gh_project   mariadb-mysql-kbs
# Packagist
%global pk_vendor    %{gh_owner}
%global pk_project   %{gh_project}
# Namespace
%global ns_vendor    Williamdes
%global ns_project   MariaDBMySQLKBS
%global major        %nil

Name:           php-%{pk_vendor}-%{pk_project}%{major}
Version:        1.2.12
Release:        1%{?gh_date?%{gh_date}git%{gh_short}}%{?dist}
Summary:        An index of the MariaDB and MySQL Knowledge bases

License:        MPLv2.0
URL:            https://github.com/%{gh_owner}/%{gh_project}
# pull from github to retrieve full data
Source0:        %{name}-%{version}-%{?gh_short}.tgz
Source1:        makesrc.sh

Patch0:         %{name}-layout.patch

BuildArch:      noarch
%if %{with_tests}
BuildRequires:  php(language) >= 7.1
BuildRequires:  php-json
BuildRequires:  php-pcre
# For tests, from composer.json "require-dev": {
#        "phpunit/phpunit": "^7 || ^8 || ^9",
#        "phpstan/phpstan": "^0.12",
#        "slevomat/coding-standard": "^6.3",
#        "squizlabs/php_codesniffer": "^3.4",
#        "swaggest/json-schema": "^0.12.29"
%if 0%{?fedora} >= 32 || 0%{?rhel} >= 9
BuildRequires:  phpunit9
%global phpunit %{_bindir}/phpunit9
%else
BuildRequires:  phpunit8
%global phpunit %{_bindir}/phpunit8
%endif
%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8
BuildRequires: (php-composer(swaggest/json-schema)    >= 0.12.29 with php-composer(swaggest/json-schema)    < 1)
%else
BuildRequires:  php-composer(swaggest/json-schema)    <  1
BuildRequires:  php-composer(swaggest/json-schema)    >= 0.12.29
%endif
# For autoloader
BuildRequires:  php-composer(fedora/autoloader)
%endif

# From composer.json, "require": {
#        "php": "^7.1 || ^8.0"
Requires:       php(language) >= 7.1
# From phpcompatinfo report for 1.2.7
Requires:       php-json
Requires:       php-pcre
# For generated autoloader
Requires:       php-composer(fedora/autoloader)

# Composer
Provides:       php-composer(%{pk_vendor}/%{pk_project}) = %{version}


%description
An index of the MariaDB and MySQL Knowledge bases.


Autoloader: %{_datadir}/php/%{ns_vendor}/%{ns_project}%{major}/autoload.php


%prep
%setup -q -n %{gh_project}-%{gh_commit}
%patch0 -p1 -b .rpm
find src -name \*.rpm -delete

: Create autoloader
cat <<'AUTOLOAD' | tee src/autoload.php
<?php
/* Autoloader for %{name} and its dependencies */
require_once '%{_datadir}/php/Fedora/Autoloader/autoload.php';

\Fedora\Autoloader\Autoload::addPsr4('%{ns_vendor}\\%{ns_project}\\', __DIR__);
AUTOLOAD


%build
: Generate merged data
%{_bindir}/php -d auto_prepend_file=src/autoload.php src/merge.php


%install
: Library
mkdir -p       %{buildroot}%{_datadir}/php/%{ns_vendor}
cp -pr src     %{buildroot}%{_datadir}/php/%{ns_vendor}/%{ns_project}%{major}

: Data
mkdir -p       %{buildroot}%{_datadir}/%{name}
# only dist is used at runtime
cp -pr dist    %{buildroot}%{_datadir}/%{name}/dist
cp -pr data    %{buildroot}%{_datadir}/%{name}/data
cp -pr schemas %{buildroot}%{_datadir}/%{name}/schemas


%check
%if %{with_tests}
mkdir vendor
cat << 'EOF' | tee vendor/autoload.php
<?php
require '%{buildroot}%{_datadir}/php/%{ns_vendor}/%{ns_project}%{major}/autoload.php';
\Fedora\Autoloader\Autoload::addPsr4('%{ns_vendor}\\%{ns_project}\\Test\\', dirname(__DIR__).'/test');
require '%{_datadir}/php/Swaggest/JsonSchema/autoload.php';
EOF

export RPM_BUILDROOT=%{buildroot}

ret=0
for cmdarg in "php %{phpunit}" "php72 %{_bindir}/phpunit8" php73 php74 php80; do
   if which $cmdarg; then
      set $cmdarg
      $1 ${2:-%{_bindir}/phpunit9} --no-coverage --verbose || ret=1
   fi
done
exit $ret
%else
: Test suite disabled
%endif


%files
# remirepo:1
%{!?_licensedir:%global license %%doc}
%license LICENSE
%doc composer.json
%doc *.md
%dir     %{_datadir}/php/%{ns_vendor}/
         %{_datadir}/php/%{ns_vendor}/%{ns_project}%{major}
%exclude %{_datadir}/php/%{ns_vendor}/%{ns_project}%{major}/merge.php
%exclude %{_datadir}/php/%{ns_vendor}/%{ns_project}%{major}/*.js
%dir     %{_datadir}/%{name}/
         %{_datadir}/%{name}/dist
%doc     %{_datadir}/%{name}/data
%doc     %{_datadir}/%{name}/schemas


%changelog
* Mon Jan  4 2021 Remi Collet <remi@remirepo.net> - 1.2.12-1
- update to 1.2.12

* Mon Sep 14 2020 Remi Collet <remi@remirepo.net> - 1.2.11-1
- update to 1.2.11
- switch to phpunit9

* Thu Feb 27 2020 Remi Collet <remi@remirepo.net> - 1.2.10-1
- update to 1.2.10
- sources from git snapshot

* Mon Jan 27 2020 Remi Collet <remi@remirepo.net> - 1.2.9-1
- update to 1.2.9
- switch to phpunit8

* Tue Nov 12 2019 Remi Collet <remi@remirepo.net> - 1.2.8-1
- update to 1.2.8

* Thu Sep 12 2019 Remi Collet <remi@remirepo.net> - 1.2.7-1
- initial package