7 @contact: Debian FTP Master <ftpmaster@debian.org>
8 @copyright: 2010 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 ################################################################################
28 ################################################################################
32 from daklib.dak_exceptions import DBUpdateError
34 ################################################################################
37 print "fix trigger for bin_contents so that it ignores non deb,udeb"
41 c.execute( """CREATE OR REPLACE FUNCTION update_contents_for_bin_a() RETURNS trigger AS $$
43 if event == "DELETE" or event == "UPDATE":
45 plpy.execute(plpy.prepare("DELETE FROM deb_contents WHERE binary_id=$1 and suite=$2",
47 [TD["old"]["bin"], TD["old"]["suite"]])
49 if event == "INSERT" or event == "UPDATE":
51 content_data = plpy.execute(plpy.prepare(
52 \"\"\"SELECT s.section, b.package, b.architecture, ot.type
54 JOIN override_type ot on o.type=ot.id
55 JOIN binaries b on b.package=o.package
56 JOIN files f on b.file=f.id
57 JOIN location l on l.id=f.location
58 JOIN section s on s.id=o.section
61 AND ot.type in ('deb','udeb')
64 [TD["new"]["bin"], TD["new"]["suite"]])[0]
66 tablename="%s_contents" % content_data['type']
68 plpy.execute(plpy.prepare(\"\"\"DELETE FROM %s
69 WHERE package=$1 and arch=$2 and suite=$3\"\"\" % tablename,
70 ['text','int','int']),
71 [content_data['package'],
72 content_data['architecture'],
75 filenames = plpy.execute(plpy.prepare(
76 "SELECT bc.file FROM bin_contents bc where bc.binary_id=$1",
80 for filename in filenames:
81 plpy.execute(plpy.prepare(
83 (filename,section,package,binary_id,arch,suite)
84 VALUES($1,$2,$3,$4,$5,$6)\"\"\" % tablename,
85 ["text","text","text","int","int","int"]),
87 content_data["section"],
88 content_data["package"],
90 content_data["architecture"],
92 $$ LANGUAGE plpythonu VOLATILE SECURITY DEFINER;
95 c.execute("UPDATE config SET value = '30' WHERE name = 'db_revision'")
98 except psycopg2.ProgrammingError, msg:
100 raise DBUpdateError, "Unable to appy debversion updates, rollback issued. Error message : %s" % (str(msg))