+++ /dev/null
-#!/usr/bin/env python
-
-"""
-Saner DM db schema
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2008 Michael Casadevall <mcasadevall@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-# <tomv_w> really, if we want to screw ourselves, let's find a better way.
-# <Ganneff> rm -rf /srv/ftp.debian.org
-
-################################################################################
-
-import psycopg2
-import time
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-
-def do_update(self):
- print "Adding DM fields to database"
-
- try:
- c = self.db.cursor()
- c.execute("ALTER TABLE source ADD COLUMN dm_upload_allowed BOOLEAN DEFAULT 'no' NOT NULL;")
- c.execute("ALTER TABLE keyrings ADD COLUMN debian_maintainer BOOLEAN DEFAULT 'false' NOT NULL;")
-
- print "Migrating DM data to source table. This might take some time ..."
-
- c.execute("UPDATE source SET dm_upload_allowed = 't' WHERE id IN (SELECT source FROM src_uploaders);")
- c.execute("UPDATE config SET value = '1' WHERE name = 'db_revision'")
-
- print "Migrating DM uids to normal uids"
- c.execute("SELECT uid FROM uid WHERE uid LIKE 'dm:%'")
- rows = c.fetchall()
- for r in rows:
- uid = r[0]
- c.execute("UPDATE uid SET uid = '%s' WHERE uid = '%s'" % (uid[3:], uid))
-
- self.db.commit()
-
- print "IMPORTANT: Set the debian_maintainer flag in the config file for keyrings that are DMs!"
- print " Failure to do so will result in DM's having full upload abilities!"
- print "REMINDER: Remember to run the updated byhand-dm crontab to update Debian Maintainer information"
- print ""
- print "Pausing for five seconds ..."
- time.sleep (5)
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError("Unable to appy DM table updates, rollback issued. Error message : %s" % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Add constraints to src_uploaders
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2009 Mark Hymers <mhy@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-# <mhy> oh no, Ganneff has just corrected my english
-
-################################################################################
-
-import psycopg2
-import time
-from daklib.dak_exceptions import DBUpdateError
-from daklib.utils import get_conf
-
-################################################################################
-
-def do_update(self):
- print "Add constraints to src_uploaders"
- Cnf = get_conf()
-
- try:
- c = self.db.cursor()
- # Deal with out-of-date src_uploaders entries
- c.execute("DELETE FROM src_uploaders WHERE source NOT IN (SELECT id FROM source)")
- c.execute("DELETE FROM src_uploaders WHERE maintainer NOT IN (SELECT id FROM maintainer)")
- # Add constraints
- c.execute("ALTER TABLE src_uploaders ADD CONSTRAINT src_uploaders_maintainer FOREIGN KEY (maintainer) REFERENCES maintainer(id) ON DELETE CASCADE")
- c.execute("ALTER TABLE src_uploaders ADD CONSTRAINT src_uploaders_source FOREIGN KEY (source) REFERENCES source(id) ON DELETE CASCADE")
- c.execute("UPDATE config SET value = '10' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError("Unable to apply suite config updates, rollback issued. Error message : %s" % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Adding process-new comments to the DB
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2009 Joerg Jaspert <joerg@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-
-################################################################################
-
-import psycopg2
-import time
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-
-def do_update(self):
- print "Adding process-new comments to the DB"
-
- try:
- c = self.db.cursor()
- c.execute("""CREATE TABLE new_comments (
- id SERIAL PRIMARY KEY NOT NULL,
- package TEXT NOT NULL,
- version TEXT NOT NULL,
- comment TEXT NOT NULL,
- author TEXT NOT NULL
- )""")
-
- c.execute("GRANT SELECT ON new_comments TO ftptrainee;")
- c.execute("GRANT INSERT ON new_comments TO ftptrainee;")
- c.execute("GRANT UPDATE ON new_comments TO ftptrainee;")
- c.execute("GRANT SELECT ON new_comments TO ftpteam;")
- c.execute("GRANT INSERT ON new_comments TO ftpteam;")
- c.execute("GRANT UPDATE ON new_comments TO ftpteam;")
- c.execute("GRANT ALL ON new_comments TO ftpmaster;")
-
- c.execute("UPDATE config SET value = '11' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError("Unable to apply process-new comments update, rollback issued. Error message : %s" % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Adding a date field to the process-new notes
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2009 Joerg Jaspert <joerg@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-
-################################################################################
-
-import psycopg2
-import time
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-
-def do_update(self):
- print "Adding a date field to the process-new notes"
-
- try:
- c = self.db.cursor()
- c.execute("ALTER TABLE new_comments ADD COLUMN notedate TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now()")
-
- c.execute("UPDATE config SET value = '12' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError("Unable to apply process-new update 12, rollback issued. Error message : %s" % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Adding a trainee field to the process-new notes
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2009 Joerg Jaspert <joerg@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-
-################################################################################
-
-import psycopg2
-import time
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-
-def do_update(self):
- print "Adding a trainee field to the process-new notes"
-
- try:
- c = self.db.cursor()
- c.execute("ALTER TABLE new_comments ADD COLUMN trainee BOOLEAN NOT NULL DEFAULT false")
-
- c.execute("UPDATE config SET value = '13' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError("Unable to apply process-new update 13, rollback issued. Error message : %s" % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Make sure we always have primary keys
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2009 Mark Hymers <mhy@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-
-################################################################################
-
-import psycopg2
-import time
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-
-def do_update(self):
- print "Adding primary keys to various tables"
-
- try:
- c = self.db.cursor()
- c.execute("ALTER TABLE content_associations ADD PRIMARY KEY (id)")
- c.execute("ALTER TABLE override ADD PRIMARY KEY (suite, component, package, type)")
- c.execute("ALTER TABLE pending_content_associations ADD PRIMARY KEY (id)")
- c.execute("ALTER TABLE queue_build ADD PRIMARY KEY (suite, queue, filename)")
- c.execute("ALTER TABLE suite_architectures ADD PRIMARY KEY (suite, architecture)")
-
- c.execute("UPDATE config SET value = '14' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError("Unable to apply process-new update 14, rollback issued. Error message : %s" % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Adding table for allowed source formats
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2009 Raphael Hertzog <hertzog@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-
-################################################################################
-
-import psycopg2
-import time
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-
-def do_update(self):
- print "Adding tables listing allowed source formats"
-
- try:
- c = self.db.cursor()
- c.execute("""
- CREATE TABLE src_format (
- id SERIAL PRIMARY KEY,
- format_name TEXT NOT NULL,
- UNIQUE (format_name)
- )
- """)
- c.execute("INSERT INTO src_format (format_name) VALUES('1.0')")
- c.execute("INSERT INTO src_format (format_name) VALUES('3.0 (quilt)')")
- c.execute("INSERT INTO src_format (format_name) VALUES('3.0 (native)')")
-
- c.execute("""
- CREATE TABLE suite_src_formats (
- suite INT4 NOT NULL REFERENCES suite(id),
- src_format INT4 NOT NULL REFERENCES src_format(id),
- PRIMARY KEY (suite, src_format)
- )
- """)
-
- print "Authorize format 1.0 on all suites by default"
- c.execute("SELECT id FROM suite")
- suites = c.fetchall()
- c.execute("SELECT id FROM src_format WHERE format_name = '1.0'")
- formats = c.fetchall()
- for s in suites:
- for f in formats:
- c.execute("INSERT INTO suite_src_formats (suite, src_format) VALUES(%s, %s)", (s[0], f[0]))
-
- print "Authorize all other formats on tpu, unstable & experimental by default"
- c.execute("SELECT id FROM suite WHERE suite_name IN ('testing-proposed-updates', 'unstable', 'experimental')")
- suites = c.fetchall()
- c.execute("SELECT id FROM src_format WHERE format_name != '1.0'")
- formats = c.fetchall()
- for s in suites:
- for f in formats:
- c.execute("INSERT INTO suite_src_formats (suite, src_format) VALUES(%s, %s)", (s[0], f[0]))
-
- c.execute("UPDATE config SET value = '15' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError("Unable to apply source format update 15, rollback issued. Error message : %s" % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Adding tables for key-based ACLs and blocks
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2009 Mark Hymers <mhy@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-
-################################################################################
-
-import psycopg2
-import time
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-
-def do_update(self):
- print "Adding tables for handling key-based ACLs and upload blocks"
-
- try:
- c = self.db.cursor()
-
- # Fix up some older table permissions
- c.execute("GRANT SELECT ON src_format TO public")
- c.execute("GRANT ALL ON src_format TO ftpmaster")
- c.execute("GRANT USAGE ON src_format_id_seq TO ftpmaster")
-
- c.execute("GRANT SELECT ON suite_src_formats TO public")
- c.execute("GRANT ALL ON suite_src_formats TO ftpmaster")
-
- # Source ACLs table
- print "Source ACLs table"
- c.execute("""
- CREATE TABLE source_acl (
- id SERIAL PRIMARY KEY,
- access_level TEXT UNIQUE NOT NULL
- )
- """)
-
- ## Can upload all packages
- c.execute("INSERT INTO source_acl (access_level) VALUES ('full')")
- ## Can upload only packages marked as DM upload allowed
- c.execute("INSERT INTO source_acl (access_level) VALUES ('dm')")
-
- c.execute("GRANT SELECT ON source_acl TO public")
- c.execute("GRANT ALL ON source_acl TO ftpmaster")
- c.execute("GRANT USAGE ON source_acl_id_seq TO ftpmaster")
-
- # Binary ACLs table
- print "Binary ACLs table"
- c.execute("""
- CREATE TABLE binary_acl (
- id SERIAL PRIMARY KEY,
- access_level TEXT UNIQUE NOT NULL
- )
- """)
-
- ## Can upload any architectures of binary packages
- c.execute("INSERT INTO binary_acl (access_level) VALUES ('full')")
- ## Can upload debs where architectures are based on the map table binary_acl_map
- c.execute("INSERT INTO binary_acl (access_level) VALUES ('map')")
-
- c.execute("GRANT SELECT ON binary_acl TO public")
- c.execute("GRANT ALL ON binary_acl TO ftpmaster")
- c.execute("GRANT USAGE ON binary_acl_id_seq TO ftpmaster")
-
- # This is only used if binary_acl is 2 for the fingerprint concerned
- c.execute("""
- CREATE TABLE binary_acl_map (
- id SERIAL PRIMARY KEY,
- fingerprint_id INT4 REFERENCES fingerprint (id) NOT NULL,
- architecture_id INT4 REFERENCES architecture (id) NOT NULL,
-
- UNIQUE (fingerprint_id, architecture_id)
- )""")
-
- c.execute("GRANT SELECT ON binary_acl_map TO public")
- c.execute("GRANT ALL ON binary_acl_map TO ftpmaster")
- c.execute("GRANT USAGE ON binary_acl_map_id_seq TO ftpmaster")
-
- ## NULL means no source upload access (i.e. any upload containing source
- ## will be rejected)
- c.execute("ALTER TABLE fingerprint ADD COLUMN source_acl_id INT4 REFERENCES source_acl(id) DEFAULT NULL")
-
- ## NULL means no binary upload access
- c.execute("ALTER TABLE fingerprint ADD COLUMN binary_acl_id INT4 REFERENCES binary_acl(id) DEFAULT NULL")
-
- ## TRUE here means that if the person doesn't have binary upload permissions for
- ## an architecture, we'll reject the .changes. FALSE means that we'll simply
- ## dispose of those particular binaries
- c.execute("ALTER TABLE fingerprint ADD COLUMN binary_reject BOOLEAN NOT NULL DEFAULT TRUE")
-
- # Blockage table (replaces the hard coded stuff we used to have in extensions)
- print "Adding blockage table"
- c.execute("""
- CREATE TABLE upload_blocks (
- id SERIAL PRIMARY KEY,
- source TEXT NOT NULL,
- version TEXT DEFAULT NULL,
- fingerprint_id INT4 REFERENCES fingerprint (id),
- uid_id INT4 REFERENCES uid (id),
- reason TEXT NOT NULL,
-
- CHECK (fingerprint_id IS NOT NULL OR uid_id IS NOT NULL)
- )""")
-
- c.execute("GRANT SELECT ON upload_blocks TO public")
- c.execute("GRANT ALL ON upload_blocks TO ftpmaster")
- c.execute("GRANT USAGE ON upload_blocks_id_seq TO ftpmaster")
-
- c.execute("ALTER TABLE keyrings ADD COLUMN default_source_acl_id INT4 REFERENCES source_acl (id) DEFAULT NULL")
- c.execute("ALTER TABLE keyrings ADD COLUMN default_binary_acl_id INT4 REFERENCES binary_acl (id) DEFAULT NULL")
- c.execute("ALTER TABLE keyrings ADD COLUMN default_binary_reject BOOLEAN NOT NULL DEFAULT TRUE")
- # Set up keyring priorities
- c.execute("ALTER TABLE keyrings ADD COLUMN priority INT4 NOT NULL DEFAULT 100")
- # And then we don't need the DM stuff any more
- c.execute("ALTER TABLE keyrings DROP COLUMN debian_maintainer")
-
- # Default ACLs for keyrings
- c.execute("""
- CREATE TABLE keyring_acl_map (
- id SERIAL PRIMARY KEY,
- keyring_id INT4 REFERENCES keyrings (id) NOT NULL,
- architecture_id INT4 REFERENCES architecture (id) NOT NULL,
-
- UNIQUE (keyring_id, architecture_id)
- )""")
-
- c.execute("GRANT SELECT ON keyring_acl_map TO public")
- c.execute("GRANT ALL ON keyring_acl_map TO ftpmaster")
- c.execute("GRANT USAGE ON keyring_acl_map_id_seq TO ftpmaster")
-
- # Set up some default stuff; default to old behaviour
- print "Setting up some defaults"
-
- c.execute("""UPDATE keyrings SET default_source_acl_id = (SELECT id FROM source_acl WHERE access_level = 'full'),
- default_binary_acl_id = (SELECT id FROM binary_acl WHERE access_level = 'full')""")
-
- c.execute("""UPDATE keyrings SET default_source_acl_id = (SELECT id FROM source_acl WHERE access_level = 'dm'),
- default_binary_acl_id = (SELECT id FROM binary_acl WHERE access_level = 'full')
- WHERE name = 'debian-maintainers.gpg'""")
-
- c.execute("""UPDATE keyrings SET priority = 90 WHERE name = 'debian-maintainers.gpg'""")
-
- # Initialize the existing keys
- c.execute("""UPDATE fingerprint SET binary_acl_id = (SELECT default_binary_acl_id FROM keyrings
- WHERE keyrings.id = fingerprint.keyring)""")
-
- c.execute("""UPDATE fingerprint SET source_acl_id = (SELECT default_source_acl_id FROM keyrings
- WHERE keyrings.id = fingerprint.keyring)""")
-
- print "Updating config version"
- c.execute("UPDATE config SET value = '16' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError("Unable to apply ACLs update (16), rollback issued. Error message : %s" % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-adding a bin_contents table to hold lists of files contained in .debs and .udebs
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2009 Mike O'Connor <stew@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-
-################################################################################
-
-import psycopg2
-import time
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-
-def do_update(self):
-
- print "adding a bin_contents table to hold lists of files contained in .debs and .udebs"
-
- try:
- c = self.db.cursor()
- c.execute("""CREATE TABLE bin_contents (
- file text,
- binary_id integer,
- UNIQUE(file,binary_id))""" )
-
- c.execute("""ALTER TABLE ONLY bin_contents
- ADD CONSTRAINT bin_contents_bin_fkey
- FOREIGN KEY (binary_id) REFERENCES binaries(id)
- ON DELETE CASCADE;""")
-
- c.execute("""CREATE INDEX ind_bin_contents_binary ON bin_contents(binary_id);""" )
-
- c.execute("GRANT ALL ON bin_contents TO ftpmaster;")
- c.execute("GRANT SELECT ON bin_contents TO public;")
- c.execute("UPDATE config SET value = '17' WHERE name = 'db_revision'")
-
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError("Unable to apply process-new update 17, rollback issued. Error message : %s" % (str(msg)))
-
-
-
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Adding table to get rid of queue/done checks
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2009 Joerg Jaspert <joerg@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-
-################################################################################
-
-import psycopg2
-import time
-import os
-import datetime
-from daklib.dak_exceptions import DBUpdateError, InvalidDscError, ChangesUnicodeError
-from daklib.config import Config
-from daklib.changes import Changes
-from daklib.utils import parse_changes, warn, gpgv_get_status_output, process_gpgv_output
-
-################################################################################
-
-def check_signature (sig_filename, data_filename=""):
- keyrings = [
- "/home/joerg/keyring/keyrings/debian-keyring.gpg",
- "/home/joerg/keyring/keyrings/debian-maintainers.gpg",
- "/home/joerg/keyring/keyrings/debian-role-keys.gpg",
- "/home/joerg/keyring/keyrings/emeritus-keyring.pgp",
- "/home/joerg/keyring/keyrings/emeritus-keyring.gpg",
- "/home/joerg/keyring/keyrings/removed-keys.gpg",
- "/home/joerg/keyring/keyrings/removed-keys.pgp"
- ]
-
- keyringargs = " ".join(["--keyring %s" % x for x in keyrings ])
-
- # Build the command line
- status_read, status_write = os.pipe()
- cmd = "gpgv --status-fd %s %s %s" % (status_write, keyringargs, sig_filename)
-
- # Invoke gpgv on the file
- (output, status, exit_status) = gpgv_get_status_output(cmd, status_read, status_write)
-
- # Process the status-fd output
- (keywords, internal_error) = process_gpgv_output(status)
-
- # If we failed to parse the status-fd output, let's just whine and bail now
- if internal_error:
- warn("Couldn't parse signature")
- return None
-
- # usually one would check for bad things here. We, however, do not care.
-
- # Next check gpgv exited with a zero return code
- if exit_status:
- warn("Couldn't parse signature")
- return None
-
- # Sanity check the good stuff we expect
- if not keywords.has_key("VALIDSIG"):
- warn("Couldn't parse signature")
- else:
- args = keywords["VALIDSIG"]
- if len(args) < 1:
- warn("Couldn't parse signature")
- else:
- fingerprint = args[0]
-
- return fingerprint
-
-################################################################################
-
-def do_update(self):
- print "Adding known_changes table"
-
- try:
- c = self.db.cursor()
- c.execute("""
- CREATE TABLE known_changes (
- id SERIAL PRIMARY KEY,
- changesname TEXT NOT NULL,
- seen TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
- source TEXT NOT NULL,
- binaries TEXT NOT NULL,
- architecture TEXT NOT NULL,
- version TEXT NOT NULL,
- distribution TEXT NOT NULL,
- urgency TEXT NOT NULL,
- maintainer TEXT NOT NULL,
- fingerprint TEXT NOT NULL,
- changedby TEXT NOT NULL,
- date TEXT NOT NULL,
- UNIQUE (changesname)
- )
- """)
- c.execute("CREATE INDEX changesname_ind ON known_changes(changesname)")
- c.execute("CREATE INDEX changestimestamp_ind ON known_changes(seen)")
- c.execute("CREATE INDEX changessource_ind ON known_changes(source)")
- c.execute("CREATE INDEX changesdistribution_ind ON known_changes(distribution)")
- c.execute("CREATE INDEX changesurgency_ind ON known_changes(urgency)")
-
- c.execute("GRANT ALL ON known_changes TO ftpmaster;")
- c.execute("GRANT SELECT ON known_changes TO public;")
-
- c.execute("UPDATE config SET value = '18' WHERE name = 'db_revision'")
- self.db.commit()
-
- print "Done. Now looking for old changes files"
- count = 0
- failure = 0
- cnf = Config()
- for directory in [ "Accepted", "Byhand", "Done", "New", "ProposedUpdates", "OldProposedUpdates" ]:
- checkdir = cnf["Dir::Queue::%s" % (directory) ]
- if os.path.exists(checkdir):
- print "Looking into %s" % (checkdir)
- for filename in os.listdir(checkdir):
- if not filename.endswith(".changes"):
- # Only interested in changes files.
- continue
- try:
- count += 1
- print "Directory %s, file %7d, failures %3d. (%s)" % (directory, count, failure, filename)
- changes = Changes()
- changes.changes_file = filename
- changesfile = os.path.join(checkdir, filename)
- changes.changes = parse_changes(changesfile, signing_rules=-1)
- changes.changes["fingerprint"] = check_signature(changesfile)
- changes.add_known_changes(directory)
- except InvalidDscError as line:
- warn("syntax error in .dsc file '%s', line %s." % (f, line))
- failure += 1
- except ChangesUnicodeError:
- warn("found invalid changes file, not properly utf-8 encoded")
- failure += 1
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError("Unable to apply knownchanges update 18, rollback issued. Error message : %s" % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Move to using the C version of debversion
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2009 Mark Hymers <mhy@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-
-################################################################################
-
-import psycopg2
-import time
-import os
-import datetime
-import traceback
-
-from daklib.dak_exceptions import DBUpdateError
-from daklib.config import Config
-
-################################################################################
-
-def do_update(self):
- print "Converting database to use new C based debversion type"
-
- try:
- c = self.db.cursor()
-
- print "Temporarily converting columns to TEXT"
- c.execute("ALTER TABLE binaries ALTER COLUMN version TYPE TEXT")
- c.execute("ALTER TABLE source ALTER COLUMN version TYPE TEXT")
- c.execute("ALTER TABLE upload_blocks ALTER COLUMN version TYPE TEXT")
- c.execute("ALTER TABLE pending_content_associations ALTER COLUMN version TYPE TEXT")
-
- print "Dropping old debversion type"
- c.execute("DROP OPERATOR >(debversion, debversion)")
- c.execute("DROP OPERATOR <(debversion, debversion)")
- c.execute("DROP OPERATOR <=(debversion, debversion)")
- c.execute("DROP OPERATOR >=(debversion, debversion)")
- c.execute("DROP OPERATOR =(debversion, debversion)")
- c.execute("DROP OPERATOR <>(debversion, debversion)")
- c.execute("DROP FUNCTION debversion_eq(debversion,debversion)")
- c.execute("DROP FUNCTION debversion_ge(debversion,debversion)")
- c.execute("DROP FUNCTION debversion_gt(debversion,debversion)")
- c.execute("DROP FUNCTION debversion_le(debversion,debversion)")
- c.execute("DROP FUNCTION debversion_lt(debversion,debversion)")
- c.execute("DROP FUNCTION debversion_ne(debversion,debversion)")
- c.execute("DROP FUNCTION debversion_compare(debversion,debversion)")
- c.execute("DROP FUNCTION debversion_revision(debversion)")
- c.execute("DROP FUNCTION debversion_version(debversion)")
- c.execute("DROP FUNCTION debversion_epoch(debversion)")
- c.execute("DROP FUNCTION debversion_split(debversion)")
- c.execute("DROP TYPE debversion")
-
- # URGH - kill me now
- print "Importing new debversion type"
- f = open('/usr/share/postgresql/8.4/contrib/debversion.sql', 'r')
- cmds = []
- curcmd = ''
- for j in f.readlines():
- j = j.replace('\t', '').replace('\n', '').split('--')[0]
- if not j.startswith('--'):
- jj = j.split(';')
- curcmd += " " + jj[0]
- if len(jj) > 1:
- for jjj in jj[1:]:
- if jjj.strip() == '':
- cmds.append(curcmd)
- curcmd = ''
- else:
- curcmd += " " + jjj
-
- for cm in cmds:
- c.execute(cm)
-
- print "Converting columns to new debversion type"
- c.execute("ALTER TABLE binaries ALTER COLUMN version TYPE debversion")
- c.execute("ALTER TABLE source ALTER COLUMN version TYPE debversion")
- c.execute("ALTER TABLE upload_blocks ALTER COLUMN version TYPE debversion")
- c.execute("ALTER TABLE pending_content_associations ALTER COLUMN version TYPE debversion")
-
- print "Committing"
- c.execute("UPDATE config SET value = '19' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.InternalError as msg:
- self.db.rollback()
- raise DBUpdateError("Unable to apply debversion update 19, rollback issued. Error message : %s" % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-debversion
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2008 Michael Casadevall <mcasadevall@debian.org>
-@copyright: 2008 Roger Leigh <rleigh@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-import time
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-
-def do_update(self):
- print "Note: to be able to enable the the PL/Perl (plperl) procedural language, we do"
- print "need postgresql-plperl-$postgres-version installed. Make sure that this is the"
- print "case before you continue. Interrupt if it isn't, sleeping 5 seconds now."
- print "(We need to be database superuser for this to work!)"
- time.sleep (5)
-
- try:
- c = self.db.cursor()
-
- print "Enabling PL/Perl language"
- c.execute("CREATE LANGUAGE plperl;")
- c.execute("CREATE LANGUAGE plpgsql;")
-
- print "Adding debversion type to database."
-
-# Not present in all databases, maybe PL/Perl version-dependent?
-# c.execute("SET SESSION plperl.use_strict TO 't';")
-
- c.execute("CREATE DOMAIN debversion AS TEXT;")
- c.execute("COMMENT ON DOMAIN debversion IS 'Debian package version number';")
-
- c.execute("""ALTER DOMAIN debversion
- ADD CONSTRAINT debversion_syntax
- CHECK (VALUE !~ '[^-+:.0-9a-zA-Z~]');""")
-
- # From Dpkg::Version::parseversion
- c.execute("""CREATE OR REPLACE FUNCTION debversion_split (debversion)
- RETURNS text[] AS $$
- my $ver = shift;
- my %verhash;
- if ($ver =~ /:/)
- {
- $ver =~ /^(\d+):(.+)/ or die "bad version number '$ver'";
- $verhash{epoch} = $1;
- $ver = $2;
- }
- else
- {
- $verhash{epoch} = 0;
- }
- if ($ver =~ /(.+)-(.*)$/)
- {
- $verhash{version} = $1;
- $verhash{revision} = $2;
- }
- else
- {
- $verhash{version} = $ver;
- $verhash{revision} = 0;
- }
-
- return [$verhash{'epoch'}, $verhash{'version'}, $verhash{'revision'}];
-$$
- LANGUAGE plperl
- IMMUTABLE STRICT;""")
- c.execute("""COMMENT ON FUNCTION debversion_split (debversion)
- IS 'Split debian version into epoch, upstream version and revision';""")
-
- c.execute("""CREATE OR REPLACE FUNCTION debversion_epoch (version debversion)
- RETURNS text AS $$
-DECLARE
- split text[];
-BEGIN
- split := debversion_split(version);
- RETURN split[1];
-END;
-$$
- LANGUAGE plpgsql
- IMMUTABLE STRICT;
-COMMENT ON FUNCTION debversion_epoch (debversion)
- IS 'Get debian version epoch';
-
-CREATE OR REPLACE FUNCTION debversion_version (version debversion)
- RETURNS text AS $$
-DECLARE
- split text[];
-BEGIN
- split := debversion_split(version);
- RETURN split[2];
-END;
-$$
- LANGUAGE plpgsql
- IMMUTABLE STRICT;""")
- c.execute("""COMMENT ON FUNCTION debversion_version (debversion)
- IS 'Get debian version upstream version';""")
-
- c.execute("""CREATE OR REPLACE FUNCTION debversion_revision (version debversion)
- RETURNS text AS $$
-DECLARE
- split text[];
-BEGIN
- split := debversion_split(version);
- RETURN split[3];
-END;
-$$
- LANGUAGE plpgsql
- IMMUTABLE STRICT;""")
- c.execute("""COMMENT ON FUNCTION debversion_revision (debversion)
- IS 'Get debian version revision';""")
-
-# From Dpkg::Version::parseversion
- c.execute("""CREATE OR REPLACE FUNCTION debversion_compare_single (version1 text, version2 text)
- RETURNS integer AS $$
- sub order{
- my ($x) = @_;
- ##define order(x) ((x) == '~' ? -1 \
- # : cisdigit((x)) ? 0 \
- # : !(x) ? 0 \
- # : cisalpha((x)) ? (x) \
- # : (x) + 256)
- # This comparison is out of dpkg's order to avoid
- # comparing things to undef and triggering warnings.
- if (not defined $x or not length $x) {
- return 0;
- }
- elsif ($x eq '~') {
- return -1;
- }
- elsif ($x =~ /^\d$/) {
- return 0;
- }
- elsif ($x =~ /^[A-Z]$/i) {
- return ord($x);
- }
- else {
- return ord($x) + 256;
- }
- }
-
- sub next_elem(\@){
- my $a = shift;
- return @{$a} ? shift @{$a} : undef;
- }
- my ($val, $ref) = @_;
- $val = "" if not defined $val;
- $ref = "" if not defined $ref;
- my @val = split //,$val;
- my @ref = split //,$ref;
- my $vc = next_elem @val;
- my $rc = next_elem @ref;
- while (defined $vc or defined $rc) {
- my $first_diff = 0;
- while ((defined $vc and $vc !~ /^\d$/) or
- (defined $rc and $rc !~ /^\d$/)) {
- my $vo = order($vc); my $ro = order($rc);
- # Unlike dpkg's verrevcmp, we only return 1 or -1 here.
- return (($vo - $ro > 0) ? 1 : -1) if $vo != $ro;
- $vc = next_elem @val; $rc = next_elem @ref;
- }
- while (defined $vc and $vc eq '0') {
- $vc = next_elem @val;
- }
- while (defined $rc and $rc eq '0') {
- $rc = next_elem @ref;
- }
- while (defined $vc and $vc =~ /^\d$/ and
- defined $rc and $rc =~ /^\d$/) {
- $first_diff = ord($vc) - ord($rc) if !$first_diff;
- $vc = next_elem @val; $rc = next_elem @ref;
- }
- return 1 if defined $vc and $vc =~ /^\d$/;
- return -1 if defined $rc and $rc =~ /^\d$/;
- return (($first_diff > 0) ? 1 : -1) if $first_diff;
- }
- return 0;
-$$
- LANGUAGE plperl
- IMMUTABLE STRICT;""")
- c.execute("""COMMENT ON FUNCTION debversion_compare_single (text, text)
- IS 'Compare upstream or revision parts of Debian versions';""")
-
-# Logic only derived from Dpkg::Version::parseversion
- c.execute("""CREATE OR REPLACE FUNCTION debversion_compare (version1 debversion, version2 debversion)
- RETURNS integer AS $$
-DECLARE
- split1 text[];
- split2 text[];
- result integer;
-BEGIN
- result := 0;
- split1 := debversion_split(version1);
- split2 := debversion_split(version2);
-
- -- RAISE NOTICE 'Version 1: %', version1;
- -- RAISE NOTICE 'Version 2: %', version2;
- -- RAISE NOTICE 'Split 1: %', split1;
- -- RAISE NOTICE 'Split 2: %', split2;
-
- IF split1[1] > split2[1] THEN
- result := 1;
- ELSIF split1[1] < split2[1] THEN
- result := -1;
- ELSE
- result := debversion_compare_single(split1[2], split2[2]);
- IF result = 0 THEN
- result := debversion_compare_single(split1[3], split2[3]);
- END IF;
- END IF;
-
- RETURN result;
-END;
-$$
- LANGUAGE plpgsql
- IMMUTABLE STRICT;""")
- c.execute("""COMMENT ON FUNCTION debversion_compare (debversion, debversion)
- IS 'Compare Debian versions';""")
-
- c.execute("""CREATE OR REPLACE FUNCTION debversion_eq (version1 debversion, version2 debversion)
- RETURNS boolean AS $$
-DECLARE
- comp integer;
- result boolean;
-BEGIN
- comp := debversion_compare(version1, version2);
- result := comp = 0;
- RETURN result;
-END;
-$$
- LANGUAGE plpgsql
- IMMUTABLE STRICT;""")
- c.execute("""COMMENT ON FUNCTION debversion_eq (debversion, debversion)
- IS 'debversion equal';""")
-
- c.execute("""CREATE OR REPLACE FUNCTION debversion_ne (version1 debversion, version2 debversion)
- RETURNS boolean AS $$
-DECLARE
- comp integer;
- result boolean;
-BEGIN
- comp := debversion_compare(version1, version2);
- result := comp <> 0;
- RETURN result;
-END;
-$$
- LANGUAGE plpgsql
- IMMUTABLE STRICT;""")
- c.execute("""COMMENT ON FUNCTION debversion_ne (debversion, debversion)
- IS 'debversion not equal';""")
-
- c.execute("""CREATE OR REPLACE FUNCTION debversion_lt (version1 debversion, version2 debversion)
- RETURNS boolean AS $$
-DECLARE
- comp integer;
- result boolean;
-BEGIN
- comp := debversion_compare(version1, version2);
- result := comp < 0;
- RETURN result;
-END;
-$$
- LANGUAGE plpgsql
- IMMUTABLE STRICT;""")
- c.execute("""COMMENT ON FUNCTION debversion_lt (debversion, debversion)
- IS 'debversion less-than';""")
-
- c.execute("""CREATE OR REPLACE FUNCTION debversion_gt (version1 debversion, version2 debversion) RETURNS boolean AS $$
-DECLARE
- comp integer;
- result boolean;
-BEGIN
- comp := debversion_compare(version1, version2);
- result := comp > 0;
- RETURN result;
-END;
-$$
- LANGUAGE plpgsql
- IMMUTABLE STRICT;""")
- c.execute("""COMMENT ON FUNCTION debversion_gt (debversion, debversion)
- IS 'debversion greater-than';""")
-
- c.execute("""CREATE OR REPLACE FUNCTION debversion_le (version1 debversion, version2 debversion)
- RETURNS boolean AS $$
-DECLARE
- comp integer;
- result boolean;
-BEGIN
- comp := debversion_compare(version1, version2);
- result := comp <= 0;
- RETURN result;
-END;
-$$
- LANGUAGE plpgsql
- IMMUTABLE STRICT;""")
- c.execute("""COMMENT ON FUNCTION debversion_le (debversion, debversion)
- IS 'debversion less-than-or-equal';""")
-
- c.execute("""CREATE OR REPLACE FUNCTION debversion_ge (version1 debversion, version2 debversion)
- RETURNS boolean AS $$
-DECLARE
- comp integer;
- result boolean;
-BEGIN
- comp := debversion_compare(version1, version2);
- result := comp >= 0;
- RETURN result;
-END;
-$$
- LANGUAGE plpgsql
- IMMUTABLE STRICT;""")
- c.execute("""COMMENT ON FUNCTION debversion_ge (debversion, debversion)
- IS 'debversion greater-than-or-equal';""")
-
- c.execute("""CREATE OPERATOR = (
- PROCEDURE = debversion_eq,
- LEFTARG = debversion,
- RIGHTARG = debversion,
- COMMUTATOR = =,
- NEGATOR = !=);""")
- c.execute("""COMMENT ON OPERATOR = (debversion, debversion)
- IS 'debversion equal';""")
-
- c.execute("""CREATE OPERATOR != (
- PROCEDURE = debversion_eq,
- LEFTARG = debversion,
- RIGHTARG = debversion,
- COMMUTATOR = !=,
- NEGATOR = =);""")
- c.execute("""COMMENT ON OPERATOR != (debversion, debversion)
- IS 'debversion not equal';""")
-
- c.execute("""CREATE OPERATOR < (
- PROCEDURE = debversion_lt,
- LEFTARG = debversion,
- RIGHTARG = debversion,
- COMMUTATOR = >,
- NEGATOR = >=);""")
- c.execute("""COMMENT ON OPERATOR < (debversion, debversion)
- IS 'debversion less-than';""")
-
- c.execute("""CREATE OPERATOR > (
- PROCEDURE = debversion_gt,
- LEFTARG = debversion,
- RIGHTARG = debversion,
- COMMUTATOR = <,
- NEGATOR = >=);""")
- c.execute("""COMMENT ON OPERATOR > (debversion, debversion)
- IS 'debversion greater-than';""")
-
- c.execute("""CREATE OPERATOR <= (
- PROCEDURE = debversion_le,
- LEFTARG = debversion,
- RIGHTARG = debversion,
- COMMUTATOR = >=,
- NEGATOR = >);""")
- c.execute("""COMMENT ON OPERATOR <= (debversion, debversion)
- IS 'debversion less-than-or-equal';""")
-
- c.execute("""CREATE OPERATOR >= (
- PROCEDURE = debversion_ge,
- LEFTARG = debversion,
- RIGHTARG = debversion,
- COMMUTATOR = <=,
- NEGATOR = <);""")
- c.execute("""COMMENT ON OPERATOR >= (debversion, debversion)
- IS 'debversion greater-than-or-equal';""")
-
- c.execute("ALTER TABLE source ALTER COLUMN version TYPE debversion;")
- c.execute("ALTER TABLE binaries ALTER COLUMN version TYPE debversion;")
-
- c.execute("UPDATE config SET value = '2' WHERE name = 'db_revision'")
-
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError("Unable to appy debversion updates, rollback issued. Error message : %s" % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Add policy queue handling support
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2009 Mark Hymers <mhy@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-
-################################################################################
-
-import psycopg2
-import time
-import os
-import datetime
-import traceback
-
-from daklib.dak_exceptions import DBUpdateError
-from daklib.config import Config
-
-################################################################################
-
-def do_update(self):
- print "Updating use of queue table"
-
- try:
- c = self.db.cursor()
-
- cnf = Config()
-
- print "Adding path to queue table"
- c.execute("ALTER TABLE queue ADD COLUMN path TEXT")
- c.execute("SELECT * FROM queue")
- rows = c.fetchall()
- seenqueues = {}
- for row in rows:
- dir = cnf["Dir::Queue::%s" % row[1]].rstrip('/')
- seenqueues[row[1].lower()] = 1
- print "Setting %s queue to use path %s" % (row[1], dir)
- c.execute("UPDATE queue SET path = %s WHERE id = %s", (dir, row[0]))
-
- print "Adding missing queues to the queue table"
- for q in cnf.subtree("Dir::Queue").keys():
- qname = q.lower()
- if qname in seenqueues.keys():
- continue
- if qname in ["done", "holding", "reject", "newstage", "btsversiontrack"]:
- print "Skipping queue %s" % qname
- continue
- pth = cnf["Dir::Queue::%s" % qname].rstrip('/')
- if not os.path.exists(pth):
- print "Skipping %s as %s does not exist" % (qname, pth)
- continue
-
- print "Adding %s queue with path %s" % (qname, pth)
- c.execute("INSERT INTO queue (queue_name, path) VALUES (%s, %s)", (qname, pth))
- seenqueues[qname] = 1
-
- print "Adding queue and approved_for columns to known_changes"
- c.execute("ALTER TABLE known_changes ADD COLUMN in_queue INT4 REFERENCES queue(id) DEFAULT NULL")
- c.execute("ALTER TABLE known_changes ADD COLUMN approved_for INT4 REFERENCES queue(id) DEFAULT NULL")
-
- print "Adding policy queue column to suite table"
- c.execute("ALTER TABLE suite DROP COLUMN policy_engine")
- c.execute("ALTER TABLE suite ADD COLUMN policy_queue_id INT4 REFERENCES queue(id) DEFAULT NULL")
- # Handle some of our common cases automatically
- if seenqueues.has_key('proposedupdates'):
- c.execute("""UPDATE suite SET policy_queue_id = (SELECT id FROM queue WHERE queue_name = 'proposedupdates')
- WHERE suite_name = 'proposed-updates'""")
-
- if seenqueues.has_key('oldproposedupdates'):
- c.execute("""UPDATE suite SET policy_queue_id = (SELECT id FROM queue WHERE queue_name = 'oldproposedupdates')
- WHERE suite_name = 'oldstable-proposed-updates'""")
-
- print "Committing"
- c.execute("UPDATE config SET value = '20' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.InternalError as msg:
- self.db.rollback()
- raise DBUpdateError("Unable to apply debversion update 20, rollback issued. Error message : %s" % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Modify queue autobuild support
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2009 Mark Hymers <mhy@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-
-################################################################################
-
-import psycopg2
-import time
-import os
-import datetime
-import traceback
-
-from daklib.dak_exceptions import DBUpdateError
-from daklib.config import Config
-
-################################################################################
-
-def do_update(self):
- print "Updating queue_build table"
-
- try:
- c = self.db.cursor()
-
- cnf = Config()
-
- print "Adding copy_files field to queue table"
- c.execute("ALTER TABLE queue ADD copy_pool_files BOOL NOT NULL DEFAULT FALSE")
-
- print "Adding queue_files table"
-
- c.execute("""CREATE TABLE queue_files (
- id SERIAL PRIMARY KEY,
- queueid INT4 NOT NULL REFERENCES queue(id) ON DELETE RESTRICT,
- insertdate TIMESTAMP NOT NULL DEFAULT now(),
- lastused TIMESTAMP DEFAULT NULL,
- filename TEXT NOT NULL,
- fileid INT4 REFERENCES files(id) ON DELETE CASCADE)""")
-
- c.execute("""SELECT queue_build.filename, queue_build.last_used, queue_build.queue
- FROM queue_build""")
-
- for r in c.fetchall():
- print r[0]
- filename = r[0]
- last_used = r[1]
- queue = r[2]
- try:
- endlink = os.readlink(filename)
- c.execute("SELECT files.id FROM files WHERE filename LIKE '%%%s'" % endlink[endlink.rindex('/')+1:])
- f = c.fetchone()
- c.execute("""INSERT INTO queue_files (queueid, lastused, filename, fileid) VALUES
- (%s, now(), %s, %s)""", (queue, filename[filename.rindex('/')+1:], f[0]))
- except OSError as e:
- print "Can't find file %s (%s)" % (filename, e)
-
- print "Dropping old queue_build table"
- c.execute("DROP TABLE queue_build")
-
- print "Adding changes_pending_files table"
- c.execute("""CREATE TABLE changes_pending_files (
- id SERIAL PRIMARY KEY,
- changeid INT4 NOT NULL REFERENCES known_changes(id) ON DELETE CASCADE,
- filename TEXT NOT NULL,
- source BOOL NOT NULL DEFAULT FALSE,
- filesize BIGINT NOT NULL,
- md5sum TEXT NOT NULL,
- sha1sum TEXT NOT NULL,
- sha256sum TEXT NOT NULL)""")
-
-
- print "Adding changes_pool_files table"
- c.execute("""CREATE TABLE changes_pool_files (
- changeid INT4 NOT NULL REFERENCES known_changes(id) ON DELETE CASCADE,
- fileid INT4 NOT NULL REFERENCES files(id) ON DELETE RESTRICT,
-
- PRIMARY KEY (changeid, fileid))""")
-
- print "Adding suite_queue_copy table"
- c.execute("""CREATE TABLE suite_queue_copy (
- suite INT4 NOT NULL REFERENCES suite(id),
- queue INT4 NOT NULL REFERENCES queue(id),
-
- PRIMARY KEY (suite, queue))""")
-
- # Link all suites from accepted
- c.execute("""SELECT suite.id FROM suite""")
- for s in c.fetchall():
- c.execute("""INSERT INTO suite_queue_copy (suite, queue) VALUES (%s, (SELECT id FROM queue WHERE queue_name = 'accepted'))""", s)
-
- # Parse the config and add any buildd stuff
- cnf = Config()
- c.execute("""INSERT INTO queue (queue_name, path) VALUES ('buildd', '%s')""" % cnf["Dir::QueueBuild"].rstrip('/'))
-
- for s in cnf.value_list("Dinstall::QueueBuildSuites"):
- c.execute("""INSERT INTO suite_queue_copy (suite, queue)
- VALUES ( (SELECT id FROM suite WHERE suite_name = '%s'),
- (SELECT id FROM queue WHERE queue_name = 'buildd'))""" % s.lower())
-
- print "Committing"
- c.execute("UPDATE config SET value = '21' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.InternalError as msg:
- self.db.rollback()
- raise DBUpdateError("Unable to apply queue_build 21, rollback issued. Error message : %s" % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Clean up queue SQL
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2009 Mark Hymers <mhy@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-
-################################################################################
-
-import psycopg2
-import time
-import os
-import datetime
-import traceback
-
-from daklib.dak_exceptions import DBUpdateError
-from daklib.config import Config
-
-################################################################################
-
-def do_update(self):
- print "Splitting up queues and fixing general design mistakes"
-
- try:
- c = self.db.cursor()
-
- cnf = Config()
-
- print "Adding build_queue table"
- c.execute("""CREATE TABLE build_queue (
- id SERIAL PRIMARY KEY,
- queue_name TEXT NOT NULL UNIQUE,
- path TEXT NOT NULL,
- copy_files BOOL DEFAULT FALSE NOT NULL)""")
-
- print "Adding policy_queue table"
- c.execute("""CREATE TABLE policy_queue (
- id SERIAL PRIMARY KEY,
- queue_name TEXT NOT NULL UNIQUE,
- path TEXT NOT NULL,
- perms CHAR(4) NOT NULL DEFAULT '0660' CHECK (perms SIMILAR TO '^[0-7][0-7][0-7][0-7]$'),
- change_perms CHAR(4) NOT NULL DEFAULT '0660' CHECK (change_perms SIMILAR TO '^[0-7][0-7][0-7][0-7]$')
- )""")
-
- print "Copying queues"
- queues = {}
- c.execute("""SELECT queue.id, queue.queue_name, queue.path, queue.copy_pool_files FROM queue""")
-
- for q in c.fetchall():
- queues[q[0]] = q[1]
- if q[1] in ['accepted', 'buildd', 'embargoed', 'unembargoed']:
- # Move to build_queue_table
- c.execute("""INSERT INTO build_queue (queue_name, path, copy_files)
- VALUES ('%s', '%s', '%s')""" % (q[1], q[2], q[3]))
-
- else:
- # Move to policy_queue_table
- c.execute("""INSERT INTO policy_queue (queue_name, path)
- VALUES ('%s', '%s')""" % (q[1], q[2]))
-
-
- print "Fixing up build_queue_files"
- c.execute("""ALTER TABLE queue_files DROP CONSTRAINT queue_files_queueid_fkey""")
- c.execute("""ALTER TABLE queue_files RENAME TO build_queue_files""")
- c.execute("""ALTER TABLE build_queue_files RENAME COLUMN queueid TO build_queue_id""")
-
- c.execute("""UPDATE build_queue_files
- SET build_queue_id = (SELECT build_queue.id FROM build_queue
- WHERE build_queue.queue_name =
- (SELECT queue.queue_name FROM queue
- WHERE queue.id = build_queue_files.build_queue_id))""")
-
- c.execute("""ALTER TABLE build_queue_files
- ADD CONSTRAINT build_queue_files_build_queue_id_fkey
- FOREIGN KEY (build_queue_id)
- REFERENCES build_queue(id)
- ON DELETE CASCADE""")
-
-
- c.execute("""ALTER TABLE suite DROP CONSTRAINT suite_policy_queue_id_fkey""")
-
- c.execute("""UPDATE suite
- SET policy_queue_id = (SELECT policy_queue.id FROM policy_queue
- WHERE policy_queue.queue_name =
- (SELECT queue.queue_name FROM queue
- WHERE queue.id = suite.policy_queue_id))""")
-
- c.execute("""ALTER TABLE suite
- ADD CONSTRAINT suite_policy_queue_fkey
- FOREIGN KEY (policy_queue_id)
- REFERENCES policy_queue (id)
- ON DELETE RESTRICT""")
-
- c.execute("""ALTER TABLE known_changes DROP CONSTRAINT known_changes_approved_for_fkey""")
- c.execute("""ALTER TABLE known_changes DROP CONSTRAINT known_changes_in_queue_fkey""")
-
- c.execute("""UPDATE known_changes
- SET in_queue = (SELECT policy_queue.id FROM policy_queue
- WHERE policy_queue.queue_name =
- (SELECT queue.queue_name FROM queue
- WHERE queue.id = known_changes.in_queue))""")
-
- c.execute("""ALTER TABLE known_changes
- ADD CONSTRAINT known_changes_in_queue_fkey
- FOREIGN KEY (in_queue)
- REFERENCES policy_queue (id)
- ON DELETE RESTRICT""")
-
-
-
- c.execute("""UPDATE known_changes
- SET approved_for = (SELECT policy_queue.id FROM policy_queue
- WHERE policy_queue.queue_name =
- (SELECT queue.queue_name FROM queue
- WHERE queue.id = known_changes.approved_for))""")
-
- c.execute("""ALTER TABLE known_changes
- ADD CONSTRAINT known_changes_approved_for_fkey
- FOREIGN KEY (in_queue)
- REFERENCES policy_queue (id)
- ON DELETE RESTRICT""")
-
- c.execute("""ALTER TABLE suite_queue_copy RENAME TO suite_build_queue_copy""")
-
- c.execute("""ALTER TABLE suite_build_queue_copy DROP CONSTRAINT suite_queue_copy_queue_fkey""")
-
- c.execute("""ALTER TABLE suite_build_queue_copy RENAME COLUMN queue TO build_queue_id""")
-
- c.execute("""UPDATE suite_build_queue_copy
- SET build_queue_id = (SELECT build_queue.id FROM build_queue
- WHERE build_queue.queue_name =
- (SELECT queue.queue_name FROM queue
- WHERE queue.id = suite_build_queue_copy.build_queue_id))""")
-
- c.execute("""ALTER TABLE suite_build_queue_copy
- ADD CONSTRAINT suite_build_queue_copy_build_queue_id_fkey
- FOREIGN KEY (build_queue_id)
- REFERENCES build_queue (id)
- ON DELETE RESTRICT""")
-
- c.execute("""DROP TABLE changes_pending_files""")
-
- c.execute("""CREATE TABLE changes_pending_files (
- id SERIAL PRIMARY KEY,
- filename TEXT NOT NULL UNIQUE,
- size BIGINT NOT NULL,
- md5sum TEXT NOT NULL,
- sha1sum TEXT NOT NULL,
- sha256sum TEXT NOT NULL )""")
-
- c.execute("""CREATE TABLE changes_pending_files_map (
- file_id INT4 NOT NULL REFERENCES changes_pending_files (id),
- change_id INT4 NOT NULL REFERENCES known_changes (id),
-
- PRIMARY KEY (file_id, change_id))""")
-
- c.execute("""CREATE TABLE changes_pending_source (
- id SERIAL PRIMARY KEY,
- change_id INT4 NOT NULL REFERENCES known_changes (id),
- source TEXT NOT NULL,
- version DEBVERSION NOT NULL,
- maintainer_id INT4 NOT NULL REFERENCES maintainer (id),
- changedby_id INT4 NOT NULL REFERENCES maintainer (id),
- sig_fpr INT4 NOT NULL REFERENCES fingerprint (id),
- dm_upload_allowed BOOL NOT NULL DEFAULT FALSE )""")
-
- c.execute("""CREATE TABLE changes_pending_source_files (
- pending_source_id INT4 REFERENCES changes_pending_source (id) NOT NULL,
- pending_file_id INT4 REFERENCES changes_pending_files (id) NOT NULL,
-
- PRIMARY KEY (pending_source_id, pending_file_id) )""")
-
- c.execute("""CREATE TABLE changes_pending_binaries (
- id SERIAL PRIMARY KEY,
- change_id INT4 NOT NULL REFERENCES known_changes (id),
- package TEXT NOT NULL,
- version DEBVERSION NOT NULL,
- architecture_id INT4 REFERENCES architecture (id) NOT NULL,
- source_id INT4 REFERENCES source (id),
- pending_source_id INT4 REFERENCES changes_pending_source (id),
- pending_file_id INT4 REFERENCES changes_pending_files (id),
-
- UNIQUE (package, version, architecture_id),
- CHECK (source_id IS NOT NULL or pending_source_id IS NOT NULL ) )""")
-
- print "Getting rid of old queue table"
- c.execute("""DROP TABLE queue""")
-
- print "Sorting out permission columns"
- c.execute("""UPDATE policy_queue SET perms = '0664' WHERE queue_name IN ('proposedupdates', 'oldproposedupdates')""")
-
- print "Moving known_changes table"
- c.execute("""ALTER TABLE known_changes RENAME TO changes""")
-
- print "Sorting out permissions"
-
- for t in ['build_queue', 'policy_queue', 'build_queue_files',
- 'changes_pending_binaries', 'changes_pending_source_files',
- 'changes_pending_source', 'changes_pending_files',
- 'changes_pool_files', 'suite_build_queue_copy']:
- c.execute("GRANT SELECT ON %s TO public" % t)
- c.execute("GRANT ALL ON %s TO ftpmaster" % t)
-
- for s in ['queue_files_id_seq', 'build_queue_id_seq',
- 'changes_pending_source_id_seq',
- 'changes_pending_binaries_id_seq',
- 'changes_pending_files_id_seq',
- 'changes_pending_source_id_seq',
- 'known_changes_id_seq',
- 'policy_queue_id_seq']:
- c.execute("GRANT USAGE ON %s TO ftpmaster" % s)
-
- print "Committing"
- c.execute("UPDATE config SET value = '22' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.InternalError as msg:
- self.db.rollback()
- raise DBUpdateError("Unable to apply queue_build 21, rollback issued. Error message : %s" % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-
-"""
-Add view for new generate_filelist command.
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2009 Torsten Werner <twerner@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-import psycopg2
-
-def do_update(self):
- print "Add views for generate_filelist to database."
-
- try:
- c = self.db.cursor()
-
- print "Drop old views."
- c.execute("DROP VIEW IF EXISTS binfiles_suite_component_arch CASCADE")
- c.execute("DROP VIEW IF EXISTS srcfiles_suite_component CASCADE")
-
- print "Create new views."
- c.execute("""
-CREATE VIEW binfiles_suite_component_arch AS
- SELECT files.filename, binaries.type, location.path, location.component,
- bin_associations.suite, binaries.architecture
- FROM binaries
- JOIN bin_associations ON binaries.id = bin_associations.bin
- JOIN files ON binaries.file = files.id
- JOIN location ON files.location = location.id;
- """)
- c.execute("""
-CREATE VIEW srcfiles_suite_component AS
- SELECT files.filename, location.path, location.component,
- src_associations.suite
- FROM source
- JOIN src_associations ON source.id = src_associations.source
- JOIN files ON source.file = files.id
- JOIN location ON files.location = location.id;
- """)
-
- print "Committing"
- c.execute("UPDATE config SET value = '23' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.InternalError as msg:
- self.db.rollback()
- raise DBUpdateError("Database error, rollback issued. Error message : %s" % (str(msg)))
-
+++ /dev/null
-#!/usr/bin/env python
-
-"""
-Add some meta info to queues
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2009 Mark Hymers <mhy@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-import psycopg2
-
-def do_update(self):
- print "Add meta info columns to queues."
-
- try:
- c = self.db.cursor()
-
- c.execute("ALTER TABLE policy_queue ADD COLUMN generate_metadata BOOL DEFAULT FALSE NOT NULL")
- c.execute("ALTER TABLE policy_queue ADD COLUMN origin TEXT DEFAULT NULL")
- c.execute("ALTER TABLE policy_queue ADD COLUMN label TEXT DEFAULT NULL")
- c.execute("ALTER TABLE policy_queue ADD COLUMN releasedescription TEXT DEFAULT NULL")
- c.execute("ALTER TABLE policy_queue ADD COLUMN signingkey TEXT DEFAULT NULL")
- c.execute("ALTER TABLE policy_queue ADD COLUMN stay_of_execution INT4 NOT NULL DEFAULT 86400 CHECK (stay_of_execution >= 0)")
- c.execute("""ALTER TABLE policy_queue
- ADD CONSTRAINT policy_queue_meta_sanity_check
- CHECK ( (generate_metadata IS FALSE)
- OR (origin IS NOT NULL AND label IS NOT NULL AND releasedescription IS NOT NULL) )""")
-
- c.execute("ALTER TABLE build_queue ADD COLUMN generate_metadata BOOL DEFAULT FALSE NOT NULL")
- c.execute("ALTER TABLE build_queue ADD COLUMN origin TEXT DEFAULT NULL")
- c.execute("ALTER TABLE build_queue ADD COLUMN label TEXT DEFAULT NULL")
- c.execute("ALTER TABLE build_queue ADD COLUMN releasedescription TEXT DEFAULT NULL")
- c.execute("ALTER TABLE build_queue ADD COLUMN signingkey TEXT DEFAULT NULL")
- c.execute("ALTER TABLE build_queue ADD COLUMN stay_of_execution INT4 NOT NULL DEFAULT 86400 CHECK (stay_of_execution >= 0)")
- c.execute("""ALTER TABLE build_queue
- ADD CONSTRAINT build_queue_meta_sanity_check
- CHECK ( (generate_metadata IS FALSE)
- OR (origin IS NOT NULL AND label IS NOT NULL AND releasedescription IS NOT NULL) )""")
-
- print "Committing"
- c.execute("UPDATE config SET value = '24' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.InternalError as msg:
- self.db.rollback()
- raise DBUpdateError("Database error, rollback issued. Error message : %s" % (str(msg)))
-
+++ /dev/null
-#!/usr/bin/env python
-
-"""
-Add views for new dominate command.
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2009 Torsten Werner <twerner@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-import psycopg2
-
-def do_update(self):
- print "Add views for generate_filelist to database."
-
- try:
- c = self.db.cursor()
-
- print "Drop old views."
- c.execute("DROP VIEW IF EXISTS binaries_suite_arch CASCADE")
- c.execute("DROP VIEW IF EXISTS newest_all_associations CASCADE")
- c.execute("DROP VIEW IF EXISTS obsolete_any_by_all_associations CASCADE")
- c.execute("DROP VIEW IF EXISTS newest_any_associations CASCADE")
- c.execute("DROP VIEW IF EXISTS obsolete_any_associations CASCADE")
- c.execute("DROP VIEW IF EXISTS source_suite CASCADE")
- c.execute("DROP VIEW IF EXISTS newest_source CASCADE")
- c.execute("DROP VIEW IF EXISTS newest_src_association CASCADE")
- c.execute("DROP VIEW IF EXISTS any_associations_source CASCADE")
- c.execute("DROP VIEW IF EXISTS src_associations_src CASCADE")
- c.execute("DROP VIEW IF EXISTS almost_obsolete_src_associations CASCADE")
- c.execute("DROP VIEW IF EXISTS obsolete_src_associations CASCADE")
- c.execute("DROP VIEW IF EXISTS bin_associations_binaries CASCADE")
- c.execute("DROP VIEW IF EXISTS src_associations_bin CASCADE")
- c.execute("DROP VIEW IF EXISTS almost_obsolete_all_associations CASCADE")
- c.execute("DROP VIEW IF EXISTS obsolete_all_associations CASCADE")
-
- print "Create new views."
- c.execute("""
-CREATE VIEW binaries_suite_arch AS
- SELECT bin_associations.id, binaries.id AS bin, binaries.package,
- binaries.version, binaries.source, bin_associations.suite,
- suite.suite_name, binaries.architecture, architecture.arch_string
- FROM binaries JOIN bin_associations ON binaries.id = bin_associations.bin
- JOIN suite ON suite.id = bin_associations.suite
- JOIN architecture ON binaries.architecture = architecture.id;
- """)
- c.execute("""
-CREATE VIEW newest_all_associations AS
- SELECT package, max(version) AS version, suite, architecture
- FROM binaries_suite_arch
- WHERE architecture = 2 GROUP BY package, suite, architecture;
- """)
- c.execute("""
-CREATE VIEW obsolete_any_by_all_associations AS
- SELECT binaries_suite_arch.id, binaries_suite_arch.package,
- binaries_suite_arch.version, binaries_suite_arch.suite,
- binaries_suite_arch.architecture
- FROM binaries_suite_arch
- JOIN newest_all_associations
- ON (binaries_suite_arch.package = newest_all_associations.package AND
- binaries_suite_arch.version < newest_all_associations.version AND
- binaries_suite_arch.suite = newest_all_associations.suite AND
- binaries_suite_arch.architecture > 2);
- """)
- c.execute("""
-CREATE VIEW newest_any_associations AS
- SELECT package, max(version) AS version, suite, architecture
- FROM binaries_suite_arch
- WHERE architecture > 2 GROUP BY package, suite, architecture;
- """)
- c.execute("""
-CREATE VIEW obsolete_any_associations AS
- SELECT id, binaries_suite_arch.architecture, binaries_suite_arch.version,
- binaries_suite_arch.package, binaries_suite_arch.suite
- FROM binaries_suite_arch
- JOIN newest_any_associations
- ON binaries_suite_arch.architecture = newest_any_associations.architecture AND
- binaries_suite_arch.package = newest_any_associations.package AND
- binaries_suite_arch.suite = newest_any_associations.suite AND
- binaries_suite_arch.version != newest_any_associations.version;
- """)
- c.execute("""
-CREATE VIEW source_suite AS
- SELECT src_associations.id, source.id AS src , source.source, source.version,
- src_associations.suite, suite.suite_name
- FROM source
- JOIN src_associations ON source.id = src_associations.source
- JOIN suite ON suite.id = src_associations.suite;
- """)
- c.execute("""
-CREATE VIEW newest_source AS
- SELECT source, max(version) AS version, suite
- FROM source_suite
- GROUP BY source, suite;
- """)
- c.execute("""
-CREATE VIEW newest_src_association AS
- SELECT id, src, source, version, suite
- FROM source_suite
- JOIN newest_source USING (source, version, suite);
- """)
- c.execute("""
-CREATE VIEW any_associations_source AS
- SELECT bin_associations.id, bin_associations.suite, binaries.id AS bin,
- binaries.package, binaries.version AS binver, binaries.architecture,
- source.id AS src, source.source, source.version AS srcver
- FROM bin_associations
- JOIN binaries ON bin_associations.bin = binaries.id AND architecture != 2
- JOIN source ON binaries.source = source.id;
- """)
- c.execute("""
-CREATE VIEW src_associations_src AS
- SELECT src_associations.id, src_associations.suite, source.id AS src,
- source.source, source.version
- FROM src_associations
- JOIN source ON src_associations.source = source.id;
- """)
- c.execute("""
-CREATE VIEW almost_obsolete_src_associations AS
- SELECT src_associations_src.id, src_associations_src.src,
- src_associations_src.source, src_associations_src.version, suite
- FROM src_associations_src
- LEFT JOIN any_associations_source USING (src, suite)
- WHERE bin IS NULL;
- """)
- c.execute("""
-CREATE VIEW obsolete_src_associations AS
- SELECT almost.id, almost.src, almost.source, almost.version, almost.suite
- FROM almost_obsolete_src_associations as almost
- JOIN newest_src_association AS newest
- ON almost.source = newest.source AND
- almost.version < newest.version AND
- almost.suite = newest.suite;
- """)
- c.execute("""
-CREATE VIEW bin_associations_binaries AS
- SELECT bin_associations.id, bin_associations.bin, binaries.package,
- binaries.version, bin_associations.suite, binaries.architecture
- FROM bin_associations
- JOIN binaries ON bin_associations.bin = binaries.id;
- """)
- c.execute("""
-CREATE VIEW src_associations_bin AS
- SELECT src_associations.id, src_associations.source, src_associations.suite,
- binaries.id AS bin, binaries.architecture
- FROM src_associations
- JOIN source ON src_associations.source = source.id
- JOIN binaries ON source.id = binaries.source;
- """)
- c.execute("""
-CREATE VIEW almost_obsolete_all_associations AS
- SELECT bin_associations_binaries.id AS id, bin, bin_associations_binaries.package,
- bin_associations_binaries.version, suite
- FROM bin_associations_binaries
- LEFT JOIN src_associations_bin USING (bin, suite, architecture)
- WHERE source IS NULL AND architecture = 2;
- """)
- c.execute("""
-CREATE VIEW obsolete_all_associations AS
- SELECT almost.id, almost.bin, almost.package, almost.version, almost.suite
- FROM almost_obsolete_all_associations AS almost
- JOIN newest_all_associations AS newest
- ON almost.package = newest.package AND
- almost.version < newest.version AND
- almost.suite = newest.suite;
- """)
-
- print "Committing"
- c.execute("UPDATE config SET value = '25' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.InternalError as msg:
- self.db.rollback()
- raise DBUpdateError("Database error, rollback issued. Error message : %s" % (str(msg)))
-
+++ /dev/null
-#!/usr/bin/env python
-
-"""
-Add created,modified columns for all tables.
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2009 Barry deFreese <bdefreese@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-import psycopg2
-
-def do_update(self):
- print "Add created, modified fields for all tables."
-
- updatetables = ['architecture', 'archive', 'bin_associations', 'bin_contents',
- 'binaries', 'binary_acl', 'binary_acl_map', 'build_queue', 'build_queue_files',
- 'changes', 'changes_pending_binaries', 'changes_pending_files',
- 'changes_pending_files_map', 'changes_pending_source', 'changes_pending_source_files',
- 'changes_pool_files', 'component', 'config', 'dsc_files', 'files', 'fingerprint',
- 'keyring_acl_map', 'keyrings', 'location', 'maintainer', 'new_comments', 'override',
- 'override_type', 'policy_queue', 'priority', 'section', 'source', 'source_acl',
- 'src_associations', 'src_format', 'src_uploaders', 'suite', 'suite_architectures',
- 'suite_build_queue_copy', 'suite_src_formats', 'uid', 'upload_blocks']
-
- c = self.db.cursor()
-
- print "Create trigger function."
- c.execute("""CREATE OR REPLACE FUNCTION tfunc_set_modified() RETURNS trigger AS $$
- BEGIN NEW.modified = now(); return NEW; END;
- $$ LANGUAGE 'plpgsql'""")
-
- try:
- for updatetable in updatetables:
-
- print "Add created field to %s." % updatetable
- c.execute("ALTER TABLE %s ADD COLUMN created TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now()" % updatetable)
-
- print "Add modified field to %s." % updatetable
- c.execute("ALTER TABLE %s ADD COLUMN modified TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now()" % updatetable)
-
- print "Create modified trigger."
- c.execute("""CREATE TRIGGER modified_%s BEFORE UPDATE ON %s
- FOR EACH ROW EXECUTE PROCEDURE tfunc_set_modified()""" % (updatetable, updatetable))
-
- print "Committing"
- c.execute("UPDATE config SET value = '26' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.InternalError as msg:
- self.db.rollback()
- raise DBUpdateError("Database error, rollback issued. Error message : %s" % (str(msg)))
-
+++ /dev/null
-#!/usr/bin/env python
-
-"""
-Add views for new obsolete source detection.
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2009 Torsten Werner <twerner@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-import psycopg2
-
-def do_update(self):
- print "Add/modify views for obsolete source detection."
-
- try:
- c = self.db.cursor()
-
- print "Replace old views."
- # joins src_associations and source
- c.execute("""
-CREATE OR REPLACE VIEW source_suite AS
- SELECT src_associations.id, source.id AS src, source.source, source.version,
- src_associations.suite, suite.suite_name, source.install_date
- FROM source
- JOIN src_associations ON source.id = src_associations.source
- JOIN suite ON suite.id = src_associations.suite;
- """)
- # joins bin_associations and binaries
- c.execute("""
-CREATE OR REPLACE VIEW bin_associations_binaries AS
- SELECT bin_associations.id, bin_associations.bin, binaries.package,
- binaries.version, bin_associations.suite, binaries.architecture,
- binaries.source
- FROM bin_associations
- JOIN binaries ON bin_associations.bin = binaries.id;
- """)
-
- print "Grant permissions to views."
- c.execute("GRANT SELECT ON binfiles_suite_component_arch TO PUBLIC;");
- c.execute("GRANT SELECT ON srcfiles_suite_component TO PUBLIC;");
- c.execute("GRANT SELECT ON binaries_suite_arch TO PUBLIC;");
- c.execute("GRANT SELECT ON newest_all_associations TO PUBLIC;");
- c.execute("GRANT SELECT ON obsolete_any_by_all_associations TO PUBLIC;");
- c.execute("GRANT SELECT ON newest_any_associations TO PUBLIC;");
- c.execute("GRANT SELECT ON obsolete_any_associations TO PUBLIC;");
- c.execute("GRANT SELECT ON source_suite TO PUBLIC;");
- c.execute("GRANT SELECT ON newest_source TO PUBLIC;");
- c.execute("GRANT SELECT ON newest_src_association TO PUBLIC;");
- c.execute("GRANT SELECT ON any_associations_source TO PUBLIC;");
- c.execute("GRANT SELECT ON src_associations_src TO PUBLIC;");
- c.execute("GRANT SELECT ON almost_obsolete_src_associations TO PUBLIC;");
- c.execute("GRANT SELECT ON obsolete_src_associations TO PUBLIC;");
- c.execute("GRANT SELECT ON bin_associations_binaries TO PUBLIC;");
- c.execute("GRANT SELECT ON src_associations_bin TO PUBLIC;");
- c.execute("GRANT SELECT ON almost_obsolete_all_associations TO PUBLIC;");
- c.execute("GRANT SELECT ON obsolete_all_associations TO PUBLIC;");
-
- print "Committing"
- c.execute("UPDATE config SET value = '27' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.InternalError as msg:
- self.db.rollback()
- raise DBUpdateError("Database error, rollback issued. Error message : %s" % (str(msg)))
-
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-keep contents of binary packages in tables so we can generate contents.gz files from dak
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2009 Mike O'Connor <stew@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-
-################################################################################
-
-import psycopg2
-import time
-from daklib.dak_exceptions import DBUpdateError
-from daklib.config import Config
-import string
-
-################################################################################
-
-def _suites():
- """
- return a list of suites to operate on
- """
- suites = Config().subtree("Suite").list()
- return suites
-
-def arches(cursor, suite):
- """
- return a list of archs to operate on
- """
- arch_list = []
- cursor.execute("""SELECT s.architecture, a.arch_string
- FROM suite_architectures s
- JOIN architecture a ON (s.architecture=a.id)
- WHERE suite = '%s'""" % suite)
-
- while True:
- r = cursor.fetchone()
- if not r:
- break
-
- if r[1] != "source" and r[1] != "all":
- arch_list.append((r[0], r[1]))
-
- return arch_list
-
-def do_update(self):
- """
- Adding contents table as first step to maybe, finally getting rid
- of apt-ftparchive
- """
-
- print __doc__
-
- try:
- c = self.db.cursor()
-
- c.execute("""CREATE TABLE pending_bin_contents (
- id serial NOT NULL,
- package text NOT NULL,
- version debversion NOT NULL,
- arch int NOT NULL,
- filename text NOT NULL,
- type int NOT NULL,
- PRIMARY KEY(id))""" );
-
- c.execute("""CREATE TABLE deb_contents (
- filename text,
- section text,
- package text,
- binary_id integer,
- arch integer,
- suite integer)""" )
-
- c.execute("""CREATE TABLE udeb_contents (
- filename text,
- section text,
- package text,
- binary_id integer,
- suite integer,
- arch integer)""" )
-
- c.execute("""ALTER TABLE ONLY deb_contents
- ADD CONSTRAINT deb_contents_arch_fkey
- FOREIGN KEY (arch) REFERENCES architecture(id)
- ON DELETE CASCADE;""")
-
- c.execute("""ALTER TABLE ONLY udeb_contents
- ADD CONSTRAINT udeb_contents_arch_fkey
- FOREIGN KEY (arch) REFERENCES architecture(id)
- ON DELETE CASCADE;""")
-
- c.execute("""ALTER TABLE ONLY deb_contents
- ADD CONSTRAINT deb_contents_pkey
- PRIMARY KEY (filename,package,arch,suite);""")
-
- c.execute("""ALTER TABLE ONLY udeb_contents
- ADD CONSTRAINT udeb_contents_pkey
- PRIMARY KEY (filename,package,arch,suite);""")
-
- c.execute("""ALTER TABLE ONLY deb_contents
- ADD CONSTRAINT deb_contents_suite_fkey
- FOREIGN KEY (suite) REFERENCES suite(id)
- ON DELETE CASCADE;""")
-
- c.execute("""ALTER TABLE ONLY udeb_contents
- ADD CONSTRAINT udeb_contents_suite_fkey
- FOREIGN KEY (suite) REFERENCES suite(id)
- ON DELETE CASCADE;""")
-
- c.execute("""ALTER TABLE ONLY deb_contents
- ADD CONSTRAINT deb_contents_binary_fkey
- FOREIGN KEY (binary_id) REFERENCES binaries(id)
- ON DELETE CASCADE;""")
-
- c.execute("""ALTER TABLE ONLY udeb_contents
- ADD CONSTRAINT udeb_contents_binary_fkey
- FOREIGN KEY (binary_id) REFERENCES binaries(id)
- ON DELETE CASCADE;""")
-
- c.execute("""CREATE INDEX ind_deb_contents_binary ON deb_contents(binary_id);""" )
-
- suites = _suites()
-
- for suite in [i.lower() for i in suites]:
-
- c.execute("SELECT id FROM suite WHERE suite_name ='%s'" % suite )
- suiterow = c.fetchone()
- suite_id = suiterow[0]
- arch_list = arches(c, suite_id)
- arch_list = arches(c, suite_id)
- suitestr=string.replace(suite,'-','_');
-
- for (arch_id,arch_str) in arch_list:
- arch_str = string.replace(arch_str,"-", "_")
- c.execute( "CREATE INDEX ind_deb_contents_%s_%s ON deb_contents (arch,suite) WHERE (arch=2 OR arch=%s) AND suite='%s'"%(arch_str,suitestr,arch_id,suite_id) )
-
- for section, sname in [("debian-installer","main"),
- ("non-free/debian-installer", "nonfree")]:
- c.execute( "CREATE INDEX ind_udeb_contents_%s_%s ON udeb_contents (section,suite) WHERE section='%s' AND suite='%s'"%(sname,suitestr,section,suite_id) )
-
-
- c.execute( """CREATE OR REPLACE FUNCTION update_contents_for_bin_a() RETURNS trigger AS $$
- event = TD["event"]
- if event == "DELETE" or event == "UPDATE":
-
- plpy.execute(plpy.prepare("DELETE FROM deb_contents WHERE binary_id=$1 and suite=$2",
- ["int","int"]),
- [TD["old"]["bin"], TD["old"]["suite"]])
-
- if event == "INSERT" or event == "UPDATE":
-
- content_data = plpy.execute(plpy.prepare(
- \"\"\"SELECT s.section, b.package, b.architecture, ot.type
- FROM override o
- JOIN override_type ot on o.type=ot.id
- JOIN binaries b on b.package=o.package
- JOIN files f on b.file=f.id
- JOIN location l on l.id=f.location
- JOIN section s on s.id=o.section
- WHERE b.id=$1
- AND o.suite=$2
- \"\"\",
- ["int", "int"]),
- [TD["new"]["bin"], TD["new"]["suite"]])[0]
-
- tablename="%s_contents" % content_data['type']
-
- plpy.execute(plpy.prepare(\"\"\"DELETE FROM %s
- WHERE package=$1 and arch=$2 and suite=$3\"\"\" % tablename,
- ['text','int','int']),
- [content_data['package'],
- content_data['architecture'],
- TD["new"]["suite"]])
-
- filenames = plpy.execute(plpy.prepare(
- "SELECT bc.file FROM bin_contents bc where bc.binary_id=$1",
- ["int"]),
- [TD["new"]["bin"]])
-
- for filename in filenames:
- plpy.execute(plpy.prepare(
- \"\"\"INSERT INTO %s
- (filename,section,package,binary_id,arch,suite)
- VALUES($1,$2,$3,$4,$5,$6)\"\"\" % tablename,
- ["text","text","text","int","int","int"]),
- [filename["file"],
- content_data["section"],
- content_data["package"],
- TD["new"]["bin"],
- content_data["architecture"],
- TD["new"]["suite"]] )
-$$ LANGUAGE plpythonu VOLATILE SECURITY DEFINER;
-""")
-
-
- c.execute( """CREATE OR REPLACE FUNCTION update_contents_for_override() RETURNS trigger AS $$
- event = TD["event"]
- if event == "UPDATE":
-
- otype = plpy.execute(plpy.prepare("SELECT type from override_type where id=$1",["int"]),[TD["new"]["type"]] )[0];
- if otype["type"].endswith("deb"):
- section = plpy.execute(plpy.prepare("SELECT section from section where id=$1",["int"]),[TD["new"]["section"]] )[0];
-
- table_name = "%s_contents" % otype["type"]
- plpy.execute(plpy.prepare("UPDATE %s set section=$1 where package=$2 and suite=$3" % table_name,
- ["text","text","int"]),
- [section["section"],
- TD["new"]["package"],
- TD["new"]["suite"]])
-
-$$ LANGUAGE plpythonu VOLATILE SECURITY DEFINER;
-""")
-
- c.execute("""CREATE OR REPLACE FUNCTION update_contents_for_override()
- RETURNS trigger AS $$
- event = TD["event"]
- if event == "UPDATE" or event == "INSERT":
- row = TD["new"]
- r = plpy.execute(plpy.prepare( \"\"\"SELECT 1 from suite_architectures sa
- JOIN binaries b ON b.architecture = sa.architecture
- WHERE b.id = $1 and sa.suite = $2\"\"\",
- ["int", "int"]),
- [row["bin"], row["suite"]])
- if not len(r):
- plpy.error("Illegal architecture for this suite")
-
-$$ LANGUAGE plpythonu VOLATILE;""")
-
- c.execute( """CREATE TRIGGER illegal_suite_arch_bin_associations_trigger
- BEFORE INSERT OR UPDATE ON bin_associations
- FOR EACH ROW EXECUTE PROCEDURE update_contents_for_override();""")
-
- c.execute( """CREATE TRIGGER bin_associations_contents_trigger
- AFTER INSERT OR UPDATE OR DELETE ON bin_associations
- FOR EACH ROW EXECUTE PROCEDURE update_contents_for_bin_a();""")
- c.execute("""CREATE TRIGGER override_contents_trigger
- AFTER UPDATE ON override
- FOR EACH ROW EXECUTE PROCEDURE update_contents_for_override();""")
-
-
- c.execute( "CREATE INDEX ind_deb_contents_name ON deb_contents(package);");
- c.execute( "CREATE INDEX ind_udeb_contents_name ON udeb_contents(package);");
-
- c.execute("UPDATE config SET value = '28' WHERE name = 'db_revision'")
-
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError("Unable to apply process-new update 28, rollback issued. Error message : %s" % (str(msg)))
-
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Adding content fields
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2010 Mike O'Connor <stew@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-################################################################################
-
-import psycopg2
-import time
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-
-def do_update(self):
- print "revert update6 since we have a new scheme for contents"
-
- try:
- c = self.db.cursor()
- c.execute("""DROP FUNCTION comma_concat(text, text) CASCADE;""" );
- c.execute("""DROP TABLE pending_content_associations;""")
- c.execute("""DROP TABLE content_associations;""")
- c.execute("""DROP TABLE content_file_names;""")
- c.execute("""DROP TABLE content_file_paths;""")
-
- c.execute("UPDATE config SET value = '29' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError("Unable to appy debversion updates, rollback issued. Error message : %s" % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-
-"""
-Remove unused versioncmp
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2008 Michael Casadevall <mcasadevall@debian.org>
-@copyright: 2009 Joerg Jaspert <joerg@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-import time
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-
-def do_update(self):
- print "Removing no longer used function versioncmp"
-
- try:
- c = self.db.cursor()
- # The reason we try and check to see if it exists is that
- # psycopg2 might leave the cursor invalid if the drop fails
- c.execute("SELECT proname from pg_catalog.pg_proc WHERE proname = 'versioncmp'")
- rows = c.fetchall()
- if rows:
- c.execute("DROP FUNCTION versioncmp(text, text);")
- else:
- print "function already does not exist"
-
- c.execute("UPDATE config SET value = '3' WHERE name = 'db_revision'")
-
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError("Unable to appy versioncmp removal, rollback issued. Error message : %s" % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Adding content fields
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2010 Mike O'Connor <stew@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-################################################################################
-
-import psycopg2
-import time
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-
-def do_update(self):
- print "fix trigger for bin_contents so that it ignores non deb,udeb"
-
- try:
- c = self.db.cursor()
- c.execute( """CREATE OR REPLACE FUNCTION update_contents_for_bin_a() RETURNS trigger AS $$
- event = TD["event"]
- if event == "DELETE" or event == "UPDATE":
-
- plpy.execute(plpy.prepare("DELETE FROM deb_contents WHERE binary_id=$1 and suite=$2",
- ["int","int"]),
- [TD["old"]["bin"], TD["old"]["suite"]])
-
- if event == "INSERT" or event == "UPDATE":
-
- content_data = plpy.execute(plpy.prepare(
- \"\"\"SELECT s.section, b.package, b.architecture, ot.type
- FROM override o
- JOIN override_type ot on o.type=ot.id
- JOIN binaries b on b.package=o.package
- JOIN files f on b.file=f.id
- JOIN location l on l.id=f.location
- JOIN section s on s.id=o.section
- WHERE b.id=$1
- AND o.suite=$2
- AND ot.type in ('deb','udeb')
- \"\"\",
- ["int", "int"]),
- [TD["new"]["bin"], TD["new"]["suite"]])[0]
-
- tablename="%s_contents" % content_data['type']
-
- plpy.execute(plpy.prepare(\"\"\"DELETE FROM %s
- WHERE package=$1 and arch=$2 and suite=$3\"\"\" % tablename,
- ['text','int','int']),
- [content_data['package'],
- content_data['architecture'],
- TD["new"]["suite"]])
-
- filenames = plpy.execute(plpy.prepare(
- "SELECT bc.file FROM bin_contents bc where bc.binary_id=$1",
- ["int"]),
- [TD["new"]["bin"]])
-
- for filename in filenames:
- plpy.execute(plpy.prepare(
- \"\"\"INSERT INTO %s
- (filename,section,package,binary_id,arch,suite)
- VALUES($1,$2,$3,$4,$5,$6)\"\"\" % tablename,
- ["text","text","text","int","int","int"]),
- [filename["file"],
- content_data["section"],
- content_data["package"],
- TD["new"]["bin"],
- content_data["architecture"],
- TD["new"]["suite"]] )
-$$ LANGUAGE plpythonu VOLATILE SECURITY DEFINER;
-""")
-
- c.execute("UPDATE config SET value = '30' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError("Unable to appy debversion updates, rollback issued. Error message : %s" % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-keep contents of binary packages in tables so we can generate contents.gz files from dak
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2009 Mike O'Connor <stew@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-def do_update(self):
- """
- add trigger to verify that bin_associations aren't added for an
- illegal suite,arch combination. Fix override trigger, re-add all
- 3 triggers
- """
- print __doc__
- try:
- c = self.db.cursor()
-
- c.execute("""CREATE OR REPLACE FUNCTION check_illegal_suite_arch()
- RETURNS trigger AS $$
- event = TD["event"]
- if event == "UPDATE" or event == "INSERT":
- row = TD["new"]
- r = plpy.execute(plpy.prepare( \"\"\"SELECT 1 from suite_architectures sa
- JOIN binaries b ON b.architecture = sa.architecture
- WHERE b.id = $1 and sa.suite = $2\"\"\",
- ["int", "int"]),
- [row["bin"], row["suite"]])
- if not len(r):
- plpy.error("Illegal architecture for this suite")
-
-$$ LANGUAGE plpythonu VOLATILE;""")
-
- c.execute( """CREATE OR REPLACE FUNCTION update_contents_for_override() RETURNS trigger AS $$
- event = TD["event"]
- if event == "UPDATE":
-
- otype = plpy.execute(plpy.prepare("SELECT type from override_type where id=$1",["int"]),[TD["new"]["type"]] )[0];
- if otype["type"].endswith("deb"):
- section = plpy.execute(plpy.prepare("SELECT section from section where id=$1",["int"]),[TD["new"]["section"]] )[0];
-
- table_name = "%s_contents" % otype["type"]
- plpy.execute(plpy.prepare("UPDATE %s set section=$1 where package=$2 and suite=$3" % table_name,
- ["text","text","int"]),
- [section["section"],
- TD["new"]["package"],
- TD["new"]["suite"]])
-
-$$ LANGUAGE plpythonu VOLATILE SECURITY DEFINER;
-""")
- c.execute( "DROP TRIGGER IF EXISTS illegal_suite_arch_bin_associations_trigger on bin_associations;" )
-
- c.execute( "DROP TRIGGER IF EXISTS bin_associations_contents_trigger ON bin_associations;" )
- c.execute( "DROP TRIGGER IF EXISTS override_contents_trigger ON override;" )
-
- c.execute( """CREATE TRIGGER bin_associations_contents_trigger
- AFTER INSERT OR UPDATE OR DELETE ON bin_associations
- FOR EACH ROW EXECUTE PROCEDURE update_contents_for_bin_a();""")
-
- c.execute("""CREATE TRIGGER override_contents_trigger
- AFTER UPDATE ON override
- FOR EACH ROW EXECUTE PROCEDURE update_contents_for_override();""")
-
- c.execute( """CREATE TRIGGER illegal_suite_arch_bin_associations_trigger
- BEFORE INSERT OR UPDATE ON bin_associations
- FOR EACH ROW EXECUTE PROCEDURE check_illegal_suite_arch();""")
-
- c.execute("UPDATE config SET value = '31' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError("Unable to apply process-new update 31, rollback issued. Error message : %s" % (str(msg)))
-
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Add notautomatic field to build_queue
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2010 Joerg Jaspert <joerg@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-def do_update(self):
- """
- Add the notautomatic field
- """
- print __doc__
- try:
- c = self.db.cursor()
-
- c.execute("ALTER TABLE build_queue ADD COLUMN notautomatic BOOLEAN NOT NULL DEFAULT false")
- c.execute("UPDATE config SET value = '32' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError("Unable to apply build_queue update 32, rollback issued. Error message : %s" % (str(msg)))
-
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Implement changelogs related tables
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2010 Luca Falavigna <dktrkranz@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-def do_update(self):
- """
- Implement changelogs table
- """
- print __doc__
- try:
- c = self.db.cursor()
- c.execute('ALTER TABLE changes ADD COLUMN changelog_id integer')
- c.execute('CREATE TABLE changelogs_text (id serial PRIMARY KEY NOT NULL, changelog text)')
- c.execute("GRANT SELECT ON changelogs_text TO public")
- c.execute("GRANT ALL ON changelogs_text TO ftpmaster")
- c.execute('CREATE VIEW changelogs AS SELECT cl.id, source, CAST(version AS debversion), architecture, changelog \
- FROM changes c JOIN changelogs_text cl ON cl.id = c.changelog_id')
- c.execute("GRANT SELECT ON changelogs TO public")
- c.execute("GRANT ALL ON changelogs TO ftpmaster")
- c.execute("UPDATE config SET value = '33' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply build_queue update 33, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Drop an obsolete view.
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2010 Luca Falavigna <dktrkranz@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-def do_update(self):
- """
- Drop view srcfiles_suite_component
- """
- print __doc__
- try:
- c = self.db.cursor()
- c.execute('DROP VIEW srcfiles_suite_component')
- c.execute("UPDATE config SET value = '34' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply build_queue update 34, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Add distribution to changelogs view
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2010 Luca Falavigna <dktrkranz@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-def do_update(self):
- """
- Add distribution to changelogs view
- """
- print __doc__
- try:
- c = self.db.cursor()
- c.execute('CREATE OR REPLACE VIEW changelogs AS SELECT cl.id, source, CAST(version AS debversion), architecture, \
- changelog, distribution FROM changes c JOIN changelogs_text cl ON cl.id = c.changelog_id')
- c.execute("GRANT SELECT ON changelogs TO public")
- c.execute("UPDATE config SET value = '35' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply build_queue update 35, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Add processed field to changes_pending_files
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2010 Mark Hymers <mhy@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-def do_update(self):
- """
- Add processed field to changes_pending_files
- """
- print __doc__
- try:
- c = self.db.cursor()
- c.execute('ALTER TABLE changes_pending_files ADD COLUMN processed BOOL DEFAULT FALSE')
- c.execute("UPDATE config SET value = '36' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply build_queue update 36, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Remove unused table columns
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2010 Joerg Jaspert <joerg@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-
-# <Ganneff> everyone - send your condolences to twerner, a new ftpmaster
-# <mhy> twerner: you poor, poor bastard
-# <mhy> twerner: look what it's done to me and Ganneff
-# <mhy> he used to be only 1.3m tall and I used to be female
-# <Tolimar> twerner: Congratulations... Uhm... Thorsta?
-# <Tolimar> Thorstine?
-# <DktrKranz> Thorstine seems the name of a candy we eat in Italy
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-def do_update(self):
- """
- Remove unused table columns
- """
- print __doc__
- try:
- c = self.db.cursor()
- c.execute('ALTER TABLE suite DROP COLUMN copydotdak')
- c.execute('ALTER TABLE suite DROP COLUMN changelogbase')
- c.execute("UPDATE config SET value = '37' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply table-colum update 37, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Remove more unused table columns
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2010 Joerg Jaspert <joerg@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-
-# <Ganneff> everyone - send your condolences to twerner, a new ftpmaster
-# <mhy> twerner: you poor, poor bastard
-# <mhy> twerner: look what it's done to me and Ganneff
-# <mhy> he used to be only 1.3m tall and I used to be female
-# <Tolimar> twerner: Congratulations... Uhm... Thorsta?
-# <Tolimar> Thorstine?
-# <DktrKranz> Thorstine seems the name of a candy we eat in Italy
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-def do_update(self):
- """
- Remove unused table columns
- """
- print __doc__
- try:
- c = self.db.cursor()
- c.execute('ALTER TABLE suite DROP COLUMN commentsdir')
- c.execute("UPDATE config SET value = '38' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply table-column update 38, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Move changelogs related config values into projectb
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2010 Luca Falavigna <dktrkranz@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-def do_update(self):
- """
- Move changelogs related config values into projectb
- """
- print __doc__
- try:
- c = self.db.cursor()
- c.execute("INSERT INTO config(name, value) VALUES ('exportpath', 'changelogs')")
- c.execute("ALTER TABLE suite ADD COLUMN changelog text NULL")
- c.execute("UPDATE suite SET changelog = 'dists/testing/ChangeLog' WHERE suite_name = 'testing'")
- c.execute("UPDATE config SET value = '39' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply table-column update 39, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-"""
-Get suite_architectures table use sane values
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2009 Joerg Jaspert <joerg@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-from daklib.utils import get_conf
-
-################################################################################
-
-suites = {} #: Cache of existing suites
-archs = {} #: Cache of existing architectures
-
-def do_update(self):
- """ Execute the DB update """
-
- print "Lets make suite_architecture table use sane values"
- Cnf = get_conf()
-
- query = "INSERT into suite_architectures (suite, architecture) VALUES (%s, %s)" #: Update query
- try:
- c = self.db.cursor()
- c.execute("DELETE FROM suite_architectures;")
-
- c.execute("SELECT id, arch_string FROM architecture;")
- a=c.fetchall()
- for arch in a:
- archs[arch[1]]=arch[0]
-
- c.execute("SELECT id,suite_name FROM suite")
- s=c.fetchall()
- for suite in s:
- suites[suite[1]]=suite[0]
-
- for suite in Cnf.subtree("Suite").list():
- print "Processing suite %s" % (suite)
- architectures = Cnf.subtree("Suite::" + suite).value_list("Architectures")
- suite = suite.lower()
- for arch in architectures:
- c.execute(query, [suites[suite], archs[arch]])
-
- c.execute("UPDATE config SET value = '4' WHERE name = 'db_revision'")
-
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError("Unable to apply sanity to suite_architecture table, rollback issued. Error message : %s" % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Rename squeeze-volatile to squeeze-updates to get more confused users
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2010 Joerg Jaspert <joerg@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-from socket import gethostname;
-
-################################################################################
-def do_update(self):
- """
- Rename squeeze-volatile to squeeze-updates to get more confused users
- """
- print __doc__
- try:
- c = self.db.cursor()
- if gethostname() == 'franck':
- c.execute("UPDATE suite SET suite_name='squeeze-updates', description='Updated packages for Debian x.y', codename='squeeze-updates' WHERE suite_name='squeeze-volatile'")
- c.execute("UPDATE build_queue SET queue_name='buildd-squeeze-updates', path='/srv/incoming.debian.org/dists/squeeze-updates/buildd', releasedescription='buildd squeeze updates incoming' WHERE queue_name='buildd-squeeze-volatile'")
- c.execute("UPDATE policy_queue SET queue_name='squeeze-updates-proposed-updates', path='/srv/ftp-master.debian.org/queue/updates/squeeze-updates-p-u-new' WHERE queue_name='squeeze-volatile-proposed-updates'")
- c.execute("UPDATE config SET value = '40' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply sick update 40, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Remove useless type casts from primary keys to support sqlalchemy's reflection
-mechanism for all tables. Rename 2 sequences and add 1 primary key.
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2011 Torsten Werner <twerner@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-from socket import gethostname;
-
-################################################################################
-def do_update(self):
- """
- Remove useless type casts from primary keys, fix 2 sequences, and add 1
- primary key.
- """
- print __doc__
- try:
- c = self.db.cursor()
-
- # remove useless type casts
- for table in ('architecture', 'archive', 'bin_associations', \
- 'binaries', 'component', 'dsc_files', 'files', \
- 'fingerprint', 'location', 'maintainer', 'override_type', \
- 'pending_bin_contents', 'priority', 'section', 'source', \
- 'src_associations', 'suite', 'uid'):
- c.execute("ALTER TABLE %s ALTER id SET DEFAULT nextval('%s_id_seq'::regclass)" % \
- (table, table))
-
- # rename sequences
- c.execute("ALTER SEQUENCE known_changes_id_seq RENAME TO changes_id_seq")
- c.execute("ALTER SEQUENCE queue_files_id_seq RENAME TO build_queue_files_id_seq")
-
- # replace unique contraint by primary key
- c.execute( \
- "ALTER TABLE bin_contents DROP CONSTRAINT bin_contents_file_key");
- c.execute("ALTER TABLE bin_contents ADD PRIMARY KEY (file, binary_id)");
-
- c.execute("UPDATE config SET value = '41' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply sick update 41, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Add "ButAutomaticUpgrades" field to the suite table
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2011 Joerg Jaspert <joerg@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-from socket import gethostname;
-
-################################################################################
-def do_update(self):
- """
- Add "ButAutomaticUpgrades" field to the suite table
- """
- print __doc__
- try:
- c = self.db.cursor()
-
- c.execute("ALTER TABLE suite ADD COLUMN butautomaticupgrades BOOLEAN NOT NULL DEFAULT FALSE;")
- c.execute("ALTER TABLE suite ADD CONSTRAINT bau_needs_na_set CHECK (not butautomaticupgrades or notautomatic);")
-
- c.execute("UPDATE config SET value = '42' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply update 42, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Fix up constraints for pg 9.0
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2011 Mark Hymers <mhy@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-from socket import gethostname;
-
-################################################################################
-def do_update(self):
- """
- Fix up constraints for pg 9.0
- """
- print __doc__
- try:
- c = self.db.cursor()
-
- c.execute("ALTER TABLE policy_queue DROP constraint policy_queue_perms_check")
- c.execute("ALTER TABLE policy_queue DROP constraint policy_queue_change_perms_check")
- c.execute("ALTER TABLE policy_queue ADD CONSTRAINT policy_queue_perms_check CHECK (perms SIMILAR TO '[0-7][0-7][0-7][0-7]')")
- c.execute("ALTER TABLE policy_queue ADD CONSTRAINT policy_queue_change_perms_check CHECK (change_perms SIMILAR TO '[0-7][0-7][0-7][0-7]')")
-
- c.execute("UPDATE config SET value = '43' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply update 43, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Remove old contents tables that are no longer needed by the current
-implementation.
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2011 Torsten Werner <twerner@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-from socket import gethostname;
-
-################################################################################
-def do_update(self):
- """
- Remove old contents tables that are no longer needed by the current
- implementation.
- """
- print __doc__
- try:
- c = self.db.cursor()
-
- # remove useless type casts
- for table in ('pending_bin_contents', 'deb_contents', 'udeb_contents'):
- c.execute("DROP TABLE %s" % table)
-
- c.execute("UPDATE config SET value = '44' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply sick update 44, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Add tables for extra_src handling
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2011 Mark Hymers <mhy@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-def do_update(self):
- """
- Add tables for extra_src handling
- """
- print __doc__
- try:
- c = self.db.cursor()
-
- c.execute("""
-CREATE TABLE extra_src_references (
- bin_id INT4 NOT NULL REFERENCES binaries(id) ON DELETE CASCADE,
- src_id INT4 NOT NULL REFERENCES source(id) ON DELETE RESTRICT,
-
- PRIMARY KEY (bin_id, src_id)
-)""")
-
- c.execute("UPDATE config SET value = '45' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply update 45, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Add columns and tables for Packages/Sources work
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2011 Mark Hymers <mhy@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-def do_update(self):
- """
- Add columns and tables for Packages/Sources work
- """
- print __doc__
- try:
- c = self.db.cursor()
-
- c.execute("""ALTER TABLE binaries ADD COLUMN stanza TEXT""")
- c.execute("""ALTER TABLE source ADD COLUMN stanza TEXT""")
-
- c.execute("""
-CREATE TABLE metadata_keys (
- key_id SERIAL NOT NULL UNIQUE,
- key TEXT NOT NULL UNIQUE,
-
- PRIMARY KEY (key_id)
-)
-""")
-
- c.execute("""
-CREATE TABLE binaries_metadata (
- bin_id INT4 NOT NULL REFERENCES binaries(id) ON DELETE CASCADE,
- key_id INT4 NOT NULL REFERENCES metadata_keys(key_id),
- value TEXT NOT NULL,
-
- PRIMARY KEY (bin_id, key_id)
-)
-""")
-
- c.execute("""
-CREATE TABLE source_metadata (
- src_id INT4 NOT NULL REFERENCES source(id) ON DELETE CASCADE,
- key_id INT4 NOT NULL REFERENCES metadata_keys(key_id),
- value TEXT NOT NULL,
-
- PRIMARY KEY (src_id, key_id)
-)
-""")
-
- c.execute("UPDATE config SET value = '46' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply update 46, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Add table for source contents.
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2011 Torsten Werner <twerner@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-from socket import gethostname;
-
-################################################################################
-def do_update(self):
- """
- Add table for source contents.
- """
- print __doc__
- try:
- c = self.db.cursor()
-
- c.execute("""
- CREATE TABLE src_contents (
- file TEXT,
- source_id INTEGER REFERENCES source(id) ON DELETE CASCADE,
- PRIMARY KEY (file, source_id))""")
-
- c.execute("UPDATE config SET value = '47' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply sick update 47, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Suite.version can be null
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2011 Joerg Jaspert <joerg@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-from socket import gethostname;
-
-################################################################################
-def do_update(self):
- """
- Add table for source contents.
- """
- print __doc__
- try:
- c = self.db.cursor()
-
- c.execute("ALTER TABLE suite ALTER COLUMN version DROP NOT NULL")
- c.execute("UPDATE suite SET version=NULL WHERE version='-'")
-
- c.execute("UPDATE config SET value = '48' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply sick update 48, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Permission fixups
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2011 Mark Hymers <mhy@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-from socket import gethostname;
-
-################################################################################
-def do_update(self):
- """
- Fix up permissions
- """
- print __doc__
- try:
- c = self.db.cursor()
-
- c.execute("GRANT SELECT, UPDATE, INSERT ON binaries_metadata TO ftpmaster")
- c.execute("GRANT SELECT ON binaries_metadata TO public")
- c.execute("GRANT USAGE ON metadata_keys_key_id_seq TO ftpmaster")
- c.execute("GRANT SELECT, UPDATE, INSERT ON source_metadata TO ftpmaster")
- c.execute("GRANT SELECT ON source_metadata TO public")
- c.execute("GRANT SELECT, UPDATE, INSERT ON metadata_keys TO ftpmaster")
- c.execute("GRANT SELECT ON metadata_keys TO public")
- c.execute("GRANT SELECT, UPDATE, INSERT ON extra_src_references TO ftpmaster")
- c.execute("GRANT SELECT ON extra_src_references TO public")
- c.execute("GRANT SELECT, UPDATE, INSERT ON src_contents TO ftpmaster")
- c.execute("GRANT SELECT ON src_contents TO public")
- c.execute("GRANT USAGE ON changelogs_text_id_seq TO ftpmaster")
- c.execute("GRANT SELECT ON changes_pending_files_map TO public")
- c.execute("GRANT SELECT ON config TO public")
-
- c.execute("UPDATE config SET value = '49' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply sick update 49, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-
-"""
-Fix bin_assoc_by_arch view
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2009 Joerg Jaspert <joerg@debian.org>
-@license: GNU General Public License version 2 or later
-
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-
-def do_update(self):
- """ Execute the DB update """
-
- print "Fixing bin_assoc_by_arch view"
- try:
- c = self.db.cursor()
-
- c.execute("""CREATE OR REPLACE VIEW bin_assoc_by_arch AS
- SELECT ba.suite, ba.bin, a.id AS arch
- FROM bin_associations ba
- JOIN binaries b ON ba.bin = b.id, architecture a
- WHERE a.id > 2 AND (b.architecture = 2 OR b.architecture = a.id) """)
- c.execute("UPDATE config SET value = '5' WHERE name = 'db_revision'")
-
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError("Unable to recreate bin_assoc_by_arch view, rollback issued. Error message : %s" % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Allow us to mark keyrings as no longer in use
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2011 Mark Hymers <mhy@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-from socket import gethostname;
-
-################################################################################
-def do_update(self):
- """
- Allow us to mark keyrings as no longer in use
- """
- print __doc__
- try:
- c = self.db.cursor()
-
- c.execute("ALTER TABLE keyrings ADD COLUMN active BOOL DEFAULT TRUE")
- c.execute("UPDATE config SET value = '50' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply sick update 50, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Fix table for source contents.
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2011 Torsten Werner <twerner@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-from socket import gethostname;
-
-################################################################################
-def do_update(self):
- """
- Fix table for source contents.
- """
- print __doc__
- try:
- c = self.db.cursor()
-
- c.execute("""
- CREATE INDEX ON src_contents (source_id)""")
- c.execute("""
- ALTER TABLE src_contents ADD COLUMN created TIMESTAMP WITH TIME ZONE
- NOT NULL DEFAULT now()""")
- c.execute("""
- ALTER TABLE src_contents ADD COLUMN modified TIMESTAMP WITH TIME ZONE
- NOT NULL DEFAULT now()""")
- c.execute("""
- CREATE TRIGGER modified_src_contents BEFORE UPDATE ON src_contents
- FOR EACH ROW EXECUTE PROCEDURE tfunc_set_modified()""")
-
- c.execute("UPDATE config SET value = '51' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply sick update 51, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Add table for version checks.
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2011 Ansgar Burchardt <ansgar@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-from daklib.config import Config
-
-################################################################################
-def do_update(self):
- """
- Add table for version checks.
- """
- print __doc__
- try:
- cnf = Config()
- c = self.db.cursor()
-
- c.execute("""
- CREATE TABLE version_check (
- suite INTEGER NOT NULL REFERENCES suite(id),
- "check" TEXT NOT NULL CHECK ("check" IN ('Enhances', 'MustBeNewerThan', 'MustBeOlderThan')),
- reference INTEGER NOT NULL REFERENCES suite(id),
- PRIMARY KEY(suite, "check", reference)
- )""")
-
- c.execute("SELECT suite_name, id FROM suite")
- suites = c.fetchall()
- suite_id_map = {}
- for suite_name, suite_id in suites:
- suite_id_map[suite_name] = suite_id
-
- for check in ["Enhances", "MustBeNewerThan", "MustBeOlderThan"]:
- for suite_name in suite_id_map.keys():
- for reference_name in [ s.lower() for s in cnf.value_list("Suite::%s::VersionChecks::%s" % (suite_name, check)) ]:
- c.execute("""INSERT INTO version_check (suite, "check", reference) VALUES (%s, %s, %s)""", (suite_id_map[suite_name], check, suite_id_map[reference_name]))
-
- c.execute("UPDATE config SET value = '52' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply sick update 52, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Add table for build queue files from policy queues.
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2011 Ansgar Burchardt <ansgar@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-def do_update(self):
- """
- Add table for build queue files from policy queues.
- """
- print __doc__
- try:
- c = self.db.cursor()
-
- c.execute("""
- CREATE TABLE build_queue_policy_files (
- build_queue_id INTEGER NOT NULL REFERENCES build_queue(id) ON DELETE CASCADE,
- file_id INTEGER NOT NULL REFERENCES changes_pending_files(id) ON DELETE CASCADE,
- filename TEXT NOT NULL,
- created TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
- lastused TIMESTAMP WITHOUT TIME ZONE,
- PRIMARY KEY (build_queue_id, file_id)
- )""")
-
- c.execute("UPDATE config SET value = '53' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply sick update 53, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Add send_to_build_queues to policy_queue table
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2011 Ansgar Burchardt <ansgar@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-def do_update(self):
- """
- Add send_to_build_queues to policy_queue table
- """
- print __doc__
- try:
- c = self.db.cursor()
-
- c.execute("""
- ALTER TABLE policy_queue ADD COLUMN send_to_build_queues BOOLEAN NOT NULL DEFAULT 'f'
- """)
- c.execute("""
- UPDATE policy_queue SET send_to_build_queues='t' WHERE queue_name IN ('embargo', 'disembargo')
- """)
-
- c.execute("UPDATE config SET value = '54' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply sick update 54, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Drop unused view bin_assoc_by_arch.
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2011 Torsten Werner <twerner@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-from socket import gethostname;
-
-################################################################################
-def do_update(self):
- """
- Drop unused view bin_assoc_by_arch.
- """
- print __doc__
- try:
- c = self.db.cursor()
-
- c.execute("""
- DROP VIEW bin_assoc_by_arch""")
-
- c.execute("UPDATE config SET value = '55' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply sick update 55, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Add order column to metadata_keys
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2011 Ansgar Burchardt <ansgar@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-def do_update(self):
- """
- Add order column to metadata_keys
- """
- print __doc__
- try:
- c = self.db.cursor()
-
- c.execute("ALTER TABLE metadata_keys ADD COLUMN ordering INTEGER NOT NULL DEFAULT 0")
-
- initial_order = {
- 'Package': -2600,
- 'Source': -2500,
- 'Binary': -2400,
- 'Version': -2300,
- 'Essential': -2250,
- 'Installed-Size': -2200,
- 'Maintainer': -2100,
- 'Uploaders': -2090,
- 'Original-Maintainer': -2080,
- 'Build-Depends': -2000,
- 'Build-Depends-Indep': -1990,
- 'Build-Conflicts': -1980,
- 'Build-Conflicts-Indep': -1970,
- 'Architecture': -1800,
- 'Standards-Version': -1700,
- 'Format': -1600,
- 'Files': -1500,
- 'DM-Upload-Allowed': -1400,
- 'Vcs-%': -1300,
- 'Checksums-%': -1200,
- 'Replaces': -1100,
- 'Provides': -1000,
- 'Depends': -900,
- 'Pre-Depends': -850,
- 'Recommends': -800,
- 'Suggests': -700,
- 'Enhances': -650,
- 'Conflicts': -600,
- 'Breaks': -500,
- 'Description': -400,
- 'Origin': -300,
- 'Bugs': -200,
- 'Multi-Arch': -150,
- 'Homepage': -100,
- 'Tag': 300,
- 'Package-Type': 400,
- 'Installer-Menu-Item': 500,
- }
-
- for key, order in initial_order.items():
- c.execute("""UPDATE metadata_keys SET ordering = '%s' WHERE key ILIKE '%s'""" % (order, key))
-
- c.execute("UPDATE config SET value = '56' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply sick update 56, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Allow per-suite signing keys
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2011 Mark Hymers <mhy@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-def do_update(self):
- """
- Allow per-suite signing keys
- """
- print __doc__
- try:
- c = self.db.cursor()
-
- c.execute("""ALTER TABLE suite ADD COLUMN signingkeys TEXT[]""")
- c.execute("""UPDATE suite SET signingkeys = signingkeys || (SELECT value FROM config WHERE name = 'signingkeyids')""")
- c.execute("""DELETE FROM config WHERE name = 'signingkeyids'""")
-
- c.execute("UPDATE config SET value = '57' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply sick update 57, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Fix permissions again
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2011 Mark Hymers <mhy@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-def do_update(self):
- """
- Fix up permissions (again)
- """
- print __doc__
- try:
- c = self.db.cursor()
-
- for table in ['build_queue_policy_files',
- 'version_check']:
- c.execute("""GRANT SELECT, UPDATE, INSERT ON %s TO ftpmaster""" % table)
- c.execute("""GRANT SELECT ON %s TO public""" % table)
-
- # Make sure all sequences are fixed up
- for seq in ['architecture_id_seq',
- 'archive_id_seq',
- 'bin_associations_id_seq',
- 'binaries_id_seq',
- 'binary_acl_id_seq',
- 'binary_acl_map_id_seq',
- 'build_queue_files_id_seq',
- 'build_queue_id_seq',
- 'changelogs_text_id_seq',
- 'changes_id_seq',
- 'changes_pending_binaries_id_seq',
- 'changes_pending_files_id_seq',
- 'changes_pending_source_id_seq',
- 'component_id_seq',
- 'config_id_seq',
- 'dsc_files_id_seq',
- 'files_id_seq',
- 'fingerprint_id_seq',
- 'keyring_acl_map_id_seq',
- 'keyrings_id_seq',
- 'location_id_seq',
- 'maintainer_id_seq',
- 'metadata_keys_key_id_seq',
- 'new_comments_id_seq',
- 'override_type_id_seq',
- 'policy_queue_id_seq',
- 'priority_id_seq',
- 'section_id_seq',
- 'source_acl_id_seq',
- 'source_id_seq',
- 'src_associations_id_seq',
- 'src_format_id_seq',
- 'src_uploaders_id_seq',
- 'suite_id_seq',
- 'uid_id_seq',
- 'upload_blocks_id_seq']:
- c.execute("""GRANT SELECT, UPDATE, USAGE ON %s TO ftpmaster""" % seq)
- c.execute("""GRANT SELECT ON %s TO public""" % seq)
-
- c.execute("UPDATE config SET value = '58' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply sick update 58, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Add external_overrides
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2011 Ansgar Burchardt <ansgar@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-def do_update(self):
- """
- Add external_overrides
- """
- print __doc__
- try:
- c = self.db.cursor()
-
- c.execute("""
- CREATE TABLE external_overrides (
- package TEXT NOT NULL,
- key TEXT NOT NULL,
- value TEXT NOT NULL,
- PRIMARY KEY (package, key)
- )""");
-
- c.execute("GRANT SELECT, UPDATE, INSERT, DELETE ON external_overrides TO ftpmaster");
- c.execute("GRANT SELECT ON external_overrides TO public");
-
- c.execute("UPDATE config SET value = '59' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply sick update 59, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Adding content fields
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2008 Michael Casadevall <mcasadevall@debian.org>
-@copyright: 2008 Roger Leigh <rleigh@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-# <tomv_w> really, if we want to screw ourselves, let's find a better way.
-# <Ganneff> rm -rf /srv/ftp.debian.org
-
-################################################################################
-
-import psycopg2
-import time
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-
-def do_update(self):
- print "Adding content fields to database"
-
- try:
- c = self.db.cursor()
- c.execute("""CREATE TABLE content_file_paths (
- id serial primary key not null,
- path text unique not null
- )""")
-
- c.execute("""CREATE TABLE content_file_names (
- id serial primary key not null,
- file text unique not null
- )""")
-
- c.execute("""CREATE TABLE content_associations (
- id serial not null,
- binary_pkg int4 not null references binaries(id) on delete cascade,
- filepath int4 not null references content_file_paths(id) on delete cascade,
- filename int4 not null references content_file_names(id) on delete cascade
- );""")
-
- c.execute("""CREATE TABLE pending_content_associations (
- id serial not null,
- package text not null,
- version debversion not null,
- filepath int4 not null references content_file_paths(id) on delete cascade,
- filename int4 not null references content_file_names(id) on delete cascade
- );""")
-
- c.execute("""CREATE FUNCTION comma_concat(text, text) RETURNS text
- AS $_$select case
- WHEN $2 is null or $2 = '' THEN $1
- WHEN $1 is null or $1 = '' THEN $2
- ELSE $1 || ',' || $2
- END$_$
- LANGUAGE sql""")
-
- c.execute("""CREATE AGGREGATE comma_separated_list (
- BASETYPE = text,
- SFUNC = comma_concat,
- STYPE = text,
- INITCOND = ''
- );""")
-
- c.execute( "CREATE INDEX content_assocaitions_binary ON content_associations(binary_pkg)" )
-
- c.execute("UPDATE config SET value = '6' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError("Unable to appy debversion updates, rollback issued. Error message : %s" % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Make external overrides specific for (suite, component)
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2011 Ansgar Burchardt <ansgar@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-def do_update(self):
- """
- Make external overrides specific for (suite, component)
- """
- print __doc__
- try:
- c = self.db.cursor()
-
- c.execute("DELETE FROM external_overrides")
- print "NOTE: Please reimport the external overrides."
-
- c.execute("""
- ALTER TABLE external_overrides
- DROP CONSTRAINT external_overrides_pkey,
- ADD COLUMN suite INTEGER NOT NULL REFERENCES suite(id),
- ADD COLUMN component INTEGER NOT NULL REFERENCES component(id),
- ADD PRIMARY KEY (suite, component, package, key)
- """)
-
- c.execute("UPDATE config SET value = '60' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply sick update 60, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Just a view for version checks
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2011 Joerg Jaspert <joerg@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-def do_update(self):
- """
- Just a view for version checks
- """
- print __doc__
- try:
- c = self.db.cursor()
-
- c.execute("""
- CREATE OR REPLACE VIEW version_checks AS
- SELECT s.suite_name AS source_suite, v.check as condition, t.suite_name AS target_suite
- FROM suite s
- JOIN version_check v ON (s.id = v.suite)
- JOIN suite t ON (v.reference = t.id)
- ORDER BY source_suite, condition, target_suite;
- """)
-
- c.execute("GRANT SELECT on version_checks TO PUBLIC;")
- c.execute("UPDATE config SET value = '61' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply sick update 61, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Ensure that suite_name is unique!
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2011 Mark Hymers <mhy@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-
-################################################################################
-def do_update(self):
- """
- Ensure that suite_name is unique
- """
- print __doc__
- try:
- c = self.db.cursor()
-
- c.execute("ALTER TABLE suite ADD CONSTRAINT suite_name_unique UNIQUE (suite_name)")
-
- c.execute("UPDATE config SET value = '62' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply sick update 62, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Add missing PrimaryMirror field to archive table
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2011 Mark Hymers <mhy@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-from daklib.config import Config
-
-################################################################################
-def do_update(self):
- """
- Add missing PrimaryMirror field to archive table
- """
- print __doc__
- try:
- cnf = Config()
-
- c = self.db.cursor()
-
- c.execute("ALTER TABLE archive ADD COLUMN primary_mirror TEXT")
-
- c.execute("SELECT id, name FROM archive")
-
- query = "UPDATE archive SET primary_mirror = %s WHERE id = %s"
- for a_id, a_name in c.fetchall():
- if cnf.has_key('Archive::%s::PrimaryMirror' % a_name):
- primloc = cnf['Archive::%s::PrimaryMirror' % a_name]
- print "Setting archive %s PrimaryMirror to %s" % (a_name, primloc)
- c.execute(query, [primloc, a_id])
-
- c.execute("UPDATE config SET value = '63' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply sick update 63, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Fix up permissions on changes_pool_files
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2011 Mark Hymers <mhy@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-from daklib.config import Config
-
-################################################################################
-def do_update(self):
- """
- Fix up permissions on changes_pool_files
- """
- print __doc__
- try:
- c = self.db.cursor()
-
- c.execute("REVOKE INSERT ON changes_pool_files FROM ftpteam")
- c.execute("GRANT DELETE ON changes_pool_files TO ftpteam")
-
- c.execute("UPDATE config SET value = '64' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply sick update 64, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Make announce field an array
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2011 Mark Hymers <mhy@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-from daklib.config import Config
-
-################################################################################
-def do_update(self):
- """
- Make announce field an array
- """
- print __doc__
- try:
- c = self.db.cursor()
-
- c.execute("ALTER TABLE suite RENAME COLUMN announce TO announce_temp")
- c.execute("ALTER TABLE suite ADD COLUMN announce TEXT[]")
- c.execute("UPDATE suite SET announce = ARRAY[announce_temp] WHERE announce_temp IS NOT NULL")
- c.execute("ALTER TABLE suite DROP COLUMN announce_temp")
-
- c.execute("UPDATE config SET value = '65' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply sick update 65, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Add 2 partial indexes to speed up dak rm.
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2011 Torsten Werner <twerner@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-from daklib.config import Config
-
-################################################################################
-def do_update(self):
- """
- Add 2 partial indexes to speed up dak rm.
- """
- print __doc__
- try:
- cnf = Config()
-
- c = self.db.cursor()
-
- # partial index for Depends
- c.execute("SELECT key_id FROM metadata_keys WHERE key = 'Depends'")
- key = c.fetchone()[0]
- c.execute("""CREATE INDEX binaries_metadata_depends
- ON binaries_metadata (bin_id) WHERE key_id = %d""" % key)
-
- # partial index for Provides
- c.execute("SELECT key_id FROM metadata_keys WHERE key = 'Provides'")
- key = c.fetchone()[0]
- c.execute("""CREATE INDEX binaries_metadata_provides
- ON binaries_metadata (bin_id) WHERE key_id = %d""" % key)
-
- c.execute("UPDATE config SET value = '66' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply sick update 66, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Add audit schema and initial package table and triggers
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2011 Mark Hymers <mhy@debian.org>
-@copyright: 2011 Ansgar Burchardt <ansgar@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-from daklib.config import Config
-
-################################################################################
-def do_update(self):
- """
- Add audit schema and initial package table and triggers
- """
- print __doc__
- try:
- c = self.db.cursor()
-
- c.execute("CREATE SCHEMA audit");
- c.execute("GRANT USAGE on SCHEMA audit TO public")
- c.execute("GRANT USAGE on SCHEMA audit TO ftpteam")
- c.execute("GRANT USAGE on SCHEMA audit TO ftpmaster")
-
- c.execute("""CREATE TABLE audit.package_changes (
- changedate TIMESTAMP NOT NULL DEFAULT now(),
- package TEXT NOT NULL,
- version DEBVERSION NOT NULL,
- architecture TEXT NOT NULL,
- suite TEXT NOT NULL,
- event TEXT NOT NULL,
- priority TEXT,
- component TEXT,
- section TEXT
-)""")
-
- c.execute("GRANT INSERT ON audit.package_changes TO dak")
- c.execute("GRANT SELECT ON audit.package_changes TO PUBLIC")
-
- c.execute("""CREATE OR REPLACE FUNCTION trigger_binsrc_assoc_update() RETURNS TRIGGER AS $$
-DECLARE
- v_data RECORD;
-
- v_package audit.package_changes.package%TYPE;
- v_version audit.package_changes.version%TYPE;
- v_architecture audit.package_changes.architecture%TYPE;
- v_suite audit.package_changes.suite%TYPE;
- v_event audit.package_changes.event%TYPE;
- v_priority audit.package_changes.priority%TYPE;
- v_component audit.package_changes.component%TYPE;
- v_section audit.package_changes.section%TYPE;
-BEGIN
- CASE TG_OP
- WHEN 'INSERT' THEN v_event := 'I'; v_data := NEW;
- WHEN 'DELETE' THEN v_event := 'D'; v_data := OLD;
- ELSE RAISE EXCEPTION 'trigger called for invalid operation (%)', TG_OP;
- END CASE;
-
- SELECT suite_name INTO STRICT v_suite FROM suite WHERE id = v_data.suite;
-
- CASE TG_TABLE_NAME
- WHEN 'bin_associations' THEN
- SELECT package, version, arch_string
- INTO STRICT v_package, v_version, v_architecture
- FROM binaries LEFT JOIN architecture ON (architecture.id = binaries.architecture)
- WHERE binaries.id = v_data.bin;
-
- SELECT component.name, priority.priority, section.section
- INTO v_component, v_priority, v_section
- FROM override
- JOIN override_type ON (override.type = override_type.id)
- JOIN priority ON (priority.id = override.priority)
- JOIN section ON (section.id = override.section)
- JOIN component ON (override.component = component.id)
- JOIN suite ON (suite.id = override.suite)
- WHERE override_type.type != 'dsc'
- AND override.package = v_package AND suite.id = v_data.suite;
-
- WHEN 'src_associations' THEN
- SELECT source, version
- INTO STRICT v_package, v_version
- FROM source WHERE source.id = v_data.source;
- v_architecture := 'source';
-
- SELECT component.name, priority.priority, section.section
- INTO v_component, v_priority, v_section
- FROM override
- JOIN override_type ON (override.type = override_type.id)
- JOIN priority ON (priority.id = override.priority)
- JOIN section ON (section.id = override.section)
- JOIN component ON (override.component = component.id)
- JOIN suite ON (suite.id = override.suite)
- WHERE override_type.type = 'dsc'
- AND override.package = v_package AND suite.id = v_data.suite;
-
- ELSE RAISE EXCEPTION 'trigger called for invalid table (%)', TG_TABLE_NAME;
- END CASE;
-
- INSERT INTO audit.package_changes
- (package, version, architecture, suite, event, priority, component, section)
- VALUES (v_package, v_version, v_architecture, v_suite, v_event, v_priority, v_component, v_section);
-
- RETURN NEW;
-END;
-$$ LANGUAGE plpgsql VOLATILE SECURITY DEFINER
-SET search_path = public, pg_temp""");
-
- c.execute("""CREATE OR REPLACE FUNCTION trigger_override_update() RETURNS TRIGGER AS $$
-DECLARE
- v_src_override_id override_type.id%TYPE;
-
- v_priority audit.package_changes.priority%TYPE := NULL;
- v_component audit.package_changes.component%TYPE := NULL;
- v_section audit.package_changes.section%TYPE := NULL;
-BEGIN
-
- IF TG_TABLE_NAME != 'override' THEN
- RAISE EXCEPTION 'trigger called for invalid table (%)', TG_TABLE_NAME;
- END IF;
- IF TG_OP != 'UPDATE' THEN
- RAISE EXCEPTION 'trigger called for invalid event (%)', TG_OP;
- END IF;
-
- IF OLD.package != NEW.package OR OLD.type != NEW.type OR OLD.suite != NEW.suite THEN
- RETURN NEW;
- END IF;
-
- IF OLD.priority != NEW.priority THEN
- SELECT priority INTO STRICT v_priority FROM priority WHERE id = NEW.priority;
- END IF;
-
- IF OLD.component != NEW.component THEN
- SELECT name INTO STRICT v_component FROM component WHERE id = NEW.component;
- END IF;
-
- IF OLD.section != NEW.section THEN
- SELECT section INTO STRICT v_section FROM section WHERE id = NEW.section;
- END IF;
-
- -- Find out if we're doing src or binary overrides
- SELECT id INTO STRICT v_src_override_id FROM override_type WHERE type = 'dsc';
- IF OLD.type = v_src_override_id THEN
- -- Doing a src_association link
- INSERT INTO audit.package_changes
- (package, version, architecture, suite, event, priority, component, section)
- SELECT NEW.package, source.version, 'source', suite.suite_name, 'U', v_priority, v_component, v_section
- FROM source
- JOIN src_associations ON (source.id = src_associations.source)
- JOIN suite ON (suite.id = src_associations.suite)
- WHERE source.source = NEW.package AND src_associations.suite = NEW.suite;
- ELSE
- -- Doing a bin_association link
- INSERT INTO audit.package_changes
- (package, version, architecture, suite, event, priority, component, section)
- SELECT NEW.package, binaries.version, architecture.arch_string, suite.suite_name, 'U', v_priority, v_component, v_section
- FROM binaries
- JOIN bin_associations ON (binaries.id = bin_associations.bin)
- JOIN architecture ON (architecture.id = binaries.architecture)
- JOIN suite ON (suite.id = bin_associations.suite)
- WHERE binaries.package = NEW.package AND bin_associations.suite = NEW.suite;
- END IF;
-
- RETURN NEW;
-END;
-$$ LANGUAGE plpgsql VOLATILE SECURITY DEFINER
-SET search_path = public, pg_temp""");
-
- c.execute("CREATE TRIGGER trigger_bin_associations_audit AFTER INSERT OR DELETE ON bin_associations FOR EACH ROW EXECUTE PROCEDURE trigger_binsrc_assoc_update()")
- c.execute("CREATE TRIGGER trigger_src_associations_audit AFTER INSERT OR DELETE ON src_associations FOR EACH ROW EXECUTE PROCEDURE trigger_binsrc_assoc_update()")
- c.execute("CREATE TRIGGER trigger_override_audit AFTER UPDATE ON override FOR EACH ROW EXECUTE PROCEDURE trigger_override_update()")
-
- c.execute("UPDATE config SET value = '67' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError, msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply sick update 67, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Drop unused plperl routine and language and plpythonu language
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2011 Mark Hymers <mhy@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-import psycopg2
-from daklib.dak_exceptions import DBUpdateError
-from daklib.config import Config
-
-################################################################################
-def do_update(self):
- """
- Drop unused plperl routine and language and plpythonu language
- """
- print __doc__
- try:
- cnf = Config()
-
- c = self.db.cursor()
-
- c.execute("DROP FUNCTION debversion_compare_single(text,text)")
- c.execute("DROP LANGUAGE plperl");
- c.execute("DROP LANGUAGE plpythonu");
-
- c.execute("UPDATE config SET value = '68' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError('Unable to apply sick update 68, rollback issued. Error message : %s' % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Moving suite config into DB
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2008 Michael Casadevall <mcasadevall@debian.org>
-@copyright: 2009 Joerg Jaspert <joerg@debian.org>
-@license: GNU General Public License version 2 or later
-
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-# * Ganneff ponders how to best write the text to -devel. (need to tell em in
-# case they find more bugs). "We fixed the fucking idiotic broken implementation
-# to be less so" is probably not the nicest, even if perfect valid, way to say so
-
-################################################################################
-
-import psycopg2
-import time
-from daklib.dak_exceptions import DBUpdateError
-from daklib.utils import get_conf
-
-################################################################################
-
-def do_update(self):
- print "Moving some of the suite config into the DB"
- Cnf = get_conf()
-
- try:
- c = self.db.cursor()
-
- c.execute("ALTER TABLE suite ADD COLUMN untouchable BOOLEAN NOT NULL DEFAULT FALSE;")
- query = "UPDATE suite SET untouchable = TRUE WHERE suite_name = %s" #: Update query
- for suite in Cnf.subtree("Suite").list():
- untouchable = Cnf.find("Suite::%s::Untouchable" % (suite))
- if not untouchable:
- continue
- print "[Untouchable] Processing suite %s" % (suite)
- suite = suite.lower()
- c.execute(query, [suite])
-
-
- c.execute("ALTER TABLE suite ADD COLUMN announce text NOT NULL DEFAULT 'debian-devel-changes@lists.debian.org';")
- query = "UPDATE suite SET announce = %s WHERE suite_name = %s" #: Update query
- for suite in Cnf.subtree("Suite").list():
- announce_list = Cnf.find("Suite::%s::Announce" % (suite))
- print "[Announce] Processing suite %s" % (suite)
- suite = suite.lower()
- c.execute(query, [announce_list, suite])
-
- c.execute("ALTER TABLE suite ADD COLUMN codename text;")
- query = "UPDATE suite SET codename = %s WHERE suite_name = %s" #: Update query
- for suite in Cnf.subtree("Suite").list():
- codename = Cnf.find("Suite::%s::CodeName" % (suite))
- print "[Codename] Processing suite %s" % (suite)
- suite = suite.lower()
- c.execute(query, [codename, suite])
-
- c.execute("ALTER TABLE suite ADD COLUMN overridecodename text;")
- query = "UPDATE suite SET overridecodename = %s WHERE suite_name = %s" #: Update query
- for suite in Cnf.subtree("Suite").list():
- codename = Cnf.find("Suite::%s::OverrideCodeName" % (suite))
- print "[OverrideCodeName] Processing suite %s" % (suite)
- suite = suite.lower()
- c.execute(query, [codename, suite])
-
- c.execute("ALTER TABLE suite ADD COLUMN validtime integer NOT NULL DEFAULT 604800;")
- query = "UPDATE suite SET validtime = %s WHERE suite_name = %s" #: Update query
- for suite in Cnf.subtree("Suite").list():
- validtime = Cnf.find("Suite::%s::ValidTime" % (suite))
- print "[ValidTime] Processing suite %s" % (suite)
- if not validtime:
- validtime = 0
- suite = suite.lower()
- c.execute(query, [validtime, suite])
-
- c.execute("ALTER TABLE suite ADD COLUMN priority integer NOT NULL DEFAULT 0;")
- query = "UPDATE suite SET priority = %s WHERE suite_name = %s" #: Update query
- for suite in Cnf.subtree("Suite").list():
- priority = Cnf.find("Suite::%s::Priority" % (suite))
- print "[Priority] Processing suite %s" % (suite)
- if not priority:
- priority = 0
- suite = suite.lower()
- c.execute(query, [priority, suite])
-
-
- c.execute("ALTER TABLE suite ADD COLUMN notautomatic BOOLEAN NOT NULL DEFAULT FALSE;")
- query = "UPDATE suite SET notautomatic = TRUE WHERE suite_name = %s" #: Update query
- for suite in Cnf.subtree("Suite").list():
- notautomatic = Cnf.find("Suite::%s::NotAutomatic" % (suite))
- print "[NotAutomatic] Processing suite %s" % (suite)
- if not notautomatic:
- continue
- suite = suite.lower()
- c.execute(query, [suite])
-
- c.execute("UPDATE config SET value = '7' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError("Unable to appy suite config updates, rollback issued. Error message : %s" % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-More suite config into the DB
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2008 Michael Casadevall <mcasadevall@debian.org>
-@copyright: 2009 Joerg Jaspert <joerg@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-# * Ganneff ponders how to best write the text to -devel. (need to tell em in
-# case they find more bugs). "We fixed the fucking idiotic broken implementation
-# to be less so" is probably not the nicest, even if perfect valid, way to say so
-
-################################################################################
-
-import psycopg2
-import time
-from daklib.dak_exceptions import DBUpdateError
-from daklib.utils import get_conf
-
-################################################################################
-
-def do_update(self):
- print "Moving some more of the suite config into the DB"
- Cnf = get_conf()
-
- try:
- c = self.db.cursor()
-
- c.execute("ALTER TABLE suite ADD COLUMN copychanges TEXT;")
- query = "UPDATE suite SET copychanges = %s WHERE suite_name = %s" #: Update query
- for suite in Cnf.subtree("Suite").list():
- copychanges = Cnf.find("Suite::%s::CopyChanges" % (suite))
- print "[CopyChanges] Processing suite %s" % (suite)
- if not copychanges:
- continue
- suite = suite.lower()
- c.execute(query, [copychanges, suite])
-
- c.execute("ALTER TABLE suite ADD COLUMN copydotdak TEXT;")
- query = "UPDATE suite SET copydotdak = %s WHERE suite_name = %s" #: Update query
- for suite in Cnf.subtree("Suite").list():
- copydotdak = Cnf.find("Suite::%s::CopyDotDak" % (suite))
- print "[CopyDotDak] Processing suite %s" % (suite)
- if not copydotdak:
- continue
- suite = suite.lower()
- c.execute(query, [copydotdak, suite])
-
- c.execute("ALTER TABLE suite ADD COLUMN commentsdir TEXT;")
- query = "UPDATE suite SET commentsdir = %s WHERE suite_name = %s" #: Update query
- for suite in Cnf.subtree("Suite").list():
- commentsdir = Cnf.find("Suite::%s::CommentsDir" % (suite))
- print "[CommentsDir] Processing suite %s" % (suite)
- if not commentsdir:
- continue
- suite = suite.lower()
- c.execute(query, [commentsdir, suite])
-
- c.execute("ALTER TABLE suite ADD COLUMN overridesuite TEXT;")
- query = "UPDATE suite SET overridesuite = %s WHERE suite_name = %s" #: Update query
- for suite in Cnf.subtree("Suite").list():
- overridesuite = Cnf.find("Suite::%s::OverrideSuite" % (suite))
- print "[OverrideSuite] Processing suite %s" % (suite)
- if not overridesuite:
- continue
- suite = suite.lower()
- c.execute(query, [overridesuite, suite])
-
- c.execute("ALTER TABLE suite ADD COLUMN changelogbase TEXT;")
- query = "UPDATE suite SET changelogbase = %s WHERE suite_name = %s" #: Update query
- for suite in Cnf.subtree("Suite").list():
- changelogbase = Cnf.find("Suite::%s::ChangeLogBase" % (suite))
- print "[ChangeLogBase] Processing suite %s" % (suite)
- if not changelogbase:
- continue
- suite = suite.lower()
- c.execute(query, [changelogbase, suite])
-
- c.execute("UPDATE config SET value = '8' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError("Unable to apply suite config updates, rollback issued. Error message : %s" % (str(msg)))
+++ /dev/null
-#!/usr/bin/env python
-# coding=utf8
-
-"""
-Pending contents disinguished by arch
-
-@contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2008 Michael Casadevall <mcasadevall@debian.org>
-@copyright: 2009 Mike O'Connor <stew@debian.org>
-@license: GNU General Public License version 2 or later
-"""
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-################################################################################
-
-# * Ganneff ponders how to best write the text to -devel. (need to tell em in
-# case they find more bugs). "We fixed the fucking idiotic broken implementation
-# to be less so" is probably not the nicest, even if perfect valid, way to say so
-
-################################################################################
-
-import psycopg2
-import time
-from daklib.dak_exceptions import DBUpdateError
-from daklib.utils import get_conf
-
-################################################################################
-
-def do_update(self):
- print "pending_contents should distinguish by arch"
- Cnf = get_conf()
-
- try:
- c = self.db.cursor()
-
- c.execute("DELETE FROM pending_content_associations")
- c.execute("""ALTER TABLE pending_content_associations
- ADD COLUMN architecture integer NOT NULL""")
- c.execute("""ALTER TABLE ONLY pending_content_associations
- ADD CONSTRAINT pending_content_assiciations_arch
- FOREIGN KEY (architecture)
- REFERENCES architecture(id)
- ON DELETE CASCADE""")
- c.execute("UPDATE config SET value = '9' WHERE name = 'db_revision'")
- self.db.commit()
-
- except psycopg2.ProgrammingError as msg:
- self.db.rollback()
- raise DBUpdateError("Unable to apply suite config updates, rollback issued. Error message : %s" % (str(msg)))