From 0e306b2c719a577f220d1084b481b2f8fcee8d6e Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 28 Jul 2014 09:25:24 +0200 Subject: checkpkgist: use data retrieved by rpmphp --- checkpkgist.php | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'checkpkgist.php') diff --git a/checkpkgist.php b/checkpkgist.php index 77c52b2..f1257c7 100755 --- a/checkpkgist.php +++ b/checkpkgist.php @@ -88,13 +88,36 @@ $verb = (in_array('-v', $_SERVER['argv']) || in_array('--verbose', $_SERVER['a $quiet = (in_array('-q', $_SERVER['argv']) || in_array('--quiet', $_SERVER['argv'])); $client = new PkgClient(); -$pkgs = file_get_contents(__DIR__."/checkpkgist.json"); +$pkgs = file_get_contents(__DIR__."/rpmphp.json"); if (!$pkgs) { - die("Missing configuration file\n"); + die("Missing configuration file rpmphp\n"); } $pkgs = json_decode($pkgs, true, 5, JSON_PARSER_NOTSTRICT); if (!$pkgs) { - die("Bad configuration file\n"); + die("Bad configuration file rpmphp\n"); +} +$pkg2 = file_get_contents(__DIR__."/checkpkgist.json"); +if (!$pkg2) { + die("Missing configuration file checkpkgist\n"); +} +$pkg2 = json_decode($pkg2, true, 5, JSON_PARSER_NOTSTRICT); +if (!$pkg2) { + die("Bad configuration file checkpkgist\n"); +} + +$change = false; +foreach ($pkg2 as $pkg => $rpm) { + if (isset($pkgs[$pkg])) { + unset($pkg2[$pkg]); + $change = true; + } else { + $pkgs[$pkg] = $pkg2[$pkg]; + } +} +if ($change) { + if (file_put_contents(__DIR__."/checkpkgist.json", json_encode($pkg2, JSON_PRETTY_PRINT))) { + printf("Configuration file changes saved\n"); + } } if ($sort) { -- cgit