summaryrefslogtreecommitdiff
path: root/composer.spec
blob: 87892165e38d28cba7dcc5816cb96d261a0be8f4 (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
%undefine __brp_mangle_shebangs

%global gh_commit    623e5e1de055e65bc6c3c61b8348dc4662d75e2b
%global gh_short     %(c=%{gh_commit}; echo ${c:0:7})
%global gh_branch    2.0-dev
%global gh_owner     composer
%global gh_project   composer
%global api_version  2.6.0
%global run_version  2.2.2

%global upstream_version 2.6.2

%global _phpunit       %{_bindir}/phpunit9
%global bashcompdir    %(pkg-config --variable=completionsdir bash-completion 2>/dev/null)
%global bashcomproot   %(dirname %{bashcompdir} 2>/dev/null)


Name:           composer
Version:        %{upstream_version}
Release:        1
Summary:        Dependency Manager for PHP

# SPDX: composer and all dependencies are MIT
License:        MIT
URL:            https://getcomposer.org/
Source0:        %{gh_project}-%{upstream_version}-%{gh_short}.tgz
# Profile scripts
Source1:        %{name}-bash-completion
Source3:        %{name}.sh
Source4:        %{name}.csh
# Get a git snapshot to retrieve the test suite
Source5:        makesrc.sh

# Use our autoloader, resources path, fix for tests
Patch0:         %{name}-rpm.patch
# Disable XDG support as only partially implemented
Patch1:         %{name}-noxdg.patch
# Use Huaweicloud mirror by default
Patch10:        composer-add-huaweicloud-repository.patch

BuildArch:      noarch
# platform set in makesrc.sh
BuildRequires:  php(language) >= 7.2.5
BuildRequires:  php-cli
BuildRequires:  pkgconfig(bash-completion)

Requires:       php(language)                           >= 7.2.5
Requires:       php-cli
Supplements:    php-cli
# System certificates
Requires:       ca-certificates
# Bundled libraries
# License MIT
Provides:       bundled(php-composer-ca-bundle) = 1.3.7
Provides:       bundled(php-composer-class-map-generator) = 1.1.0
Provides:       bundled(php-composer-metadata-minifier) = 1.0.0
Provides:       bundled(php-composer-pcre) = 2.1.0
Provides:       bundled(php-composer-semver) = 3.4.0
Provides:       bundled(php-composer-spdx-licenses) = 1.5.7
Provides:       bundled(php-composer-xdebug-handler) = 3.0.3
Provides:       bundled(php-justinrainbow-json-schema) = 5.2.12
Provides:       bundled(php-psr-container) = 1.1.1
Provides:       bundled(php-psr-log) = 1.1.4
Provides:       bundled(php-react-promise) = v3.0.0
Provides:       bundled(php-seld-jsonlint) = 1.10.0
Provides:       bundled(php-seld-phar-utils) = 1.2.1
Provides:       bundled(php-seld-signal-handler) = 2.0.2
Provides:       bundled(php-symfony-console) = v5.4.28
Provides:       bundled(php-symfony-deprecation-contracts) = v2.5.2
Provides:       bundled(php-symfony-filesystem) = v5.4.25
Provides:       bundled(php-symfony-finder) = v5.4.27
Provides:       bundled(php-symfony-polyfill-ctype) = v1.28.0
Provides:       bundled(php-symfony-polyfill-intl-grapheme) = v1.28.0
Provides:       bundled(php-symfony-polyfill-intl-normalizer) = v1.28.0
Provides:       bundled(php-symfony-polyfill-mbstring) = v1.28.0
Provides:       bundled(php-symfony-polyfill-php73) = v1.28.0
Provides:       bundled(php-symfony-polyfill-php80) = v1.28.0
Provides:       bundled(php-symfony-polyfill-php81) = v1.28.0
Provides:       bundled(php-symfony-process) = v5.4.28
Provides:       bundled(php-symfony-service-contracts) = v2.5.2
Provides:       bundled(php-symfony-string) = v5.4.26

Requires:       php-openssl
Requires:       php-zip
Requires:       php-zlib
# From phpcompatinfo for version 2.2.5
Requires:       php-ctype
Requires:       php-curl
Requires:       php-date
Requires:       php-dom
Requires:       php-filter
Requires:       php-hash
Requires:       php-iconv
Requires:       php-intl
Requires:       php-libxml
Requires:       php-mbstring
Requires:       php-pcntl
Requires:       php-pcre
Requires:       php-phar
Requires:       php-posix
Requires:       php-reflection
Requires:       php-spl
Requires:       php-tokenizer
Requires:       php-xsl
Requires:       php-zlib

# Composer library
Provides:       php-composer(composer/composer) = %{version}
# Special internal for Plugin API
Provides:       php-composer(composer-plugin-api) = %{api_version}
Provides:       php-composer(composer-runtime-api) = %{run_version}


%description
Composer helps you declare, manage and install dependencies of PHP projects,
ensuring you have the right stack everywhere.

Documentation: https://getcomposer.org/doc/

%prep
%autosetup -p1 -n %{gh_project}-%{gh_commit}

find . \( -name \*.rpm -o -name \*noxdg \) -delete -print

if grep -r '\.\./res'; then
	: Patch need to fixed
	exit 1
fi

rm src/bootstrap.php
rm src/Composer/vendor/composer/ca-bundle/res/cacert.pem

: symlink autoloader for library
ln -s vendor/autoload.php src/Composer/autoload.php

: fix layout
sed -e "s:/../..' . '/src/Composer::" -i src/Composer/vendor/composer/autoload_static.php

: List bundled libraries and Licenses
php -r '
	$pkgs = file_get_contents("src/Composer/vendor/composer/installed.json");
	$pkgs = json_decode($pkgs, true);
	if (!is_array($pkgs) || !isset($pkgs["packages"])) {
        echo "cant decode json file\n";
		exit(3);
	}
	$res = [];
    foreach($pkgs["packages"] as $pkg) {
		$lic = implode(" and ", $pkg["license"]);
		if (!isset($res[$lic])) $res[$lic] = [];
		$res[$lic][] = sprintf("Provides:       bundled(php-%s) = %s", str_replace(["/", "_"], ["-", "-"], $pkg["name"]), $pkg["version"]);
	}
	foreach($res as $lic => $lib) {
		sort($lib);
		printf("# License %s\n%s\n", $lic, implode("\n", $lib));
	}
'

: fix reported version
sed -e '/BRANCH_ALIAS_VERSION/s/@package_branch_alias_version@//' \
    -i src/Composer/Composer.php

: check Plugin API version
php -r '
namespace Composer;
include "src/Composer/autoload.php";
if (version_compare(Plugin\PluginInterface::PLUGIN_API_VERSION, "%{api_version}")) {
  printf("Plugin API version is %s, expected %s\n", Plugin\PluginInterface::PLUGIN_API_VERSION, "%{api_version}");
  exit(1);
}
if (version_compare(Composer::RUNTIME_API_VERSION, "%{run_version}")) {
  printf("Runtime API version is %s, expected %s\n", Composer::RUNTIME_API_VERSION, "%{run_version}");
  exit(1);
}'


%build
# Nothing


%install
install -Dpm 644 %{SOURCE1} %{buildroot}%{bashcompdir}/%{name}
mkdir -p %{buildroot}%{_sysconfdir}/profile.d
install -m 644 %{SOURCE3} %{SOURCE4} %{buildroot}%{_sysconfdir}/profile.d/

mkdir -p     %{buildroot}%{_datadir}/php
cp -pr src/* %{buildroot}%{_datadir}/php

mkdir -p       %{buildroot}%{_datadir}/%{name}
cp -pr res     %{buildroot}%{_datadir}/%{name}/res
cp -p  LICENSE %{buildroot}%{_datadir}/%{name}/LICENSE

ln -sf %{_datadir}/%{name}/LICENSE LICENSE

install -Dpm 755 bin/%{name} %{buildroot}%{_bindir}/%{name}


%files
%license LICENSE
%doc *.md doc
%doc composer.json
%config(noreplace) %{_sysconfdir}/profile.d/%{name}.*
%{_bindir}/%{name}
%{_datadir}/php/Composer
%{_datadir}/%{name}
%{bashcomproot}

%changelog
* Mon Sep 04 2023 Funda Wang <fundawang@yeah.net> - 2.6.2-1
- New version 2.6.2

* Mon Jul 10 2023 Funda Wang <fundawang@yeah.net> - 2.5.8-1
- Import package from Remi