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

%global with_tests   0%{!?_without_tests:1}
# Github
%global gh_commit    fd5ff0531a48b193a659309cc5fb882c14dbd03f
%global gh_short     %(c=%{gh_commit}; echo ${c:0:7})
%global gh_owner     antonioribeiro
%global gh_project   google2fa-qrcode
# Packagist
%global pk_vendor    pragmarx
%global pk_project   %{gh_project}
# Namespace
%global ns_vendor    PragmaRX
%global ns_project   Google2FAQRCode
%global major        %nil

Name:           php-%{pk_vendor}-%{pk_project}%{major}
Version:        1.0.3
Release:        1%{?gh_date?%{gh_date}git%{gh_short}}%{?dist}
Summary:        QR Code package for Google2FA

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.4
%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8
BuildRequires: (php-composer(pragmarx/google2fa)                   >= 5.0   with php-composer(pragmarx/google2fa)                   < 6)
BuildRequires: (php-composer(bacon/bacon-qr-code)                  >= 1.0   with php-composer(bacon/bacon-qr-code)                  < 3)
%else
BuildRequires:  php-pragmarx-google2fa5
BuildRequires:  php-bacon-qr-code
%endif
# For tests, from composer.json "require-dev": {
#        "phpunit/phpunit": "~4|~5|~6|~7",
#        "khanamiryan/qrcode-detector-decoder": "^1.0"
BuildRequires:  php-composer(phpunit/phpunit)
%global phpunit %{_bindir}/phpunit
%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8
BuildRequires: (php-composer(khanamiryan/qrcode-detector-decoder)  >= 1.0   with php-composer(khanamiryan/qrcode-detector-decoder)  < 2)
%else
BuildRequires:  php-khanamiryan-qrcode-detector-decoder
%endif
BuildRequires:  php-date
# For autoloader
BuildRequires:  php-composer(fedora/autoloader)
# Optional dependency of khanamiryan/qrcode-detector-decoder
BuildRequires:  php-imagick
%endif

# From composer.json, "require": {
#        "php": ">=5.4",
#        "pragmarx/google2fa": ">=4.0",
#        "bacon/bacon-qr-code": "~1.0|~2.0"
Requires:       php(language) >= 5.4
%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8
Requires:       (php-composer(pragmarx/google2fa)    >= 5.0   with php-composer(pragmarx/google2fa)   < 6)
Requires:       (php-composer(bacon/bacon-qr-code)   >= 1.0   with php-composer(bacon/bacon-qr-code)  < 3)
%else
Requires:       php-pragmarx-google2fa5
Requires:       php-bacon-qr-code
%endif
# From phpcompatinfo report for 1.0.3
# only Core and standard
# From composer.json, "suggest": {
#      "bacon/bacon-qr-code": "Required to generate inline QR Codes."
%if 0%{?fedora} >= 21 || 0%{?rhel} >= 8
Recommends:     php-composer(bacon/bacon-qr-code)
%endif
# For generated autoloader
Requires:       php-composer(fedora/autoloader)

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


%description
This is package is Goole2FA integrated with a QRCode generator,
providing an easy way to plot QRCode for your two factor authentication. 

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


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

: 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__);
\Fedora\Autoloader\Dependencies::required([
    '%{_datadir}/php/%{ns_vendor}/Google2FA5/autoload.php',
    [
        '%{_datadir}/php/BaconQrCode2/autoload.php',
        '%{_datadir}/php/BaconQrCode/autoload.php',
    ],
]);
AUTOLOAD


%build
: Nothing to build


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


%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}\\Tests\\', dirname(__DIR__).'/tests');
require '%{_datadir}/php/Zxing/autoload.php';
EOF

ret=0
for cmd in php php71 php72 php73 php74; do
   if which $cmd; then
      $cmd %{phpunit} --no-coverage --verbose || ret=1
   fi
done
exit $ret
%else
: Test suite disabled
%endif


%files
# remirepo:1
%{!?_licensedir:%global license %%doc}
%license LICENSE.md
%doc composer.json
%doc README.md CHANGELOG.md
%dir %{_datadir}/php/%{ns_vendor}
     %{_datadir}/php/%{ns_vendor}/%{ns_project}%{major}


%changelog
* Wed Sep 11 2019 Remi Collet <remi@remirepo.net> - 1.0.3-1
- initial package