summaryrefslogtreecommitdiffstats
path: root/composer.prov
diff options
context:
space:
mode:
authorRemi Collet <remi@remirepo.net>2024-12-30 09:10:20 +0100
committerRemi Collet <remi@php.net>2024-12-30 09:10:20 +0100
commit139345d0093e3677a2a0fe862cdf02b83c043dab (patch)
treee3e0a5b5206ed12110e8bf6ec462aa60d57ecf18 /composer.prov
parentbe6d564551cc9d63812cd4e2bf6b1313e0b3661e (diff)
remove 'v' in version numberHEADv0.1.1master
Diffstat (limited to 'composer.prov')
-rwxr-xr-xcomposer.prov23
1 files changed, 13 insertions, 10 deletions
diff --git a/composer.prov b/composer.prov
index d866711..d8bb84d 100755
--- a/composer.prov
+++ b/composer.prov
@@ -16,32 +16,35 @@
*/
// Check if composer "pretty_version" is usable in RPM
-function isValid($version) {
- if (empty($version)
- || strpos($version, '-')
+function isValid(Array $package) {
+ if (!isset($package['pretty_version'])
+ || empty($package['pretty_version'])
+ || strpos($package['pretty_version'], '-')
) {
return false;
}
return true;
}
+// Clean"pretty_version"
+function getVersion(Array $package) {
+ return ltrim($package['pretty_version'], 'v');
+}
+
// 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'])) {
+ && isValid($installed['root'])) {
$main = $installed['root']['name'];
- printf("php-composer(%s) = %s\n", $installed['root']['name'], $installed['root']['pretty_version']);
+ printf("php-composer(%s) = %s\n", $installed['root']['name'], getVersion($installed['root']));
}
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']);
+ if ($name !== $main && isValid($v)) {
+ printf("bundled(php-composer(%s)) = %s\n", $name, getVersion($v));
}
}
}