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

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Sat Apr 2 14:04:16 CEST 2011


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

Log Message:
-----------
submitpkg: Better warnings about missing pkgs

Evaluating not just architectures, but architecture+os release duples.
This way submitpkg can detect missing packages from a set with packages
specific to 5.9 and 5.10.

For example:

  foo-5.9-sparc
  foo-5.9-i386
  foo-5.10-sparc

What's missing? foo-5.10-i386.  submitpkg can now detect that.

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

Modified: csw/mgar/gar/v2/lib/python/submit_to_newpkgs.py
===================================================================
--- csw/mgar/gar/v2/lib/python/submit_to_newpkgs.py	2011-04-02 12:03:40 UTC (rev 14051)
+++ csw/mgar/gar/v2/lib/python/submit_to_newpkgs.py	2011-04-02 12:04:15 UTC (rev 14052)
@@ -34,6 +34,7 @@
 import sys
 import opencsw
 import tag
+import common_constants
 
 
 CONFIG_INFO = """Create a file in ~/.releases.ini with the following content:
@@ -118,29 +119,62 @@
              parsed_filename["vendortag"])))
     return tags
 
+  def _CheckMissingArchs(self, files_with_metadata):
+    tags = []
+    catalognames_by_arch = {}
+    # We check all the OS releases that are included in the file set.
+    # We won't report a missing i386-SunOS5.8 package if there was no
+    # SunOS5.8 package in the set.
+    osrels = set(x[1]["osrel"] for x in files_with_metadata)
+    # Prepopulate sets, so that we have one set per each arch-osrel pair
+    # that is applicable to this set of files.
+    for arch in common_constants.PHYSICAL_ARCHITECTURES:
+      for osrel in osrels:
+      	key = arch, osrel
+      	catalognames_by_arch[key] = set()
+    # Assign files from the set to appropriate set.
+    for file_path, file_metadata in files_with_metadata:
+      catalogname = file_metadata["catalogname"]
+      if file_metadata["arch"] == "all":
+        archs = common_constants.PHYSICAL_ARCHITECTURES
+      else:
+        archs = [file_metadata["arch"]]
+      osrel = file_metadata["osrel"]
+      for arch in archs:
+        key = arch, osrel
+        catalognames_by_arch[key].add(catalogname)
+    missing = {}
+    for key1, set1 in catalognames_by_arch.iteritems():
+      for catalogname in set1:
+        for key2, set2 in catalognames_by_arch.iteritems():
+          if catalogname not in set2:
+            arch, osrel = key2
+            missing_key = arch, osrel, catalogname
+            missing.setdefault(missing_key, set()).add(
+                "Because %s-%s-%s exists" % (catalogname, key1[0], key1[1]))
+    for arch, osrel, catalogname in missing:
+      error_tag_name = "%s-%s-missing" % (arch, osrel)
+      tags.append(tag.CheckpkgTag(None, error_tag_name, catalogname))
+    return tags
+
   def CheckFiles(self, file_list):
     """Checks a set of files. Returns error tags."""
-    catalognames_by_arch = {
-        "i386": set(),
-        "sparc": set(),
-    }
     files_with_metadata = []
     for file_path in file_list:
       pkg_path, basename = os.path.split(file_path)
       parsed = opencsw.ParsePackageFileName(basename)
+      catalogname = parsed["catalogname"]
       files_with_metadata.append((basename, parsed))
       if parsed["arch"] == "all":
-        for arch in ("i386", "sparc"):
-          catalognames_by_arch[arch].add(parsed["catalogname"])
+        archs = common_constants.PHYSICAL_ARCHITECTURES
       else:
-        catalognames_by_arch[parsed["arch"]].add(parsed["catalogname"])
-    i386 = catalognames_by_arch["i386"]
-    sparc = catalognames_by_arch["sparc"]
+        archs = [parsed["arch"]]
+      for arch in archs:
+        for osrel in common_constants.OS_RELS:
+          key = arch, osrel
+          # catalognames_by_arch.setdefault(key, set()).add(catalogname)
     tags = []
-    for catalogname in i386.difference(sparc):
-      tags.append(tag.CheckpkgTag(None, "sparc-arch-missing", catalogname))
-    for catalogname in sparc.difference(i386):
-      tags.append(tag.CheckpkgTag(None, "i386-arch-missing", catalogname))
+    tags.extend(self._CheckMissingArchs(files_with_metadata))
     tags.extend(self._CheckUncommitted(files_with_metadata))
     return tags
 

Modified: csw/mgar/gar/v2/lib/python/submit_to_newpkgs_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/submit_to_newpkgs_test.py	2011-04-02 12:03:40 UTC (rev 14051)
+++ csw/mgar/gar/v2/lib/python/submit_to_newpkgs_test.py	2011-04-02 12:04:15 UTC (rev 14052)
@@ -22,11 +22,23 @@
 
 class FileSetCheckerUnitTest(unittest.TestCase):
 
-  def testNsprFiles(self):
+  def testMissingArchitecture(self):
     fc = stn.FileSetChecker()
-    expected = [tag.CheckpkgTag(None, 'i386-arch-missing', 'libnspr4')]
+    expected = [tag.CheckpkgTag(None, 'i386-SunOS5.9-missing', 'libnspr4')]
     self.assertEqual(expected, fc.CheckFiles(SAMPLE_FILES))
 
+  def testMissingArchitectureWithOsrel(self):
+    files = [
+        'foo-1.0,REV=2011.03.30-SunOS5.9-i386-CSW.pkg.gz',
+        'foo-1.0,REV=2011.03.30-SunOS5.9-sparc-CSW.pkg.gz',
+        'foo-1.0,REV=2011.03.30-SunOS5.10-i386-CSW.pkg.gz',
+        # Intentionally missing
+        # 'foo-1.0,REV=2011.03.30-SunOS5.10-sparc-CSW.pkg.gz',
+    ]
+    fc = stn.FileSetChecker()
+    expected = [tag.CheckpkgTag(None, 'sparc-SunOS5.10-missing', 'foo')]
+    self.assertEqual(expected, fc.CheckFiles(files))
+
   def testUncommitted(self):
     fc = stn.FileSetChecker()
     expected = [


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