From 58ae5bbf25835bd30fa385275ff4486dbc31f0a2 Mon Sep 17 00:00:00 2001 From: BlackNoxis Date: Wed, 3 Dec 2014 03:20:49 +0200 Subject: Making public our Kogaion bin --- bin/get_package_changes | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100755 bin/get_package_changes (limited to 'bin/get_package_changes') diff --git a/bin/get_package_changes b/bin/get_package_changes new file mode 100755 index 0000000..0d54747 --- /dev/null +++ b/bin/get_package_changes @@ -0,0 +1,54 @@ +#!/usr/bin/python2 +import sys + +from entropy.server.interfaces import Server +from entropy.const import etpUi +etpUi['quiet'] = True +import entropy.dep +import portage + +def print_help(): + sys.stderr.write("get_package_changes \n") + +if __name__ == "__main__": + + args = sys.argv[1:] + if not args: + print_help() + raise SystemExit(1) + + cmd = args.pop(0) + if cmd not in ("added", "removed"): + print_help() + raise SystemExit(1) + + srv = Server() + repositories = srv.repositories() + pkg_keys = set() + + for repository_id in repositories: + repo = srv.open_repository(repository_id) + for atom, package_id, branch in repo.listAllPackages(): + pkg_keys.add(entropy.dep.dep_getkey(atom)) + + portdb = portage.db["/"]['porttree'] + def _match_filter(atom): + best_visible = portdb.dbapi.xmatch("bestmatch-visible", atom) + if best_visible: + return True + return False + + portage_pkg_keys = set(portdb.getallnodes()) + + if cmd == "added": + added = sorted(filter(_match_filter, portage_pkg_keys - pkg_keys)) + for pkg_key in added: + sys.stdout.write(pkg_key + "\n") + sys.stdout.flush() + elif cmd == "removed": + removed = sorted(pkg_keys - portage_pkg_keys) + for pkg_key in removed: + sys.stdout.write(pkg_key + "\n") + sys.stdout.flush() + srv.shutdown() + raise SystemExit(0) -- cgit v1.2.3