summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <fedora@famillecollet.com>2014-05-16 10:24:22 +0200
committerRemi Collet <fedora@famillecollet.com>2014-05-16 10:24:22 +0200
commita52812be79ab79dac4190988c6e837ddf436ffc9 (patch)
treef0ebba1af5de8a01eba57dc0f6bbeabc67aff3e5
checkpkgist: new tool, to check upstream new version, using packagist
-rw-r--r--checkpkgist.json50
-rwxr-xr-xcheckpkgist.php98
2 files changed, 148 insertions, 0 deletions
diff --git a/checkpkgist.json b/checkpkgist.json
new file mode 100644
index 0000000..86aa3d8
--- /dev/null
+++ b/checkpkgist.json
@@ -0,0 +1,50 @@
+/*
+ CheckPkgist configuration file
+
+ Key: packagist name
+ Value: RPM name
+
+ Last update: 2014-05-16
+*/
+{
+ "michelf/php-markdown": "php-markdown",
+ "mikey179/vfsStream": "php-mikey179-vfsstream",
+ "sabberworm/php-css-parser": "php-PHP-CSS-Parser",
+ "solarium/solarium": "php-solarium",
+ "twig/twig": "php-twig-Twig",
+ "zendframework/zendframework1": "php-ZendFramework",
+
+ "bartlett/php-compatinfo": "php-bartlett-PHP-CompatInfo",
+ "bartlett/php-reflect": "php-bartlett-PHP-Reflect",
+
+ "sabre/dav": "php-sabre-dav",
+ "sabre/event": "php-sabre-event",
+ "sabre/http": "php-sabre-http",
+ "sabre/vobject": "php-sabre-vobject",
+
+ "phploc/phploc": "php-phpunit-phploc",
+
+ "phpunit/dbunit": "php-phpunit-DbUnit",
+ "phpunit/phpcov": "php-phpunit-phpcov",
+ "phpunit/php-code-coverage": "php-phpunit-PHP-CodeCoverage",
+ "phpunit/php-file-iterator": "php-phpunit-File-Iterator",
+ "phpunit/php-invoker": "php-phpunit-PHP-Invoker",
+ "phpunit/php-text-template": "php-phpunit-Text-Template",
+ "phpunit/php-timer": "php-phpunit-PHP-Timer",
+ "phpunit/php-token-stream": "php-phpunit-PHP-TokenStream",
+ "phpunit/phpunit": "php-phpunit-PHPUnit",
+ "phpunit/phpunit-mock-objects": "php-phpunit-PHPUnit-MockObject",
+ "phpunit/phpunit-selenium": "php-phpunit-PHPUnit-Selenium",
+ "phpunit/phpunit-skeleton-generator": "php-phpunit-PHPUnit-SkeletonGenerator",
+ "phpunit/phpunit-story": "php-phpunit-PHPUnit-Story",
+
+ "sebastian/comparator": "php-phpunit-comparator",
+ "sebastian/diff": "php-phpunit-diff",
+ "sebastian/environment": "php-phpunit-environment",
+ "sebastian/exporter": "php-phpunit-exporter",
+ "sebastian/finder-facade": "php-phpunit-FinderFacade",
+ "sebastian/git": "php-phpunit-git",
+ "sebastian/phpcpd": "php-phpunit-phpcpd",
+ "sebastian/phpdcd": "php-phpunit-phpdcd",
+ "sebastian/version": "php-phpunit-Version",
+} \ No newline at end of file
diff --git a/checkpkgist.php b/checkpkgist.php
new file mode 100755
index 0000000..0a0c961
--- /dev/null
+++ b/checkpkgist.php
@@ -0,0 +1,98 @@
+#!/usr/bin/php
+<?php
+require_once 'Cache/Lite.php';
+
+class PkgClient {
+ const URL = 'https://packagist.org/';
+ protected $cache;
+
+ function __construct () {
+ $dir = "/tmp/pkgist-".posix_getlogin()."/";
+ @mkdir($dir);
+ $this->cache = new Cache_Lite(
+ array(
+ 'memoryCaching' => true,
+ 'cacheDir' => $dir,
+ 'automaticSerialization' => true
+ )
+ );
+ }
+
+ function getPackage($name) {
+ $url = self::URL.'packages/'.$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 (in_array('-h', $_SERVER['argv']) || in_array('--help', $_SERVER['argv'])) {
+ echo <<<END
+
+usage checkpkg [ options ]
+
+ -h
+ --help Display help (this page)
+
+ -v
+ --verbose Display all packages, with upsteam information
+
+ -q
+ --quiet Don't display not installed packages
+ or packages with latest version installed
+END;
+ die("\n\n");
+}
+
+$verb = (in_array('-v', $_SERVER['argv']) || in_array('--verbose', $_SERVER['argv']));
+$quiet = (in_array('-q', $_SERVER['argv']) || in_array('--quiet', $_SERVER['argv']));
+$client = new PkgClient();
+
+$pkgs = file_get_contents(__DIR__."/checkpkgist.json");
+if (!$pkgs) {
+ die("Missing configuration file\n");
+}
+$pkgs = json_decode($pkgs, true, 5, JSON_PARSER_NOTSTRICT);
+if (!$pkgs) {
+ die("Bad configuration file\n");
+}
+
+printf(" %-40s %15s %15s\n", "Name", "Version", "Upstream");
+
+foreach ($pkgs as $name => $rpm) {
+ $rpmver = exec("rpm -q --qf '%{VERSION}' $rpm", $out, $ret);
+ if ($ret) {
+ if ($quiet) {
+ continue;
+ }
+ $rpmver = "n/a";
+ }
+ $pkgs = $client->getPackage($name);
+ if ($pkgs) {
+ foreach ($pkgs['package']['versions'] as $pkver => $pkg) {
+ if (strpos($pkver, 'dev') !== false) {
+ continue;
+ }
+ if (version_compare($pkver, $rpmver, 'gt')) {
+ if ($pkg['source']['type']=='git') {
+ printf(" %-40s %15s %15s\n", $rpm, $rpmver, $pkver);
+ if ($verb) {
+ printf("\tURL: %s\n\tHash: %s\n",
+ ($pkg['source']['url']?:'unkown'),
+ ($pkg['source']['reference']?:'unkown'));
+ }
+ }
+ break;
+ }
+ else if (version_compare($pkver, $rpmver, 'eq') && $verb) {
+ printf(" %-40s %15s %15s\n", $rpm, $rpmver, $pkver);
+ break;
+ }
+ }
+ } else {
+ printf(" %-40s %15s %15s\n", $rpm, $rpmver, 'Not found !');
+ }
+} \ No newline at end of file