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

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Sun Jan 23 12:43:42 CET 2011


Revision: 13067
          http://gar.svn.sourceforge.net/gar/?rev=13067&view=rev
Author:   wahwah
Date:     2011-01-23 11:43:42 +0000 (Sun, 23 Jan 2011)

Log Message:
-----------
csw_upload_pkg: Put pkgs into multiple catalogs

OS release: Put 5.9 into 5.9 and all later releases

Architecture: Put 'all' into both sparc and i386.

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

Modified: csw/mgar/gar/v2/lib/python/csw_upload_pkg.py
===================================================================
--- csw/mgar/gar/v2/lib/python/csw_upload_pkg.py	2011-01-23 11:43:09 UTC (rev 13066)
+++ csw/mgar/gar/v2/lib/python/csw_upload_pkg.py	2011-01-23 11:43:42 UTC (rev 13067)
@@ -14,6 +14,7 @@
 import os.path
 import opencsw
 import json
+import common_constants
 
 
 BASE_URL = "http://buildfarm.opencsw.org/releases/"
@@ -58,17 +59,28 @@
       self._PostFile(filename)
     file_in_allpkgs, file_metadata = self._GetSrv4FileMetadata(md5_sum)
     logging.debug("file_metadata %s", repr(file_metadata))
-    self._InsertIntoCatalog(filename, file_metadata)
+    osrel = file_metadata['osrel']
+    arch = file_metadata['arch']
+    # Implementing backward compatibility.  A package for SunOS5.x is also
+    # inserted into SunOS5.(x+n) for n=(0, 1, ...)
+    for idx, known_osrel in enumerate(common_constants.OS_RELS):
+      if osrel == known_osrel:
+        osrels = common_constants.OS_RELS[idx:]
+    if arch == 'all':
+      archs = ('sparc', 'i386')
+    else:
+      archs = (arch,)
+    for arch in archs:
+      for osrel in osrels:
+        self._InsertIntoCatalog(filename, arch, osrel, file_metadata)
 
-  def _InsertIntoCatalog(self, filename, file_metadata):
-    logging.info("_InsertIntoCatalog(%s)", repr(filename))
+  def _InsertIntoCatalog(self, filename, arch, osrel, file_metadata):
+    logging.info("_InsertIntoCatalog(%s, %s, %s)", repr(arch), repr(osrel), repr(filename))
     md5_sum = self._GetFileMd5sum(filename)
     basename = os.path.basename(filename)
     parsed_basename = opencsw.ParsePackageFileName(basename)
     logging.debug("parsed_basename: %s", parsed_basename)
 
-    arch = file_metadata['arch']
-    osrel = file_metadata['osrel']
     url = (
         "%scatalogs/unstable/%s/%s/%s/"
         % (BASE_URL, arch, osrel, md5_sum))

Modified: csw/mgar/gar/v2/lib/web/releases_web.py
===================================================================
--- csw/mgar/gar/v2/lib/web/releases_web.py	2011-01-23 11:43:09 UTC (rev 13066)
+++ csw/mgar/gar/v2/lib/web/releases_web.py	2011-01-23 11:43:42 UTC (rev 13067)
@@ -135,6 +135,8 @@
       # We should return an error message instead.
       raise web.notfound()
     try:
+      if arch_name == 'all':
+        raise checkpkg_lib.CatalogDatabaseError("Cannot add to 'all' catalog.")
       srv4 = models.Srv4FileStats.selectBy(md5_sum=md5_sum).getOne()
       if not srv4.registered:
         # Package needs to be registered for releases
@@ -144,35 +146,28 @@
         package_stats.PackageStats.ImportPkg(stats, True)
         srv4 = models.Srv4FileStats.selectBy(md5_sum=md5_sum).getOne()
       c = checkpkg_lib.Catalog()
-      if arch_name == 'all':
-        # The arch='all' packages need special handling; they need to be added
-        # to both sparc and i386 catalogs.
-        archs = ('sparc', 'i386')
-      else:
-        archs = (arch_name,)
-      for arch_name in archs:
-        # See if there already is a package with that catalogname.
-        sqo_osrel, sqo_arch, sqo_catrel = pkgdb.GetSqoTriad(
-            osrel_name, arch_name, catrel_name)
-        res = c.GetConflictingSrv4ByCatalognameResult(
-            srv4, srv4.catalogname,
-            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',
-            'application/x-vnd.opencsw.pkg;type=catalog-update')
-        response = json.dumps({
-          "message": "Added to catalog %s %s %s\n%s"
-                     % (catrel_name, arch_name, osrel_name, srv4.basename),
-          "code_version": code_version,
-        })
-        web.header('Content-Length', len(response))
-        return response
+      # See if there already is a package with that catalogname.
+      sqo_osrel, sqo_arch, sqo_catrel = pkgdb.GetSqoTriad(
+          osrel_name, arch_name, catrel_name)
+      res = c.GetConflictingSrv4ByCatalognameResult(
+          srv4, srv4.catalogname,
+          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',
+          'application/x-vnd.opencsw.pkg;type=catalog-update')
+      response = json.dumps({
+        "message": "Added to catalog %s %s %s\n%s"
+                   % (catrel_name, arch_name, osrel_name, srv4.basename),
+        "code_version": code_version,
+      })
+      web.header('Content-Length', len(response))
+      return response
     except (
         checkpkg_lib.CatalogDatabaseError,
         sqlobject.dberrors.OperationalError), e:


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