From 0f101c6b7f641ca20e256839f7f3d763c54c3fbf Mon Sep 17 00:00:00 2001 From: Michael Casadevall Date: Thu, 1 Jan 2009 15:34:27 -0500 Subject: [PATCH] Modified dm status to be a keyring specific switch, modified update1 to handle the dm: format change, added support for changing the keyring switch in dak.conf Signed-off-by: Michael Casadevall --- config/debian/dak.conf | 8 ++++++++ dak/dakdb/update1.py | 31 ++++++++++++++++++++++--------- dak/import_keyring.py | 18 +++++++----------- dak/process_unchecked.py | 2 +- 4 files changed, 38 insertions(+), 21 deletions(-) diff --git a/config/debian/dak.conf b/config/debian/dak.conf index 332a6170..345565b3 100644 --- a/config/debian/dak.conf +++ b/config/debian/dak.conf @@ -126,6 +126,14 @@ Import-Archive ExportDir "/srv/ftp.debian.org/dak/import-archive-files/"; }; +Import-Keyring +{ + /srv/ftp.debian.org/keyrings/debian-maintainers.gpg + { + Debian-Maintainer "true"; + }; +}; + Reject-Proposed-Updates { StableRejector "the Stable Release Team"; diff --git a/dak/dakdb/update1.py b/dak/dakdb/update1.py index 5c027c51..3f0aa801 100644 --- a/dak/dakdb/update1.py +++ b/dak/dakdb/update1.py @@ -24,7 +24,7 @@ ################################################################################ -import psycopg2 +import psycopg2, time ################################################################################ @@ -32,17 +32,30 @@ 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 fingerprint ADD COLUMN is_dm BOOLEAN DEFAULT 'false' NOT NULL;") + 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 ..." + print "Migrating DM data to source table. This might take some time ..." - c.execute("UPDATE source SET dm_upload_allowed = 't' WHERE id = (SELECT source FROM src_uploaders);") - c.execute("UPDATE config SET value = '1' WHERE name = 'db_revision'") - self.db.commit() + 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 "REMINDER: Remember to run the updated byhand-dm crontab to update Debian Maintainer information" + 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, msg: self.db.rollback() diff --git a/dak/import_keyring.py b/dak/import_keyring.py index 3482a14b..8daf4e5c 100755 --- a/dak/import_keyring.py +++ b/dak/import_keyring.py @@ -172,8 +172,7 @@ def usage (exit_code=0): print """Usage: dak import-keyring [OPTION]... [KEYRING] -h, --help show this help and exit. -L, --import-ldap-users generate uid entries for keyring from LDAP - -U, --generate-users FMT generate uid entries from keyring as FMT - -D, --debian-maintainer mark generated uids as debian-maintainers""" + -U, --generate-users FMT generate uid entries from keyring as FMT""" sys.exit(exit_code) @@ -186,8 +185,7 @@ def main(): Arguments = [('h',"help","Import-Keyring::Options::Help"), ('L',"import-ldap-users","Import-Keyring::Options::Import-Ldap-Users"), ('U',"generate-users","Import-Keyring::Options::Generate-Users", "HasArg"), - ('D',"debian-maintainer","Import-Keyring::Options::Debian-Maintainer"), - ] + ] for i in [ "help", "report-changes", "generate-users", "import-ldap-users" ]: if not Cnf.has_key("Import-Keyring::Options::%s" % (i)): @@ -224,6 +222,9 @@ def main(): keyringname = keyring_names[0] keyring = Keyring(keyringname) + if Cnf.has_key("Import-Keyring::"+keyringname+"::Debian-Maintainer"): + projectB.query("UPDATE keyrings SET debian_maintainer = '%s' WHERE name = '%s'" % (Cnf["Import-Keyring::"+keyringname+"::Debian-Maintainer"], keyringname.split("/")[-1])) + keyring_id = database.get_or_set_keyring_id( keyringname.split("/")[-1]) @@ -270,11 +271,6 @@ def main(): # For the keys in this keyring, add/update any fingerprints that've # changed. - # Determine if we need to set the DM flag - is_dm = "no" - if Cnf("Import-Keyring::Options::Debian-Maintainer"): - is_dm = "yes" - for f in fpr: newuid = fpr[f][0] newuiduid = db_uid_byid.get(newuid, [None])[0] @@ -284,9 +280,9 @@ def main(): if oldfid == -1: changes.append((newuiduid, "Added key: %s" % (f))) if newuid: - projectB.query("INSERT INTO fingerprint (fingerprint, uid, keyring, debian_maintainer) VALUES ('%s', %d, %d, %s)" % (f, newuid, keyring_id, is_dm)) + projectB.query("INSERT INTO fingerprint (fingerprint, uid, keyring) VALUES ('%s', %d, %d)" % (f, newuid, keyring_id)) else: - projectB.query("INSERT INTO fingerprint (fingerprint, keyring) VALUES ('%s', %d, %s)" % (f, keyring_id, is_dm)) + projectB.query("INSERT INTO fingerprint (fingerprint, keyring) VALUES ('%s', %d)" % (f, keyring_id)) else: if newuid and olduid != newuid: if olduid != -1: diff --git a/dak/process_unchecked.py b/dak/process_unchecked.py index 14a9c775..fd0afc4e 100755 --- a/dak/process_unchecked.py +++ b/dak/process_unchecked.py @@ -997,7 +997,7 @@ def check_timestamps(): ################################################################################ def lookup_uid_from_fingerprint(fpr): - q = Upload.projectB.query("SELECT u.uid, u.name, f.is_dm FROM fingerprint f, uid u WHERE f.uid = u.id AND f.fingerprint = '%s'" % (fpr)) + q = Upload.projectB.query("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)) qs = q.getresult() if len(qs) == 0: return (None, None) -- 2.39.5