5 new views binary_component, source_component and package_list
7 @contact: Debian FTP Master <ftpmaster@debian.org>
8 @copyright: 2014, Ansgar Burchardt <ansgar@debian.org>
9 @license: GNU General Public License version 2 or later
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2 of the License, or
15 # (at your option) any later version.
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 ################################################################################
29 from daklib.dak_exceptions import DBUpdateError
30 from daklib.config import Config
34 CREATE OR REPLACE VIEW source_component AS
38 af.component_id AS component_id
40 JOIN src_associations sa ON s.id = sa.source
41 JOIN suite ON sa.suite = suite.id
42 JOIN files_archive_map af ON s.file = af.file_id AND suite.archive_id = af.archive_id
45 COMMENT ON VIEW source_component IS 'Map (source_id, suite_id) to the component(s) that the source is included in. Note that this view might return more components than expected as we can only query the component for (source_id, archive_id).'
47 "GRANT SELECT ON source_component TO PUBLIC",
50 CREATE OR REPLACE VIEW binary_component AS
54 af.component_id AS component_id
56 JOIN bin_associations ba ON b.id = ba.bin
57 JOIN suite ON ba.suite = suite.id
58 JOIN files_archive_map af ON b.file = af.file_id AND suite.archive_id = af.archive_id
61 COMMENT ON VIEW binary_component IS 'Map (binary_id, suite_id) to the component(s) that the binary is included in. Note that this view might return more components than expected as we can only query the component for (binary_id, archive_id).'
63 "GRANT SELECT ON binary_component TO PUBLIC",
66 CREATE OR REPLACE VIEW package_list AS
72 suite.suite_name AS suite,
73 archive.name AS archive,
74 component.name AS component,
76 WHEN 'main' THEN suite.suite_name
77 ELSE CONCAT(suite.suite_name, '/', component.name)
79 tmp.architecture_is_source,
87 s.version AS source_version,
89 TRUE AS architecture_is_source,
90 'source' AS architecture,
94 JOIN src_associations sa ON s.id = sa.source
95 JOIN source_component sc ON s.id = sc.source_id AND sa.suite = sc.suite_id
101 s.version AS source_version,
102 ba.suite AS suite_id,
103 FALSE AS architecture_is_source,
104 a.arch_string AS architecture,
108 JOIN source s ON b.source = s.id
109 JOIN architecture a ON b.architecture = a.id
110 JOIN bin_associations ba ON b.id = ba.bin
111 JOIN binary_component bc ON b.id = bc.binary_id AND ba.suite = bc.suite_id) AS tmp
112 JOIN suite ON tmp.suite_id = suite.id
113 JOIN archive ON suite.archive_id = archive.id
114 JOIN component ON tmp.component_id = component.id
116 "GRANT SELECT ON package_list TO PUBLIC"
119 ################################################################################
127 for stmt in statements:
130 c.execute("UPDATE config SET value = '106' WHERE name = 'db_revision'")
133 except psycopg2.ProgrammingError as msg:
135 raise DBUpdateError('Unable to apply sick update 106, rollback issued. Error message: {0}'.format(msg))