[csw-devel] SF.net SVN: gar:[18489] csw/mgar/gar/v2/lib/python/safe_remove_package.py

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Fri Jun 22 01:07:38 CEST 2012


Revision: 18489
          http://gar.svn.sourceforge.net/gar/?rev=18489&view=rev
Author:   wahwah
Date:     2012-06-21 23:07:38 +0000 (Thu, 21 Jun 2012)
Log Message:
-----------
safe-remove-package: Add --os-releases

This allows to remove packages for e.g. Solaris 10 and Solaris 11 only. It's
useful when a reverse dependency blocks removal on Solaris 9, but not on 10 or
11.

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/python/safe_remove_package.py

Modified: csw/mgar/gar/v2/lib/python/safe_remove_package.py
===================================================================
--- csw/mgar/gar/v2/lib/python/safe_remove_package.py	2012-06-21 23:01:33 UTC (rev 18488)
+++ csw/mgar/gar/v2/lib/python/safe_remove_package.py	2012-06-21 23:07:38 UTC (rev 18489)
@@ -68,14 +68,22 @@
 
 class PackageRemover(object):
 
-  def RemovePackage(self, catalogname, execute=False):
+  def RemovePackage(self, catalogname, execute=False, os_releases=None):
+    if not os_releases:
+      os_releases = common_constants.OS_RELS
     # Get md5 sums
     rest_client = rest.RestClient()
     rd = RevDeps()
     rev_deps = {}
     to_remove = {}
-    for osrel in common_constants.OS_RELS:
+    for osrel in os_releases:
+      if osrel not in common_constants.OS_RELS:
+        logging.warning(
+            "%s not found in common_constants.OS_RELS (%s). Skipping.",
+            osrel, common_constants.OS_RELS)
+        continue
       if osrel in common_constants.OBSOLETE_OS_RELS:
+        logging.info("%s is an obsolete OS release. Skipping.", osrel)
         continue
       for arch in common_constants.PHYSICAL_ARCHITECTURES:
         pkg_simple = rest_client.Srv4ByCatalogAndCatalogname("unstable", arch, osrel, catalogname)
@@ -106,15 +114,23 @@
 def main():
   parser = optparse.OptionParser()
   parser.add_option("-c", "--catalogname", dest="catalogname")
+  parser.add_option("--os-releases", dest="os_releases",
+                    help=("Comma separated OS releases, e.g. "
+                          "SunOS5.9,SunOS5.10"))
   parser.add_option("--debug", dest="debug", action="store_true")
-  parser.add_option("--execute", dest="execute", action="store_true")
+  parser.add_option("--execute", dest="execute", action="store_true",
+                    help=("Don't just display, but execute and remove the "
+                          "packages."))
   options, args = parser.parse_args()
   debug_level = logging.INFO
   if options.debug:
     debug_level = logging.DEBUG
   logging.basicConfig(level=debug_level)
+  os_relases = None
+  if options.os_releases:
+    os_releases = options.os_releases.split(",")
   pr = PackageRemover()
-  pr.RemovePackage(options.catalogname, options.execute)
+  pr.RemovePackage(options.catalogname, options.execute, os_releases)
 
 
 if __name__ == '__main__':

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