summaryrefslogtreecommitdiffstats
path: root/php-Assetic.spec
blob: 87c2b55f2b2dbabadcb2127fc1f836bbe39fde01 (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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
# remirepo spec file for php-Assetic, from
#
# Fedora spec file for php-Assetic
#
# Copyright (c) 2013-2019 Shawn Iwinski <shawn.iwinski@gmail.com>
#
# License: MIT
# http://opensource.org/licenses/MIT
#
# Please preserve changelog entries
#

%global github_owner     kriswallsmith
%global github_name      assetic
%global github_version   1.4.0
%global github_commit    e911c437dbdf006a8f62c2f59b15b2d69a5e0aa1

%global composer_vendor  kriswallsmith
%global composer_project assetic

# "php": ">=5.3.1"
%global php_min_ver 5.3.1
# "cssmin/cssmin": "3.0.1"
%global cssmin_min_ver 3.0.1
%global cssmin_max_ver 3.0.2
# "joliclic/javascript-packer": "1.1"
%global javascript_packer_min_ver 1.1
%global javascript_packer_max_ver 1.2
# "kamicane/packager": "1.0"
%global packager_min_ver 1.0
%global packager_max_ver 1.1
# "leafo/lessphp": "^0.3.7"
%global lessphp_min_ver 0.3.7
%global lessphp_max_ver 1.0
# "leafo/scssphp": "~0.1"
#     NOTE: Min version not 0.1 because autoloader required
%global scssphp_min_ver 0.1.6
%global scssphp_max_ver 1.0
# "mrclay/minify": "~2.2"
%global minify_min_ver 2.2
%global minify_max_ver 3.0
# "patchwork/jsqueeze": "~1.0|~2.0"
%global jsqueeze_min_ver 1.0
%global jsqueeze_max_ver 3.0
# "psr/log": "~1.0"
#     NOTE: Min version not 1.0 because autoloader required
%global psr_log_min_ver 1.0.1
%global psr_log_max_ver 2.0
# "ptachoire/cssembed": "~1.0"
%global cssembed_min_ver 1.0
%global cssembed_max_ver 2.0
# "symfony/process": "~2.1|~3.0"
#     NOTE: Min version not 2.1 because autoloader required
%global symfony_min_ver %{?el6:2.3.31}%{!?el6:2.7.1}
%global symfony_max_ver 4.0
# twig/twig": "~1.23|~2.0"
#     "conflict": "twig/twig": "<1.27"
%global twig_min_ver 1.27
%global twig_max_ver 3.0

# Conditionals for BuildRequires and Suggests
%global with_libjpeg_turbo_utils 0%{?fedora} || 0%{?rhl} >= 7
%global with_npm_clean_css       0%{?fedora} || 0%{?rhl} >= 7
%global with_npm_handlebars      1
%global with_npm_typescript      0%{?fedora} >= 23
%global with_rubygem_compass     0%{?fedora} >= 23 && 1%{?fedora} < 129
%global with_rubygem_sass        0%{?fedora} >= 23
%global with_rubygem_sprockets   0%{?fedora}

# Build using "--without tests" to disable tests
%global with_tests 0%{!?_without_tests:1}

%{!?phpdir:  %global phpdir  %{_datadir}/php}

Name:          php-Assetic
Version:       %{github_version}
Release:       10%{?dist}
Summary:       Asset Management for PHP

License:       MIT
URL:           https://github.com/%{github_owner}/%{github_name}

# GitHub export does not include tests.
# Run php-Assetic-get-source.sh to create full source.
Source0:       %{name}-%{github_version}-%{github_commit}.tar.gz
Source1:       %{name}-get-source.sh

BuildArch:     noarch
# Tests
%if %{with_tests}
## composer.json
BuildRequires: php(language)                    >= %{php_min_ver}
BuildRequires: php-composer(leafo/lessphp)      <  %{lessphp_max_ver}
BuildRequires: php-composer(leafo/lessphp)      >= %{lessphp_min_ver}
BuildRequires: php-composer(leafo/scssphp)      <  %{scssphp_max_ver}
BuildRequires: php-composer(leafo/scssphp)      >= %{scssphp_min_ver}
BuildRequires: php-composer(patchwork/jsqueeze) <  %{jsqueeze_max_ver}
BuildRequires: php-composer(patchwork/jsqueeze) >= %{jsqueeze_min_ver}
BuildRequires: php-composer(phpunit/phpunit)
BuildRequires: php-composer(psr/log)            <  %{psr_log_max_ver}
BuildRequires: php-composer(psr/log)            >= %{psr_log_min_ver}
BuildRequires: php-composer(symfony/process)    <  %{symfony_max_ver}
BuildRequires: php-composer(symfony/process)    >= %{symfony_min_ver}
BuildRequires: php-composer(twig/twig)          <  %{twig_max_ver}
BuildRequires: php-composer(twig/twig)          >= %{twig_min_ver}
## phpcompatinfo (computed from version 1.4.0)
BuildRequires: php-ctype
BuildRequires: php-curl
BuildRequires: php-date
BuildRequires: php-fileinfo
BuildRequires: php-hash
BuildRequires: php-json
BuildRequires: php-pcre
BuildRequires: php-reflection
BuildRequires: php-simplexml
BuildRequires: php-spl
BuildRequires: php-tokenizer
## Autoloader
BuildRequires: php-composer(fedora/autoloader)
## package.json
%if %{with_npm_clean_css}
BuildRequires: npm(clean-css)
%endif
%if %{with_npm_handlebars}
BuildRequires: npm(handlebars)
%endif
%if %{with_npm_typescript}
BuildRequires: npm(typescript)
%endif
## Gemfile
%if %{with_rubygem_compass}
BuildRequires: rubygem(compass)
%endif
%if %{with_rubygem_sass}
BuildRequires: rubygem(sass)
%endif
%if %{with_rubygem_sprockets}
BuildRequires: rubygem(sprockets)
%endif
## Other
%if %{with_libjpeg_turbo_utils}
BuildRequires: libjpeg-turbo-utils
%endif
BuildRequires: optipng
%endif

# composer.json
Requires:      php(language)                 >= %{php_min_ver}
Requires:      php-composer(symfony/process) >= %{symfony_min_ver}
Requires:      php-composer(symfony/process) <  %{symfony_max_ver}
# phpcompatinfo (computed from version 1.4.0)
Requires:      php-ctype
Requires:      php-curl
Requires:      php-date
Requires:      php-hash
Requires:      php-json
Requires:      php-pcre
Requires:      php-reflection
Requires:      php-spl
Requires:      php-tokenizer
# Autoloader
Requires:      php-composer(fedora/autoloader)

# Weak dependencies
%if 0%{?fedora} >= 21
Suggests:      optipng
Suggests:      php-composer(leafo/lessphp)
Suggests:      php-composer(leafo/scssphp)
Suggests:      php-composer(patchwork/jsqueeze)
Suggests:      php-composer(twig/twig)
Suggests:      php-pecl(apcu)
%if %{with_libjpeg_turbo_utils}
Suggests:      libjpeg-turbo-utils
%endif
%if %{with_npm_clean_css}
Suggests:      npm(clean-css)
%endif
%if %{with_npm_handlebars}
Suggests:      npm(handlebars)
%endif
%if %{with_npm_typescript}
Suggests:      npm(typescript)
%endif
%if %{with_rubygem_compass}
Suggests:      rubygem(compass)
%endif
%if %{with_rubygem_sass}
Suggests:      rubygem(sass)
%endif
%if %{with_rubygem_sprockets}
Suggests:      rubygem(sprockets)
%endif
%endif

# Standard "php-{COMPOSER_VENDOR}-{COMPOSER_PROJECT}" naming
Provides:      php-%{composer_vendor}-%{composer_project} = %{version}-%{release}
# Composer
Provides:      php-composer(%{composer_vendor}/%{composer_project}) = %{version}

%description
Assetic is an asset management framework for PHP.

Autoloader: %{phpdir}/Assetic/autoload.php


%prep
%setup -q -n %{github_name}-%{github_commit}

: Move functions file
mv src/functions.php src/Assetic/

: Remove executable bits
chmod a-x package.json


%build
: Create autoloader
cat <<'AUTOLOAD' | tee src/Assetic/autoload.php
<?php
/**
 * Autoloader for %{name} and its' dependencies
 * (created by %{name}-%{version}-%{release}).
 */
require_once '%{phpdir}/Fedora/Autoloader/autoload.php';

\Fedora\Autoloader\Autoload::addPsr4('Assetic\\', __DIR__);

\Fedora\Autoloader\Dependencies::required(array(
    __DIR__.'/functions.php',
    array(
        '%{phpdir}/Symfony3/Component/Process/autoload.php',
        '%{phpdir}/Symfony/Component/Process/autoload.php',
    ),
));

\Fedora\Autoloader\Dependencies::optional(array(
    '%{phpdir}/Leafo/ScssPhp/autoload.php',
    '%{phpdir}/lessphp/lessc.inc.php',
    '%{phpdir}/Patchwork/JSqueeze.php',
    '%{phpdir}/Twig/autoload.php',
));
AUTOLOAD


%install
mkdir -p %{buildroot}%{phpdir}
cp -rp src/Assetic %{buildroot}%{phpdir}/


%check
%if %{with_tests}
: Skip tests known to fail
rm -f \
    tests/Assetic/Test/Asset/HttpAssetTest.php \
    tests/Assetic/Test/Filter/GoogleClosure/CompilerApiFilterTest.php
sed 's/function testMinimizeHandlebars/function SKIP_testMinimizeHandlebars/' \
    -i tests/Assetic/Test/Filter/HandlebarsFilterTest.php
sed 's/function testCompassExtensionCanBeDisabled/function SKIP_testCompassExtensionCanBeDisabled/' \
    -i tests/Assetic/Test/Filter/ScssphpFilterTest.php
: skip for https://github.com/kriswallsmith/assetic/issues/863
rm tests/Assetic/Test/Filter/UglifyJs2FilterTest.php

: Create tests bootstrap
cat <<'BOOTSTRAP' | tee bootstrap.php
<?php
require '%{buildroot}%{phpdir}/Assetic/autoload.php';
\Fedora\Autoloader\Autoload::addPsr4('Assetic\\Test\\', __DIR__.'/tests/Assetic/Test');
BOOTSTRAP

: Upstream tests
%{_bindir}/phpunit --verbose --bootstrap bootstrap.php

: Upstream tests with SCLs if available
SCL_RETURN_CODE=0
for SCL in php71 php72 php73 php74; do
    if which $SCL; then
        $SCL %{_bindir}/phpunit --verbose --bootstrap bootstrap.php || SCL_RETURN_CODE=1
    fi
done
exit $SCL_RETURN_CODE
%else
: Tests skipped
%endif


%files
%{!?_licensedir:%global license %%doc}
%license LICENSE
%doc *.json
%doc *.md
%doc docs
%doc Gemfile
%{phpdir}/Assetic


%changelog
* Sat Sep 14 2019 Shawn Iwinski <shawn.iwinski@gmail.com> - 1.4.0-10
- Fix FTBFS (RHBZ #1736429)

* Thu Feb 14 2019 Shawn Iwinski <shawn.iwinski@gmail.com> - 1.4.0-8
- Disable Ruby Compass for Fedora >= 29 to fix FTBFS because dependency
  FTBFS "nothing provides rubygem(sass) < 3.5 needed by rubygem-compass"
  (RHBZ #1605436 / RHBZ #1675660)

* Wed Nov  8 2017 Remi Collet <remi@remirepo.net> - 1.4.0-4
- fix FTBFS from Koschei, add maximum version to build dependencies
- fix autoloader for Symfony 3
- skip test failing with uglify-js 2.8
  https://github.com/kriswallsmith/assetic/issues/863

* Thu Dec 29 2016 Shawn Iwinski <shawn.iwinski@gmail.com> - 1.4.0-1
- Updated to 1.4.0 (RHBZ #1394441)
- Use php-composer(fedora/autoloader)
- Run upstream tests with SCLs if they are available

* Mon Oct 10 2016 Shawn Iwinski <shawn.iwinski@gmail.com> - 1.3.2-4
- Skip addtional test known to fail (FTBFS in rawhide; RHBZ #1383374)

* Wed Apr 13 2016 James Hogarth <james.hogarth@gmail.com> - 1.3.2-3
- Change to using array() in autoloader to be php5.3 compatible for el6

* Wed Apr 13 2016 James Hogarth <james.hogarth@gmail.com> - 1.3.2-2
- Check if file exists and then require in the Fedora autoloader (RHBZ #1326825)

* Sat Mar 26 2016 Shawn Iwinski <shawn.iwinski@gmail.com> - 1.3.2-1
- Updated to 1.3.2 (RHBZ #1153986)
- Added additional non-PHP build dependencies
- Added additional non-PHP weak dependencies

* Fri Mar 25 2016 Shawn Iwinski <shawn.iwinski@gmail.com> - 1.2.1-4
- Added spec copyright header
- Included tests in source, added BuildRequires, enabled tests
- Dependencies changed to virtual provides ("php*(*)")
- Added weak dependencies suggests (Fedora >= 21)
- Added autoloader
- Added additional docs

* Mon Dec 29 2014 Adam Williamson <awilliam@redhat.com> - 1.2.1-1
- new release 1.2.1

* Tue Aug 20 2013 Remi Collet <remi@fedoraproject.org> - 1.1.2-1
- backport 1.1.2 for remi repo.

* Sun Aug 18 2013 Shawn Iwinski <shawn.iwinski@gmail.com> 1.1.2-1
- Updated to 1.1.2

* Mon Jun 10 2013 Remi Collet <remi@fedoraproject.org> - 1.1.1-1
- backport 1.1.1 for remi repo.

* Fri Jun 07 2013 Shawn Iwinski <shawn.iwinski@gmail.com> 1.1.1-1
- Updated to 1.1.1

* Mon Mar 11 2013 Remi Collet <remi@fedoraproject.org> - 1.1.0-0.2.alpha4
- backport for remi repo.

* Sat Mar 09 2013 Shawn Iwinski <shawn.iwinski@gmail.com> 1.1.0-0.2.alpha4
- Updated to upstream pre-release version 1.1.0-alpha4

* Wed Feb 27 2013 Shawn Iwinski <shawn.iwinski@gmail.com> 1.1.0-0.1.alpha3
- Initial package