summaryrefslogtreecommitdiffstats
path: root/php-composer-installers.spec
blob: d3336726844436ce3d3f090f404a54f9cbbef4d1 (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
# remirepo spec file for php-composer-installers, from:
#
# Fedora spec file for php-composer-installers
#
# Copyright (c) 2015-2016 Shawn Iwinski <shawn.iwinski@gmail.com>
#
# License: MIT
# http://opensource.org/licenses/MIT
#
# Please preserve changelog entries
#

%global github_owner     composer
%global github_name      installers
%global github_version   1.2.0
%global github_commit    d78064c68299743e0161004f2de3a0204e33b804

%global composer_vendor  composer
%global composer_project installers

# "composer-plugin-api": "^1.0"
%global composer_plugin_min_ver 1.0
%global composer_plugin_max_ver 2.0
# "composer/composer": "1.0.*@dev"
%global composer_min_ver 1.0

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

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

Name:          php-%{composer_vendor}-%{composer_project}
Version:       %{github_version}
Release:       1%{?github_release}%{?dist}
Summary:       A multi-framework Composer library installer

Group:         Development/Libraries
License:       MIT
URL:           http://composer.github.io/installers/
Source0:       https://github.com/%{github_owner}/%{github_name}/archive/%{github_commit}/%{name}-%{github_version}-%{github_commit}.tar.gz

BuildArch:     noarch
BuildRoot:     %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
# Tests
%if %{with_tests}
## composer.json
BuildRequires: php-composer(composer-plugin-api) >= %{composer_plugin_min_ver}
BuildRequires: php-composer(composer/composer)   >= %{composer_min_ver}
BuildRequires: php-composer(phpunit/phpunit)
## phpcompatinfo (computed from version 1.2.0)
BuildRequires: php(language) >= 5.3.0
BuildRequires: php-pcre
BuildRequires: php-spl
## Autoloader
BuildRequires: php-composer(symfony/class-loader)
%endif

# composer.json
Requires:      php-composer(composer-plugin-api) >= %{composer_plugin_min_ver}
Requires:      php-composer(composer-plugin-api) <  %{composer_plugin_max_ver}
# phpcompatinfo (computed from version 1.2.0)
Requires:      php(language) >= 5.3.0
Requires:      php-pcre
Requires:      php-spl
# Autoloader
Requires:      php-composer(symfony/class-loader)

# Composer
Provides:      php-composer(%{composer_vendor}/%{composer_project}) = %{version}

%description
This is for PHP package authors to require in their composer.json. It will
install their package to the correct location based on the specified package
type.

The goal of installers is to be a simple package type to install path map.
Users can also customize the install path per package and package authors
can modify the package name upon installing.

installers isn't intended on replacing all custom installers. If your package
requires special installation handling then by all means, create a custom
installer to handle it.


%prep
%setup -qn %{github_name}-%{github_commit}


%build
: Create autoloader
cat <<'AUTOLOAD' | tee src/Composer/Installers/autoload.php
<?php
/**
 * Autoloader for %{name} and its' dependencies
 * (created by %{name}-%{version}-%{release}).
 *
 * @return \Symfony\Component\ClassLoader\ClassLoader
 */

if (!isset($fedoraClassLoader) || !($fedoraClassLoader instanceof \Symfony\Component\ClassLoader\ClassLoader)) {
    if (!class_exists('Symfony\\Component\\ClassLoader\\ClassLoader', false)) {
        require_once '%{phpdir}/Symfony/Component/ClassLoader/ClassLoader.php';
    }

    $fedoraClassLoader = new \Symfony\Component\ClassLoader\ClassLoader();
    $fedoraClassLoader->register();
}

$fedoraClassLoader->addPrefix('Composer\\Installers\\', dirname(dirname(__DIR__)));

require_once '%{phpdir}/Composer/autoload.php';

return $fedoraClassLoader;
AUTOLOAD


%install
rm -rf   %{buildroot}

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


%check
%if %{with_tests}
: Create tests bootstrap
cat <<'BOOTSTRAP' | tee bootstrap.php
<?php
require_once '%{buildroot}%{phpdir}/Composer/Installers/autoload.php';
$fedoraClassLoader->addPrefix('Composer\\Installers\\Test\\', __DIR__ . '/tests');
BOOTSTRAP

: Run tests
run=0
ret=0
if which php56; then
   php56 %{_bindir}/phpunit --bootstrap bootstrap.php || ret=1
   run=1
fi
if which php71; then
   php71 %{_bindir}/phpunit --bootstrap bootstrap.php || ret=1
   run=1
fi
if [ $run -eq 0 ]; then
%{_bindir}/phpunit --verbose --bootstrap bootstrap.php
fi
exit $ret
%else
: Tests skipped
%endif


%clean
rm -rf %{buildroot}


%files
%defattr(-,root,root,-)
%{!?_licensedir:%global license %%doc}
%license LICENSE
%doc *.md
%doc composer.json
%{phpdir}/Composer/Installers


%changelog
* Sun Sep 11 2016 Shawn Iwinski <shawn@iwin.ski> - 1.2.0-1
- Updated to 1.2.0 (RHBZ #1372115)

* Sat Jul 23 2016 Shawn Iwinski <shawn.iwinski@gmail.com> - 1.1.0-1
- Updated to 1.1.0 (RHBZ #1352896)
- Updated URL

* Thu Apr 14 2016 Remi Collet <remi@remirepo.net> - 1.0.25-1
- update to 1.0.25

* Wed Apr  6 2016 Remi Collet <remi@remirepo.net> - 1.0.24-1
- update to 1.0.24

* Sat Mar 12 2016 Shawn Iwinski <shawn.iwinski@gmail.com> - 1.0.23-1
- Updated to 1.0.23 (RHBZ #1302488)

* Fri Feb 26 2016 Remi Collet <remi@remirepo.net> - 1.0.23-1
- update to 1.0.23
- run test suite with both PHP 5 and 7 when available

* Wed Nov 04 2015 Shawn Iwinski <shawn.iwinski@gmail.com> - 1.0.22-2
- Dependency updates

* Wed Nov 04 2015 Shawn Iwinski <shawn.iwinski@gmail.com> - 1.0.22-1
- Updated to 1.0.22 (RHBZ #1276816)

* Fri Oct 30 2015 Remi Collet <remi@remirepo.net> - 1.0.22-1
- update to 1.0.22

* Tue Aug 25 2015 Remi Collet <remi@remirepo.net> - 1.0.21-1
- backport for #remirepo

* Thu Aug 20 2015 Shawn Iwinski <shawn.iwinski@gmail.com> - 1.0.21-1
- Initial package