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

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Mon Dec 20 12:57:03 CET 2010


Revision: 12033
          http://gar.svn.sourceforge.net/gar/?rev=12033&view=rev
Author:   wahwah
Date:     2010-12-20 11:57:03 +0000 (Mon, 20 Dec 2010)

Log Message:
-----------
checkpkg: Representing dependencies in the DB

Dependencies are sometimes need to be accessed without unpickling the
whole data structure.  Storing them in a special table.

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/python/database.py
    csw/mgar/gar/v2/lib/python/models.py
    csw/mgar/gar/v2/lib/python/package_stats.py
    csw/mgar/gar/v2/lib/python/package_stats_test.py

Modified: csw/mgar/gar/v2/lib/python/database.py
===================================================================
--- csw/mgar/gar/v2/lib/python/database.py	2010-12-20 11:56:26 UTC (rev 12032)
+++ csw/mgar/gar/v2/lib/python/database.py	2010-12-20 11:57:03 UTC (rev 12033)
@@ -24,6 +24,7 @@
             m.Maintainer,
             m.OsRelease,
             m.Pkginst,
+            m.Srv4DependsOn,
             m.Srv4FileInCatalog,
             m.Srv4FileStats,
             m.Srv4FileStatsBlob)

Modified: csw/mgar/gar/v2/lib/python/models.py
===================================================================
--- csw/mgar/gar/v2/lib/python/models.py	2010-12-20 11:56:26 UTC (rev 12032)
+++ csw/mgar/gar/v2/lib/python/models.py	2010-12-20 11:57:03 UTC (rev 12033)
@@ -226,3 +226,11 @@
   uniqueness_idx = sqlobject.DatabaseIndex(
           'arch', 'osrel', 'catrel', 'srv4file',
           unique=True)
+
+
+class Srv4DependsOn(sqlobject.SQLObject):
+  """Models dependencies."""
+  srv4_file = sqlobject.ForeignKey('Srv4FileStats', notNone=True)
+  pkginst = sqlobject.ForeignKey('Pkginst', notNone=True)
+  dep_uniq_idx = sqlobject.DatabaseIndex(
+      'srv4_file', 'pkginst')

Modified: csw/mgar/gar/v2/lib/python/package_stats.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_stats.py	2010-12-20 11:56:26 UTC (rev 12032)
+++ csw/mgar/gar/v2/lib/python/package_stats.py	2010-12-20 11:57:03 UTC (rev 12033)
@@ -377,6 +377,12 @@
     for override_dict in pkg_stats["overrides"]:
       o = m.CheckpkgOverride(srv4_file=db_pkg_stats,
                              **override_dict)
+    # Save dependencies in the database
+    for dep_pkgname, unused_desc in pkg_stats["depends"]:
+      dep_pkginst = cls.GetOrSetPkginst(dep_pkgname)
+      obj = m.Srv4DependsOn(
+          srv4_file=db_pkg_stats,
+          pkginst=dep_pkginst)
 
     # The ldd -r reporting breaks on bigger packages during yaml saving.
     # It might work when yaml is disabled

Modified: csw/mgar/gar/v2/lib/python/package_stats_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_stats_test.py	2010-12-20 11:56:26 UTC (rev 12032)
+++ csw/mgar/gar/v2/lib/python/package_stats_test.py	2010-12-20 11:57:03 UTC (rev 12033)
@@ -236,6 +236,17 @@
     self.assertEquals("CSWtree", o.pkgname)
     self.assertEquals("bad-rpath-entry", o.tag_name)
 
+  def testImportDependencies(self):
+    md5_sum = tree_stats[0]["basic_stats"]["md5_sum"]
+    self.assertEqual(u'1e43fa1c7e637b25d9356ad516ae0403', md5_sum)
+    new_stats = copy.deepcopy(tree_stats[0])
+    self.TestPackageStats.SaveStats(new_stats)
+    depends = list(m.Srv4DependsOn.select())
+    self.assertEquals(1, len(depends))
+    dep = depends[0]
+    self.assertEquals(md5_sum, dep.srv4_file.md5_sum)
+    self.assertEquals(u"CSWcommon", dep.pkginst.pkgname)
+
   def testImportPkg(self):
     """Registers the package in the database."""
     package_stats.PackageStats.ImportPkg(neon_stats[0])


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