summaryrefslogtreecommitdiffstats
path: root/checkpkgist.php
diff options
context:
space:
mode:
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);
}