[csw-devel] SF.net SVN: gar:[12042] csw/mgar/gar/v2/lib/python
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Mon Dec 20 14:37:52 CET 2010
Revision: 12042
http://gar.svn.sourceforge.net/gar/?rev=12042&view=rev
Author: wahwah
Date: 2010-12-20 13:37:51 +0000 (Mon, 20 Dec 2010)
Log Message:
-----------
checkpkg: Dependencies recorded at registration
The database rows representing package dependencies should not be inserted
during data collection, but during the registration stage.
It also ensures the idempotence of the operation, cleaning potential old
dependencies before registering.
Modified Paths:
--------------
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/package_stats.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_stats.py 2010-12-20 13:23:39 UTC (rev 12041)
+++ csw/mgar/gar/v2/lib/python/package_stats.py 2010-12-20 13:37:51 UTC (rev 12042)
@@ -377,13 +377,6 @@
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
# self.DumpObject(self.GetLddMinusRlines(), "ldd_dash_r")
@@ -435,6 +428,19 @@
line=line_u,
pkginst=pkginst,
srv4_file=stats)
+ # Save dependencies in the database. First remove any dependency rows
+ # that might be in the database.
+ # TODO(maciej): Unit test it
+ deps_res = m.Srv4DependsOn.select(
+ m.Srv4DependsOn.q.srv4_file==stats)
+ for dep_obj in deps_res:
+ dep_obj.destroySelf()
+ for dep_pkgname, unused_desc in pkg_stats["depends"]:
+ dep_pkginst = cls.GetOrSetPkginst(dep_pkgname)
+ obj = m.Srv4DependsOn(
+ srv4_file=stats,
+ pkginst=dep_pkginst)
+
# At this point, we've registered the srv4 file.
# Setting the registered bit to True
stats.registered = True
Modified: csw/mgar/gar/v2/lib/python/package_stats_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_stats_test.py 2010-12-20 13:23:39 UTC (rev 12041)
+++ csw/mgar/gar/v2/lib/python/package_stats_test.py 2010-12-20 13:37:51 UTC (rev 12042)
@@ -236,17 +236,41 @@
self.assertEquals("CSWtree", o.pkgname)
self.assertEquals("bad-rpath-entry", o.tag_name)
- def testImportDependencies(self):
+ def testSaveStatsDependencies(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())
+ # Dependencies should not be inserted into the db at that stage
+ self.assertEquals(0, len(depends))
+
+ def testImportPkgDependencies(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.ImportPkg(new_stats)
+ depends = list(m.Srv4DependsOn.select())
+ # Dependencies should be inserted into the db at that stage
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 testImportPkgDependenciesReplace(self):
+ """Make sure deps are not imported twice."""
+ md5_sum = tree_stats[0]["basic_stats"]["md5_sum"]
+ self.assertEqual(u'1e43fa1c7e637b25d9356ad516ae0403', md5_sum)
+ new_stats = copy.deepcopy(tree_stats[0])
+ self.TestPackageStats.ImportPkg(new_stats)
+ self.TestPackageStats.ImportPkg(new_stats, replace=True)
+ depends = list(m.Srv4DependsOn.select())
+ # Dependencies should be inserted into the db at that stage
+ 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