#!/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(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']) && isValid($installed['root'])) { $main = $installed['root']['name']; 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 && isValid($v)) { printf("bundled(php-composer(%s)) = %s\n", $name, getVersion($v)); } } } // 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)); }