- AND sec.id = o.section AND NOT (f.filename ~ '^potato/')
- AND b.architecture = a.id AND l.component = c.id
-UNION SELECT DISTINCT ON (f.id) null, a.arch_string, sec.section, b.package,
- b.version, l.path, f.filename, f.id
- FROM architecture a, bin_associations ba, binaries b, component c, files f,
- location l, override o, section sec, suite su
- WHERE su.suite_name = 'stable' AND ba.suite = su.id AND ba.bin = b.id
- AND f.id = b.file AND f.location = l.id AND o.package = b.package
- AND sec.id = o.section AND NOT (f.filename ~ '^potato/')
- AND b.architecture = a.id AND NOT EXISTS
- (SELECT l.path FROM location l WHERE l.component IS NOT NULL AND f.location = l.id);
-""");
+ AND sec.id = o.section AND NOT (f.filename ~ '^%s/')
+ AND b.architecture = a.id AND l.component = c.id AND o.suite = su.id""" %
+ (codename));
+# Only needed if you have files in legacy-mixed locations
+# UNION SELECT DISTINCT ON (f.id) null, a.arch_string, sec.section, b.package,
+# b.version, l.path, f.filename, f.id
+# FROM architecture a, bin_associations ba, binaries b, component c, files f,
+# location l, override o, section sec, suite su
+# WHERE su.suite_name = 'stable' AND ba.suite = su.id AND ba.bin = b.id
+# AND f.id = b.file AND f.location = l.id AND o.package = b.package
+# AND sec.id = o.section AND NOT (f.filename ~ '^%s/')
+# AND b.architecture = a.id AND o.suite = su.id AND NOT EXISTS
+# (SELECT 1 FROM location l WHERE l.component IS NOT NULL AND f.location = l.id);