5 keep contents of binary packages in tables so we can generate contents.gz files from dak
7 @contact: Debian FTP Master <ftpmaster@debian.org>
8 @copyright: 2009 Mike O'Connor <stew@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 ################################################################################
32 from daklib.dak_exceptions import DBUpdateError
34 ################################################################################
37 add trigger to verify that bin_associations aren't added for an
38 illegal suite,arch combination. Fix override trigger, re-add all
45 c.execute("""CREATE OR REPLACE FUNCTION check_illegal_suite_arch()
48 if event == "UPDATE" or event == "INSERT":
50 r = plpy.execute(plpy.prepare( \"\"\"SELECT 1 from suite_architectures sa
51 JOIN binaries b ON b.architecture = sa.architecture
52 WHERE b.id = $1 and sa.suite = $2\"\"\",
54 [row["bin"], row["suite"]])
56 plpy.error("Illegal architecture for this suite")
58 $$ LANGUAGE plpythonu VOLATILE;""")
60 c.execute( """CREATE OR REPLACE FUNCTION update_contents_for_override() RETURNS trigger AS $$
64 otype = plpy.execute(plpy.prepare("SELECT type from override_type where id=$1",["int"]),[TD["new"]["type"]] )[0];
65 if otype["type"].endswith("deb"):
66 section = plpy.execute(plpy.prepare("SELECT section from section where id=$1",["int"]),[TD["new"]["section"]] )[0];
68 table_name = "%s_contents" % otype["type"]
69 plpy.execute(plpy.prepare("UPDATE %s set section=$1 where package=$2 and suite=$3" % table_name,
70 ["text","text","int"]),
75 $$ LANGUAGE plpythonu VOLATILE SECURITY DEFINER;
77 c.execute( "DROP TRIGGER IF EXISTS illegal_suite_arch_bin_associations_trigger on bin_associations;" )
79 c.execute( "DROP TRIGGER IF EXISTS bin_associations_contents_trigger ON bin_associations;" )
80 c.execute( "DROP TRIGGER IF EXISTS override_contents_trigger ON override;" )
82 c.execute( """CREATE TRIGGER bin_associations_contents_trigger
83 AFTER INSERT OR UPDATE OR DELETE ON bin_associations
84 FOR EACH ROW EXECUTE PROCEDURE update_contents_for_bin_a();""")
86 c.execute("""CREATE TRIGGER override_contents_trigger
87 AFTER UPDATE ON override
88 FOR EACH ROW EXECUTE PROCEDURE update_contents_for_override();""")
90 c.execute( """CREATE TRIGGER illegal_suite_arch_bin_associations_trigger
91 BEFORE INSERT OR UPDATE ON bin_associations
92 FOR EACH ROW EXECUTE PROCEDURE check_illegal_suite_arch();""")
94 c.execute("UPDATE config SET value = '31' WHERE name = 'db_revision'")
97 except psycopg2.ProgrammingError, msg:
99 raise DBUpdateError, "Unable to apply process-new update 31, rollback issued. Error message : %s" % (str(msg))