- 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:
+ # source must exist in suite X, or in some other suite that's
+ # mapped to X, recursively... silent-maps are counted too,
+ # unreleased-maps aren't.
+ maps = self.Cnf.ValueList("SuiteMappings")[:]
+ maps.reverse()
+ maps = [ m.split() for m in maps ]
+ maps = [ (x[1], x[2]) for x in maps
+ if x[0] == "map" or x[0] == "silent-map" ]
+ s = [suite]
+ for x in maps:
+ if x[1] in s and x[0] not in s:
+ s.append(x[0])
+
+ que = "SELECT s.version FROM source s JOIN src_associations sa ON (s.id = sa.source) JOIN suite su ON (sa.suite = su.id) WHERE s.source = '%s' AND (%s)" % (package, string.join(["su.suite_name = '%s'" % a for a in s], " OR "));
+ 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