X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=katie.py;h=bee2c03e63b431a4ac00cf85403244d36f52f6df;hb=c5617d291dc17395a9d23c757d7dc815f6eed49e;hp=fc691a62b9f25e774deaa26d2f4822f6276f2977;hpb=599caeee8541b68797a3b20262b40d179091f6b4;p=dak.git diff --git a/katie.py b/katie.py index fc691a62..bee2c03e 100644 --- a/katie.py +++ b/katie.py @@ -2,7 +2,7 @@ # Utility functions for katie # Copyright (C) 2001, 2002, 2003 James Troup -# $Id: katie.py,v 1.32 2003-04-08 18:44:21 troup Exp $ +# $Id: katie.py,v 1.36 2003-07-29 14:57:03 ajt Exp $ # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -601,28 +601,37 @@ distribution."""; # (2) Bin-only NMU of an MU => 1.0-3.0.1 # (3) Bin-only NMU of a sourceful-NMU => 1.0-3.1.1 - def source_exists (self, package, source_version): - q = self.projectB.query("SELECT s.version FROM source s WHERE s.source = '%s'" % (package)); - - # Reduce the query results to a list of version numbers - ql = map(lambda x: x[0], q.getresult()); - - # Try (1) - if ql.count(source_version): - return 1; - - # Try (2) - orig_source_version = re_bin_only_nmu_of_mu.sub('', source_version); - if ql.count(orig_source_version): - return 1; - - # Try (3) - orig_source_version = re_bin_only_nmu_of_nmu.sub('', source_version); - if ql.count(orig_source_version): - return 1; - - # No source found... - return 0; + def source_exists (self, package, source_version, suites = ["any"]): + okay = 1 + for suite in suites: + if suite == "any": + que = "SELECT s.version FROM source s WHERE s.source = '%s'" % \ + (package) + else: + suite_id = db_access.get_suite_id(suite); + que = "SELECT s.version FROM source s JOIN src_associations sa ON (s.id = sa.source) WHERE sa.suite = %d AND s.source = '%s'" % (suite_id, package) + q = self.projectB.query(que) + + # Reduce the query results to a list of version numbers + ql = map(lambda x: x[0], q.getresult()); + + # Try (1) + if ql.count(source_version): + continue + + # Try (2) + orig_source_version = re_bin_only_nmu_of_mu.sub('', source_version) + if ql.count(orig_source_version): + continue + + # Try (3) + orig_source_version = re_bin_only_nmu_of_nmu.sub('', source_version) + if ql.count(orig_source_version): + continue + + # No source found... + okay = 0 + return okay ################################################################################ @@ -746,6 +755,14 @@ SELECT s.version, su.suite_name FROM source s, src_associations sa, suite su ################################################################################ + # **WARNING** + # NB: this function can remove entries from the 'files' index [if + # the .orig.tar.gz is a duplicate of the one in the archive]; if + # you're iterating over 'files' and call this function as part of + # the loop, be sure to add a check to the top of the loop to + # ensure you haven't just tried to derefernece the deleted entry. + # **WARNING** + def check_dsc_against_db(self, file): self.reject_message = ""; files = self.pkg.files; @@ -763,13 +780,13 @@ SELECT s.version, su.suite_name FROM source s, src_associations sa, suite su actual_size = int(files[dsc_file]["size"]); found = "%s in incoming" % (dsc_file) # Check the file does not already exist in the archive - q = self.projectB.query("SELECT f.size, f.md5sum FROM files f WHERE f.filename LIKE '%%%s%%'" % (dsc_file)); + q = self.projectB.query("SELECT size, md5sum, filename FROM files WHERE filename LIKE '%%%s%%'" % (dsc_file)); ql = q.getresult(); # Strip out anything that isn't '%s' or '/%s$' for i in ql: - if i[0] != dsc_file and i[0][-(len(dsc_file)+1):] != '/'+dsc_file: - self.Logger.log(["check_dsc_against_db",i[0],dsc_file]); + if i[2] != dsc_file and i[2][-(len(dsc_file)+1):] != '/'+dsc_file: + self.Logger.log(["check_dsc_against_db",i[2],dsc_file]); ql.remove(i); # "[katie] has not broken them. [katie] has fixed a