diff options
author | Remi Collet <fedora@famillecollet.com> | 2014-07-28 09:25:24 +0200 |
---|---|---|
committer | Remi Collet <fedora@famillecollet.com> | 2014-07-28 09:25:24 +0200 |
commit | 0e306b2c719a577f220d1084b481b2f8fcee8d6e (patch) | |
tree | 029d15de22aece519c6ef9aa52291b4c2156c6d7 /checkpkgist.php | |
parent | 6eb9e049223f363ba89fae0e0a34a0aa62cd7a20 (diff) |
checkpkgist: use data retrieved by rpmphp
Diffstat (limited to 'checkpkgist.php')
-rwxr-xr-x | checkpkgist.php | 29 |
1 files changed, 26 insertions, 3 deletions
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) { |