blob: d866711ef4bef25163464cad27a7fb7347b52072 (
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
|
#!/usr/bin/php
<?php
/*
Use this script to generate bundled provides, e.g.:
./composer.prov vendor/composer/installed.php
Copyright (C) 2024 Remi Collet <remi@fedoraproject.org>.
SPDX-3.0-License-Identifier: GPL-2.0-or-later
This program is free software.
For more information on the license, see COPYING or
<https://www.gnu.org/licenses/gpl-2.0.en.html>.
For more information on free software, see
<https://www.gnu.org/philosophy/free-sw.en.html>.
*/
// Check if composer "pretty_version" is usable in RPM
function isValid($version) {
if (empty($version)
|| strpos($version, '-')
) {
return false;
}
return true;
}
// Parse an installed.php file
function run($file) {
fputs(STDERR, "Search bundled libraries installed, parsing $file\n");
$installed = include $file;
$main = false;
if (isset($installed['root']['name'])
&& isset($installed['root']['pretty_version'])
&& isValid($installed['root']['pretty_version'])) {
$main = $installed['root']['name'];
printf("php-composer(%s) = %s\n", $installed['root']['name'], $installed['root']['pretty_version']);
}
if (isset($installed['versions'])) foreach($installed['versions'] as $name => $v) {
if ($name !== $main
&& isset($v['pretty_version'])
&& isValid($v['pretty_version'])) {
printf("bundled(php-composer(%s)) = %s\n", $name, $v['pretty_version']);
}
}
}
// From command line argument, manual usage
if (isset($_SERVER['argv'][1])) {
run($_SERVER['argv'][1]);
// From input lines, rpmbuild usage
} else while($f = fgets(STDIN)) {
run(trim($f));
}
|