#!/usr/bin/php . SPDX-3.0-License-Identifier: GPL-2.0-or-later This program is free software. For more information on the license, see COPYING or . For more information on free software, see . */ // 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)); }