summaryrefslogtreecommitdiffstats
path: root/php-phpmyadmin-twig-i18n-extension.spec
blob: 8ba175d17e3cf36da9e697200ed8240fbb970de8 (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
# remirepo/fedora spec file for php-phpmyadmin-twig-i18n-extension
#
# Copyright (c) 2020 Remi Collet
# License: CC-BY-SA
# http://creativecommons.org/licenses/by-sa/4.0/
#
# Please, preserve the changelog entries
#

%global gh_commit    1f509fa3c3f66551e1f4a346e4477c6c0dc76f9e
%global gh_short     %(c=%{gh_commit}; echo ${c:0:7})
%global gh_owner     phpmyadmin
#global gh_date      20150820
%global gh_project   twig-i18n-extension
%global with_tests   0%{!?_without_tests:1}
%global ns_vendor    PhpMyAdmin
%global ns_project   Twig
%global ns_sub       Extensions
%global major        %nil

Name:           php-%{gh_owner}-%{gh_project}%{major}
Version:        3.0.0
Release:        1%{?dist}
Summary:        Internationalization support for Twig via the gettext library

License:        MIT
URL:            https://github.com/%{gh_owner}/%{gh_project}
Source0:        https://github.com/%{gh_owner}/%{gh_project}/archive/%{gh_commit}/%{name}-%{version}-%{?gh_short}.tar.gz

BuildArch:      noarch
%if %{with_tests}
BuildRequires:  php(language) >= 7.1
# remirepo:1
%if 0%{?fedora} >= 29 || 0%{?rhel} >= 8
BuildRequires: (php-composer(twig/twig) >= 2 with php-composer(twig/twig) < 4)
# For tests, from composer.json "require-dev": {
#        "phpmyadmin/coding-standard": "^2.0",
#        "phpunit/phpunit": "^7 || ^8 || ^9"
%if 0%{?fedora} >= 31 || 0%{?rhel} >= 9
BuildRequires:  phpunit9
%global phpunit %{_bindir}/phpunit9
%else
BuildRequires:  phpunit8
%global phpunit %{_bindir}/phpunit8
%endif
# remirepo:5
%else
BuildRequires:  php-twig2
BuildRequires:  phpunit
%global phpunit %{_bindir}/phpunit
%endif
%endif
# For autoloader
BuildRequires:  php-fedora-autoloader-devel

# From composer.json, "require": {
#        "php": ">=7.1",
#        "twig/twig": "^2.0|^3.0"
Requires:       php(language) >= 7.1
# remirepo:1
%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8
Requires:      (php-composer(twig/twig) >= 2 with php-composer(twig/twig) < 4)
# remirepo:3
%else
Requires:       php-twig2
%endif
# From phpcompatinfo report for 3.0.0
# Only Core and standard
# For generated autoloader
Requires:       php-composer(fedora/autoloader)

# Composer
Provides:       php-composer(%{gh_owner}/%{gh_project}) = %{version}


%description
The i18n extension adds gettext support to Twig.
It defines one tag, trans.

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


%prep
%setup -q -n %{gh_project}-%{gh_commit}


%build
: Create autoloader
phpab --template fedora -o src/autoload.php src
cat <<'AUTOLOAD' | tee -a src/autoload.php

\Fedora\Autoloader\Dependencies::required(array(
    [
        '%{_datadir}/php/Twig3/autoload.php',
        '%{_datadir}/php/Twig2/autoload.php',
    ],
));
AUTOLOAD


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


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

: upstream test suite
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 README.rst
%dir %{_datadir}/php/%{ns_vendor}
%dir %{_datadir}/php/%{ns_vendor}/%{ns_project}
     %{_datadir}/php/%{ns_vendor}/%{ns_project}/%{ns_sub}%{major}


%changelog
* Fri Oct  9 2020 Remi Collet <remi@remirepo.net> - 3.0.0-1
- update to 3.0.0
- raise dependency on PHP 7.1
- raise dependency on twig v2 and allow v3
- switch to phpunit9

* Tue Jan 28 2020 Remi Collet <remi@remirepo.net> - 2.0.0-1
- initial package