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

# For compatibility with SCL
#undefine __brp_mangle_shebangs

%global with_tests   0%{!?_without_tests:1}
# Github
%global gh_commit    e2dadd21ef6188f038aaf72cd2d55d0e1b522741
%global gh_short     %(c=%{gh_commit}; echo ${c:0:7})
%global gh_owner     scssphp
%global gh_project   scssphp
# Packagist
%global pk_vendor    %{gh_owner}
%global pk_project   %{gh_project}
# Namespace
%global ns_vendor    ScssPhp
%global ns_project   ScssPhp
%global major        %nil

Name:           php-%{pk_vendor}-%{pk_project}%{major}
Version:        1.0.7
Release:        1%{?gh_date?%{gh_date}git%{gh_short}}%{?dist}
Summary:        Compiler for SCSS

License:        MIT
URL:            https://github.com/%{gh_owner}/%{gh_project}
Source0:        %{name}-%{version}-%{?gh_short}.tgz
# Create a git snapshot with test suite
Source1:        makesrc.sh

# Use our autoloader
Patch0:         %{name}-rpm.patch

BuildArch:      noarch
BuildRequires:  php(language) >= 5.6.0
BuildRequires:  php-cli
%if %{with_tests}
BuildRequires:  php-ctype
BuildRequires:  php-date
BuildRequires:  php-json
BuildRequires:  php-mbstring
BuildRequires:  php-pcre
BuildRequires:  php-spl
# For tests, from composer.json "require-dev": {
#        "squizlabs/php_codesniffer": "~2.5",
#        "phpunit/phpunit": "^5.7 || ^6.5 || ^7.5 || ^8.3",
#        "twbs/bootstrap": "~4.3",
#        "zurb/foundation": "~6.5"
# remirepo:1
%if 0%{?fedora} >= 29 || 0%{?rhel} >= 8
BuildRequires:  phpunit8 >= 8.3
%global phpunit %{_bindir}/phpunit8
# remirepo:4
%else
BuildRequires:  php-composer(phpunit/phpunit) >= 5.7
%global phpunit %{_bindir}/phpunit
%endif
%endif
# For autoloader
BuildRequires:  php-fedora-autoloader-devel

# From composer.json, "require": {
#        "php": ">=5.6.0",
#        "ext-json": "*",
#        "ext-ctype": "*"
Requires:       php(language) >= 5.6.0
Requires:       php-cli
Requires:       php-ctype
Requires:       php-json
# From phpcompatinfo report for 1.0.4
Requires:       php-date
Requires:       php-mbstring
Requires:       php-pcre
Requires:       php-spl
# For generated autoloader
Requires:       php-composer(fedora/autoloader)

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


%description
%{name} is a compiler for SCSS written in PHP.

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


%prep
%setup -q -n %{gh_project}-%{gh_commit}
%patch0 -p1 -b .rpm

mv LICENSE.md LICENSE


%build
: Create autoloader
%{_bindir}/phpab -t fedora -o src/autoload.php src


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

: Command
mkdir -p %{buildroot}%{_bindir}
install -pm 0755 bin/pscss %{buildroot}%{_bindir}/%{name}


%check
php -r '
  require "%{buildroot}%{_datadir}/php/%{ns_vendor}/%{ns_project}%{major}/autoload.php";
  printf("Project version: %s\n", ScssPhp\ScssPhp\Version::VERSION);
  exit(ScssPhp\ScssPhp\Version::VERSION === "v%{version}" ? 0 : 1);
'

%if %{with_tests}
mkdir -p 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');
EOF

: Ignore tests for non-packaged frameworks
rm tests/FrameworkTest.php

ret=0
for cmdarg in "php %{phpunit}" php72 php73 php74; do
   if which $cmdarg; then
      set $cmdarg
      if [ $(php -r 'echo PHP_INT_SIZE;') -lt 8 ] ; then
        # see https://github.com/scssphp/scssphp/issues/51
        $1 ${2:-%{_bindir}/phpunit8} --filter '^((?!(testTests|testEncode)).)*$' --no-coverage --verbose || ret=1
      else
        $1 ${2:-%{_bindir}/phpunit8} --no-coverage --verbose || ret=1
      fi
   fi
done
exit $ret
%else
: Test suite disabled
%endif


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


%changelog
* Sat Feb  1 2020 Remi Collet <remi@remirepo.net> - 1.0.7-1
- update to 1.0.7

* Thu Dec 12 2019 Remi Collet <remi@remirepo.net> - 1.0.6-1
- update to 1.0.6

* Fri Oct  4 2019 Remi Collet <remi@remirepo.net> - 1.0.5-1
- update to 1.0.5

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