summaryrefslogtreecommitdiffstats
path: root/checkpkgist/checkpkgist.php
diff options
context:
space:
mode:
authorRemi Collet <fedora@famillecollet.com>2017-01-12 12:25:09 +0100
committerRemi Collet <fedora@famillecollet.com>2017-01-12 12:25:09 +0100
commit0c9a7cfb694c245589ca2556ff5ca8a363ffb68a (patch)
treec66fbc30aa8edc7e5d7d1467e232bf63ea41ec5a /checkpkgist/checkpkgist.php
parent268f8b576ee41e618f5dd2dbe6b7d329b1271b23 (diff)
checkpkgist: improve report for multi-versions
Diffstat (limited to 'checkpkgist/checkpkgist.php')
-rwxr-xr-xcheckpkgist/checkpkgist.php45
1 files changed, 43 insertions, 2 deletions
diff --git a/checkpkgist/checkpkgist.php b/checkpkgist/checkpkgist.php
index 6acc6c8..33aee0e 100755
--- a/checkpkgist/checkpkgist.php
+++ b/checkpkgist/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";