[csw-devel] SF.net SVN: gar:[15393] csw/mgar/gar/v2/lib

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Sun Aug 21 10:39:27 CEST 2011


Revision: 15393
          http://gar.svn.sourceforge.net/gar/?rev=15393&view=rev
Author:   wahwah
Date:     2011-08-21 08:39:27 +0000 (Sun, 21 Aug 2011)

Log Message:
-----------
csw-upload-pkg: During updates remove by pkgname

Fixes an annoying case when renaming packages:
http://lists.opencsw.org/pipermail/maintainers/2011-July/015023.html

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/python/checkpkg_lib.py
    csw/mgar/gar/v2/lib/web/releases_web.py

Modified: csw/mgar/gar/v2/lib/python/checkpkg_lib.py
===================================================================
--- csw/mgar/gar/v2/lib/python/checkpkg_lib.py	2011-08-21 07:03:53 UTC (rev 15392)
+++ csw/mgar/gar/v2/lib/python/checkpkg_lib.py	2011-08-21 08:39:27 UTC (rev 15393)
@@ -991,6 +991,27 @@
                   m.Srv4FileInCatalog.q.srv4file!=sqo_srv4))
     return res
 
+  def GetConflictingSrv4ByPkgnameResult(self,
+      sqo_srv4, pkgname,
+      sqo_osrel, sqo_arch, sqo_catrel):
+    join = [
+          m.Srv4FileStats,
+          m.Pkginst.q.id==m.Srv4FileStats.q.pkginst,
+        sqlbuilder.INNERJOINOn(None,
+          m.Srv4FileInCatalog,
+          m.Srv4FileStats.q.id==m.Srv4FileInCatalog.q.srv4file),
+    ]
+    res = m.Srv4FileStats.select(
+            m.Pkginst.q.pkgname==pkgname
+            ).throughTo.in_catalogs.filter(
+                sqlobject.AND(
+                  m.Srv4FileInCatalog.q.osrel==sqo_osrel,
+                  m.Srv4FileInCatalog.q.arch==sqo_arch,
+                  m.Srv4FileInCatalog.q.catrel==sqo_catrel,
+                  m.Srv4FileInCatalog.q.srv4file!=sqo_srv4),
+            join=join)
+    return res
+
   def AddSrv4ToCatalog(self, sqo_srv4, osrel, arch, catrel):
     """Registers a srv4 file in a catalog."""
     logging.debug("AddSrv4ToCatalog(%s, %s, %s, %s)",

Modified: csw/mgar/gar/v2/lib/web/releases_web.py
===================================================================
--- csw/mgar/gar/v2/lib/web/releases_web.py	2011-08-21 07:03:53 UTC (rev 15392)
+++ csw/mgar/gar/v2/lib/web/releases_web.py	2011-08-21 08:39:27 UTC (rev 15393)
@@ -164,9 +164,9 @@
         package_stats.PackageStats.ImportPkg(stats, True)
         srv4 = models.Srv4FileStats.selectBy(md5_sum=md5_sum).getOne()
       c = checkpkg_lib.Catalog()
-      # See if there already is a package with that catalogname.
       sqo_osrel, sqo_arch, sqo_catrel = pkgdb.GetSqoTriad(
           osrel_name, arch_name, catrel_name)
+      # See if there already is a package with that catalogname.
       res = c.GetConflictingSrv4ByCatalognameResult(
           srv4, srv4.catalogname,
           sqo_osrel, sqo_arch, sqo_catrel)
@@ -175,6 +175,15 @@
         for pkg_in_catalog in res:
           srv4_to_remove = pkg_in_catalog.srv4file
           c.RemoveSrv4(srv4_to_remove, osrel_name, arch_name, catrel_name)
+      # See if there already is a package with that pkgname.
+      res = c.GetConflictingSrv4ByPkgnameResult(
+          srv4, srv4.pkginst.pkgname,
+          sqo_osrel, sqo_arch, sqo_catrel)
+      if res.count() == 1:
+        # Removing old version of the package from the catalog
+        for pkg_in_catalog in res:
+          srv4_to_remove = pkg_in_catalog.srv4file
+          c.RemoveSrv4(srv4_to_remove, osrel_name, arch_name, catrel_name)
       c.AddSrv4ToCatalog(srv4, osrel_name, arch_name, catrel_name)
       web.header(
           'Content-type',


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