summaryrefslogtreecommitdiffstats
path: root/checkpkgist.php
diff options
context:
space:
mode:
authorRemi Collet <remi@remirepo.net>2018-01-22 14:48:42 +0100
committerRemi Collet <remi@remirepo.net>2018-01-22 14:48:42 +0100
commit192f18454275ee771bf05c5884fbccfbd961106f (patch)
tree6d1fa081d053c772a45d5dc3c5e9f8a745de4f93 /checkpkgist.php
parent147212c9ee5faa3dd8800d5a9c24aeb5a79148dd (diff)
fix packagist api usage
Diffstat (limited to 'checkpkgist.php')
-rwxr-xr-xcheckpkgist.php17
1 files changed, 13 insertions, 4 deletions
diff --git a/checkpkgist.php b/checkpkgist.php
index e853081..2b8c3d7 100755
--- a/checkpkgist.php
+++ b/checkpkgist.php
@@ -55,13 +55,21 @@ class PkgClient {
}
function getPackage($name) {
- $url = self::URL.'packages/'.$name.'.json';
+ $url = self::URL . "p/$name.json";
$rep = $this->cache->get(__METHOD__, $url);
if (!$rep) {
$rep = @file_get_contents($url);
$this->cache->save($rep, __METHOD__, $url);
}
- return ($rep ? json_decode($rep, true) : false);
+ if ($rep) {
+ $rep =json_decode($rep, true);
+ if (isset($rep['packages'][$name])) {
+ // Higher version first
+ uksort($rep['packages'][$name], function($a, $b) { return version_compare($b, $a); });
+ }
+ return $rep;
+ }
+ return false;
}
}
@@ -131,11 +139,12 @@ function run($name, $rpm) {
$rpmver = "n/a";
}
$pkgs = $client->getPackage($name);
- if ($pkgs) {
+ if ($pkgs && isset($pkgs['packages'][$name])) {
$maxver = "";
$maxdat = false;
$display = false;
- foreach ($pkgs['package']['versions'] as $pkver => $pkg) {
+
+ foreach ($pkgs['packages'][$name] as $pkver => $pkg) {
if (preg_match('/^v[\.0-9]*$/', $pkver)) {
$pkver = substr($pkver, 1);
}