summaryrefslogtreecommitdiffstats
path: root/php-phpmyadmin-twig-i18n-extension.spec
blob: cb8c9c243c56f20919fff89bf6cd9ddab149dbf5 (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
# 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    00250be43cc33e174077614807025e9e9bfc3171
%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:        2.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) >= 5.5
# remirepo:1
%if 0%{?fedora} >= 29 || 0%{?rhel} >= 8
BuildRequires: (php-composer(twig/twig) >= 1.42.3 with php-composer(twig/twig) < 3)
# For tests, from composer.json "require-dev": {
#        "symfony/phpunit-bridge": "^4.2|^5.0"
# NOTICE: symfony/phpunit-bridge only used to pull phpunit
BuildRequires:  phpunit8
%global phpunit %{_bindir}/phpunit8
# remirepo:5
%else
BuildRequires:  php-twig
BuildRequires:  phpunit
%global phpunit %{_bindir}/phpunit
%endif
%endif
# For autoloader
BuildRequires:  php-fedora-autoloader-devel

# From composer.json, "require": {
#        "php": ">=5.5.0",
#        "twig/twig": "^1.42.3|^2.0"
Requires:       php(language) >= 5.5
# remirepo:1
%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8
Requires:      (php-composer(twig/twig) >= 1.42.3 with php-composer(twig/twig) < 3)
# remirepo:3
%else
Requires:       php-twig
%endif
# From phpcompatinfo report for 2.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/Twig2/autoload.php',
        '%{_datadir}/php/Twig/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

: fix commands
ret=0
for cmdarg in "php %{phpunit}" php72 php73 php74; do
   if which $cmdarg; then
      set $cmdarg
      $1 ${2:-%{_bindir}/phpunit8} --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
* Tue Jan 28 2020 Remi Collet <remi@remirepo.net> - 2.0.0-1
- initial package