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

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Sat Apr 2 15:09:19 CEST 2011


Revision: 14056
          http://gar.svn.sourceforge.net/gar/?rev=14056&view=rev
Author:   wahwah
Date:     2011-04-02 13:09:19 +0000 (Sat, 02 Apr 2011)

Log Message:
-----------
pkgdb: removepkg support

Removes a package from the database, removing also all metadata

Does not allow to remove a package which is part of one or more catalogs.

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

Modified: csw/mgar/gar/v2/lib/python/pkgdb.py
===================================================================
--- csw/mgar/gar/v2/lib/python/pkgdb.py	2011-04-02 12:06:04 UTC (rev 14055)
+++ csw/mgar/gar/v2/lib/python/pkgdb.py	2011-04-02 13:09:19 UTC (rev 14056)
@@ -31,11 +31,14 @@
 USAGE = """
   Preparing the database:
        %prog initdb
-       %prog importpkg <file1> [ ... ]
        %prog system-files-to-file [ <infile-contents> <infile-pkginfo>
                                     [ <outfile> [ <osrel> <arch> ] ] ]
        %prog import-system-file <infile>
 
+  Managing individual packages:
+       %prog importpkg <file1> [ ... ]
+       %prog removepkg <md5sum> [ ... ]
+
   Managing catalogs:
        %prog add-to-cat <osrel> <arch> <cat-release> <md5sum> [ ... ]
        %prog del-from-cat <osrel> <arch> <cat-release> <md5sum> [ ... ]
@@ -449,6 +452,20 @@
           stats["basic_stats"]["md5_sum"],
           stats["basic_stats"]["pkg_basename"])
       package_stats.PackageStats.ImportPkg(stats, options.replace)
+  elif command == 'removepkg':
+    for md5_sum in md5_sums:
+      srv4 = GetPkg(md5_sum)
+      in_catalogs = list(srv4.in_catalogs)
+      if in_catalogs:
+        for in_catalog in in_catalogs:
+          logging.warning("%s", in_catalog)
+        logging.warning(
+            "Not removing from the database, because the package "
+            "in question is part of at least one catalog.")
+      else:
+        logging.info("Removing %s", srv4)
+        srv4.DeleteAllDependentObjects()
+        srv4.destroySelf()
   elif command == 'add-to-cat':
     if len(args) <= 3:
       raise UsageError("Not enough arguments, see usage.")


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