From: Joerg Jaspert Date: Thu, 24 Apr 2008 21:50:17 +0000 (+0200) Subject: Merge from Thomas X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=55a4e729db84095b12a67974092216be09ea384c;hp=7ca4fe7e35fd9927bdbac185fe7a36d3d5f6b464;p=dak.git Merge from Thomas --- diff --git a/ChangeLog b/ChangeLog index c4298b10..ce36677e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24,7 +24,7 @@ dumps, using a scheme to keep more of the recent dumps. * config/debian/cron.daily: Use the new script. Also - compress - all files older than 7 days, instead of 30. + all files older than 7 days, instead of 30. * dak/process_accepted.py (install): Do not break if a source/maintainer combination is already in src_uploaders, "just" @@ -155,6 +155,20 @@ changes[architecture] has source included. (check_transition): Now call the database.get_testing_version +2008-02-09 Christoph Berg + + * daklib/queue.py (get_type): fubar does not exist in global + namespace. + + * setup/add_constraints.sql setup/init_pool.sql: Add changedby column + to source table, and move src_uploaders after source so the REFERNCES + clause works. + * dak/process_accepted.py (install): Fill the changedby column from + the information found in the .changes. This will allow to identify + NMUs and sponsored uploads more precisely in tools querying projectb. + * scripts/debian/insert_missing_changedby.py: Script to import yet + missing fields from filippo's uploads-history DB. + 2008-02-06 Joerg Jaspert * daklib/utils.py (check_signature): Make variable key available, diff --git a/dak/clean_suites.py b/dak/clean_suites.py index a59d6e3a..e680f5ef 100755 --- a/dak/clean_suites.py +++ b/dak/clean_suites.py @@ -250,7 +250,7 @@ def clean_maintainers(): q = projectB.query(""" SELECT m.id FROM maintainer m WHERE NOT EXISTS (SELECT 1 FROM binaries b WHERE b.maintainer = m.id) - AND NOT EXISTS (SELECT 1 FROM source s WHERE s.maintainer = m.id) + AND NOT EXISTS (SELECT 1 FROM source s WHERE s.maintainer = m.id OR s.changedby = m.id) AND NOT EXISTS (SELECT 1 FROM src_uploaders u WHERE u.maintainer = m.id)""") ql = q.getresult() diff --git a/dak/process_accepted.py b/dak/process_accepted.py index 90edaf55..86396832 100755 --- a/dak/process_accepted.py +++ b/dak/process_accepted.py @@ -281,6 +281,9 @@ def install (): maintainer = dsc["maintainer"] maintainer = maintainer.replace("'", "\\'") maintainer_id = daklib.database.get_or_set_maintainer_id(maintainer) + changedby = changes["changed-by"] + changedby = changedby.replace("'", "\\'") + changedby_id = daklib.database.get_or_set_maintainer_id(changedby) fingerprint_id = daklib.database.get_or_set_fingerprint_id(dsc["fingerprint"]) install_date = time.strftime("%Y-%m-%d") filename = files[file]["pool name"] + file @@ -288,8 +291,8 @@ def install (): dsc_location_id = files[file]["location id"] if not files[file].has_key("files id") or not files[file]["files id"]: files[file]["files id"] = daklib.database.set_files_id (filename, files[file]["size"], files[file]["md5sum"], dsc_location_id) - projectB.query("INSERT INTO source (source, version, maintainer, file, install_date, sig_fpr) VALUES ('%s', '%s', %d, %d, '%s', %s)" - % (package, version, maintainer_id, files[file]["files id"], install_date, fingerprint_id)) + projectB.query("INSERT INTO source (source, version, maintainer, changedby, file, install_date, sig_fpr) VALUES ('%s', '%s', %d, %d, %d, '%s', %s)" + % (package, version, maintainer_id, changedby_id, files[file]["files id"], install_date, fingerprint_id)) for suite in changes["distribution"].keys(): suite_id = daklib.database.get_suite_id(suite) diff --git a/daklib/queue.py b/daklib/queue.py index 7b3aba09..a5a8eab4 100755 --- a/daklib/queue.py +++ b/daklib/queue.py @@ -106,12 +106,12 @@ def get_type(f): elif f["type"] in [ "orig.tar.gz", "orig.tar.bz2", "tar.gz", "tar.bz2", "diff.gz", "diff.bz2", "dsc" ]: type = "dsc" else: - fubar("invalid type (%s) for new. Dazed, confused and sure as heck not continuing." % (type)) + utils.fubar("invalid type (%s) for new. Dazed, confused and sure as heck not continuing." % (type)) # Validate the override type type_id = database.get_override_type_id(type) if type_id == -1: - fubar("invalid type (%s) for new. Say wha?" % (type)) + utils.fubar("invalid type (%s) for new. Say wha?" % (type)) return type diff --git a/scripts/debian/insert_missing_changedby.py b/scripts/debian/insert_missing_changedby.py new file mode 100755 index 00000000..7b817b5e --- /dev/null +++ b/scripts/debian/insert_missing_changedby.py @@ -0,0 +1,86 @@ +#!/usr/bin/env python + +# Adds yet unknown changedby fields when this column is added to an existing +# database. If everything goes well, it needs to be run only once. Data is +# extracted from Filippo Giunchedi's upload-history project, get the file at +# merkel:/home/filippo/upload-history/*.db. + +# Copyright (C) 2008 Christoph Berg + +# 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 + +############################################################################### + +# /Everybody stand back/ +# +# I know regular expressions + +############################################################################### + +import errno, fcntl, os, sys, time, re +import apt_pkg +import daklib.database +import daklib.queue +import daklib.utils +from pysqlite2 import dbapi2 as sqlite + +projectB = None +DBNAME = "uploads-ddc.db" +sqliteConn = None + +############################################################################### + +def insert (): + print "Adding missing changedby fields." + + projectB.query("BEGIN WORK") + + q = projectB.query("SELECT id, source, version FROM source WHERE changedby IS NULL") + + for i in q.getresult(): + print i[1] + "/" + i[2] + ":", + + cur = sqliteConn.cursor() + cur.execute("SELECT changedby FROM uploads WHERE package = '%s' AND version = '%s' LIMIT 1" % (i[1], i[2])) + res = cur.fetchall() + if len(res) != 1: + print "nothing found" + continue + + changedby = res[0][0].replace("'", "\\'") + changedby_id = daklib.database.get_or_set_maintainer_id(changedby) + + projectB.query("UPDATE source SET changedby = %d WHERE id = %d" % (changedby_id, i[0])) + print changedby, "(%d)" % changedby_id + + projectB.query("COMMIT WORK") + +############################################################################### + +def main(): + global projectB, sqliteConn + + Cnf = daklib.utils.get_conf() + Upload = daklib.queue.Upload(Cnf) + projectB = Upload.projectB + + sqliteConn = sqlite.connect(DBNAME) + + insert() + +############################################################################### + +if __name__ == '__main__': + main() diff --git a/setup/add_constraints.sql b/setup/add_constraints.sql index 8d275502..1d2bad66 100644 --- a/setup/add_constraints.sql +++ b/setup/add_constraints.sql @@ -5,6 +5,7 @@ ALTER TABLE files ADD CONSTRAINT files_location FOREIGN KEY (location) REFERENCES location(id) MATCH FULL; ALTER TABLE source ADD CONSTRAINT source_maintainer FOREIGN KEY (maintainer) REFERENCES maintainer(id) MATCH FULL; +ALTER TABLE source ADD CONSTRAINT source_changedby FOREIGN KEY (changedby) REFERENCES maintainer(id) MATCH FULL; ALTER TABLE source ADD CONSTRAINT source_file FOREIGN KEY (file) REFERENCES files(id) MATCH FULL; ALTER TABLE source ADD CONSTRAINT source_sig_fpr FOREIGN KEY (sig_fpr) REFERENCES fingerprint(id) MATCH FULL; diff --git a/setup/init_pool.sql b/setup/init_pool.sql index 0ab91ad6..9925148c 100644 --- a/setup/init_pool.sql +++ b/setup/init_pool.sql @@ -28,12 +28,6 @@ CREATE TABLE maintainer ( name TEXT UNIQUE NOT NULL ); -CREATE TABLE src_uploaders ( - id SERIAL PRIMARY KEY, - source INT4 NOT NULL REFERENCES source, - maintainer INT4 NOT NULL REFERENCES maintainer -); - CREATE TABLE uid ( id SERIAL PRIMARY KEY, uid TEXT UNIQUE NOT NULL, @@ -78,12 +72,19 @@ CREATE TABLE source ( source TEXT NOT NULL, version TEXT NOT NULL, maintainer INT4 NOT NULL, -- REFERENCES maintainer + changedby INT4 NOT NULL, -- REFERENCES maintainer file INT4 UNIQUE NOT NULL, -- REFERENCES files install_date TIMESTAMP NOT NULL, sig_fpr INT4 NOT NULL, -- REFERENCES fingerprint unique (source, version) ); +CREATE TABLE src_uploaders ( + id SERIAL PRIMARY KEY, + source INT4 NOT NULL REFERENCES source, + maintainer INT4 NOT NULL REFERENCES maintainer +); + CREATE TABLE dsc_files ( id SERIAL PRIMARY KEY, source INT4 NOT NULL, -- REFERENCES source,