SF.net SVN: gar:[23368] csw/mgar/gar/v2/lib/python/recursive_remove_order. py

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Sun Apr 6 18:50:45 CEST 2014


Revision: 23368
          http://sourceforge.net/p/gar/code/23368
Author:   wahwah
Date:     2014-04-06 16:50:45 +0000 (Sun, 06 Apr 2014)
Log Message:
-----------
recursive-remove-order: A new tool

It displays in which order to remove a given package.

Added Paths:
-----------
    csw/mgar/gar/v2/lib/python/recursive_remove_order.py

Added: csw/mgar/gar/v2/lib/python/recursive_remove_order.py
===================================================================
--- csw/mgar/gar/v2/lib/python/recursive_remove_order.py	                        (rev 0)
+++ csw/mgar/gar/v2/lib/python/recursive_remove_order.py	2014-04-06 16:50:45 UTC (rev 23368)
@@ -0,0 +1,51 @@
+#!/opt/csw/bin/python
+# coding: utf-8
+
+"""Display in which order to remove packages with safe_remove_pkg.
+
+We do not build this into safe_remove_pkg on purpose: we want the list of
+packages to be reviewed by a human before removal.
+"""
+
+import logging
+import requests
+import argparse
+import dateutil.parser
+import datetime
+import jinja2
+
+from collections import namedtuple
+
+from lib.python import opencsw
+
+
+def RemoveDFS(fd, pkgs_by_pkgname, revdeps, removed, pkgname):
+  pkg = pkgs_by_pkgname[pkgname]
+  for revdep_pkgname in revdeps[pkgname]:
+    RemoveDFS(fd, pkgs_by_pkgname, revdeps, removed, revdep_pkgname)
+  c = pkg['catalogname']
+  if c not in removed:
+    fd.write('./lib/python/safe_remove_package.py --os-releases=SunOS5.9,SunOS5.10,SunOS5.11 -c %s\n' % c)
+    removed.add(c)
+
+def main():
+  parser = argparse.ArgumentParser()
+  parser.add_argument('pkgname', help='Package to remove (pkgname)')
+  parser.add_argument('output', help='output file')
+  args = parser.parse_args()
+  url = ('http://buildfarm.opencsw.org/pkgdb/rest/catalogs/'
+         'unstable/i386/SunOS5.10/timing/')
+  data = requests.get(url).json()
+  revdeps = {}
+  pkgs_by_pkgname = {}
+  removed = set()
+  for entry in data:
+    pkgs_by_pkgname[entry['pkgname']] = entry
+    revdeps.setdefault(entry['pkgname'], set())
+    for dep in entry['deps']:
+      revdeps.setdefault(dep, set()).add(entry['pkgname'])
+  with open(args.output, 'wb') as fd:
+    RemoveDFS(fd, pkgs_by_pkgname, revdeps, removed, args.pkgname)
+
+if __name__ == '__main__':
+  main()


Property changes on: csw/mgar/gar/v2/lib/python/recursive_remove_order.py
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the devel mailing list