4 Helper functions for list generating commands (Packages, Sources).
6 @contact: Debian FTP Master <ftpmaster@debian.org>
7 @copyright: 2009-2011 Torsten Werner <twerner@debian.org>
8 @license: GNU General Public License version 2 or later
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 ################################################################################
27 from dbconn import get_architecture
29 def fetch(query, args, session):
30 for (id, path, filename) in session.execute(query, args).fetchall():
31 yield (id, path + filename)
33 def getSources(suite, component, session, timestamp = None):
35 Calculates the sources in suite and component optionally limited by
36 sources newer than timestamp. Returns a generator that yields a
37 tuple of source id and full pathname to the dsc file. See function
38 writeSourceList() in dak/generate_filelist.py for an example that
43 extra_cond = "AND extract(epoch from sa.created) > %d" % timestamp
45 SELECT s.id, l.path, f.filename
47 JOIN src_associations sa
48 ON s.id = sa.source AND sa.suite = :suite %s
52 ON f.location = l.id AND l.component = :component
55 args = { 'suite': suite.suite_id,
56 'component': component.component_id }
57 return fetch(query, args, session)
59 def getBinaries(suite, component, architecture, type, session, timestamp = None):
61 Calculates the binaries in suite and component of architecture and
62 type 'deb' or 'udeb' optionally limited to binaries newer than
63 timestamp. Returns a generator that yields a tuple of binary id and
64 full pathname to the u(deb) file. See function writeBinaryList() in
65 dak/generate_filelist.py for an example that uses this function.
69 extra_cond = "AND extract(epoch from ba.created) > %d" % timestamp
71 CREATE TEMP TABLE b_candidates (
75 architecture integer);
77 INSERT INTO b_candidates (id, source, file, architecture)
78 SELECT b.id, b.source, b.file, b.architecture
80 JOIN bin_associations ba ON b.id = ba.bin
81 WHERE b.type = :type AND ba.suite = :suite AND
82 b.architecture IN (:arch_all, :architecture) %s;
84 CREATE TEMP TABLE gf_candidates (
92 INSERT INTO gf_candidates (id, filename, path, architecture, src, source)
93 SELECT bc.id, f.filename, l.path, bc.architecture, bc.source as src, s.source
95 JOIN source s ON bc.source = s.id
96 JOIN files f ON bc.file = f.id
97 JOIN location l ON f.location = l.id
98 WHERE l.component = :component;
102 (SELECT id, path, filename FROM gf_candidates
103 WHERE architecture <> :arch_all),
106 (SELECT id, path, filename FROM gf_candidates
107 WHERE architecture = :arch_all AND
108 src IN (SELECT src FROM gf_candidates WHERE architecture <> :arch_all)),
110 arch_all_without_any AS
111 (SELECT id, path, filename FROM gf_candidates
112 WHERE architecture = :arch_all AND
113 source NOT IN (SELECT DISTINCT source FROM gf_candidates WHERE architecture <> :arch_all)),
116 (SELECT * FROM arch_any
118 SELECT * FROM arch_all_with_any
120 SELECT * FROM arch_all_without_any)
122 SELECT * FROM filelist ORDER BY filename
124 args = { 'suite': suite.suite_id,
125 'component': component.component_id,
126 'architecture': architecture.arch_id,
127 'arch_all': get_architecture('all', session).arch_id,
129 return fetch(query, args, session)