]> err.no Git - dak/commitdiff
Move version_checks to the database
authorAnsgar Burchardt <ansgar@debian.org>
Thu, 24 Mar 2011 16:35:45 +0000 (16:35 +0000)
committerAnsgar Burchardt <ansgar@debian.org>
Thu, 24 Mar 2011 16:35:45 +0000 (16:35 +0000)
No longer use Suite::*::VersionCheck::* from the configuration file.
Instead move these settings to the version_checks table.

Signed-off-by: Ansgar Burchardt <ansgar@debian.org>
daklib/dbconn.py
daklib/queue.py

index 6317b5844467a260865d5c7c67996eda537d7822..bd2356176e49e3d75fce13f67e6bed005dff71ec 100755 (executable)
@@ -3021,6 +3021,33 @@ __all__.append('SourceMetadata')
 
 ################################################################################
 
+class VersionCheck(ORMObject):
+    def __init__(self, *args, **kwargs):
+       pass
+
+    def properties(self):
+        #return ['suite_id', 'check', 'reference_id']
+        return ['check']
+
+    def not_null_constraints(self):
+        return ['suite', 'check', 'reference']
+
+__all__.append('VersionCheck')
+
+@session_wrapper
+def get_version_checks(suite_name, check = None, session = None):
+    suite = get_suite(suite_name, session)
+    if not suite:
+        return None
+    q = session.query(VersionCheck).filter_by(suite=suite)
+    if check:
+        q = q.filter_by(check=check)
+    return q.all()
+
+__all__.append('get_version_checks')
+
+################################################################################
+
 class DBConn(object):
     """
     database module init.
@@ -3085,6 +3112,7 @@ class DBConn(object):
             'suite_src_formats',
             'uid',
             'upload_blocks',
+            'version_check',
         )
 
         views = (
@@ -3401,6 +3429,13 @@ class DBConn(object):
                 key = relation(MetadataKey),
                 value = self.tbl_source_metadata.c.value))
 
+       mapper(VersionCheck, self.tbl_version_check,
+           properties = dict(
+               suite_id = self.tbl_version_check.c.suite,
+               suite = relation(Suite, primaryjoin=self.tbl_version_check.c.suite==self.tbl_suite.c.id),
+               reference_id = self.tbl_version_check.c.reference,
+               reference = relation(Suite, primaryjoin=self.tbl_version_check.c.reference==self.tbl_suite.c.id, lazy='joined')))
+
     ## Connection functions
     def __createconn(self):
         from config import Config
index 52483cca4bd8dc0d53b2f6b95670f250ef3d2b9e..a1ab43ef531774e2f697ad360db264b3b765d508 100755 (executable)
@@ -2467,7 +2467,7 @@ distribution."""
         """
         Cnf = Config()
         anyversion = None
-        anysuite = [suite] + Cnf.ValueList("Suite::%s::VersionChecks::Enhances" % (suite))
+        anysuite = [suite] + [ vc.reference.suite_name for vc in get_version_checks(suite, "Enhances") ]
         for (s, v) in sv_list:
             if s in [ x.lower() for x in anysuite ]:
                 if not anyversion or apt_pkg.VersionCompare(anyversion, v) <= 0:
@@ -2497,8 +2497,8 @@ distribution."""
 
         # Check versions for each target suite
         for target_suite in self.pkg.changes["distribution"].keys():
-            must_be_newer_than = [ i.lower() for i in cnf.ValueList("Suite::%s::VersionChecks::MustBeNewerThan" % (target_suite)) ]
-            must_be_older_than = [ i.lower() for i in cnf.ValueList("Suite::%s::VersionChecks::MustBeOlderThan" % (target_suite)) ]
+            must_be_newer_than = [ vc.reference.suite_name for vc in get_version_checks(target_suite, "MustBeNewerThan") ]
+            must_be_older_than = [ vc.reference.suite_name for vc in get_version_checks(target_suite, "MustBeOlderThan") ]
 
             # Enforce "must be newer than target suite" even if conffile omits it
             if target_suite not in must_be_newer_than: