X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fqueue.py;h=dfbe36853490c8b9b99c72eebb50daa45d60c9de;hb=d7b90c4606e6f4fe32965d3c77d8f5f7428b7168;hp=fa0925470993f005525d448d07a5f0f8b093015f;hpb=f92dee5ccd013494f09f20454eb027d6f8e1d8f7;p=dak.git diff --git a/daklib/queue.py b/daklib/queue.py index fa092547..dfbe3685 100755 --- a/daklib/queue.py +++ b/daklib/queue.py @@ -53,9 +53,18 @@ from dbconn import * from summarystats import SummaryStats from utils import parse_changes, check_dsc_files from textutils import fix_maintainer -from binary import Binary from lintian import parse_lintian_output, generate_reject_messages +# suppress some deprecation warnings in squeeze related to apt_pkg +# module +import warnings +warnings.filterwarnings('ignore', \ + "apt_pkg.ParseSection\(\) is deprecated. Please see apt_pkg\.TagSection\(\) for the replacement\.", \ + DeprecationWarning) +warnings.filterwarnings('ignore', \ + "Attribute 'Find' of the 'apt_pkg\.TagSection' object is deprecated, use 'find' instead\.", \ + DeprecationWarning) + ############################################################################### def get_type(f, session): @@ -383,7 +392,7 @@ def get_newest_source(source, session): order_by(desc('source.version')) return q.first() -def get_suite_version(source, session): +def get_suite_version_by_source(source, session): 'returns a list of tuples (suite_name, version) for source package' q = session.query(Suite.suite_name, DBSource.version). \ join(Suite.sources).filter_by(source = source) @@ -398,6 +407,16 @@ def get_source_by_package_and_suite(package, suite_name, session): join(DBSource.binaries).filter_by(package = package). \ join(DBBinary.suites).filter_by(suite_name = suite_name) +def get_suite_version_by_package(package, arch_string, session): + ''' + returns a list of tuples (suite_name, version) for binary package and + arch_string + ''' + return session.query(Suite.suite_name, DBBinary.version). \ + join(Suite.binaries).filter_by(package = package). \ + join(DBBinary.architecture). \ + filter(Architecture.arch_string.in_([arch_string, 'all'])).all() + class Upload(object): """ Everything that has to do with an upload processed. @@ -753,6 +772,30 @@ class Upload(object): if not re_valid_pkg_name.match(prov): self.rejects.append("%s: Invalid Provides field content %s." % (f, prov)) + # If there is a Built-Using field, we need to check we can find the + # exact source version + built_using = control.Find("Built-Using") + if built_using: + try: + entry["built-using"] = [] + for dep in apt_pkg.parse_depends(built_using): + bu_s, bu_v, bu_e = dep[0] + # Check that it's an exact match dependency and we have + # some form of version + if bu_e != "=" or len(bu_v) < 1: + self.rejects.append("%s: Built-Using contains non strict dependency (%s %s %s)" % (f, bu_s, bu_e, bu_v)) + else: + # Find the source id for this version + bu_so = get_sources_from_name(bu_s, version=bu_v, session = session) + if len(bu_so) != 1: + self.rejects.append("%s: Built-Using (%s = %s): Cannot find source package" % (f, bu_s, bu_v)) + else: + entry["built-using"].append( (bu_so[0].source, bu_so[0].version, ) ) + + except ValueError, e: + self.rejects.append("%s: Cannot parse Built-Using field: %s" % (f, str(e))) + + # Check the section & priority match those given in the .changes (non-fatal) if control.Find("Section") and entry["section"] != "" \ and entry["section"] != control.Find("Section"): @@ -846,13 +889,6 @@ class Upload(object): # Check the version and for file overwrites self.check_binary_against_db(f, session) - # Temporarily disable contents generation until we change the table storage layout - #b = Binary(f) - #b.scan_package() - #if len(b.rejects) > 0: - # for j in b.rejects: - # self.rejects.append(j) - def source_file_checks(self, f, session): entry = self.pkg.files[f] @@ -962,9 +998,11 @@ class Upload(object): # Check for packages that have moved from one component to another entry['suite'] = suite - res = get_binary_components(self.pkg.files[f]['package'], suite, entry["architecture"], session) - if res.rowcount > 0: - entry["othercomponents"] = res.fetchone()[0] + arch_list = [entry["architecture"], 'all'] + component = get_component_by_package_suite(self.pkg.files[f]['package'], \ + [suite], arch_list = arch_list, session = session) + if component is not None: + entry["othercomponents"] = component def check_files(self, action=True): file_keys = self.pkg.files.keys() @@ -2504,12 +2542,10 @@ distribution.""" ################################################################################ def check_binary_against_db(self, filename, session): # Ensure version is sane - q = session.query(BinAssociation) - q = q.join(DBBinary).filter(DBBinary.package==self.pkg.files[filename]["package"]) - q = q.join(Architecture).filter(Architecture.arch_string.in_([self.pkg.files[filename]["architecture"], 'all'])) - - self.cross_suite_version_check([ (x.suite.suite_name, x.binary.version) for x in q.all() ], - filename, self.pkg.files[filename]["version"], sourceful=False) + self.cross_suite_version_check( \ + get_suite_version_by_package(self.pkg.files[filename]["package"], \ + self.pkg.files[filename]["architecture"], session), + filename, self.pkg.files[filename]["version"], sourceful=False) # Check for any existing copies of the file q = session.query(DBBinary).filter_by(package=self.pkg.files[filename]["package"]) @@ -2526,8 +2562,9 @@ distribution.""" version = self.pkg.dsc.get("version") # Ensure version is sane - self.cross_suite_version_check(get_suite_version(source, session), - filename, version, sourceful=True) + self.cross_suite_version_check( \ + get_suite_version_by_source(source, session), filename, version, + sourceful=True) ################################################################################ def check_dsc_against_db(self, filename, session):