From: Ansgar Burchardt Date: Thu, 24 Mar 2011 16:35:45 +0000 (+0000) Subject: Move version_checks to the database X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=ca14da13a68f3c03000ec77cf3855980e80007c9;p=dak.git Move version_checks to the database No longer use Suite::*::VersionCheck::* from the configuration file. Instead move these settings to the version_checks table. Signed-off-by: Ansgar Burchardt --- diff --git a/daklib/dbconn.py b/daklib/dbconn.py index 6317b584..bd235617 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -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 diff --git a/daklib/queue.py b/daklib/queue.py index 52483cca..a1ab43ef 100755 --- a/daklib/queue.py +++ b/daklib/queue.py @@ -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: