diff options
author | Remi Collet <fedora@famillecollet.com> | 2017-01-12 12:25:09 +0100 |
---|---|---|
committer | Remi Collet <fedora@famillecollet.com> | 2017-01-12 12:25:09 +0100 |
commit | 2e5606454349d3038e98012bec92846406b4d6fb (patch) | |
tree | c2da3f429a452ba495562e6d5cdd5d40bfe6fff6 /checkpkgist.php | |
parent | 61b23d9394f621c17912dfedb03e4967224c66e4 (diff) |
checkpkgist: improve report for multi-versions
Diffstat (limited to 'checkpkgist.php')
-rwxr-xr-x | checkpkgist.php | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/checkpkgist.php b/checkpkgist.php index 6acc6c8..33aee0e 100755 --- a/checkpkgist.php +++ b/checkpkgist.php @@ -65,10 +65,46 @@ class PkgClient { } } +function getMax($name, $rpm) { + static $vers = NULL; + global $pkgs; + + if (is_null($vers)) { + if ($vers = file_get_contents(__DIR__."/multiver.json")) { + $vers = json_decode($vers, true, 5); + } else { + $vers = []; + } + } + + $rpms = array_keys($pkgs, $name); + $crt = 0; + $max = 9999; + + if (preg_match('/[0-9]+$/', $rpm, $reg)) { + // This already a versionned name + $crt = intval($reg[0]); + } + if (isset($vers[$rpm])) { + $crt = $vers[$rpm]; + $max = $crt+1; + } + foreach($rpms as $alt) { + if ($alt != $rpm && preg_match('/[0-9]+$/', $alt, $reg)) { + $ver = intval($reg[0]); + if ($ver>$crt && $ver<$max) { + $max = $ver; + } + } + } + return $max; +} + function run($name, $rpm) { global $quiet, $verb, $client; $len = 50; + $limit = getMax($name, $rpm); if (in_array($name, ['znerol/php-stringprep', 'psr/http-message-implementation'])) { return; @@ -110,6 +146,9 @@ function run($name, $rpm) { $maxver = $pkver; $maxdat = $date; } + if (version_compare($pkver, $limit, 'ge')) { + continue; + } if (version_compare($pkver, $rpmver, 'gt')) { $diff = $date->diff(new DateTime("now")); $rpm2 = $rpm; @@ -225,9 +264,11 @@ for ($i=1 ; $i<$_SERVER['argc'] ; $i++) { } if (count($tmp)) { $verb = true; - $pkgs = $tmp; + $scan = $tmp; +} else { + $scan = $pkgs; } -foreach ($pkgs as $rpm => $name) { +foreach ($scan as $rpm => $name) { run($name, $rpm); } echo str_repeat(' ', 80)."\n"; |