From: Mark Hymers Date: Sat, 11 Apr 2009 18:35:06 +0000 (+0100) Subject: Merge commit 'mhyftpmaster/master' X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=ec44bcc3b4bbeb7a389dda77f39ff54436d1b181;hp=20c0374a2f1273dbf2f45363e6838753ee07709f;p=dak.git Merge commit 'mhyftpmaster/master' --- diff --git a/dak/dakdb/__init__.py b/dak/dakdb/__init__.py index e69de29b..a35616dd 100644 --- a/dak/dakdb/__init__.py +++ b/dak/dakdb/__init__.py @@ -0,0 +1,33 @@ +""" +Database update scripts for usage with B{dak update-db} + +@contact: Debian FTP Master +@copyright: 2008 Michael Casadevall +@license: GNU General Public License version 2 or later + +Update scripts have to C{import psycopg2} and +C{from daklib.dak_exceptions import DBUpdateError}. + +There has to be B{at least} the function C{do_update(self)} to be +defined. It should take all neccessary steps to update the +database. If the update fails the changes have to be rolled back and the +C{DBUpdateError} exception raised to properly halt the execution of any +other update. + +Example:: + def do_update(self): + print "Doing something" + + try: + c = self.db.cursor() + c.execute("SOME SQL STATEMENT") + self.db.commit() + + except psycopg2.ProgrammingError, msg: + self.db.rollback() + raise DBUpdateError, "Unable to do whatever, rollback issued. Error message : %s" % (str(msg)) + +This function can do whatever it wants and use everything from dak and +daklib. + +""" diff --git a/dak/dakdb/update1.py b/dak/dakdb/update1.py index 92fc4498..0c833773 100755 --- a/dak/dakdb/update1.py +++ b/dak/dakdb/update1.py @@ -1,7 +1,12 @@ #!/usr/bin/env python -""" Database Update Script - Saner DM db schema """ -# Copyright (C) 2008 Michael Casadevall +""" +Saner DM db schema + +@contact: Debian FTP Master +@copyright: 2008 Michael Casadevall +@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 diff --git a/dak/dakdb/update2.py b/dak/dakdb/update2.py index 850e3ab5..2e3cb446 100755 --- a/dak/dakdb/update2.py +++ b/dak/dakdb/update2.py @@ -1,9 +1,14 @@ #!/usr/bin/env python # coding=utf8 -""" Database Update Script - debversion """ -# Copyright © 2008 Michael Casadevall -# Copyright © 2008 Roger Leigh +""" +debversion + +@contact: Debian FTP Master +@copyright: 2008 Michael Casadevall +@copyright: 2008 Roger Leigh +@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 diff --git a/dak/dakdb/update3.py b/dak/dakdb/update3.py index eef7d4c6..c91ecf56 100755 --- a/dak/dakdb/update3.py +++ b/dak/dakdb/update3.py @@ -1,8 +1,13 @@ #!/usr/bin/env python -""" Database Update Script - Remove unused versioncmp """ -# Copyright (C) 2008 Michael Casadevall -# Copyright (C) 2009 Joerg Jaspert +""" +Remove unused versioncmp + +@contact: Debian FTP Master +@copyright: 2008 Michael Casadevall +@copyright: 2009 Joerg Jaspert +@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 diff --git a/dak/dakdb/update4.py b/dak/dakdb/update4.py old mode 100644 new mode 100755 index 1a9d9c3a..477944c8 --- a/dak/dakdb/update4.py +++ b/dak/dakdb/update4.py @@ -1,6 +1,6 @@ #!/usr/bin/env python """ -Database Update Script - Get suite_architectures table use sane values +Get suite_architectures table use sane values @contact: Debian FTP Master @copyright: 2009 Joerg Jaspert diff --git a/dak/dakdb/update5.py b/dak/dakdb/update5.py index 1d820de4..beb961cc 100755 --- a/dak/dakdb/update5.py +++ b/dak/dakdb/update5.py @@ -1,7 +1,7 @@ #!/usr/bin/env python """ -Database Update Script - Fix bin_assoc_by_arch view +Fix bin_assoc_by_arch view @contact: Debian FTP Master @copyright: 2009 Joerg Jaspert diff --git a/dak/dakdb/update6.py b/dak/dakdb/update6.py old mode 100644 new mode 100755 index 4537579a..c7b0b17f --- a/dak/dakdb/update6.py +++ b/dak/dakdb/update6.py @@ -2,11 +2,12 @@ # coding=utf8 """ -Debian Archive Kit Database Update Script -Copyright © 2008 Michael Casadevall -Copyright © 2008 Roger Leigh +Adding content fields -Debian Archive Kit Database Update Script 2 +@contact: Debian FTP Master +@copyright: 2008 Michael Casadevall +@copyright: 2008 Roger Leigh +@license: GNU General Public License version 2 or later """ # This program is free software; you can redistribute it and/or modify diff --git a/dak/dakdb/update7.py b/dak/dakdb/update7.py index c8828535..6f91eb37 100755 --- a/dak/dakdb/update7.py +++ b/dak/dakdb/update7.py @@ -2,11 +2,13 @@ # coding=utf8 """ -Debian Archive Kit Database Update Script -Copyright © 2008 Michael Casadevall -Copyright © 2009 Joerg Jaspert +Moving suite config into DB + +@contact: Debian FTP Master +@copyright: 2008 Michael Casadevall +@copyright: 2009 Joerg Jaspert +@license: GNU General Public License version 2 or later -Debian Archive Kit Database Update Script 7 """ # This program is free software; you can redistribute it and/or modify diff --git a/dak/dakdb/update8.py b/dak/dakdb/update8.py index fc505f7a..2f92c4d8 100755 --- a/dak/dakdb/update8.py +++ b/dak/dakdb/update8.py @@ -2,11 +2,12 @@ # coding=utf8 """ -Debian Archive Kit Database Update Script -Copyright © 2008 Michael Casadevall -Copyright © 2009 Joerg Jaspert +More suite config into the DB -Debian Archive Kit Database Update Script 8 +@contact: Debian FTP Master +@copyright: 2008 Michael Casadevall +@copyright: 2009 Joerg Jaspert +@license: GNU General Public License version 2 or later """ # This program is free software; you can redistribute it and/or modify diff --git a/dak/dakdb/update9.py b/dak/dakdb/update9.py old mode 100644 new mode 100755 index 09785773..2ca3c51e --- a/dak/dakdb/update9.py +++ b/dak/dakdb/update9.py @@ -2,11 +2,12 @@ # coding=utf8 """ -Debian Archive Kit Database Update Script -Copyright © 2008 Michael Casadevall -Copyright © 2009 Mike O'Connor +Pending contents disinguished by arch -Debian Archive Kit Database Update Script 8 +@contact: Debian FTP Master +@copyright: 2008 Michael Casadevall +@copyright: 2009 Mike O'Connor +@license: GNU General Public License version 2 or later """ # This program is free software; you can redistribute it and/or modify diff --git a/dak/process_accepted.py b/dak/process_accepted.py index e55ac54d..9883bb20 100755 --- a/dak/process_accepted.py +++ b/dak/process_accepted.py @@ -1,8 +1,14 @@ #!/usr/bin/env python -""" Installs Debian packages from queue/accepted into the pool """ -# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 James Troup +""" +Installs Debian packages from queue/accepted into the pool +@contact: Debian FTP Master +@copyright: 2000, 2001, 2002, 2003, 2004, 2006 James Troup +@copyright: 2009 Joerg Jaspert +@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 @@ -218,7 +224,7 @@ def usage (exit_code=0): ############################################################################### -def action (): +def action (queue=""): (summary, short_summary) = Upload.build_summaries() (prompt, answer) = ("", "XXX") @@ -250,7 +256,7 @@ def action (): if not installing_to_stable: install() else: - stable_install(summary, short_summary) + stable_install(summary, short_summary, queue) elif answer == 'Q': sys.exit(0) @@ -488,10 +494,15 @@ def install (): ################################################################################ -def stable_install (summary, short_summary): +def stable_install (summary, short_summary, fromsuite="proposed-updates"): global install_count - print "Installing to stable." + fromsuite = fromsuite.lower() + tosuite = "Stable" + if fromsuite == "oldstable-proposed-updates": + tosuite = "OldStable" + + print "Installing from %s to %s." % (fromsuite, tosuite) # Begin a transaction; if we bomb out anywhere between here and # the COMMIT WORK below, the DB won't be changed. @@ -507,9 +518,9 @@ def stable_install (summary, short_summary): if not ql: utils.fubar("[INTERNAL ERROR] couldn't find '%s' (%s) in source table." % (package, version)) source_id = ql[0][0] - suite_id = database.get_suite_id('proposed-updates') + suite_id = database.get_suite_id(fromsuite) projectB.query("DELETE FROM src_associations WHERE suite = '%s' AND source = '%s'" % (suite_id, source_id)) - suite_id = database.get_suite_id('stable') + suite_id = database.get_suite_id(tosuite.lower()) projectB.query("INSERT INTO src_associations (suite, source) VALUES ('%s', '%s')" % (suite_id, source_id)) # Add the binaries to stable (and remove it/them from proposed-updates) @@ -524,9 +535,9 @@ def stable_install (summary, short_summary): utils.fubar("[INTERNAL ERROR] couldn't find '%s' (%s for %s architecture) in binaries table." % (package, version, architecture)) binary_id = ql[0][0] - suite_id = database.get_suite_id('proposed-updates') + suite_id = database.get_suite_id(fromsuite) projectB.query("DELETE FROM bin_associations WHERE suite = '%s' AND bin = '%s'" % (suite_id, binary_id)) - suite_id = database.get_suite_id('stable') + suite_id = database.get_suite_id(tosuite.lower()) projectB.query("INSERT INTO bin_associations (suite, bin) VALUES ('%s', '%s')" % (suite_id, binary_id)) projectB.query("COMMIT WORK") @@ -534,17 +545,17 @@ def stable_install (summary, short_summary): utils.move (pkg.changes_file, Cnf["Dir::Morgue"] + '/process-accepted/' + os.path.basename(pkg.changes_file)) ## Update the Stable ChangeLog file - new_changelog_filename = Cnf["Dir::Root"] + Cnf["Suite::Stable::ChangeLogBase"] + ".ChangeLog" - changelog_filename = Cnf["Dir::Root"] + Cnf["Suite::Stable::ChangeLogBase"] + "ChangeLog" + new_changelog_filename = Cnf["Dir::Root"] + Cnf["Suite::%s::ChangeLogBase" % (tosuite)] + ".ChangeLog" + changelog_filename = Cnf["Dir::Root"] + Cnf["Suite::%s::ChangeLogBase" % (tosuite)] + "ChangeLog" if os.path.exists(new_changelog_filename): os.unlink (new_changelog_filename) new_changelog = utils.open_file(new_changelog_filename, 'w') for newfile in files.keys(): if files[newfile]["type"] == "deb": - new_changelog.write("stable/%s/binary-%s/%s\n" % (files[newfile]["component"], files[newfile]["architecture"], newfile)) + new_changelog.write("%s/%s/binary-%s/%s\n" % (tosuite.lower(), files[newfile]["component"], files[newfile]["architecture"], newfile)) elif re_issource.match(newfile): - new_changelog.write("stable/%s/source/%s\n" % (files[newfile]["component"], newfile)) + new_changelog.write("%s/%s/source/%s\n" % (tosuite.lower(), files[newfile]["component"], newfile)) else: new_changelog.write("%s\n" % (newfile)) chop_changes = re_fdnic.sub("\n", changes["changes"]) @@ -560,19 +571,19 @@ def stable_install (summary, short_summary): install_count += 1 if not Options["No-Mail"] and changes["architecture"].has_key("source"): - Subst["__SUITE__"] = " into stable" + Subst["__SUITE__"] = " into %s" % (tosuite) Subst["__SUMMARY__"] = summary mail_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/process-accepted.install") utils.send_mail(mail_message) Upload.announce(short_summary, 1) # Finally remove the .dak file - dot_dak_file = os.path.join(Cnf["Suite::Proposed-Updates::CopyDotDak"], os.path.basename(Upload.pkg.changes_file[:-8]+".dak")) + dot_dak_file = os.path.join(Cnf["Suite::%s::CopyDotDak" % (fromsuite)], os.path.basename(Upload.pkg.changes_file[:-8]+".dak")) os.unlink(dot_dak_file) ################################################################################ -def process_it (changes_file): +def process_it (changes_file, queue=""): global reject_message reject_message = "" @@ -588,7 +599,7 @@ def process_it (changes_file): if installing_to_stable: old = Upload.pkg.changes_file Upload.pkg.changes_file = os.path.basename(old) - os.chdir(Cnf["Suite::Proposed-Updates::CopyDotDak"]) + os.chdir(Cnf["Suite::%s::CopyDotDak" % (queue)]) Upload.init_vars() Upload.update_vars() @@ -598,7 +609,7 @@ def process_it (changes_file): Upload.pkg.changes_file = old check() - action() + action(queue) # Restore CWD os.chdir(pkg.directory) @@ -620,7 +631,12 @@ def main(): utils.fubar("Archive maintenance in progress. Try again later.") # If running from within proposed-updates; assume an install to stable - if os.getcwd().find('proposed-updates') != -1: + queue = "" + if os.getenv('PWD').find('oldstable-proposed-updates') != -1: + queue = "Oldstable-Proposed-Updates" + installing_to_stable = 1 + elif os.getenv('PWD').find('proposed-updates') != -1: + queue = "Proposed-Updates" installing_to_stable = 1 # Obtain lock if not in no-action mode and initialize the log @@ -650,7 +666,7 @@ def main(): # Process the changes files for changes_file in changes_files: print "\n" + changes_file - process_it (changes_file) + process_it (changes_file, queue) if install_count: sets = "set" diff --git a/dak/process_unchecked.py b/dak/process_unchecked.py index 403f1400..9301497b 100755 --- a/dak/process_unchecked.py +++ b/dak/process_unchecked.py @@ -1003,10 +1003,10 @@ def lookup_uid_from_fingerprint(fpr): """ Return the uid,name,isdm for a given gpg fingerprint - @ptype fpr: string + @type fpr: string @param fpr: a 40 byte GPG fingerprint - @return (uid, name, isdm) + @return: (uid, name, isdm) """ cursor = DBConn().cursor() cursor.execute( "SELECT u.uid, u.name, k.debian_maintainer FROM fingerprint f JOIN keyrings k ON (f.keyring=k.id), uid u WHERE f.uid = u.id AND f.fingerprint = '%s'" % (fpr)) @@ -1058,6 +1058,7 @@ def check_signed_by_key(): if sponsored and not may_sponsor: reject("%s is not authorised to sponsor uploads" % (uid)) + cursor = DBConn().cursor() if not sponsored and not may_nmu: source_ids = [] cursor.execute( "SELECT s.id, s.version FROM source s JOIN src_associations sa ON (s.id = sa.source) WHERE s.source = %(source)s AND s.dm_upload_allowed = 'yes'", changes ) diff --git a/daklib/binary.py b/daklib/binary.py index 88d78761..bd7f1cc1 100755 --- a/daklib/binary.py +++ b/daklib/binary.py @@ -56,10 +56,10 @@ import utils class Binary(object): def __init__(self, filename, reject=None): """ - @ptype filename: string + @type filename: string @param filename: path of a .deb - @ptype reject: function + @type reject: function @param reject: a function to log reject messages to """ self.filename = filename @@ -165,12 +165,12 @@ class Binary(object): the hopefully near future, it should also include gathering info from the control file. - @ptype bootstrap_id: int + @type bootstrap_id: int @param bootstrap_id: the id of the binary these packages should be associated or zero meaning we are not bootstrapping so insert into a temporary table - @return True if the deb is valid and contents were imported + @return: True if the deb is valid and contents were imported """ result = False rejected = not self.valid_deb(relaxed) @@ -212,12 +212,11 @@ class Binary(object): the hopefully near future, it should also include gathering info from the control file. - @ptype bootstrap_id: int - @param bootstrap_id: the id of the binary these packages - should be associated or zero meaning we are not bootstrapping - so insert into a temporary table + @type package: string + @param package: the name of the package to be checked - @return True if the deb is valid and contents were imported + @rtype: boolean + @return: True if the deb is valid and contents were imported """ rejected = not self.valid_deb(True) self.__unpack() diff --git a/daklib/dbconn.py b/daklib/dbconn.py index b532c351..9770cf84 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -203,8 +203,8 @@ class DBConn(Singleton): Returns database id for given override C{type}. Results are kept in a cache during runtime to minimize database queries. - @type type: string - @param type: The name of the override type + @type override_type: string + @param override_type: The name of the override type @rtype: int @return: the database id for the given override type @@ -500,10 +500,10 @@ class DBConn(Singleton): @type bin_id: int @param bin_id: the id of the binary - @type fullpath: string - @param fullpath: the path of the file being associated with the binary + @type fullpaths: list + @param fullpaths: the list of paths of the file being associated with the binary - @return True upon success + @return: True upon success """ c = self.db_con.cursor() @@ -539,7 +539,7 @@ class DBConn(Singleton): @type fullpaths: list @param fullpaths: the list of paths of the file being associated with the binary - @return True upon success + @return: True upon success """ c = self.db_con.cursor() diff --git a/docs/TODO b/docs/TODO index f142c66b..3a99ad94 100644 --- a/docs/TODO +++ b/docs/TODO @@ -3,6 +3,7 @@ Various ------- + * Implement autosigning, see ftpmaster_autosigning on ftp-master host in text/. * Check TODO.old and move still-valid/useful entries over here.