From: James Troup Date: Wed, 17 May 2006 18:45:30 +0000 (-0500) Subject: Enmasse adaptation for removal of silly names. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=06ce98c8111a8b09e5603dbbd34324a216412d69;p=dak Enmasse adaptation for removal of silly names. --- diff --git a/dak/ChangeLog b/dak/ChangeLog index 2c1bff45..49c185d8 100644 --- a/dak/ChangeLog +++ b/dak/ChangeLog @@ -1,3 +1,64 @@ +2006-05-17 James Troup + + * check_archive.py: remove $Id$ and $Revision$ strings. Update + imports of and calls to dak.lib modules. Change script name + everywhere, i.e. in output, mails, comments and configuration tree + + filenames. Also update references to other renamed scripts, + classes and templates. Use '.dak' instead of '.katie' for the + queue info storage files. + (Renamed from tea) + * check_overrides.py: likewise. (Renamed from cindy) + * check_proposed_updates.py: likewise. (Renamed from jeri) + * clean_proposed_updates.py: likewise. (Renamed from halle) + * clean_queues.py: likewise. (Renamed from shania) + * clean_suites.py: likewise. (Renamed from rhona) + * compare_suites.py: likewise. (Renamed from andrea) + * control_overrides.py: likewise. (Renamed from natalie) + * control_suite.py: likewise. (Renamed from heidi) + * cruft_report.py: likewise. (Renamed from rene) + * decode_dot_dak.py: likewise. (Renamed from ashley) + * find_null_maintainers.py: likewise. (Renamed from rosamund) + * generate_index_diffs.py: likewise. (Renamed from tiffani) + * generate_releases.py: likewise. (Renamed from ziyi) + * import_archive.py: likewise. (Renamed from neve) + * import_ldap_fingerprints.py: likewise. (Renamed from emilie) + * import_users_from_passwd.py: likewise. (Renamed from julia) + * init_db.py: likewise. (Renamed from alyson) + * init_dirs.py: likewise. (Renamed from rose) + * lib/database.py: likewise. (Renamed from db_access) + * lib/queue.py: likewise. 'Katie' class -> 'Upload'. (Renamed from katie) + * lib/utils.py: likewise. + * ls.py: likewise. (Renamed from madison) + * make_maintainers.py: likewise. (Renamed from charisma) + * make_overrides.py: likewise. (Renamed from denise) + * make_suite_file_list.py: likewise. (Renamed from jenna) + * mirror_split.py: likewise. (Renamed from billie) + * override.py: likewise. (Renamed from alicia) + * poolize.py: likewise. (Renamed from catherine) + * process_accepted.py: likewise. (Renamed from kelly) + * process_new.py: likewise. (Renamed from lisa) + * process_unchecked.py: likewise. (Renamed from jennifer) + * queue_report.py: likewise. (Renamed from helena) + * reject_proposed_updates.py: likewise. (Renamed from lauren) + * rm.py: likewise. (Renamed from melanie) + * security_install.py: likewise. (Renamed from amber) + * split_done.py: likewise. (Renamed from nina) + * stats.py: likewise. (Renamed from saffron) + * symlink_dists.py: likewise. (Renamed from saffron) + + * cruft_report.py: Use '[auto-cruft]' as the magic "this removal + doesn't need to notify anyone" string. + * rm.py: likewise, look for '[auto-cruft]' as the magic string. + + * process_accepted.py (init): drop -V/--version argument. + * process_new.py (init): likewise. + * process_unchecked.py (init): likewise. + * reject_proposed_updates.py (init): likewise + + * shell.py: Renamed from dak. ".katie" -> ".dak" + + * stats.py: in usage() output change STAT to MODE. + 2006-05-15 James Troup * queue_report.py: remove unused encodings imports. @@ -895,7 +956,7 @@ * kelly (install): if we can't move the .changes into queue/done, fail don't warn and carry on. The old behaviour pre-dates NI and doesn't make much sense now since jennifer checks both - queue/accepted and queue/done for any .changes files she's + queue/accepted and queue/done for any .changes files it's processing. * utils.py (move): don't throw exceptions on existing files or diff --git a/dak/check_archive.py b/dak/check_archive.py index 6b83cd17..65dca8c6 100755 --- a/dak/check_archive.py +++ b/dak/check_archive.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # Various different sanity checks -# Copyright (C) 2000, 2001, 2002, 2003, 2004 James Troup -# $Id: tea,v 1.31 2004-11-27 18:03:11 troup Exp $ +# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 James Troup # 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 @@ -28,7 +27,7 @@ ################################################################################ import commands, os, pg, stat, string, sys, time -import db_access, utils +import dak.lib.database, dak.lib.utils import apt_pkg, apt_inst ################################################################################ @@ -45,7 +44,7 @@ current_time = time.time() ################################################################################ def usage(exit_code=0): - print """Usage: tea MODE + print """Usage: dak check-archive MODE Run various sanity checks of the archive and/or database. -h, --help show this help and exit. @@ -96,11 +95,11 @@ def check_files(): filename = os.path.abspath(i[0] + i[1]) db_files[filename] = "" if os.access(filename, os.R_OK) == 0: - utils.warn("'%s' doesn't exist." % (filename)) + dak.lib.utils.warn("'%s' doesn't exist." % (filename)) filename = Cnf["Dir::Override"]+'override.unreferenced' if os.path.exists(filename): - file = utils.open_file(filename) + file = dak.lib.utils.open_file(filename) for filename in file.readlines(): filename = filename[:-1] excluded[filename] = "" @@ -110,7 +109,7 @@ def check_files(): os.path.walk(Cnf["Dir::Root"]+'pool/', process_dir, None) print - print "%s wasted..." % (utils.size_type(waste)) + print "%s wasted..." % (dak.lib.utils.size_type(waste)) ################################################################################ @@ -122,17 +121,17 @@ def check_dscs(): continue component = component.lower() list_filename = '%s%s_%s_source.list' % (Cnf["Dir::Lists"], suite, component) - list_file = utils.open_file(list_filename) + list_file = dak.lib.utils.open_file(list_filename) for line in list_file.readlines(): file = line[:-1] try: - utils.parse_changes(file, signing_rules=1) - except utils.invalid_dsc_format_exc, line: - utils.warn("syntax error in .dsc file '%s', line %s." % (file, line)) + dak.lib.utils.parse_changes(file, signing_rules=1) + except dak.lib.utils.invalid_dsc_format_exc, line: + dak.lib.utils.warn("syntax error in .dsc file '%s', line %s." % (file, line)) count += 1 if count: - utils.warn("Found %s invalid .dsc files." % (count)) + dak.lib.utils.warn("Found %s invalid .dsc files." % (count)) ################################################################################ @@ -141,7 +140,7 @@ def check_override(): print suite print "-"*len(suite) print - suite_id = db_access.get_suite_id(suite) + suite_id = dak.lib.database.get_suite_id(suite) q = projectB.query(""" SELECT DISTINCT b.package FROM binaries b, bin_associations ba WHERE b.id = ba.bin AND ba.suite = %s AND NOT EXISTS @@ -200,16 +199,16 @@ def check_md5sums(): db_md5sum = i[2] db_size = int(i[3]) try: - file = utils.open_file(filename) + file = dak.lib.utils.open_file(filename) except: - utils.warn("can't open '%s'." % (filename)) + dak.lib.utils.warn("can't open '%s'." % (filename)) continue md5sum = apt_pkg.md5sum(file) size = os.stat(filename)[stat.ST_SIZE] if md5sum != db_md5sum: - utils.warn("**WARNING** md5sum mismatch for '%s' ('%s' [current] vs. '%s' [db])." % (filename, md5sum, db_md5sum)) + dak.lib.utils.warn("**WARNING** md5sum mismatch for '%s' ('%s' [current] vs. '%s' [db])." % (filename, md5sum, db_md5sum)) if size != db_size: - utils.warn("**WARNING** size mismatch for '%s' ('%s' [current] vs. '%s' [db])." % (filename, size, db_size)) + dak.lib.utils.warn("**WARNING** size mismatch for '%s' ('%s' [current] vs. '%s' [db])." % (filename, size, db_size)) print "Done." @@ -235,7 +234,7 @@ def check_timestamps(): for i in ql: filename = os.path.abspath(i[0] + i[1]) if os.access(filename, os.R_OK): - file = utils.open_file(filename) + file = dak.lib.utils.open_file(filename) current_file = filename sys.stderr.write("Processing %s.\n" % (filename)) apt_inst.debExtract(file,Ent,"control.tar.gz") @@ -260,24 +259,24 @@ def check_missing_tar_gz_in_dsc(): filename = os.path.abspath(i[0] + i[1]) try: # NB: don't enforce .dsc syntax - dsc = utils.parse_changes(filename) + dsc = dak.lib.utils.parse_changes(filename) except: - utils.fubar("error parsing .dsc file '%s'." % (filename)) - dsc_files = utils.build_file_list(dsc, is_a_dsc=1) + dak.lib.utils.fubar("error parsing .dsc file '%s'." % (filename)) + dsc_files = dak.lib.utils.build_file_list(dsc, is_a_dsc=1) has_tar = 0 for file in dsc_files.keys(): - m = utils.re_issource.match(file) + m = dak.lib.utils.re_issource.match(file) if not m: - utils.fubar("%s not recognised as source." % (file)) + dak.lib.utils.fubar("%s not recognised as source." % (file)) type = m.group(3) if type == "orig.tar.gz" or type == "tar.gz": has_tar = 1 if not has_tar: - utils.warn("%s has no .tar.gz in the .dsc file." % (file)) + dak.lib.utils.warn("%s has no .tar.gz in the .dsc file." % (file)) count += 1 if count: - utils.warn("Found %s invalid .dsc files." % (count)) + dak.lib.utils.warn("Found %s invalid .dsc files." % (count)) ################################################################################ @@ -286,12 +285,12 @@ def validate_sources(suite, component): filename = "%s/dists/%s/%s/source/Sources.gz" % (Cnf["Dir::Root"], suite, component) print "Processing %s..." % (filename) # apt_pkg.ParseTagFile needs a real file handle and can't handle a GzipFile instance... - temp_filename = utils.temp_filename() + temp_filename = dak.lib.utils.temp_filename() (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename)) if (result != 0): sys.stderr.write("Gunzip invocation failed!\n%s\n" % (output)) sys.exit(result) - sources = utils.open_file(temp_filename) + sources = dak.lib.utils.open_file(temp_filename) Sources = apt_pkg.ParseTagFile(sources) while Sources.Step(): source = Sources.Section.Find('Package') @@ -304,7 +303,7 @@ def validate_sources(suite, component): if directory.find("potato") == -1: print "W: %s missing." % (filename) else: - pool_location = utils.poolify (source, component) + pool_location = dak.lib.utils.poolify (source, component) pool_filename = "%s/%s/%s" % (Cnf["Dir::Pool"], pool_location, name) if not os.path.exists(pool_filename): print "E: %s missing (%s)." % (filename, pool_filename) @@ -312,7 +311,7 @@ def validate_sources(suite, component): # Create symlink pool_filename = os.path.normpath(pool_filename) filename = os.path.normpath(filename) - src = utils.clean_symlink(pool_filename, filename, Cnf["Dir::Root"]) + src = dak.lib.utils.clean_symlink(pool_filename, filename, Cnf["Dir::Root"]) print "Symlinking: %s -> %s" % (filename, src) #os.symlink(src, filename) sources.close() @@ -325,12 +324,12 @@ def validate_packages(suite, component, architecture): % (Cnf["Dir::Root"], suite, component, architecture) print "Processing %s..." % (filename) # apt_pkg.ParseTagFile needs a real file handle and can't handle a GzipFile instance... - temp_filename = utils.temp_filename() + temp_filename = dak.lib.utils.temp_filename() (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename)) if (result != 0): sys.stderr.write("Gunzip invocation failed!\n%s\n" % (output)) sys.exit(result) - packages = utils.open_file(temp_filename) + packages = dak.lib.utils.open_file(temp_filename) Packages = apt_pkg.ParseTagFile(packages) while Packages.Step(): filename = "%s/%s" % (Cnf["Dir::Root"], Packages.Section.Find('Filename')) @@ -373,10 +372,10 @@ def check_files_not_symlinks(): filename = os.path.normpath(i[0] + i[1]) # file_id = i[2] if os.access(filename, os.R_OK) == 0: - utils.warn("%s: doesn't exist." % (filename)) + dak.lib.utils.warn("%s: doesn't exist." % (filename)) else: if os.path.islink(filename): - utils.warn("%s: is a symlink." % (filename)) + dak.lib.utils.warn("%s: is a symlink." % (filename)) # You probably don't want to use the rest of this... # print "%s: is a symlink." % (filename) # dest = os.readlink(filename) @@ -391,7 +390,7 @@ def check_files_not_symlinks(): # (location, location_id) = locations[path] # break # if not location_id: -# utils.fubar("Can't find location for %s (%s)." % (dest, filename)) +# dak.lib.utils.fubar("Can't find location for %s (%s)." % (dest, filename)) # new_filename = dest.replace(location, "") # q = projectB.query("UPDATE files SET filename = '%s', location = %s WHERE id = %s" % (new_filename, location_id, file_id)) # q = projectB.query("COMMIT WORK") @@ -403,7 +402,7 @@ def chk_bd_process_dir (unused, dirname, filenames): if not name.endswith(".dsc"): continue filename = os.path.abspath(dirname+'/'+name) - dsc = utils.parse_changes(filename) + dsc = dak.lib.utils.parse_changes(filename) for field_name in [ "build-depends", "build-depends-indep" ]: field = dsc.get(field_name) if field: @@ -423,28 +422,28 @@ def check_build_depends(): def main (): global Cnf, projectB, db_files, waste, excluded - Cnf = utils.get_conf() - Arguments = [('h',"help","Tea::Options::Help")] + Cnf = dak.lib.utils.get_conf() + Arguments = [('h',"help","Check-Archive::Options::Help")] for i in [ "help" ]: - if not Cnf.has_key("Tea::Options::%s" % (i)): - Cnf["Tea::Options::%s" % (i)] = "" + if not Cnf.has_key("Check-Archive::Options::%s" % (i)): + Cnf["Check-Archive::Options::%s" % (i)] = "" args = apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv) - Options = Cnf.SubTree("Tea::Options") + Options = Cnf.SubTree("Check-Archive::Options") if Options["Help"]: usage() if len(args) < 1: - utils.warn("tea requires at least one argument") + dak.lib.utils.warn("dak check-archive requires at least one argument") usage(1) elif len(args) > 1: - utils.warn("tea accepts only one argument") + dak.lib.utils.warn("dak check-archive accepts only one argument") usage(1) mode = args[0].lower() projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - db_access.init(Cnf, projectB) + dak.lib.database.init(Cnf, projectB) if mode == "md5sums": check_md5sums() @@ -467,11 +466,10 @@ def main (): elif mode == "validate-builddeps": check_build_depends() else: - utils.warn("unknown mode '%s'" % (mode)) + dak.lib.utils.warn("unknown mode '%s'" % (mode)) usage(1) ################################################################################ if __name__ == '__main__': main() - diff --git a/dak/check_overrides.py b/dak/check_overrides.py index 282bce08..0915b8d4 100755 --- a/dak/check_overrides.py +++ b/dak/check_overrides.py @@ -1,9 +1,8 @@ #!/usr/bin/env python # Cruft checker and hole filler for overrides -# Copyright (C) 2000, 2001, 2002, 2004 James Troup +# Copyright (C) 2000, 2001, 2002, 2004, 2006 James Troup # Copyright (C) 2005 Jeroen van Wolffelaar -# $Id: cindy,v 1.14 2005-11-15 09:50:32 ajt Exp $ # 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 @@ -22,17 +21,19 @@ ################################################################################ ###################################################################### -# NB: cindy is not a good idea with New Incoming as she doesn't take # -# into account accepted. You can minimize the impact of this by # -# running her immediately after kelly but that's still racy because # -# lisa doesn't lock with kelly. A better long term fix is the evil # -# plan for accepted to be in the DB. # +# NB: dak check-overrides is not a good idea with New Incoming as it # +# doesn't take into account accepted. You can minimize the impact # +# of this by running it immediately after dak process-accepted but # +# that's still racy because 'dak process-new' doesn't lock with 'dak # +# process-accepted'. A better long term fix is the evil plan for # +# accepted to be in the DB. # ###################################################################### -# cindy should now work fine being done during cron.daily, for example just -# before denise (after kelly and jenna). At that point, queue/accepted should -# be empty and installed, so... Cindy does now take into account suites -# sharing overrides +# dak check-overrides should now work fine being done during +# cron.daily, for example just before 'dak make-overrides' (after 'dak +# process-accepted' and 'dak make-suite-file-list'). At that point, +# queue/accepted should be empty and installed, so... dak +# check-overrides does now take into account suites sharing overrides # TODO: # * Only update out-of-sync overrides when corresponding versions are equal to @@ -48,7 +49,7 @@ ################################################################################ import pg, sys, os -import utils, db_access, logging +import dak.lib.utils, dak.lib.database, dak.lib.logging import apt_pkg ################################################################################ @@ -63,7 +64,7 @@ blacklist = {} ################################################################################ def usage (exit_code=0): - print """Usage: cindy + print """Usage: dak check-overrides Check for cruft in overrides. -n, --no-action don't do anything @@ -81,26 +82,26 @@ def gen_blacklist(dir): def process(osuite, affected_suites, originosuite, component, type): global Logger, Options, projectB, sections, priorities - osuite_id = db_access.get_suite_id(osuite) + osuite_id = dak.lib.database.get_suite_id(osuite) if osuite_id == -1: - utils.fubar("Suite '%s' not recognised." % (osuite)) + dak.lib.utils.fubar("Suite '%s' not recognised." % (osuite)) originosuite_id = None if originosuite: - originosuite_id = db_access.get_suite_id(originosuite) + originosuite_id = dak.lib.database.get_suite_id(originosuite) if originosuite_id == -1: - utils.fubar("Suite '%s' not recognised." % (originosuite)) + dak.lib.utils.fubar("Suite '%s' not recognised." % (originosuite)) - component_id = db_access.get_component_id(component) + component_id = dak.lib.database.get_component_id(component) if component_id == -1: - utils.fubar("Component '%s' not recognised." % (component)) + dak.lib.utils.fubar("Component '%s' not recognised." % (component)) - type_id = db_access.get_override_type_id(type) + type_id = dak.lib.database.get_override_type_id(type) if type_id == -1: - utils.fubar("Type '%s' not recognised. (Valid types are deb, udeb and dsc)" % (type)) - dsc_type_id = db_access.get_override_type_id("dsc") - deb_type_id = db_access.get_override_type_id("deb") + dak.lib.utils.fubar("Type '%s' not recognised. (Valid types are deb, udeb and dsc)" % (type)) + dsc_type_id = dak.lib.database.get_override_type_id("dsc") + deb_type_id = dak.lib.database.get_override_type_id("deb") - source_priority_id = db_access.get_priority_id("source") + source_priority_id = dak.lib.database.get_priority_id("source") if type == "deb" or type == "udeb": packages = {} @@ -135,7 +136,7 @@ SELECT s.source FROM source s, src_associations sa, files f, location l, src_packages[package] = 1 else: if blacklist.has_key(package): - utils.warn("%s in incoming, not touching" % package) + dak.lib.utils.warn("%s in incoming, not touching" % package) continue Logger.log(["removing unused override", osuite, component, type, package, priorities[i[1]], sections[i[2]], i[3]]) @@ -199,7 +200,7 @@ SELECT s.source FROM source s, src_associations sa, files f, location l, for package, hasoverride in src_packages.items(): if not hasoverride: - utils.warn("%s has no override!" % package) + dak.lib.utils.warn("%s has no override!" % package) else: # binary override for i in q.getresult(): @@ -208,7 +209,7 @@ SELECT s.source FROM source s, src_associations sa, files f, location l, packages[package] = 1 else: if blacklist.has_key(package): - utils.warn("%s in incoming, not touching" % package) + dak.lib.utils.warn("%s in incoming, not touching" % package) continue Logger.log(["removing unused override", osuite, component, type, package, priorities[i[1]], sections[i[2]], i[3]]) @@ -253,7 +254,7 @@ SELECT s.source FROM source s, src_associations sa, files f, location l, for package, hasoverride in packages.items(): if not hasoverride: - utils.warn("%s has no override!" % package) + dak.lib.utils.warn("%s has no override!" % package) projectB.query("COMMIT WORK") sys.stdout.flush() @@ -264,21 +265,21 @@ SELECT s.source FROM source s, src_associations sa, files f, location l, def main (): global Logger, Options, projectB, sections, priorities - Cnf = utils.get_conf() + Cnf = dak.lib.utils.get_conf() - Arguments = [('h',"help","Cindy::Options::Help"), - ('n',"no-action", "Cindy::Options::No-Action")] + Arguments = [('h',"help","Check-Overrides::Options::Help"), + ('n',"no-action", "Check-Overrides::Options::No-Action")] for i in [ "help", "no-action" ]: - if not Cnf.has_key("Cindy::Options::%s" % (i)): - Cnf["Cindy::Options::%s" % (i)] = "" + if not Cnf.has_key("Check-Overrides::Options::%s" % (i)): + Cnf["Check-Overrides::Options::%s" % (i)] = "" apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv) - Options = Cnf.SubTree("Cindy::Options") + Options = Cnf.SubTree("Check-Overrides::Options") if Options["Help"]: usage() projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - db_access.init(Cnf, projectB) + dak.lib.database.init(Cnf, projectB) # init sections, priorities: q = projectB.query("SELECT id, section FROM section") @@ -289,14 +290,14 @@ def main (): priorities[i[0]] = i[1] if not Options["No-Action"]: - Logger = logging.Logger(Cnf, "cindy") + Logger = dak.lib.logging.Logger(Cnf, "check-overrides") else: - Logger = logging.Logger(Cnf, "cindy", 1) + Logger = dak.lib.logging.Logger(Cnf, "check-overrides", 1) gen_blacklist(Cnf["Dir::Queue::Accepted"]) - for osuite in Cnf.SubTree("Cindy::OverrideSuites").List(): - if "1" != Cnf["Cindy::OverrideSuites::%s::Process" % osuite]: + for osuite in Cnf.SubTree("Check-Overrides::OverrideSuites").List(): + if "1" != Cnf["Check-Overrides::OverrideSuites::%s::Process" % osuite]: continue osuite = osuite.lower() @@ -304,7 +305,7 @@ def main (): originosuite = None originremark = "" try: - originosuite = Cnf["Cindy::OverrideSuites::%s::OriginSuite" % osuite] + originosuite = Cnf["Check-Overrides::OverrideSuites::%s::OriginSuite" % osuite] originosuite = originosuite.lower() originremark = " taking missing from %s" % originosuite except KeyError: @@ -326,7 +327,7 @@ def main (): suiteids.append(i[0]) if len(suiteids) != len(suites) or len(suiteids) < 1: - utils.fubar("Couldn't find id's of all suites: %s" % suites) + dak.lib.utils.fubar("Couldn't find id's of all suites: %s" % suites) for component in Cnf.SubTree("Component").List(): if component == "mixed": diff --git a/dak/check_proposed_updates.py b/dak/check_proposed_updates.py index d935399e..cb2ef9bb 100755 --- a/dak/check_proposed_updates.py +++ b/dak/check_proposed_updates.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # Dependency check proposed-updates -# Copyright (C) 2001, 2002, 2004 James Troup -# $Id: jeri,v 1.15 2005-02-08 22:43:45 troup Exp $ +# Copyright (C) 2001, 2002, 2004, 2006 James Troup # 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 @@ -30,7 +29,7 @@ ################################################################################ import pg, sys, os -import utils, db_access +import dak.lib.utils, dak.lib.database import apt_pkg, apt_inst ################################################################################ @@ -45,7 +44,7 @@ architectures = None ################################################################################ def usage (exit_code=0): - print """Usage: jeri [OPTION] [...] + print """Usage: dak check-proposed-updates [OPTION] [...] (Very) Basic dependency checking for proposed-updates. -q, --quiet be quieter about what is being done @@ -79,7 +78,7 @@ def check_dep (depends, dep_type, check_archs, filename, files): if stable[dep].has_key(arch): if apt_pkg.CheckDep(stable[dep][arch], constraint, version): if Options["debug"]: - print "Found %s as a real package." % (utils.pp_deps(parsed_dep)) + print "Found %s as a real package." % (dak.lib.utils.pp_deps(parsed_dep)) unsat = 0 break # As a virtual? @@ -87,20 +86,20 @@ def check_dep (depends, dep_type, check_archs, filename, files): if stable_virtual[dep].has_key(arch): if not constraint and not version: if Options["debug"]: - print "Found %s as a virtual package." % (utils.pp_deps(parsed_dep)) + print "Found %s as a virtual package." % (dak.lib.utils.pp_deps(parsed_dep)) unsat = 0 break # As part of the same .changes? - epochless_version = utils.re_no_epoch.sub('', version) + epochless_version = dak.lib.utils.re_no_epoch.sub('', version) dep_filename = "%s_%s_%s.deb" % (dep, epochless_version, arch) if files.has_key(dep_filename): if Options["debug"]: - print "Found %s in the same upload." % (utils.pp_deps(parsed_dep)) + print "Found %s in the same upload." % (dak.lib.utils.pp_deps(parsed_dep)) unsat = 0 break # Not found... # [FIXME: must be a better way ... ] - error = "%s not found. [Real: " % (utils.pp_deps(parsed_dep)) + error = "%s not found. [Real: " % (dak.lib.utils.pp_deps(parsed_dep)) if stable.has_key(dep): if stable[dep].has_key(arch): error += "%s:%s:%s" % (dep, arch, stable[dep][arch]) @@ -125,7 +124,7 @@ def check_dep (depends, dep_type, check_archs, filename, files): unsat.append(error) if unsat: - sys.stderr.write("MWAAP! %s: '%s' %s can not be satisifed:\n" % (filename, utils.pp_deps(parsed_dep), dep_type)) + sys.stderr.write("MWAAP! %s: '%s' %s can not be satisifed:\n" % (filename, dak.lib.utils.pp_deps(parsed_dep), dep_type)) for error in unsat: sys.stderr.write(" %s\n" % (error)) pkg_unsat = 1 @@ -134,9 +133,9 @@ def check_dep (depends, dep_type, check_archs, filename, files): def check_package(filename, files): try: - control = apt_pkg.ParseSection(apt_inst.debExtractControl(utils.open_file(filename))) + control = apt_pkg.ParseSection(apt_inst.debExtractControl(dak.lib.utils.open_file(filename))) except: - utils.warn("%s: debExtractControl() raised %s." % (filename, sys.exc_type)) + dak.lib.utils.warn("%s: debExtractControl() raised %s." % (filename, sys.exc_type)) return 1 Depends = control.Find("Depends") Pre_Depends = control.Find("Pre-Depends") @@ -173,10 +172,10 @@ def pass_fail (filename, result): def check_changes (filename): try: - changes = utils.parse_changes(filename) - files = utils.build_file_list(changes) + changes = dak.lib.utils.parse_changes(filename) + files = dak.lib.utils.build_file_list(changes) except: - utils.warn("Error parsing changes file '%s'" % (filename)) + dak.lib.utils.warn("Error parsing changes file '%s'" % (filename)) return result = 0 @@ -184,7 +183,7 @@ def check_changes (filename): # Move to the pool directory cwd = os.getcwd() file = files.keys()[0] - pool_dir = Cnf["Dir::Pool"] + '/' + utils.poolify(changes["source"], files[file]["component"]) + pool_dir = Cnf["Dir::Pool"] + '/' + dak.lib.utils.poolify(changes["source"], files[file]["component"]) os.chdir(pool_dir) changes_result = 0 @@ -210,7 +209,7 @@ def check_deb (filename): ################################################################################ def check_joey (filename): - file = utils.open_file(filename) + file = dak.lib.utils.open_file(filename) cwd = os.getcwd() os.chdir("%s/dists/proposed-updates" % (Cnf["Dir::Root"])) @@ -220,10 +219,10 @@ def check_joey (filename): if line.find('install') != -1: split_line = line.split() if len(split_line) != 2: - utils.fubar("Parse error (not exactly 2 elements): %s" % (line)) + dak.lib.utils.fubar("Parse error (not exactly 2 elements): %s" % (line)) install_type = split_line[0] if install_type not in [ "install", "install-u", "sync-install" ]: - utils.fubar("Unknown install type ('%s') from: %s" % (install_type, line)) + dak.lib.utils.fubar("Unknown install type ('%s') from: %s" % (install_type, line)) changes_filename = split_line[1] if Options["debug"]: print "Processing %s..." % (changes_filename) @@ -241,11 +240,11 @@ def parse_packages(): suite = "stable" stable = {} components = Cnf.ValueList("Suite::%s::Components" % (suite)) - architectures = filter(utils.real_arch, Cnf.ValueList("Suite::%s::Architectures" % (suite))) + architectures = filter(dak.lib.utils.real_arch, Cnf.ValueList("Suite::%s::Architectures" % (suite))) for component in components: for architecture in architectures: filename = "%s/dists/%s/%s/binary-%s/Packages" % (Cnf["Dir::Root"], suite, component, architecture) - packages = utils.open_file(filename, 'r') + packages = dak.lib.utils.open_file(filename, 'r') Packages = apt_pkg.ParseTagFile(packages) while Packages.Step(): package = Packages.Section.Find('Package') @@ -267,26 +266,26 @@ def parse_packages(): def main (): global Cnf, projectB, Options - Cnf = utils.get_conf() + Cnf = dak.lib.utils.get_conf() - Arguments = [('d', "debug", "Jeri::Options::Debug"), - ('q',"quiet","Jeri::Options::Quiet"), - ('v',"verbose","Jeri::Options::Verbose"), - ('h',"help","Jeri::Options::Help")] + Arguments = [('d', "debug", "Check-Proposed-Updates::Options::Debug"), + ('q',"quiet","Check-Proposed-Updates::Options::Quiet"), + ('v',"verbose","Check-Proposed-Updates::Options::Verbose"), + ('h',"help","Check-Proposed-Updates::Options::Help")] for i in [ "debug", "quiet", "verbose", "help" ]: - if not Cnf.has_key("Jeri::Options::%s" % (i)): - Cnf["Jeri::Options::%s" % (i)] = "" + if not Cnf.has_key("Check-Proposed-Updates::Options::%s" % (i)): + Cnf["Check-Proposed-Updates::Options::%s" % (i)] = "" arguments = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv) - Options = Cnf.SubTree("Jeri::Options") + Options = Cnf.SubTree("Check-Proposed-Updates::Options") if Options["Help"]: usage(0) if not arguments: - utils.fubar("need at least one package name as an argument.") + dak.lib.utils.fubar("need at least one package name as an argument.") projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - db_access.init(Cnf, projectB) + dak.lib.database.init(Cnf, projectB) print "Parsing packages files...", parse_packages() @@ -300,7 +299,7 @@ def main (): elif file.endswith(".joey"): check_joey(file) else: - utils.fubar("Unrecognised file type: '%s'." % (file)) + dak.lib.utils.fubar("Unrecognised file type: '%s'." % (file)) ####################################################################################### diff --git a/dak/clean_proposed_updates.py b/dak/clean_proposed_updates.py index 9faf7eb1..8c823b50 100755 --- a/dak/clean_proposed_updates.py +++ b/dak/clean_proposed_updates.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # Remove obsolete .changes files from proposed-updates -# Copyright (C) 2001, 2002, 2003, 2004 James Troup -# $Id: halle,v 1.13 2005-12-17 10:57:03 rmurray Exp $ +# Copyright (C) 2001, 2002, 2003, 2004, 2006 James Troup # 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 @@ -21,7 +20,7 @@ ################################################################################ import os, pg, re, sys -import utils, db_access +import dak.lib.utils, dak.lib.database import apt_pkg ################################################################################ @@ -36,7 +35,7 @@ re_isdeb = re.compile (r"^(.+)_(.+?)_(.+?).u?deb$") ################################################################################ def usage (exit_code=0): - print """Usage: halle [OPTION] [...] + print """Usage: dak clean-proposed-updates [OPTION] [...] Remove obsolete changes files from proposed-updates. -v, --verbose be more verbose about what is being done @@ -49,14 +48,14 @@ Need either changes files or an admin.txt file with a '.joey' suffix.""" def check_changes (filename): try: - changes = utils.parse_changes(filename) - files = utils.build_file_list(changes) + changes = dak.lib.utils.parse_changes(filename) + files = dak.lib.utils.build_file_list(changes) except: - utils.warn("Couldn't read changes file '%s'." % (filename)) + dak.lib.utils.warn("Couldn't read changes file '%s'." % (filename)) return num_files = len(files.keys()) for file in files.keys(): - if utils.re_isadeb.match(file): + if dak.lib.utils.re_isadeb.match(file): m = re_isdeb.match(file) pkg = m.group(1) version = m.group(2) @@ -64,7 +63,7 @@ def check_changes (filename): if Options["debug"]: print "BINARY: %s ==> %s_%s_%s" % (file, pkg, version, arch) else: - m = utils.re_issource.match(file) + m = dak.lib.utils.re_issource.match(file) if m: pkg = m.group(1) version = m.group(2) @@ -77,16 +76,16 @@ def check_changes (filename): if Options["debug"]: print "SOURCE: %s ==> %s_%s_%s" % (file, pkg, version, arch) else: - utils.fubar("unknown type, fix me") + dak.lib.utils.fubar("unknown type, fix me") if not pu.has_key(pkg): # FIXME - utils.warn("%s doesn't seem to exist in p-u?? (from %s [%s])" % (pkg, file, filename)) + dak.lib.utils.warn("%s doesn't seem to exist in p-u?? (from %s [%s])" % (pkg, file, filename)) continue if not pu[pkg].has_key(arch): # FIXME - utils.warn("%s doesn't seem to exist for %s in p-u?? (from %s [%s])" % (pkg, arch, file, filename)) + dak.lib.utils.warn("%s doesn't seem to exist for %s in p-u?? (from %s [%s])" % (pkg, arch, file, filename)) continue - pu_version = utils.re_no_epoch.sub('', pu[pkg][arch]) + pu_version = dak.lib.utils.re_no_epoch.sub('', pu[pkg][arch]) if pu_version == version: if Options["verbose"]: print "%s: ok" % (file) @@ -99,7 +98,7 @@ def check_changes (filename): if new_num_files == 0: print "%s: no files left, superseded by %s" % (filename, pu_version) dest = Cnf["Dir::Morgue"] + "/misc/" - utils.move(filename, dest) + dak.lib.utils.move(filename, dest) elif new_num_files < num_files: print "%s: lost files, MWAAP." % (filename) else: @@ -109,7 +108,7 @@ def check_changes (filename): ################################################################################ def check_joey (filename): - file = utils.open_file(filename) + file = dak.lib.utils.open_file(filename) cwd = os.getcwd() os.chdir("%s/dists/proposed-updates" % (Cnf["Dir::Root"])) @@ -119,10 +118,10 @@ def check_joey (filename): if line.find('install') != -1: split_line = line.split() if len(split_line) != 2: - utils.fubar("Parse error (not exactly 2 elements): %s" % (line)) + dak.lib.utils.fubar("Parse error (not exactly 2 elements): %s" % (line)) install_type = split_line[0] if install_type not in [ "install", "install-u", "sync-install" ]: - utils.fubar("Unknown install type ('%s') from: %s" % (install_type, line)) + dak.lib.utils.fubar("Unknown install type ('%s') from: %s" % (install_type, line)) changes_filename = split_line[1] if Options["debug"]: print "Processing %s..." % (changes_filename) @@ -158,25 +157,25 @@ ORDER BY package, version, arch_string def main (): global Cnf, projectB, Options - Cnf = utils.get_conf() + Cnf = dak.lib.utils.get_conf() - Arguments = [('d', "debug", "Halle::Options::Debug"), - ('v',"verbose","Halle::Options::Verbose"), - ('h',"help","Halle::Options::Help")] + Arguments = [('d', "debug", "Clean-Proposed-Updates::Options::Debug"), + ('v',"verbose","Clean-Proposed-Updates::Options::Verbose"), + ('h',"help","Clean-Proposed-Updates::Options::Help")] for i in [ "debug", "verbose", "help" ]: - if not Cnf.has_key("Halle::Options::%s" % (i)): - Cnf["Halle::Options::%s" % (i)] = "" + if not Cnf.has_key("Clean-Proposed-Updates::Options::%s" % (i)): + Cnf["Clean-Proposed-Updates::Options::%s" % (i)] = "" arguments = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv) - Options = Cnf.SubTree("Halle::Options") + Options = Cnf.SubTree("Clean-Proposed-Updates::Options") if Options["Help"]: usage(0) if not arguments: - utils.fubar("need at least one package name as an argument.") + dak.lib.utils.fubar("need at least one package name as an argument.") projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - db_access.init(Cnf, projectB) + dak.lib.database.init(Cnf, projectB) init_pu() @@ -186,7 +185,7 @@ def main (): elif file.endswith(".joey"): check_joey(file) else: - utils.fubar("Unrecognised file type: '%s'." % (file)) + dak.lib.utils.fubar("Unrecognised file type: '%s'." % (file)) ####################################################################################### diff --git a/dak/clean_queues.py b/dak/clean_queues.py index 32d8cd7e..baf53d80 100755 --- a/dak/clean_queues.py +++ b/dak/clean_queues.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # Clean incoming of old unused files -# Copyright (C) 2000, 2001, 2002 James Troup -# $Id: shania,v 1.18 2005-03-06 21:51:51 rmurray Exp $ +# Copyright (C) 2000, 2001, 2002, 2006 James Troup # 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 @@ -35,7 +34,7 @@ ################################################################################ import os, stat, sys, time -import utils +import dak.lib.utils import apt_pkg ################################################################################ @@ -48,7 +47,7 @@ delete_date = None ################################################################################ def usage (exit_code=0): - print """Usage: shania [OPTIONS] + print """Usage: dak clean-queues [OPTIONS] Clean out incoming directories. -d, --days=DAYS remove anything older than DAYS old @@ -69,11 +68,11 @@ def init (): # Ensure a directory exists to remove files to if not Options["No-Action"]: date = time.strftime("%Y-%m-%d") - del_dir = Cnf["Dir::Morgue"] + '/' + Cnf["Shania::MorgueSubDir"] + '/' + date + del_dir = Cnf["Dir::Morgue"] + '/' + Cnf["Clean-Queues::MorgueSubDir"] + '/' + date if not os.path.exists(del_dir): os.makedirs(del_dir, 02775) if not os.path.isdir(del_dir): - utils.fubar("%s must be a directory." % (del_dir)) + dak.lib.utils.fubar("%s must be a directory." % (del_dir)) # Move to the directory to clean incoming = Options["Incoming"] @@ -87,10 +86,10 @@ def remove (file): dest_filename = del_dir + '/' + os.path.basename(file) # If the destination file exists; try to find another filename to use if os.path.exists(dest_filename): - dest_filename = utils.find_next_free(dest_filename, 10) - utils.move(file, dest_filename, 0660) + dest_filename = dak.lib.utils.find_next_free(dest_filename, 10) + dak.lib.utils.move(file, dest_filename, 0660) else: - utils.warn("skipping '%s', permission denied." % (os.path.basename(file))) + dak.lib.utils.warn("skipping '%s', permission denied." % (os.path.basename(file))) # Removes any old files. # [Used for Incoming/REJECT] @@ -126,20 +125,20 @@ def flush_orphans (): # Proces all .changes and .dsc files. for changes_filename in changes_files: try: - changes = utils.parse_changes(changes_filename) - files = utils.build_file_list(changes) + changes = dak.lib.utils.parse_changes(changes_filename) + files = dak.lib.utils.build_file_list(changes) except: - utils.warn("error processing '%s'; skipping it. [Got %s]" % (changes_filename, sys.exc_type)) + dak.lib.utils.warn("error processing '%s'; skipping it. [Got %s]" % (changes_filename, sys.exc_type)) continue dsc_files = {} for file in files.keys(): if file.endswith(".dsc"): try: - dsc = utils.parse_changes(file) - dsc_files = utils.build_file_list(dsc, is_a_dsc=1) + dsc = dak.lib.utils.parse_changes(file) + dsc_files = dak.lib.utils.build_file_list(dsc, is_a_dsc=1) except: - utils.warn("error processing '%s'; skipping it. [Got %s]" % (file, sys.exc_type)) + dak.lib.utils.warn("error processing '%s'; skipping it. [Got %s]" % (file, sys.exc_type)) continue # Ensure all the files we've seen aren't deleted @@ -171,22 +170,22 @@ def flush_orphans (): def main (): global Cnf, Options - Cnf = utils.get_conf() + Cnf = dak.lib.utils.get_conf() for i in ["Help", "Incoming", "No-Action", "Verbose" ]: - if not Cnf.has_key("Shania::Options::%s" % (i)): - Cnf["Shania::Options::%s" % (i)] = "" - if not Cnf.has_key("Shania::Options::Days"): - Cnf["Shania::Options::Days"] = "14" + if not Cnf.has_key("Clean-Queues::Options::%s" % (i)): + Cnf["Clean-Queues::Options::%s" % (i)] = "" + if not Cnf.has_key("Clean-Queues::Options::Days"): + Cnf["Clean-Queues::Options::Days"] = "14" - Arguments = [('h',"help","Shania::Options::Help"), - ('d',"days","Shania::Options::Days", "IntLevel"), - ('i',"incoming","Shania::Options::Incoming", "HasArg"), - ('n',"no-action","Shania::Options::No-Action"), - ('v',"verbose","Shania::Options::Verbose")] + Arguments = [('h',"help","Clean-Queues::Options::Help"), + ('d',"days","Clean-Queues::Options::Days", "IntLevel"), + ('i',"incoming","Clean-Queues::Options::Incoming", "HasArg"), + ('n',"no-action","Clean-Queues::Options::No-Action"), + ('v',"verbose","Clean-Queues::Options::Verbose")] apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv) - Options = Cnf.SubTree("Shania::Options") + Options = Cnf.SubTree("Clean-Queues::Options") if Options["Help"]: usage() diff --git a/dak/clean_suites.py b/dak/clean_suites.py index fbeacb67..ad1d209d 100755 --- a/dak/clean_suites.py +++ b/dak/clean_suites.py @@ -1,8 +1,7 @@ #!/usr/bin/env python -# rhona, cleans up unassociated binary and source packages -# Copyright (C) 2000, 2001, 2002, 2003 James Troup -# $Id: rhona,v 1.29 2005-11-25 06:59:45 ajt Exp $ +# Cleans up unassociated binary and source packages +# Copyright (C) 2000, 2001, 2002, 2003, 2006 James Troup # 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 @@ -31,7 +30,7 @@ import os, pg, stat, sys, time import apt_pkg -import utils +import dak.lib.utils ################################################################################ @@ -44,7 +43,7 @@ delete_date = None; # delete things marked "deleted" earler than this ################################################################################ def usage (exit_code=0): - print """Usage: rhona [OPTIONS] + print """Usage: dak clean-suites [OPTIONS] Clean old packages from suites. -n, --no-action don't do anything @@ -192,7 +191,7 @@ def clean(): print "Cleaning out packages..." date = time.strftime("%Y-%m-%d") - dest = Cnf["Dir::Morgue"] + '/' + Cnf["Rhona::MorgueSubDir"] + '/' + date + dest = Cnf["Dir::Morgue"] + '/' + Cnf["Clean-Suites::MorgueSubDir"] + '/' + date if not os.path.exists(dest): os.mkdir(dest) @@ -209,7 +208,7 @@ def clean(): for i in q.getresult(): filename = i[0] + i[1] if not os.path.exists(filename): - utils.warn("can not find '%s'." % (filename)) + dak.lib.utils.warn("can not find '%s'." % (filename)) continue if os.path.isfile(filename): if os.path.islink(filename): @@ -225,14 +224,14 @@ def clean(): dest_filename = dest + '/' + os.path.basename(filename) # If the destination file exists; try to find another filename to use if os.path.exists(dest_filename): - dest_filename = utils.find_next_free(dest_filename) + dest_filename = dak.lib.utils.find_next_free(dest_filename) if Options["No-Action"]: print "Cleaning %s -> %s ..." % (filename, dest_filename) else: - utils.move(filename, dest_filename) + dak.lib.utils.move(filename, dest_filename) else: - utils.fubar("%s is neither symlink nor file?!" % (filename)) + dak.lib.utils.fubar("%s is neither symlink nor file?!" % (filename)) # Delete from the 'files' table if not Options["No-Action"]: @@ -241,7 +240,7 @@ def clean(): projectB.query("DELETE FROM files WHERE last_used <= '%s'" % (delete_date)) sys.stdout.write("done. (%d seconds)]\n" % (int(time.time()-before))) if count > 0: - sys.stderr.write("Cleaned %d files, %s.\n" % (count, utils.size_type(size))) + sys.stderr.write("Cleaned %d files, %s.\n" % (count, dak.lib.utils.size_type(size))) ################################################################################ @@ -299,17 +298,17 @@ def clean_queue_build(): print "Cleaning out queue build symlinks..." - our_delete_date = time.strftime("%Y-%m-%d %H:%M", time.localtime(time.time()-int(Cnf["Rhona::QueueBuildStayOfExecution"]))) + our_delete_date = time.strftime("%Y-%m-%d %H:%M", time.localtime(time.time()-int(Cnf["Clean-Suites::QueueBuildStayOfExecution"]))) count = 0 q = projectB.query("SELECT filename FROM queue_build WHERE last_used <= '%s'" % (our_delete_date)) for i in q.getresult(): filename = i[0] if not os.path.exists(filename): - utils.warn("%s (from queue_build) doesn't exist." % (filename)) + dak.lib.utils.warn("%s (from queue_build) doesn't exist." % (filename)) continue if not Cnf.FindB("Dinstall::SecurityQueueBuild") and not os.path.islink(filename): - utils.fubar("%s (from queue_build) should be a symlink but isn't." % (filename)) + dak.lib.utils.fubar("%s (from queue_build) should be a symlink but isn't." % (filename)) os.unlink(filename) count += 1 projectB.query("DELETE FROM queue_build WHERE last_used <= '%s'" % (our_delete_date)) @@ -322,16 +321,16 @@ def clean_queue_build(): def main(): global Cnf, Options, projectB, delete_date, now_date - Cnf = utils.get_conf() + Cnf = dak.lib.utils.get_conf() for i in ["Help", "No-Action" ]: - if not Cnf.has_key("Rhona::Options::%s" % (i)): - Cnf["Rhona::Options::%s" % (i)] = "" + if not Cnf.has_key("Clean-Suites::Options::%s" % (i)): + Cnf["Clean-Suites::Options::%s" % (i)] = "" - Arguments = [('h',"help","Rhona::Options::Help"), - ('n',"no-action","Rhona::Options::No-Action")] + Arguments = [('h',"help","Clean-Suites::Options::Help"), + ('n',"no-action","Clean-Suites::Options::No-Action")] apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv) - Options = Cnf.SubTree("Rhona::Options") + Options = Cnf.SubTree("Clean-Suites::Options") if Options["Help"]: usage() @@ -339,7 +338,7 @@ def main(): projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) now_date = time.strftime("%Y-%m-%d %H:%M") - delete_date = time.strftime("%Y-%m-%d %H:%M", time.localtime(time.time()-int(Cnf["Rhona::StayOfExecution"]))) + delete_date = time.strftime("%Y-%m-%d %H:%M", time.localtime(time.time()-int(Cnf["Clean-Suites::StayOfExecution"]))) check_binaries() clean_binaries() diff --git a/dak/compare_suites.py b/dak/compare_suites.py index cbceeb11..0eb458a6 100755 --- a/dak/compare_suites.py +++ b/dak/compare_suites.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # Check for fixable discrepancies between stable and unstable -# Copyright (C) 2000, 2001, 2002, 2003 James Troup -# $Id: andrea,v 1.10 2003-09-07 13:52:13 troup Exp $ +# Copyright (C) 2000, 2001, 2002, 2003, 2006 James Troup # 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 @@ -22,7 +21,7 @@ ################################################################################ import pg, sys -import utils, db_access +import dak.lib.utils, dak.lib.database import apt_pkg ################################################################################ @@ -33,7 +32,7 @@ projectB = None ################################################################################ def usage(exit_code=0): - print """Usage: andrea + print """Usage: dak compare-suites Looks for fixable descrepancies between stable and unstable. -h, --help show this help and exit.""" @@ -44,28 +43,28 @@ Looks for fixable descrepancies between stable and unstable. def main (): global Cnf, projectB - Cnf = utils.get_conf() - Arguments = [('h',"help","Andrea::Options::Help")] + Cnf = dak.lib.utils.get_conf() + Arguments = [('h',"help","Compare-Suites::Options::Help")] for i in [ "help" ]: - if not Cnf.has_key("Andrea::Options::%s" % (i)): - Cnf["Andrea::Options::%s" % (i)] = "" + if not Cnf.has_key("Compare-Suites::Options::%s" % (i)): + Cnf["Compare-Suites::Options::%s" % (i)] = "" apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv) - Options = Cnf.SubTree("Andrea::Options") + Options = Cnf.SubTree("Compare-Suites::Options") if Options["Help"]: usage() projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - db_access.init(Cnf, projectB) + dak.lib.database.init(Cnf, projectB) src_suite = "stable" dst_suite = "unstable" - src_suite_id = db_access.get_suite_id(src_suite) - dst_suite_id = db_access.get_suite_id(dst_suite) - arch_all_id = db_access.get_architecture_id("all") - dsc_type_id = db_access.get_override_type_id("dsc") + src_suite_id = dak.lib.database.get_suite_id(src_suite) + dst_suite_id = dak.lib.database.get_suite_id(dst_suite) + arch_all_id = dak.lib.database.get_architecture_id("all") + dsc_type_id = dak.lib.database.get_override_type_id("dsc") for arch in Cnf.ValueList("Suite::%s::Architectures" % (src_suite)): if arch == "source": @@ -77,7 +76,7 @@ def main (): if arch == "all": continue - arch_id = db_access.get_architecture_id(arch) + arch_id = dak.lib.database.get_architecture_id(arch) q = projectB.query(""" SELECT b_src.package, b_src.version, a.arch_string FROM binaries b_src, bin_associations ba, override o, architecture a diff --git a/dak/control_overrides.py b/dak/control_overrides.py index 4015f2ae..cf33e26f 100755 --- a/dak/control_overrides.py +++ b/dak/control_overrides.py @@ -1,8 +1,7 @@ #!/usr/bin/env python -# Manipulate override files -# Copyright (C) 2000, 2001, 2002, 2003 James Troup -# $Id: natalie,v 1.7 2005-11-15 09:50:32 ajt Exp $ +# Bulk manipulation of the overrides +# Copyright (C) 2000, 2001, 2002, 2003, 2006 James Troup # 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 @@ -51,7 +50,7 @@ ################################################################################ import pg, sys, time -import utils, db_access, logging +import dak.lib.utils, dak.lib.database, dak.lib.logging import apt_pkg ################################################################################ @@ -63,7 +62,7 @@ Logger = None ################################################################################ def usage (exit_code=0): - print """Usage: natalie.py [OPTIONS] + print """Usage: dak control-overrides [OPTIONS] -h, --help print this help and exit -c, --component=CMPT list/set overrides by component @@ -85,17 +84,17 @@ def usage (exit_code=0): ################################################################################ def process_file (file, suite, component, type, action): - suite_id = db_access.get_suite_id(suite) + suite_id = dak.lib.database.get_suite_id(suite) if suite_id == -1: - utils.fubar("Suite '%s' not recognised." % (suite)) + dak.lib.utils.fubar("Suite '%s' not recognised." % (suite)) - component_id = db_access.get_component_id(component) + component_id = dak.lib.database.get_component_id(component) if component_id == -1: - utils.fubar("Component '%s' not recognised." % (component)) + dak.lib.utils.fubar("Component '%s' not recognised." % (component)) - type_id = db_access.get_override_type_id(type) + type_id = dak.lib.database.get_override_type_id(type) if type_id == -1: - utils.fubar("Type '%s' not recognised. (Valid types are deb, udeb and dsc.)" % (type)) + dak.lib.utils.fubar("Type '%s' not recognised. (Valid types are deb, udeb and dsc.)" % (type)) # --set is done mostly internal for performance reasons; most # invocations of --set will be updates and making people wait 2-3 @@ -117,7 +116,7 @@ def process_file (file, suite, component, type, action): start_time = time.time() projectB.query("BEGIN WORK") for line in file.readlines(): - line = utils.re_comments.sub('', line).strip() + line = dak.lib.utils.re_comments.sub('', line).strip() if line == "": continue @@ -129,7 +128,7 @@ def process_file (file, suite, component, type, action): elif len(split_line) == 3: (package, section, maintainer_override) = split_line else: - utils.warn("'%s' does not break into 'package section [maintainer-override]'." % (line)) + dak.lib.utils.warn("'%s' does not break into 'package section [maintainer-override]'." % (line)) c_error += 1 continue priority = "source" @@ -140,23 +139,23 @@ def process_file (file, suite, component, type, action): elif len(split_line) == 4: (package, priority, section, maintainer_override) = split_line else: - utils.warn("'%s' does not break into 'package priority section [maintainer-override]'." % (line)) + dak.lib.utils.warn("'%s' does not break into 'package priority section [maintainer-override]'." % (line)) c_error += 1 continue - section_id = db_access.get_section_id(section) + section_id = dak.lib.database.get_section_id(section) if section_id == -1: - utils.warn("'%s' is not a valid section. ['%s' in suite %s, component %s]." % (section, package, suite, component)) + dak.lib.utils.warn("'%s' is not a valid section. ['%s' in suite %s, component %s]." % (section, package, suite, component)) c_error += 1 continue - priority_id = db_access.get_priority_id(priority) + priority_id = dak.lib.database.get_priority_id(priority) if priority_id == -1: - utils.warn("'%s' is not a valid priority. ['%s' in suite %s, component %s]." % (priority, package, suite, component)) + dak.lib.utils.warn("'%s' is not a valid priority. ['%s' in suite %s, component %s]." % (priority, package, suite, component)) c_error += 1 continue if new.has_key(package): - utils.warn("Can't insert duplicate entry for '%s'; ignoring all but the first. [suite %s, component %s]" % (package, suite, component)) + dak.lib.utils.warn("Can't insert duplicate entry for '%s'; ignoring all but the first. [suite %s, component %s]" % (package, suite, component)) c_error += 1 continue new[package] = "" @@ -207,84 +206,86 @@ def process_file (file, suite, component, type, action): Logger.log(["removed override",suite,component,type,package]) projectB.query("COMMIT WORK") - if not Cnf["Natalie::Options::Quiet"]: + if not Cnf["Control-Overrides::Options::Quiet"]: print "Done in %d seconds. [Updated = %d, Added = %d, Removed = %d, Skipped = %d, Errors = %d]" % (int(time.time()-start_time), c_updated, c_added, c_removed, c_skipped, c_error) Logger.log(["set complete",c_updated, c_added, c_removed, c_skipped, c_error]) ################################################################################ def list(suite, component, type): - suite_id = db_access.get_suite_id(suite) + suite_id = dak.lib.database.get_suite_id(suite) if suite_id == -1: - utils.fubar("Suite '%s' not recognised." % (suite)) + dak.lib.utils.fubar("Suite '%s' not recognised." % (suite)) - component_id = db_access.get_component_id(component) + component_id = dak.lib.database.get_component_id(component) if component_id == -1: - utils.fubar("Component '%s' not recognised." % (component)) + dak.lib.utils.fubar("Component '%s' not recognised." % (component)) - type_id = db_access.get_override_type_id(type) + type_id = dak.lib.database.get_override_type_id(type) if type_id == -1: - utils.fubar("Type '%s' not recognised. (Valid types are deb, udeb and dsc)" % (type)) + dak.lib.utils.fubar("Type '%s' not recognised. (Valid types are deb, udeb and dsc)" % (type)) if type == "dsc": q = projectB.query("SELECT o.package, s.section, o.maintainer FROM override o, section s WHERE o.suite = %s AND o.component = %s AND o.type = %s AND o.section = s.id ORDER BY s.section, o.package" % (suite_id, component_id, type_id)) for i in q.getresult(): - print utils.result_join(i) + print dak.lib.utils.result_join(i) else: q = projectB.query("SELECT o.package, p.priority, s.section, o.maintainer, p.level FROM override o, priority p, section s WHERE o.suite = %s AND o.component = %s AND o.type = %s AND o.priority = p.id AND o.section = s.id ORDER BY s.section, p.level, o.package" % (suite_id, component_id, type_id)) for i in q.getresult(): - print utils.result_join(i[:-1]) + print dak.lib.utils.result_join(i[:-1]) ################################################################################ def main (): global Cnf, projectB, Logger - Cnf = utils.get_conf() - Arguments = [('a', "add", "Natalie::Options::Add"), - ('c', "component", "Natalie::Options::Component", "HasArg"), - ('h', "help", "Natalie::Options::Help"), - ('l', "list", "Natalie::Options::List"), - ('q', "quiet", "Natalie::Options::Quiet"), - ('s', "suite", "Natalie::Options::Suite", "HasArg"), - ('S', "set", "Natalie::Options::Set"), - ('t', "type", "Natalie::Options::Type", "HasArg")] + Cnf = dak.lib.utils.get_conf() + Arguments = [('a', "add", "Control-Overrides::Options::Add"), + ('c', "component", "Control-Overrides::Options::Component", "HasArg"), + ('h', "help", "Control-Overrides::Options::Help"), + ('l', "list", "Control-Overrides::Options::List"), + ('q', "quiet", "Control-Overrides::Options::Quiet"), + ('s', "suite", "Control-Overrides::Options::Suite", "HasArg"), + ('S', "set", "Control-Overrides::Options::Set"), + ('t', "type", "Control-Overrides::Options::Type", "HasArg")] # Default arguments for i in [ "add", "help", "list", "quiet", "set" ]: - if not Cnf.has_key("Natalie::Options::%s" % (i)): - Cnf["Natalie::Options::%s" % (i)] = "" - if not Cnf.has_key("Natalie::Options::Component"): - Cnf["Natalie::Options::Component"] = "main" - if not Cnf.has_key("Natalie::Options::Suite"): - Cnf["Natalie::Options::Suite"] = "unstable" - if not Cnf.has_key("Natalie::Options::Type"): - Cnf["Natalie::Options::Type"] = "deb" + if not Cnf.has_key("Control-Overrides::Options::%s" % (i)): + Cnf["Control-Overrides::Options::%s" % (i)] = "" + if not Cnf.has_key("Control-Overrides::Options::Component"): + Cnf["Control-Overrides::Options::Component"] = "main" + if not Cnf.has_key("Control-Overrides::Options::Suite"): + Cnf["Control-Overrides::Options::Suite"] = "unstable" + if not Cnf.has_key("Control-Overrides::Options::Type"): + Cnf["Control-Overrides::Options::Type"] = "deb" file_list = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv) - if Cnf["Natalie::Options::Help"]: + if Cnf["Control-Overrides::Options::Help"]: usage() projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - db_access.init(Cnf, projectB) + dak.lib.database.init(Cnf, projectB) action = None for i in [ "add", "list", "set" ]: - if Cnf["Natalie::Options::%s" % (i)]: + if Cnf["Control-Overrides::Options::%s" % (i)]: if action: - utils.fubar("Can not perform more than one action at once.") + dak.lib.utils.fubar("Can not perform more than one action at once.") action = i - (suite, component, type) = (Cnf["Natalie::Options::Suite"], Cnf["Natalie::Options::Component"], Cnf["Natalie::Options::Type"]) + (suite, component, type) = (Cnf["Control-Overrides::Options::Suite"], + Cnf["Control-Overrides::Options::Component"], + Cnf["Control-Overrides::Options::Type"]) if action == "list": list(suite, component, type) else: - Logger = logging.Logger(Cnf, "natalie") + Logger = dak.lib.logging.Logger(Cnf, "control-overrides") if file_list: for file in file_list: - process_file(utils.open_file(file), suite, component, type, action) + process_file(dak.lib.utils.open_file(file), suite, component, type, action) else: process_file(sys.stdin, suite, component, type, action) Logger.close() diff --git a/dak/control_suite.py b/dak/control_suite.py index fb3f5fcc..35f49eb1 100755 --- a/dak/control_suite.py +++ b/dak/control_suite.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # Manipulate suite tags -# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 James Troup -# $Id: heidi,v 1.19 2005-11-15 09:50:32 ajt Exp $ +# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 James Troup # 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 @@ -44,7 +43,7 @@ import pg, sys import apt_pkg -import utils, db_access, logging +import dak.lib.utils, dak.lib.database, dak.lib.logging ####################################################################################### @@ -55,7 +54,7 @@ Logger = None ################################################################################ def usage (exit_code=0): - print """Usage: heidi [OPTIONS] [FILE] + print """Usage: dak control-suite [OPTIONS] [FILE] Display or alter the contents of a suite using FILE(s), or stdin. -a, --add=SUITE add to SUITE @@ -76,10 +75,10 @@ def get_id (package, version, architecture): ql = q.getresult() if not ql: - utils.warn("Couldn't find '%s~%s~%s'." % (package, version, architecture)) + dak.lib.utils.warn("Couldn't find '%s~%s~%s'." % (package, version, architecture)) return None if len(ql) > 1: - utils.warn("Found more than one match for '%s~%s~%s'." % (package, version, architecture)) + dak.lib.utils.warn("Found more than one match for '%s~%s~%s'." % (package, version, architecture)) return None id = ql[0][0] return id @@ -109,7 +108,7 @@ def set_suite (file, suite_id): for line in lines: split_line = line.strip().split() if len(split_line) != 3: - utils.warn("'%s' does not break into 'package version architecture'." % (line[:-1])) + dak.lib.utils.warn("'%s' does not break into 'package version architecture'." % (line[:-1])) continue key = " ".join(split_line) desired[key] = "" @@ -144,7 +143,7 @@ def set_suite (file, suite_id): def process_file (file, suite, action): - suite_id = db_access.get_suite_id(suite) + suite_id = dak.lib.database.get_suite_id(suite) if action == "set": set_suite (file, suite_id) @@ -157,7 +156,7 @@ def process_file (file, suite, action): for line in lines: split_line = line.strip().split() if len(split_line) != 3: - utils.warn("'%s' does not break into 'package version architecture'." % (line[:-1])) + dak.lib.utils.warn("'%s' does not break into 'package version architecture'." % (line[:-1])) continue (package, version, architecture) = split_line @@ -177,13 +176,13 @@ def process_file (file, suite, action): # Take action if action == "add": if assoication_id: - utils.warn("'%s~%s~%s' already exists in suite %s." % (package, version, architecture, suite)) + dak.lib.utils.warn("'%s~%s~%s' already exists in suite %s." % (package, version, architecture, suite)) continue else: q = projectB.query("INSERT INTO src_associations (suite, source) VALUES (%s, %s)" % (suite_id, id)) elif action == "remove": if assoication_id == None: - utils.warn("'%s~%s~%s' doesn't exist in suite %s." % (package, version, architecture, suite)) + dak.lib.utils.warn("'%s~%s~%s' doesn't exist in suite %s." % (package, version, architecture, suite)) continue else: q = projectB.query("DELETE FROM src_associations WHERE id = %s" % (assoication_id)) @@ -198,13 +197,13 @@ def process_file (file, suite, action): # Take action if action == "add": if assoication_id: - utils.warn("'%s~%s~%s' already exists in suite %s." % (package, version, architecture, suite)) + dak.lib.utils.warn("'%s~%s~%s' already exists in suite %s." % (package, version, architecture, suite)) continue else: q = projectB.query("INSERT INTO bin_associations (suite, bin) VALUES (%s, %s)" % (suite_id, id)) elif action == "remove": if assoication_id == None: - utils.warn("'%s~%s~%s' doesn't exist in suite %s." % (package, version, architecture, suite)) + dak.lib.utils.warn("'%s~%s~%s' doesn't exist in suite %s." % (package, version, architecture, suite)) continue else: q = projectB.query("DELETE FROM bin_associations WHERE id = %s" % (assoication_id)) @@ -214,7 +213,7 @@ def process_file (file, suite, action): ####################################################################################### def get_list (suite): - suite_id = db_access.get_suite_id(suite) + suite_id = dak.lib.database.get_suite_id(suite) # List binaries q = projectB.query("SELECT b.package, b.version, a.arch_string FROM binaries b, bin_associations ba, architecture a WHERE ba.suite = %s AND ba.bin = b.id AND b.architecture = a.id" % (suite_id)) ql = q.getresult() @@ -232,55 +231,55 @@ def get_list (suite): def main (): global Cnf, projectB, Logger - Cnf = utils.get_conf() + Cnf = dak.lib.utils.get_conf() - Arguments = [('a',"add","Heidi::Options::Add", "HasArg"), - ('h',"help","Heidi::Options::Help"), - ('l',"list","Heidi::Options::List","HasArg"), - ('r',"remove", "Heidi::Options::Remove", "HasArg"), - ('s',"set", "Heidi::Options::Set", "HasArg")] + Arguments = [('a',"add","Control-Suite::Options::Add", "HasArg"), + ('h',"help","Control-Suite::Options::Help"), + ('l',"list","Control-Suite::Options::List","HasArg"), + ('r',"remove", "Control-Suite::Options::Remove", "HasArg"), + ('s',"set", "Control-Suite::Options::Set", "HasArg")] for i in ["add", "help", "list", "remove", "set", "version" ]: - if not Cnf.has_key("Heidi::Options::%s" % (i)): - Cnf["Heidi::Options::%s" % (i)] = "" + if not Cnf.has_key("Control-Suite::Options::%s" % (i)): + Cnf["Control-Suite::Options::%s" % (i)] = "" file_list = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv) - Options = Cnf.SubTree("Heidi::Options") + Options = Cnf.SubTree("Control-Suite::Options") if Options["Help"]: usage() projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"],int(Cnf["DB::Port"])) - db_access.init(Cnf, projectB) + dak.lib.database.init(Cnf, projectB) action = None for i in ("add", "list", "remove", "set"): - if Cnf["Heidi::Options::%s" % (i)] != "": - suite = Cnf["Heidi::Options::%s" % (i)] - if db_access.get_suite_id(suite) == -1: - utils.fubar("Unknown suite '%s'." %(suite)) + if Cnf["Control-Suite::Options::%s" % (i)] != "": + suite = Cnf["Control-Suite::Options::%s" % (i)] + if dak.lib.database.get_suite_id(suite) == -1: + dak.lib.utils.fubar("Unknown suite '%s'." %(suite)) else: if action: - utils.fubar("Can only perform one action at a time.") + dak.lib.utils.fubar("Can only perform one action at a time.") action = i # Need an action... if action == None: - utils.fubar("No action specified.") + dak.lib.utils.fubar("No action specified.") # Safety/Sanity check if action == "set" and suite != "testing": - utils.fubar("Will not reset a suite other than testing.") + dak.lib.utils.fubar("Will not reset a suite other than testing.") if action == "list": get_list(suite) else: - Logger = logging.Logger(Cnf, "heidi") + Logger = dak.lib.logging.Logger(Cnf, "control-suite") if file_list: for file in file_list: - process_file(utils.open_file(file), suite, action) + process_file(dak.lib.utils.open_file(file), suite, action) else: process_file(sys.stdin, suite, action) Logger.close() diff --git a/dak/cruft_report.py b/dak/cruft_report.py index 803a7752..e13b11ce 100755 --- a/dak/cruft_report.py +++ b/dak/cruft_report.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # Check for obsolete binary packages -# Copyright (C) 2000, 2001, 2002, 2003, 2004 James Troup -# $Id: rene,v 1.23 2005-04-16 09:19:20 rmurray Exp $ +# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 James Troup # 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 @@ -29,7 +28,7 @@ ################################################################################ import commands, pg, os, string, sys, time -import utils, db_access +import dak.lib.utils, dak.lib.database import apt_pkg ################################################################################ @@ -45,7 +44,7 @@ source_versions = {} ################################################################################ def usage(exit_code=0): - print """Usage: rene + print """Usage: dak cruft-report Check for obsolete or duplicated packages. -h, --help show this help and exit. @@ -116,7 +115,7 @@ def do_anais(architecture, binaries_list, source): ################################################################################ def do_nviu(): - experimental_id = db_access.get_suite_id("experimental") + experimental_id = dak.lib.database.get_suite_id("experimental") if experimental_id == -1: return # Check for packages in experimental obsoleted by versions in unstable @@ -126,7 +125,7 @@ SELECT s.source, s.version AS experimental, s2.version AS unstable WHERE sa.suite = %s AND sa2.suite = %d AND sa.source = s.id AND sa2.source = s2.id AND s.source = s2.source AND versioncmp(s.version, s2.version) < 0""" % (experimental_id, - db_access.get_suite_id("unstable"))) + dak.lib.database.get_suite_id("unstable"))) ql = q.getresult() if ql: nviu_to_remove = [] @@ -139,7 +138,7 @@ SELECT s.source, s.version AS experimental, s2.version AS unstable nviu_to_remove.append(source) print print "Suggested command:" - print " melanie -m \"[rene] NVIU\" -s experimental %s" % (" ".join(nviu_to_remove)) + print " dak rm -m \"[auto-cruft] NVIU\" -s experimental %s" % (" ".join(nviu_to_remove)) print ################################################################################ @@ -171,7 +170,7 @@ def do_nbs(real_nbs): print output print "Suggested command:" - print " melanie -m \"[rene] NBS\" -b %s" % (" ".join(nbs_to_remove)) + print " dak rm -m \"[auto-cruft] NBS\" -b %s" % (" ".join(nbs_to_remove)) print ################################################################################ @@ -239,7 +238,7 @@ def do_obsolete_source(duplicate_bins, bin2source): print output print "Suggested command:" - print " melanie -S -p -m \"[rene] obsolete source package\" %s" % (" ".join(to_remove)) + print " dak rm -S -p -m \"[auto-cruft] obsolete source package\" %s" % (" ".join(to_remove)) print ################################################################################ @@ -247,22 +246,22 @@ def do_obsolete_source(duplicate_bins, bin2source): def main (): global Cnf, projectB, suite_id, source_binaries, source_versions - Cnf = utils.get_conf() + Cnf = dak.lib.utils.get_conf() - Arguments = [('h',"help","Rene::Options::Help"), - ('m',"mode","Rene::Options::Mode", "HasArg"), - ('s',"suite","Rene::Options::Suite","HasArg")] + Arguments = [('h',"help","Cruft-Report::Options::Help"), + ('m',"mode","Cruft-Report::Options::Mode", "HasArg"), + ('s',"suite","Cruft-Report::Options::Suite","HasArg")] for i in [ "help" ]: - if not Cnf.has_key("Rene::Options::%s" % (i)): - Cnf["Rene::Options::%s" % (i)] = "" - Cnf["Rene::Options::Suite"] = Cnf["Dinstall::DefaultSuite"] + if not Cnf.has_key("Cruft-Report::Options::%s" % (i)): + Cnf["Cruft-Report::Options::%s" % (i)] = "" + Cnf["Cruft-Report::Options::Suite"] = Cnf["Dinstall::DefaultSuite"] - if not Cnf.has_key("Rene::Options::Mode"): - Cnf["Rene::Options::Mode"] = "daily" + if not Cnf.has_key("Cruft-Report::Options::Mode"): + Cnf["Cruft-Report::Options::Mode"] = "daily" apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv) - Options = Cnf.SubTree("Rene::Options") + Options = Cnf.SubTree("Cruft-Report::Options") if Options["Help"]: usage() @@ -272,11 +271,11 @@ def main (): elif Options["Mode"] == "full": checks = [ "nbs", "nviu", "obsolete source", "dubious nbs", "bnb", "bms", "anais" ] else: - utils.warn("%s is not a recognised mode - only 'full' or 'daily' are understood." % (Options["Mode"])) + dak.lib.utils.warn("%s is not a recognised mode - only 'full' or 'daily' are understood." % (Options["Mode"])) usage(1) projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - db_access.init(Cnf, projectB) + dak.lib.database.init(Cnf, projectB) bin_pkgs = {} src_pkgs = {} @@ -289,7 +288,7 @@ def main (): duplicate_bins = {} suite = Options["Suite"] - suite_id = db_access.get_suite_id(suite) + suite_id = dak.lib.database.get_suite_id(suite) bin_not_built = {} @@ -308,12 +307,12 @@ def main (): for component in components: filename = "%s/dists/%s/%s/source/Sources.gz" % (Cnf["Dir::Root"], suite, component) # apt_pkg.ParseTagFile needs a real file handle and can't handle a GzipFile instance... - temp_filename = utils.temp_filename() + temp_filename = dak.lib.utils.temp_filename() (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename)) if (result != 0): sys.stderr.write("Gunzip invocation failed!\n%s\n" % (output)) sys.exit(result) - sources = utils.open_file(temp_filename) + sources = dak.lib.utils.open_file(temp_filename) Sources = apt_pkg.ParseTagFile(sources) while Sources.Step(): source = Sources.Section.Find('Package') @@ -353,16 +352,16 @@ def main (): # Checks based on the Packages files for component in components + ['main/debian-installer']: - architectures = filter(utils.real_arch, Cnf.ValueList("Suite::%s::Architectures" % (suite))) + architectures = filter(dak.lib.utils.real_arch, Cnf.ValueList("Suite::%s::Architectures" % (suite))) for architecture in architectures: filename = "%s/dists/%s/%s/binary-%s/Packages.gz" % (Cnf["Dir::Root"], suite, component, architecture) # apt_pkg.ParseTagFile needs a real file handle - temp_filename = utils.temp_filename() + temp_filename = dak.lib.utils.temp_filename() (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename)) if (result != 0): sys.stderr.write("Gunzip invocation failed!\n%s\n" % (output)) sys.exit(result) - packages = utils.open_file(temp_filename) + packages = dak.lib.utils.open_file(temp_filename) Packages = apt_pkg.ParseTagFile(packages) while Packages.Step(): package = Packages.Section.Find('Package') @@ -379,7 +378,7 @@ def main (): bin2source[package]["version"] = version bin2source[package]["source"] = source if source.find("(") != -1: - m = utils.re_extract_src_version.match(source) + m = dak.lib.utils.re_extract_src_version.match(source) source = m.group(1) version = m.group(2) if not bin_pkgs.has_key(package): diff --git a/dak/decode_dot_dak.py b/dak/decode_dot_dak.py index 51620ca9..84b68408 100755 --- a/dak/decode_dot_dak.py +++ b/dak/decode_dot_dak.py @@ -1,8 +1,7 @@ #!/usr/bin/env python -# Dump variables from a .katie file to stdout -# Copyright (C) 2001, 2002, 2004 James Troup -# $Id: ashley,v 1.11 2004-11-27 16:05:12 troup Exp $ +# Dump variables from a .dak file to stdout +# Copyright (C) 2001, 2002, 2004, 2006 James Troup # 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 @@ -28,15 +27,15 @@ ################################################################################ import sys -import katie, utils +import dak.lib.queue, dak.lib.utils import apt_pkg ################################################################################ def usage(exit_code=0): - print """Usage: ashley FILE... -Dumps the info in .katie FILE(s). + print """Usage: dak decode-dot-dak FILE... +Dumps the info in .dak FILE(s). -h, --help show this help and exit.""" sys.exit(exit_code) @@ -44,21 +43,21 @@ Dumps the info in .katie FILE(s). ################################################################################ def main(): - Cnf = utils.get_conf() - Arguments = [('h',"help","Ashley::Options::Help")] + Cnf = dak.lib.utils.get_conf() + Arguments = [('h',"help","Decode-Dot-Dak::Options::Help")] for i in [ "help" ]: - if not Cnf.has_key("Ashley::Options::%s" % (i)): - Cnf["Ashley::Options::%s" % (i)] = "" + if not Cnf.has_key("Decode-Dot-Dak::Options::%s" % (i)): + Cnf["Decode-Dot-Dak::Options::%s" % (i)] = "" apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv) - Options = Cnf.SubTree("Ashley::Options") + Options = Cnf.SubTree("Decode-Dot-Dak::Options") if Options["Help"]: usage() - k = katie.Katie(Cnf) + k = dak.lib.queue.Upload(Cnf) for arg in sys.argv[1:]: - arg = utils.validate_changes_file_arg(arg,require_changes=-1) + arg = dak.lib.utils.validate_changes_file_arg(arg,require_changes=-1) k.pkg.changes_file = arg print "%s:" % (arg) k.init_vars() @@ -84,7 +83,7 @@ def main(): del changes[i] print if changes: - utils.warn("changes still has following unrecognised keys: %s" % (changes.keys())) + dak.lib.utils.warn("changes still has following unrecognised keys: %s" % (changes.keys())) dsc = k.pkg.dsc print " Dsc:" @@ -95,7 +94,7 @@ def main(): del dsc[i] print if dsc: - utils.warn("dsc still has following unrecognised keys: %s" % (dsc.keys())) + dak.lib.utils.warn("dsc still has following unrecognised keys: %s" % (dsc.keys())) files = k.pkg.files print " Files:" @@ -109,7 +108,7 @@ def main(): print " %s: %s" % (i.capitalize(), files[file][i]) del files[file][i] if files[file]: - utils.warn("files[%s] still has following unrecognised keys: %s" % (file, files[file].keys())) + dak.lib.utils.warn("files[%s] still has following unrecognised keys: %s" % (file, files[file].keys())) print dsc_files = k.pkg.dsc_files @@ -126,7 +125,7 @@ def main(): print " %s: %s" % (i.capitalize(), dsc_files[file][i]) del dsc_files[file][i] if dsc_files[file]: - utils.warn("dsc_files[%s] still has following unrecognised keys: %s" % (file, dsc_files[file].keys())) + dak.lib.utils.warn("dsc_files[%s] still has following unrecognised keys: %s" % (file, dsc_files[file].keys())) ################################################################################ diff --git a/dak/examine_package.py b/dak/examine_package.py index 1f4633a9..1749bb20 100755 --- a/dak/examine_package.py +++ b/dak/examine_package.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # Script to automate some parts of checking NEW packages -# Copyright (C) 2000, 2001, 2002, 2003 James Troup -# $Id: fernanda.py,v 1.10 2003-11-10 23:01:17 troup Exp $ +# Copyright (C) 2000, 2001, 2002, 2003, 2006 James Troup # 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 @@ -34,9 +33,9 @@ ################################################################################ import errno, os, re, sys -import utils +import dak.lib.utils import apt_pkg, apt_inst -import pg, db_access +import pg, dak.lib.database ################################################################################ @@ -80,14 +79,14 @@ maintainer_colour = arch_colour Cnf = None projectB = None -Cnf = utils.get_conf() +Cnf = dak.lib.utils.get_conf() projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) -db_access.init(Cnf, projectB) +dak.lib.database.init(Cnf, projectB) ################################################################################ def usage (exit_code=0): - print """Usage: fernanda [PACKAGE]... + print """Usage: dak examine-package [PACKAGE]... Check NEW package(s). -h, --help show this help and exit @@ -145,7 +144,7 @@ def read_control (filename): maintainer = '' arch = '' - deb_file = utils.open_file(filename) + deb_file = dak.lib.utils.open_file(filename) try: extracts = apt_inst.debExtractControl(deb_file) control = apt_pkg.ParseSection(extracts) @@ -196,9 +195,9 @@ def read_control (filename): def read_dsc (dsc_filename): dsc = {} - dsc_file = utils.open_file(dsc_filename) + dsc_file = dak.lib.utils.open_file(dsc_filename) try: - dsc = utils.parse_changes(dsc_filename) + dsc = dak.lib.utils.parse_changes(dsc_filename) except: print "can't parse control info" dsc_file.close() @@ -347,7 +346,7 @@ def check_deb (deb_filename): # Read a file, strip the signature and return the modified contents as # a string. def strip_pgp_signature (filename): - file = utils.open_file (filename) + file = dak.lib.utils.open_file (filename) contents = "" inside_signature = 0 skip_next = 0 @@ -380,8 +379,8 @@ def display_changes (changes_filename): def check_changes (changes_filename): display_changes(changes_filename) - changes = utils.parse_changes (changes_filename) - files = utils.build_file_list(changes) + changes = dak.lib.utils.parse_changes (changes_filename) + files = dak.lib.utils.build_file_list(changes) for file in files.keys(): if file.endswith(".deb") or file.endswith(".udeb"): check_deb(file) @@ -392,15 +391,15 @@ def check_changes (changes_filename): def main (): global Cnf, projectB, db_files, waste, excluded -# Cnf = utils.get_conf() +# Cnf = dak.lib.utils.get_conf() - Arguments = [('h',"help","Fernanda::Options::Help")] + Arguments = [('h',"help","Examine-Package::Options::Help")] for i in [ "help" ]: if not Cnf.has_key("Frenanda::Options::%s" % (i)): - Cnf["Fernanda::Options::%s" % (i)] = "" + Cnf["Examine-Package::Options::%s" % (i)] = "" args = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv) - Options = Cnf.SubTree("Fernanda::Options") + Options = Cnf.SubTree("Examine-Package::Options") if Options["Help"]: usage() @@ -422,19 +421,19 @@ def main (): elif file.endswith(".dsc"): check_dsc(file) else: - utils.fubar("Unrecognised file type: '%s'." % (file)) + dak.lib.utils.fubar("Unrecognised file type: '%s'." % (file)) finally: # Reset stdout here so future less invocations aren't FUBAR less_fd.close() sys.stdout = stdout_fd except IOError, e: if errno.errorcode[e.errno] == 'EPIPE': - utils.warn("[fernanda] Caught EPIPE; skipping.") + dak.lib.utils.warn("[examine-package] Caught EPIPE; skipping.") pass else: raise except KeyboardInterrupt: - utils.warn("[fernanda] Caught C-c; skipping.") + dak.lib.utils.warn("[examine-package] Caught C-c; skipping.") pass ####################################################################################### diff --git a/dak/find_null_maintainers.py b/dak/find_null_maintainers.py index 82eed196..574dc0b9 100755 --- a/dak/find_null_maintainers.py +++ b/dak/find_null_maintainers.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # Check for users with no packages in the archive -# Copyright (C) 2003 James Troup -# $Id: rosamund,v 1.1 2003-09-07 13:48:51 troup Exp $ +# Copyright (C) 2003, 2006 James Troup # 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 @@ -22,7 +21,7 @@ import ldap, pg, sys, time import apt_pkg -import utils +import dak.lib.utils ################################################################################ @@ -32,7 +31,7 @@ projectB = None ################################################################################ def usage(exit_code=0): - print """Usage: rosamund + print """Usage: dak find-null-maintainers Checks for users with no packages in the archive -h, --help show this help and exit.""" @@ -51,15 +50,15 @@ def get_ldap_value(entry, value): def main(): global Cnf, projectB - Cnf = utils.get_conf() - Arguments = [('h',"help","Rosamund::Options::Help")] + Cnf = dak.lib.utils.get_conf() + Arguments = [('h',"help","Find-Null-Maintainers::Options::Help")] for i in [ "help" ]: - if not Cnf.has_key("Rosamund::Options::%s" % (i)): - Cnf["Rosamund::Options::%s" % (i)] = "" + if not Cnf.has_key("Find-Null-Maintainers::Options::%s" % (i)): + Cnf["Find-Null-Maintainers::Options::%s" % (i)] = "" apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv) - Options = Cnf.SubTree("Rosamund::Options") + Options = Cnf.SubTree("Find-Null-Maintainers::Options") if Options["Help"]: usage() @@ -67,12 +66,12 @@ def main(): before = time.time() sys.stderr.write("[Getting info from the LDAP server...") - LDAPDn = Cnf["Emilie::LDAPDn"] - LDAPServer = Cnf["Emilie::LDAPServer"] + LDAPDn = Cnf["Import-LDAP-Fingerprints::LDAPDn"] + LDAPServer = Cnf["Import-LDAP-Fingerprints::LDAPServer"] l = ldap.open(LDAPServer) l.simple_bind_s("","") Attrs = l.search_s(LDAPDn, ldap.SCOPE_ONELEVEL, - "(&(keyfingerprint=*)(gidnumber=%s))" % (Cnf["Julia::ValidGID"]), + "(&(keyfingerprint=*)(gidnumber=%s))" % (Cnf["Import-Users-From-Passwd::ValidGID"]), ["uid", "cn", "mn", "sn", "createtimestamp"]) sys.stderr.write("done. (%d seconds)]\n" % (int(time.time()-before))) diff --git a/dak/generate_index_diffs.py b/dak/generate_index_diffs.py index ee602e05..de473d65 100755 --- a/dak/generate_index_diffs.py +++ b/dak/generate_index_diffs.py @@ -4,9 +4,9 @@ # generates partial package updates list # idea and basic implementation by Anthony, some changes by Andreas -# parts are stolen from ziyi +# parts are stolen from 'dak generate-releases' # -# Copyright (C) 2004-5 Anthony Towns +# Copyright (C) 2004-6, 6 Anthony Towns # Copyright (C) 2004-5 Andreas Barth # This program is free software; you can redistribute it and/or modify @@ -32,7 +32,7 @@ import sys, os, tempfile import apt_pkg -import utils +import dak.lib.utils ################################################################################ @@ -44,7 +44,7 @@ Options = None ################################################################################ def usage (exit_code=0): - print """Usage: tiffani [OPTIONS] [suites] + print """Usage: dak generate-index-diffs [OPTIONS] [suites] Write out ed-style diffs to Packages/Source lists -h, --help show this help and exit @@ -288,17 +288,17 @@ def main(): os.umask(0002) - Cnf = utils.get_conf() - Arguments = [ ('h', "help", "Tiffani::Options::Help"), - ('c', None, "Tiffani::Options::CanonicalPath", "hasArg"), - ('p', "patchname", "Tiffani::Options::PatchName", "hasArg"), - ('r', "rootdir", "Tiffani::Options::RootDir", "hasArg"), - ('d', "tmpdir", "Tiffani::Options::TempDir", "hasArg"), - ('m', "maxdiffs", "Tiffani::Options::MaxDiffs", "hasArg"), - ('n', "n-act", "Tiffani::Options::NoAct"), + Cnf = dak.lib.utils.get_conf() + Arguments = [ ('h', "help", "Generate-Index-Diffs::Options::Help"), + ('c', None, "Generate-Index-Diffs::Options::CanonicalPath", "hasArg"), + ('p', "patchname", "Generate-Index-Diffs::Options::PatchName", "hasArg"), + ('r', "rootdir", "Generate-Index-Diffs::Options::RootDir", "hasArg"), + ('d', "tmpdir", "Generate-Index-Diffs::Options::TempDir", "hasArg"), + ('m', "maxdiffs", "Generate-Index-Diffs::Options::MaxDiffs", "hasArg"), + ('n', "n-act", "Generate-Index-Diffs::Options::NoAct"), ] suites = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv) - Options = Cnf.SubTree("Tiffani::Options") + Options = Cnf.SubTree("Generate-Index-Diffs::Options") if Options.has_key("Help"): usage() maxdiffs = Options.get("MaxDiffs::Default", "14") @@ -314,7 +314,7 @@ def main(): o.close() AptCnf = apt_pkg.newConfiguration() - apt_pkg.ReadConfigFileISC(AptCnf,utils.which_apt_conf_file()) + apt_pkg.ReadConfigFileISC(AptCnf,dak.lib.utils.which_apt_conf_file()) if Options.has_key("RootDir"): Cnf["Dir::Root"] = Options["RootDir"] @@ -353,7 +353,7 @@ def main(): elif AptCnf.has_key("bindirectory::%s" % (tree)): sections = AptCnf["bindirectory::%s::Sections" % (tree)].split() else: - aptcnf_filename = os.path.basename(utils.which_apt_conf_file()) + aptcnf_filename = os.path.basename(dak.lib.utils.which_apt_conf_file()) print "ALERT: suite %s not in %s, nor untouchable!" % (suite, aptcnf_filename) continue @@ -368,9 +368,9 @@ def main(): storename = "%s/%s_contents_%s" % (Options["TempDir"], suite, architecture) print "running contents for %s %s : " % (suite, architecture), genchanges(Options, file + ".diff", storename, file, \ - Cnf.get("Suite::%s::Tiffani::MaxDiffs::Contents" % (suite), maxcontents)) + Cnf.get("Suite::%s::Generate-Index-Diffs::MaxDiffs::Contents" % (suite), maxcontents)) - # use sections instead of components since katie.conf + # use sections instead of components since dak.conf # treats "foo/bar main" as suite "foo", suitesuffix "bar" and # component "bar/main". suck. @@ -389,7 +389,7 @@ def main(): storename = "%s/%s_%s_%s" % (Options["TempDir"], suite, component, architecture) print "running for %s %s %s : " % (suite, component, architecture), genchanges(Options, file + ".diff", storename, file, \ - Cnf.get("Suite::%s::Tiffani::MaxDiffs::%s" % (suite, packages), maxsuite)) + Cnf.get("Suite::%s::Generate-Index-Diffs::MaxDiffs::%s" % (suite, packages), maxsuite)) ################################################################################ diff --git a/dak/generate_releases.py b/dak/generate_releases.py index 4dba71f0..6ca6d3d3 100755 --- a/dak/generate_releases.py +++ b/dak/generate_releases.py @@ -2,8 +2,7 @@ # Create all the Release files -# Copyright (C) 2001, 2002 Anthony Towns -# $Id: ziyi,v 1.27 2005-11-15 09:50:32 ajt Exp $ +# Copyright (C) 2001, 2002, 2006 Anthony Towns # 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 @@ -24,7 +23,7 @@ ################################################################################ import sys, os, popen2, tempfile, stat, time -import utils +import dak.lib.utils import apt_pkg ################################################################################ @@ -37,7 +36,7 @@ AptCnf = None ################################################################################ def usage (exit_code=0): - print """Usage: ziyi [OPTION]... [SUITE]... + print """Usage: dak generate-releases [OPTION]... [SUITE]... Generate Release files (for SUITE). -h, --help show this help and exit @@ -105,8 +104,8 @@ def print_md5sha_files (tree, files, hashop): (cat, path, name, ext)) else: size = os.stat(path + name)[stat.ST_SIZE] - file_handle = utils.open_file(path + name) - except utils.cant_open_exc: + file_handle = dak.lib.utils.open_file(path + name) + except dak.lib.utils.cant_open_exc: print "ALERT: Couldn't open " + path + name else: hash = hashop(file_handle) @@ -125,21 +124,21 @@ def main (): global Cnf, AptCnf, projectB, out out = sys.stdout - Cnf = utils.get_conf() + Cnf = dak.lib.utils.get_conf() - Arguments = [('h',"help","Ziyi::Options::Help")] + Arguments = [('h',"help","Generate-Releases::Options::Help")] for i in [ "help" ]: - if not Cnf.has_key("Ziyi::Options::%s" % (i)): - Cnf["Ziyi::Options::%s" % (i)] = "" + if not Cnf.has_key("Generate-Releases::Options::%s" % (i)): + Cnf["Generate-Releases::Options::%s" % (i)] = "" suites = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv) - Options = Cnf.SubTree("Ziyi::Options") + Options = Cnf.SubTree("Generate-Releases::Options") if Options["Help"]: usage() AptCnf = apt_pkg.newConfiguration() - apt_pkg.ReadConfigFileISC(AptCnf,utils.which_apt_conf_file()) + apt_pkg.ReadConfigFileISC(AptCnf,dak.lib.utils.which_apt_conf_file()) if not suites: suites = Cnf.SubTree("Suite").List() @@ -182,7 +181,7 @@ def main (): elif AptCnf.has_key("bindirectory::%s" % (tree)): pass else: - aptcnf_filename = os.path.basename(utils.which_apt_conf_file()) + aptcnf_filename = os.path.basename(dak.lib.utils.which_apt_conf_file()) print "ALERT: suite %s not in %s, nor untouchable!" % (suite, aptcnf_filename) continue @@ -199,7 +198,7 @@ def main (): out.write("Date: %s\n" % (time.strftime("%a, %d %b %Y %H:%M:%S UTC", time.gmtime(time.time())))) if notautomatic != "": out.write("NotAutomatic: %s\n" % (notautomatic)) - out.write("Architectures: %s\n" % (" ".join(filter(utils.real_arch, SuiteBlock.ValueList("Architectures"))))) + out.write("Architectures: %s\n" % (" ".join(filter(dak.lib.utils.real_arch, SuiteBlock.ValueList("Architectures"))))) if components: out.write("Components: %s\n" % (" ".join(components))) @@ -238,7 +237,7 @@ def main (): release = open(relpath, "w") #release = open(longsuite.replace("/","_") + "_" + arch + "_" + sec + "_Release", "w") except IOError: - utils.fubar("Couldn't write to " + relpath) + dak.lib.utils.fubar("Couldn't write to " + relpath) release.write("Archive: %s\n" % (suite)) if version != "": diff --git a/dak/import_archive.py b/dak/import_archive.py index 86bcbec5..7e271d8d 100755 --- a/dak/import_archive.py +++ b/dak/import_archive.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # Populate the DB -# Copyright (C) 2000, 2001, 2002, 2003, 2004 James Troup -# $Id: neve,v 1.20 2004-06-17 14:59:57 troup Exp $ +# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 James Troup # 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 @@ -39,7 +38,7 @@ import commands, os, pg, re, sys, time import apt_pkg -import db_access, utils +import dak.lib.database, dak.lib.utils ############################################################################### @@ -76,7 +75,7 @@ reject_message = "" ################################################################################ def usage(exit_code=0): - print """Usage: neve + print """Usage: dak import-archive Initializes a projectB database from an existing archive -a, --action actually perform the initalization @@ -93,14 +92,14 @@ def reject (str, prefix="Rejected: "): ############################################################################### def check_signature (filename): - if not utils.re_taint_free.match(os.path.basename(filename)): + if not dak.lib.utils.re_taint_free.match(os.path.basename(filename)): reject("!!WARNING!! tainted filename: '%s'." % (filename)) return None status_read, status_write = os.pipe() cmd = "gpgv --status-fd %s --keyring %s --keyring %s %s" \ % (status_write, Cnf["Dinstall::PGPKeyring"], Cnf["Dinstall::GPGKeyring"], filename) - (output, status, exit_status) = utils.gpgv_get_status_output(cmd, status_read, status_write) + (output, status, exit_status) = dak.lib.utils.gpgv_get_status_output(cmd, status_read, status_write) # Process the status-fd output keywords = {} @@ -133,7 +132,7 @@ def check_signature (filename): # Now check for obviously bad things in the processed output if keywords.has_key("SIGEXPIRED"): - utils.warn("%s: signing key has expired." % (filename)) + dak.lib.utils.warn("%s: signing key has expired." % (filename)) if keywords.has_key("KEYREVOKED"): reject("key used to sign %s has been revoked." % (filename)) bad = 1 @@ -154,7 +153,7 @@ def check_signature (filename): reject("ascii armour of signature was corrupt in %s." % (filename)) bad = 1 if keywords.has_key("NODATA"): - utils.warn("no signature found for %s." % (filename)) + dak.lib.utils.warn("no signature found for %s." % (filename)) return "NOSIG" #reject("no signature found in %s." % (filename)) #bad = 1 @@ -166,9 +165,9 @@ def check_signature (filename): if exit_status and not keywords.has_key("NO_PUBKEY"): reject("gpgv failed while checking %s." % (filename)) if status.strip(): - reject(utils.prefix_multi_line_string(status, " [GPG status-fd output:] "), "") + reject(dak.lib.utils.prefix_multi_line_string(status, " [GPG status-fd output:] "), "") else: - reject(utils.prefix_multi_line_string(output, " [GPG output:] "), "") + reject(dak.lib.utils.prefix_multi_line_string(output, " [GPG output:] "), "") return None # Sanity check the good stuff we expect @@ -191,7 +190,7 @@ def check_signature (filename): bad = 1 # Finally ensure there's not something we don't recognise - known_keywords = utils.Dict(VALIDSIG="",SIG_ID="",GOODSIG="",BADSIG="",ERRSIG="", + known_keywords = dak.lib.utils.Dict(VALIDSIG="",SIG_ID="",GOODSIG="",BADSIG="",ERRSIG="", SIGEXPIRED="",KEYREVOKED="",NO_PUBKEY="",BADARMOR="", NODATA="") @@ -232,13 +231,13 @@ def update_locations (): projectB.query("DELETE FROM location") for location in Cnf.SubTree("Location").List(): SubSec = Cnf.SubTree("Location::%s" % (location)) - archive_id = db_access.get_archive_id(SubSec["archive"]) + archive_id = dak.lib.database.get_archive_id(SubSec["archive"]) type = SubSec.Find("type") if type == "legacy-mixed": projectB.query("INSERT INTO location (path, archive, type) VALUES ('%s', %d, '%s')" % (location, archive_id, SubSec["type"])) else: for component in Cnf.SubTree("Component").List(): - component_id = db_access.get_component_id(component) + component_id = dak.lib.database.get_component_id(component) projectB.query("INSERT INTO location (path, component, archive, type) VALUES ('%s', %d, %d, '%s')" % (location, component_id, archive_id, SubSec["type"])) @@ -256,7 +255,7 @@ def update_suites (): if SubSec.has_key(i): projectB.query("UPDATE suite SET %s = '%s' WHERE suite_name = '%s'" % (i.lower(), SubSec[i], suite.lower())) for architecture in Cnf.ValueList("Suite::%s::Architectures" % (suite)): - architecture_id = db_access.get_architecture_id (architecture) + architecture_id = dak.lib.database.get_architecture_id (architecture) projectB.query("INSERT INTO suite_architectures (suite, architecture) VALUES (currval('suite_id_seq'), %d)" % (architecture_id)) def update_override_type(): @@ -272,7 +271,7 @@ def update_priority(): def update_section(): projectB.query("DELETE FROM section") for component in Cnf.SubTree("Component").List(): - if Cnf["Natalie::ComponentPosition"] == "prefix": + if Cnf["Control-Overrides::ComponentPosition"] == "prefix": suffix = "" if component != 'main': prefix = component + '/' @@ -298,7 +297,7 @@ def get_location_path(directory): try: path = q.getresult()[0][0] except: - utils.fubar("[neve] get_location_path(): Couldn't get path for %s" % (directory)) + dak.lib.utils.fubar("[import-archive] get_location_path(): Couldn't get path for %s" % (directory)) location_path_cache[directory] = path return path @@ -321,41 +320,41 @@ def process_sources (filename, suite, component, archive): global source_cache, source_query_cache, src_associations_query_cache, dsc_files_query_cache, source_id_serial, src_associations_id_serial, dsc_files_id_serial, source_cache_for_binaries, orig_tar_gz_cache, reject_message suite = suite.lower() - suite_id = db_access.get_suite_id(suite) + suite_id = dak.lib.database.get_suite_id(suite) try: - file = utils.open_file (filename) - except utils.cant_open_exc: - utils.warn("can't open '%s'" % (filename)) + file = dak.lib.utils.open_file (filename) + except dak.lib.utils.cant_open_exc: + dak.lib.utils.warn("can't open '%s'" % (filename)) return Scanner = apt_pkg.ParseTagFile(file) while Scanner.Step() != 0: package = Scanner.Section["package"] version = Scanner.Section["version"] directory = Scanner.Section["directory"] - dsc_file = os.path.join(Cnf["Dir::Root"], directory, "%s_%s.dsc" % (package, utils.re_no_epoch.sub('', version))) + dsc_file = os.path.join(Cnf["Dir::Root"], directory, "%s_%s.dsc" % (package, dak.lib.utils.re_no_epoch.sub('', version))) # Sometimes the Directory path is a lie; check in the pool if not os.path.exists(dsc_file): if directory.split('/')[0] == "dists": - directory = Cnf["Dir::PoolRoot"] + utils.poolify(package, component) - dsc_file = os.path.join(Cnf["Dir::Root"], directory, "%s_%s.dsc" % (package, utils.re_no_epoch.sub('', version))) + directory = Cnf["Dir::PoolRoot"] + dak.lib.utils.poolify(package, component) + dsc_file = os.path.join(Cnf["Dir::Root"], directory, "%s_%s.dsc" % (package, dak.lib.utils.re_no_epoch.sub('', version))) if not os.path.exists(dsc_file): - utils.fubar("%s not found." % (dsc_file)) + dak.lib.utils.fubar("%s not found." % (dsc_file)) install_date = time.strftime("%Y-%m-%d", time.localtime(os.path.getmtime(dsc_file))) fingerprint = check_signature(dsc_file) - fingerprint_id = db_access.get_or_set_fingerprint_id(fingerprint) + fingerprint_id = dak.lib.database.get_or_set_fingerprint_id(fingerprint) if reject_message: - utils.fubar("%s: %s" % (dsc_file, reject_message)) + dak.lib.utils.fubar("%s: %s" % (dsc_file, reject_message)) maintainer = Scanner.Section["maintainer"] maintainer = maintainer.replace("'", "\\'") - maintainer_id = db_access.get_or_set_maintainer_id(maintainer) + maintainer_id = dak.lib.database.get_or_set_maintainer_id(maintainer) location = get_location_path(directory.split('/')[0]) - location_id = db_access.get_location_id (location, component, archive) + location_id = dak.lib.database.get_location_id (location, component, archive) if not directory.endswith("/"): directory += '/' directory = poolify (directory, location) if directory != "" and not directory.endswith("/"): directory += '/' - no_epoch_version = utils.re_no_epoch.sub('', version) + no_epoch_version = dak.lib.utils.re_no_epoch.sub('', version) # Add all files referenced by the .dsc to the files table ids = [] for line in Scanner.Section["files"].split('\n'): @@ -404,11 +403,11 @@ def process_packages (filename, suite, component, archive): count_total = 0 count_bad = 0 suite = suite.lower() - suite_id = db_access.get_suite_id(suite) + suite_id = dak.lib.database.get_suite_id(suite) try: - file = utils.open_file (filename) - except utils.cant_open_exc: - utils.warn("can't open '%s'" % (filename)) + file = dak.lib.utils.open_file (filename) + except dak.lib.utils.cant_open_exc: + dak.lib.utils.warn("can't open '%s'" % (filename)) return Scanner = apt_pkg.ParseTagFile(file) while Scanner.Step() != 0: @@ -416,25 +415,25 @@ def process_packages (filename, suite, component, archive): version = Scanner.Section["version"] maintainer = Scanner.Section["maintainer"] maintainer = maintainer.replace("'", "\\'") - maintainer_id = db_access.get_or_set_maintainer_id(maintainer) + maintainer_id = dak.lib.database.get_or_set_maintainer_id(maintainer) architecture = Scanner.Section["architecture"] - architecture_id = db_access.get_architecture_id (architecture) + architecture_id = dak.lib.database.get_architecture_id (architecture) fingerprint = "NOSIG" - fingerprint_id = db_access.get_or_set_fingerprint_id(fingerprint) + fingerprint_id = dak.lib.database.get_or_set_fingerprint_id(fingerprint) if not Scanner.Section.has_key("source"): source = package else: source = Scanner.Section["source"] source_version = "" if source.find("(") != -1: - m = utils.re_extract_src_version.match(source) + m = dak.lib.utils.re_extract_src_version.match(source) source = m.group(1) source_version = m.group(2) if not source_version: source_version = version filename = Scanner.Section["filename"] location = get_location_path(filename.split('/')[0]) - location_id = db_access.get_location_id (location, component, archive) + location_id = dak.lib.database.get_location_id (location, component, archive) filename = poolify (filename, location) if architecture == "all": filename = re_arch_from_filename.sub("binary-all", filename) @@ -474,10 +473,10 @@ def process_packages (filename, suite, component, archive): ############################################################################### def do_sources(sources, suite, component, server): - temp_filename = utils.temp_filename() + temp_filename = dak.lib.utils.temp_filename() (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (sources, temp_filename)) if (result != 0): - utils.fubar("Gunzip invocation failed!\n%s" % (output), result) + dak.lib.utils.fubar("Gunzip invocation failed!\n%s" % (output), result) print 'Processing '+sources+'...' process_sources (temp_filename, suite, component, server) os.unlink(temp_filename) @@ -487,21 +486,21 @@ def do_sources(sources, suite, component, server): def do_da_do_da (): global Cnf, projectB, query_cache, files_query_cache, source_query_cache, src_associations_query_cache, dsc_files_query_cache, bin_associations_query_cache, binaries_query_cache - Cnf = utils.get_conf() - Arguments = [('a', "action", "Neve::Options::Action"), - ('h', "help", "Neve::Options::Help")] + Cnf = dak.lib.utils.get_conf() + Arguments = [('a', "action", "Import-Archive::Options::Action"), + ('h', "help", "Import-Archive::Options::Help")] for i in [ "action", "help" ]: - if not Cnf.has_key("Neve::Options::%s" % (i)): - Cnf["Neve::Options::%s" % (i)] = "" + if not Cnf.has_key("Import-Archive::Options::%s" % (i)): + Cnf["Import-Archive::Options::%s" % (i)] = "" apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv) - Options = Cnf.SubTree("Neve::Options") + Options = Cnf.SubTree("Import-Archive::Options") if Options["Help"]: usage() if not Options["Action"]: - utils.warn("""no -a/--action given; not doing anything. + dak.lib.utils.warn("""no -a/--action given; not doing anything. Please read the documentation before running this script. """) usage(1) @@ -509,12 +508,12 @@ Please read the documentation before running this script. print "Re-Creating DB..." (result, output) = commands.getstatusoutput("psql -f init_pool.sql template1") if (result != 0): - utils.fubar("psql invocation failed!\n", result) + dak.lib.utils.fubar("psql invocation failed!\n", result) print output projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - db_access.init (Cnf, projectB) + dak.lib.database.init (Cnf, projectB) print "Adding static tables from conf file..." projectB.query("BEGIN WORK") @@ -528,12 +527,12 @@ Please read the documentation before running this script. update_section() projectB.query("COMMIT WORK") - files_query_cache = utils.open_file(Cnf["Neve::ExportDir"]+"files","w") - source_query_cache = utils.open_file(Cnf["Neve::ExportDir"]+"source","w") - src_associations_query_cache = utils.open_file(Cnf["Neve::ExportDir"]+"src_associations","w") - dsc_files_query_cache = utils.open_file(Cnf["Neve::ExportDir"]+"dsc_files","w") - binaries_query_cache = utils.open_file(Cnf["Neve::ExportDir"]+"binaries","w") - bin_associations_query_cache = utils.open_file(Cnf["Neve::ExportDir"]+"bin_associations","w") + files_query_cache = dak.lib.utils.open_file(Cnf["Import-Archive::ExportDir"]+"files","w") + source_query_cache = dak.lib.utils.open_file(Cnf["Import-Archive::ExportDir"]+"source","w") + src_associations_query_cache = dak.lib.utils.open_file(Cnf["Import-Archive::ExportDir"]+"src_associations","w") + dsc_files_query_cache = dak.lib.utils.open_file(Cnf["Import-Archive::ExportDir"]+"dsc_files","w") + binaries_query_cache = dak.lib.utils.open_file(Cnf["Import-Archive::ExportDir"]+"binaries","w") + bin_associations_query_cache = dak.lib.utils.open_file(Cnf["Import-Archive::ExportDir"]+"bin_associations","w") projectB.query("BEGIN WORK") # Process Sources files to popoulate `source' and friends @@ -551,7 +550,7 @@ Please read the documentation before running this script. sources = Cnf["Dir::Root"] + "dists/" + Cnf["Suite::%s::CodeName" % (suite)] + '/' + component + '/source/' + 'Sources.gz' do_sources(sources, suite, component, server) else: - utils.fubar("Unknown location type ('%s')." % (type)) + dak.lib.utils.fubar("Unknown location type ('%s')." % (type)) # Process Packages files to populate `binaries' and friends @@ -567,7 +566,7 @@ Please read the documentation before running this script. elif type == "legacy" or type == "pool": for suite in Cnf.ValueList("Location::%s::Suites" % (location)): for component in Cnf.SubTree("Component").List(): - architectures = filter(utils.real_arch, + architectures = filter(dak.lib.utils.real_arch, Cnf.ValueList("Suite::%s::Architectures" % (suite))) for architecture in architectures: packages = Cnf["Dir::Root"] + "dists/" + Cnf["Suite::%s::CodeName" % (suite)] + '/' + component + '/binary-' + architecture + '/Packages' @@ -581,17 +580,17 @@ Please read the documentation before running this script. binaries_query_cache.close() bin_associations_query_cache.close() print "Writing data to `files' table..." - projectB.query("COPY files FROM '%s'" % (Cnf["Neve::ExportDir"]+"files")) + projectB.query("COPY files FROM '%s'" % (Cnf["Import-Archive::ExportDir"]+"files")) print "Writing data to `source' table..." - projectB.query("COPY source FROM '%s'" % (Cnf["Neve::ExportDir"]+"source")) + projectB.query("COPY source FROM '%s'" % (Cnf["Import-Archive::ExportDir"]+"source")) print "Writing data to `src_associations' table..." - projectB.query("COPY src_associations FROM '%s'" % (Cnf["Neve::ExportDir"]+"src_associations")) + projectB.query("COPY src_associations FROM '%s'" % (Cnf["Import-Archive::ExportDir"]+"src_associations")) print "Writing data to `dsc_files' table..." - projectB.query("COPY dsc_files FROM '%s'" % (Cnf["Neve::ExportDir"]+"dsc_files")) + projectB.query("COPY dsc_files FROM '%s'" % (Cnf["Import-Archive::ExportDir"]+"dsc_files")) print "Writing data to `binaries' table..." - projectB.query("COPY binaries FROM '%s'" % (Cnf["Neve::ExportDir"]+"binaries")) + projectB.query("COPY binaries FROM '%s'" % (Cnf["Import-Archive::ExportDir"]+"binaries")) print "Writing data to `bin_associations' table..." - projectB.query("COPY bin_associations FROM '%s'" % (Cnf["Neve::ExportDir"]+"bin_associations")) + projectB.query("COPY bin_associations FROM '%s'" % (Cnf["Import-Archive::ExportDir"]+"bin_associations")) print "Committing..." projectB.query("COMMIT WORK") @@ -602,14 +601,14 @@ Please read the documentation before running this script. (result, output) = commands.getstatusoutput("psql %s < add_constraints.sql" % (Cnf["DB::Name"])) print output if (result != 0): - utils.fubar("psql invocation failed!\n%s" % (output), result) + dak.lib.utils.fubar("psql invocation failed!\n%s" % (output), result) return ################################################################################ def main(): - utils.try_with_debug(do_da_do_da) + dak.lib.utils.try_with_debug(do_da_do_da) ################################################################################ diff --git a/dak/import_ldap_fingerprints.py b/dak/import_ldap_fingerprints.py index 4fa6d665..381feeb6 100755 --- a/dak/import_ldap_fingerprints.py +++ b/dak/import_ldap_fingerprints.py @@ -2,7 +2,6 @@ # Sync fingerprint and uid tables with a debian.org LDAP DB # Copyright (C) 2003, 2004, 2006 James Troup -# $Id: emilie,v 1.3 2004-11-27 13:25:35 troup Exp $ # 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 @@ -47,7 +46,7 @@ import commands, ldap, pg, re, sys import apt_pkg -import db_access, utils +import dak.lib.database, dak.lib.utils ################################################################################ @@ -60,7 +59,7 @@ re_debian_address = re.compile(r"^.*<(.*)@debian\.org>$", re.MULTILINE) ################################################################################ def usage(exit_code=0): - print """Usage: emilie + print """Usage: dak import-ldap-fingerprints Syncs fingerprint and uid tables with a debian.org LDAP DB -h, --help show this help and exit.""" @@ -79,27 +78,27 @@ def get_ldap_value(entry, value): def main(): global Cnf, projectB - Cnf = utils.get_conf() - Arguments = [('h',"help","Emilie::Options::Help")] + Cnf = dak.lib.utils.get_conf() + Arguments = [('h',"help","Import-LDAP-Fingerprints::Options::Help")] for i in [ "help" ]: - if not Cnf.has_key("Emilie::Options::%s" % (i)): - Cnf["Emilie::Options::%s" % (i)] = "" + if not Cnf.has_key("Import-LDAP-Fingerprints::Options::%s" % (i)): + Cnf["Import-LDAP-Fingerprints::Options::%s" % (i)] = "" apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv) - Options = Cnf.SubTree("Emilie::Options") + Options = Cnf.SubTree("Import-LDAP-Fingerprints::Options") if Options["Help"]: usage() projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - db_access.init(Cnf, projectB) + dak.lib.database.init(Cnf, projectB) - LDAPDn = Cnf["Emilie::LDAPDn"] - LDAPServer = Cnf["Emilie::LDAPServer"] + LDAPDn = Cnf["Import-LDAP-Fingerprints::LDAPDn"] + LDAPServer = Cnf["Import-LDAP-Fingerprints::LDAPServer"] l = ldap.open(LDAPServer) l.simple_bind_s("","") Attrs = l.search_s(LDAPDn, ldap.SCOPE_ONELEVEL, - "(&(keyfingerprint=*)(gidnumber=%s))" % (Cnf["Julia::ValidGID"]), + "(&(keyfingerprint=*)(gidnumber=%s))" % (Cnf["Import-Users-From-Passwd::ValidGID"]), ["uid", "keyfingerprint"]) @@ -120,7 +119,7 @@ SELECT f.fingerprint, f.id, u.uid FROM fingerprint f, uid u WHERE f.uid = u.id entry = i[1] fingerprints = entry["keyFingerPrint"] uid = entry["uid"][0] - uid_id = db_access.get_or_set_uid_id(uid) + uid_id = dak.lib.database.get_or_set_uid_id(uid) for fingerprint in fingerprints: ldap_fin_uid_id[fingerprint] = (uid, uid_id) if db_fin_uid.has_key(fingerprint): @@ -130,7 +129,7 @@ SELECT f.fingerprint, f.id, u.uid FROM fingerprint f, uid u WHERE f.uid = u.id print "Assigning %s to 0x%s." % (uid, fingerprint) else: if existing_uid != uid: - utils.fubar("%s has %s in LDAP, but projectB says it should be %s." % (uid, fingerprint, existing_uid)) + dak.lib.utils.fubar("%s has %s in LDAP, but projectB says it should be %s." % (uid, fingerprint, existing_uid)) # Try to update people who sign with non-primary key q = projectB.query("SELECT fingerprint, id FROM fingerprint WHERE uid is null") @@ -144,24 +143,24 @@ SELECT f.fingerprint, f.id, u.uid FROM fingerprint f, uid u WHERE f.uid = u.id m = re_gpg_fingerprint.search(output) if not m: print output - utils.fubar("0x%s: No fingerprint found in gpg output but it returned 0?\n%s" % (fingerprint, utils.prefix_multi_line_string(output, " [GPG output:] "))) + dak.lib.utils.fubar("0x%s: No fingerprint found in gpg output but it returned 0?\n%s" % (fingerprint, dak.lib.utils.prefix_multi_line_string(output, " [GPG output:] "))) primary_key = m.group(1) primary_key = primary_key.replace(" ","") if not ldap_fin_uid_id.has_key(primary_key): - utils.fubar("0x%s (from 0x%s): no UID found in LDAP" % (primary_key, fingerprint)) + dak.lib.utils.fubar("0x%s (from 0x%s): no UID found in LDAP" % (primary_key, fingerprint)) (uid, uid_id) = ldap_fin_uid_id[primary_key] q = projectB.query("UPDATE fingerprint SET uid = %s WHERE id = %s" % (uid_id, fingerprint_id)) print "Assigning %s to 0x%s." % (uid, fingerprint) else: extra_keyrings = "" - for keyring in Cnf.ValueList("Emilie::ExtraKeyrings"): + for keyring in Cnf.ValueList("Import-LDAP-Fingerprints::ExtraKeyrings"): extra_keyrings += " --keyring=%s" % (keyring) cmd = "gpg --keyring=%s --keyring=%s %s --list-key %s" \ % (Cnf["Dinstall::PGPKeyring"], Cnf["Dinstall::GPGKeyring"], extra_keyrings, fingerprint) (result, output) = commands.getstatusoutput(cmd) if result != 0: - cmd = "gpg --keyserver=%s --allow-non-selfsigned-uid --recv-key %s" % (Cnf["Emilie::KeyServer"], fingerprint) + cmd = "gpg --keyserver=%s --allow-non-selfsigned-uid --recv-key %s" % (Cnf["Import-LDAP-Fingerprints::KeyServer"], fingerprint) (result, output) = commands.getstatusoutput(cmd) if result != 0: print "0x%s: NOT found on keyserver." % (fingerprint) @@ -189,7 +188,7 @@ SELECT f.fingerprint, f.id, u.uid FROM fingerprint f, uid u WHERE f.uid = u.id # FIXME: default to the guessed ID uid = None while not uid: - uid = utils.our_raw_input("Map to which UID ? ") + uid = dak.lib.utils.our_raw_input("Map to which UID ? ") Attrs = l.search_s(LDAPDn,ldap.SCOPE_ONELEVEL,"(uid=%s)" % (uid), ["cn","mn","sn"]) if not Attrs: print "That UID doesn't exist in LDAP!" @@ -200,9 +199,9 @@ SELECT f.fingerprint, f.id, u.uid FROM fingerprint f, uid u WHERE f.uid = u.id get_ldap_value(entry, "mn"), get_ldap_value(entry, "sn")]) prompt = "Map to %s - %s (y/N) ? " % (uid, name.replace(" "," ")) - yn = utils.our_raw_input(prompt).lower() + yn = dak.lib.utils.our_raw_input(prompt).lower() if yn == "y": - uid_id = db_access.get_or_set_uid_id(uid) + uid_id = dak.lib.database.get_or_set_uid_id(uid) projectB.query("UPDATE fingerprint SET uid = %s WHERE id = %s" % (uid_id, fingerprint_id)) print "Assigning %s to 0x%s." % (uid, fingerprint) else: diff --git a/dak/import_users_from_passwd.py b/dak/import_users_from_passwd.py index e28afa98..cc7ac7a2 100755 --- a/dak/import_users_from_passwd.py +++ b/dak/import_users_from_passwd.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # Sync PostgreSQL users with system users -# Copyright (C) 2001, 2002 James Troup -# $Id: julia,v 1.9 2003-01-02 18:12:50 troup Exp $ +# Copyright (C) 2001, 2002, 2006 James Troup # 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 @@ -31,7 +30,7 @@ ################################################################################ import pg, pwd, sys -import utils +import dak.lib.utils import apt_pkg ################################################################################ @@ -41,7 +40,7 @@ projectB = None ################################################################################ def usage (exit_code=0): - print """Usage: julia [OPTION]... + print """Usage: dak import-users-from-passwd [OPTION]... Sync PostgreSQL's users with system users. -h, --help show this help and exit @@ -55,27 +54,27 @@ Sync PostgreSQL's users with system users. def main (): global Cnf, projectB - Cnf = utils.get_conf() + Cnf = dak.lib.utils.get_conf() - Arguments = [('n', "no-action", "Julia::Options::No-Action"), - ('q', "quiet", "Julia::Options::Quiet"), - ('v', "verbose", "Julia::Options::Verbose"), - ('h', "help", "Julia::Options::Help")] + Arguments = [('n', "no-action", "Import-Users-From-Passwd::Options::No-Action"), + ('q', "quiet", "Import-Users-From-Passwd::Options::Quiet"), + ('v', "verbose", "Import-Users-From-Passwd::Options::Verbose"), + ('h', "help", "Import-Users-From-Passwd::Options::Help")] for i in [ "no-action", "quiet", "verbose", "help" ]: - if not Cnf.has_key("Julia::Options::%s" % (i)): - Cnf["Julia::Options::%s" % (i)] = "" + if not Cnf.has_key("Import-Users-From-Passwd::Options::%s" % (i)): + Cnf["Import-Users-From-Passwd::Options::%s" % (i)] = "" arguments = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv) - Options = Cnf.SubTree("Julia::Options") + Options = Cnf.SubTree("Import-Users-From-Passwd::Options") if Options["Help"]: usage() elif arguments: - utils.warn("julia takes no non-option arguments.") + dak.lib.utils.warn("dak import-users-from-passwd takes no non-option arguments.") usage(1) projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - valid_gid = int(Cnf.get("Julia::ValidGID","")) + valid_gid = int(Cnf.get("Import-Users-From-Passwd::ValidGID","")) passwd_unames = {} for entry in pwd.getpwall(): @@ -95,7 +94,7 @@ def main (): postgres_unames[uname] = "" known_postgres_unames = {} - for i in Cnf.get("Julia::KnownPostgres","").split(","): + for i in Cnf.get("Import-Users-From-Passwd::KnownPostgres","").split(","): uname = i.strip() known_postgres_unames[uname] = "" diff --git a/dak/init_db.py b/dak/init_db.py index 92e6a6e7..bb00eeec 100755 --- a/dak/init_db.py +++ b/dak/init_db.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # Sync the ISC configuartion file and the SQL database -# Copyright (C) 2000, 2001, 2002, 2003 James Troup -# $Id: alyson,v 1.12 2003-09-07 13:52:07 troup Exp $ +# Copyright (C) 2000, 2001, 2002, 2003, 2006 James Troup # 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 @@ -21,7 +20,7 @@ ################################################################################ import pg, sys -import utils, db_access +import dak.lib.utils, dak.lib.database import apt_pkg ################################################################################ @@ -32,7 +31,7 @@ projectB = None ################################################################################ def usage(exit_code=0): - print """Usage: alyson + print """Usage: dak init-db Initalizes some tables in the projectB database based on the config file. -h, --help show this help and exit.""" @@ -49,20 +48,20 @@ def get (c, i): def main (): global Cnf, projectB - Cnf = utils.get_conf() - Arguments = [('h',"help","Alyson::Options::Help")] + Cnf = dak.lib.utils.get_conf() + Arguments = [('h',"help","Init-DB::Options::Help")] for i in [ "help" ]: - if not Cnf.has_key("Alyson::Options::%s" % (i)): - Cnf["Alyson::Options::%s" % (i)] = "" + if not Cnf.has_key("Init-DB::Options::%s" % (i)): + Cnf["Init-DB::Options::%s" % (i)] = "" apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv) - Options = Cnf.SubTree("Alyson::Options") + Options = Cnf.SubTree("Init-DB::Options") if Options["Help"]: usage() projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - db_access.init(Cnf, projectB) + dak.lib.database.init(Cnf, projectB) # archive @@ -104,17 +103,17 @@ def main (): projectB.query("DELETE FROM location") for location in Cnf.SubTree("Location").List(): Location = Cnf.SubTree("Location::%s" % (location)) - archive_id = db_access.get_archive_id(Location["Archive"]) + archive_id = dak.lib.database.get_archive_id(Location["Archive"]) type = Location.get("type") if type == "legacy-mixed": projectB.query("INSERT INTO location (path, archive, type) VALUES ('%s', %d, '%s')" % (location, archive_id, Location["type"])) elif type == "legacy" or type == "pool": for component in Cnf.SubTree("Component").List(): - component_id = db_access.get_component_id(component) + component_id = dak.lib.database.get_component_id(component) projectB.query("INSERT INTO location (path, component, archive, type) VALUES ('%s', %d, %d, '%s')" % (location, component_id, archive_id, type)) else: - utils.fubar("E: type '%s' not recognised in location %s." % (type, location)) + dak.lib.utils.fubar("E: type '%s' not recognised in location %s." % (type, location)) projectB.query("COMMIT WORK") # suite @@ -129,9 +128,9 @@ def main (): projectB.query("INSERT INTO suite (suite_name, version, origin, description) VALUES ('%s', %s, %s, %s)" % (suite.lower(), version, origin, description)) for architecture in Cnf.ValueList("Suite::%s::Architectures" % (suite)): - architecture_id = db_access.get_architecture_id (architecture) + architecture_id = dak.lib.database.get_architecture_id (architecture) if architecture_id < 0: - utils.fubar("architecture '%s' not found in architecture table for suite %s." % (architecture, suite)) + dak.lib.utils.fubar("architecture '%s' not found in architecture table for suite %s." % (architecture, suite)) projectB.query("INSERT INTO suite_architectures (suite, architecture) VALUES (currval('suite_id_seq'), %d)" % (architecture_id)) projectB.query("COMMIT WORK") @@ -156,7 +155,7 @@ def main (): projectB.query("BEGIN WORK") projectB.query("DELETE FROM section") for component in Cnf.SubTree("Component").List(): - if Cnf["Natalie::ComponentPosition"] == "prefix": + if Cnf["Control-Overrides::ComponentPosition"] == "prefix": suffix = "" if component != "main": prefix = component + '/' diff --git a/dak/init_dirs.py b/dak/init_dirs.py index b38b4b86..f36c4ca0 100755 --- a/dak/init_dirs.py +++ b/dak/init_dirs.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # Initial setup of an archive -# Copyright (C) 2002, 2004 James Troup -# $Id: rose,v 1.4 2004-03-11 00:20:51 troup Exp $ +# Copyright (C) 2002, 2004, 2006 James Troup # 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 @@ -21,7 +20,7 @@ ################################################################################ import os, sys -import utils +import dak.lib.utils import apt_pkg ################################################################################ @@ -32,8 +31,8 @@ AptCnf = None ################################################################################ def usage(exit_code=0): - print """Usage: rose -Creates directories for an archive based on katie.conf configuration file. + print """Usage: dak init-dirs +Creates directories for an archive based on dak.conf configuration file. -h, --help show this help and exit.""" sys.exit(exit_code) @@ -43,7 +42,7 @@ Creates directories for an archive based on katie.conf configuration file. def do_dir(target, config_name): if os.path.exists(target): if not os.path.isdir(target): - utils.fubar("%s (%s) is not a directory." % (target, config_name)) + dak.lib.utils.fubar("%s (%s) is not a directory." % (target, config_name)) else: print "Creating %s ..." % (target) os.makedirs(target) @@ -75,9 +74,9 @@ def create_directories(): # Process directories from apt.conf process_tree(Cnf, "Dir") process_tree(Cnf, "Dir::Queue") - for file in [ "Dinstall::LockFile", "Melanie::LogFile", "Neve::ExportDir" ]: + for file in [ "Dinstall::LockFile", "Rm::LogFile", "Import-Archive::ExportDir" ]: process_file(Cnf, file) - for subdir in [ "Shania", "Rhona" ]: + for subdir in [ "Clean-Queues", "Clean-Suites" ]: process_morguesubdir(subdir) # Process directories from apt.conf @@ -101,20 +100,20 @@ def create_directories(): def main (): global AptCnf, Cnf, projectB - Cnf = utils.get_conf() - Arguments = [('h',"help","Rose::Options::Help")] + Cnf = dak.lib.utils.get_conf() + Arguments = [('h',"help","Init-Dirs::Options::Help")] for i in [ "help" ]: - if not Cnf.has_key("Rose::Options::%s" % (i)): - Cnf["Rose::Options::%s" % (i)] = "" + if not Cnf.has_key("Init-Dirs::Options::%s" % (i)): + Cnf["Init-Dirs::Options::%s" % (i)] = "" apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv) - Options = Cnf.SubTree("Rose::Options") + Options = Cnf.SubTree("Init-Dirs::Options") if Options["Help"]: usage() AptCnf = apt_pkg.newConfiguration() - apt_pkg.ReadConfigFileISC(AptCnf,utils.which_apt_conf_file()) + apt_pkg.ReadConfigFileISC(AptCnf,dak.lib.utils.which_apt_conf_file()) create_directories() diff --git a/dak/lib/database.py b/dak/lib/database.py index 6976f2fb..f511d27d 100644 --- a/dak/lib/database.py +++ b/dak/lib/database.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # DB access fucntions -# Copyright (C) 2000, 2001, 2002, 2003, 2004 James Troup -# $Id: db_access.py,v 1.18 2005-12-05 05:08:10 ajt Exp $ +# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 James Troup # 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/lib/queue.py b/dak/lib/queue.py index d565c4de..72d226ad 100644 --- a/dak/lib/queue.py +++ b/dak/lib/queue.py @@ -1,8 +1,7 @@ #!/usr/bin/env python -# Utility functions for katie -# Copyright (C) 2001, 2002, 2003, 2004, 2005 James Troup -# $Id: katie.py,v 1.59 2005-12-17 10:57:03 rmurray Exp $ +# Queue utility functions for dak +# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 James Troup # 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 @@ -21,8 +20,8 @@ ############################################################################### import cPickle, errno, os, pg, re, stat, string, sys, time -import utils, db_access import apt_inst, apt_pkg +import utils, database from types import * @@ -89,7 +88,7 @@ class nmu_p: ############################################################################### -class Katie: +class Upload: def __init__(self, Cnf): self.Cnf = Cnf @@ -105,10 +104,10 @@ class Katie: Subst["__ADMIN_ADDRESS__"] = Cnf["Dinstall::MyAdminAddress"] Subst["__BUG_SERVER__"] = Cnf["Dinstall::BugServer"] Subst["__DISTRO__"] = Cnf["Dinstall::MyDistribution"] - Subst["__KATIE_ADDRESS__"] = Cnf["Dinstall::MyEmailAddress"] + Subst["__DAK_ADDRESS__"] = Cnf["Dinstall::MyEmailAddress"] self.projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - db_access.init(Cnf, self.projectB) + database.init(Cnf, self.projectB) ########################################################################### @@ -122,7 +121,7 @@ class Katie: ########################################################################### def update_vars (self): - dump_filename = self.pkg.changes_file[:-8]+".katie" + dump_filename = self.pkg.changes_file[:-8]+".dak" dump_file = utils.open_file(dump_filename) p = cPickle.Unpickler(dump_file) for i in [ "changes", "dsc", "files", "dsc_files", "legacy_source_untouchable" ]: @@ -133,14 +132,15 @@ class Katie: ########################################################################### - # This could just dump the dictionaries as is, but I'd like to avoid - # this so there's some idea of what katie & lisa use from jennifer + # This could just dump the dictionaries as is, but I'd like to + # avoid this so there's some idea of what process-accepted & + # process-new use from process-unchecked def dump_vars(self, dest_dir): for i in [ "changes", "dsc", "files", "dsc_files", "legacy_source_untouchable", "orig_tar_id", "orig_tar_location" ]: exec "%s = self.pkg.%s;" % (i,i) - dump_filename = os.path.join(dest_dir,self.pkg.changes_file[:-8] + ".katie") + dump_filename = os.path.join(dest_dir,self.pkg.changes_file[:-8] + ".dak") dump_file = utils.open_file(dump_filename, 'w') try: os.chmod(dump_filename, 0660) @@ -174,7 +174,7 @@ class Katie: "closes", "changes" ]: d_changes[i] = changes[i] # Optional changes fields - for i in [ "changed-by", "filecontents", "format", "lisa note", "distribution-version" ]: + for i in [ "changed-by", "filecontents", "format", "process-new note", "distribution-version" ]: if changes.has_key(i): d_changes[i] = changes[i] ## dsc @@ -205,7 +205,7 @@ class Katie: def update_subst (self, reject_message = ""): Subst = self.Subst changes = self.pkg.changes - # If jennifer crashed out in the right place, architecture may still be a string. + # If 'dak process-unchecked' crashed out in the right place, architecture may still be a string. if not changes.has_key("architecture") or not isinstance(changes["architecture"], DictType): changes["architecture"] = { "Unknown" : "" } # and maintainer2047 may not exist. @@ -306,7 +306,7 @@ class Katie: control_message += "tag %s + fixed-in-experimental\n" % (bug) if action and control_message != "": Subst["__CONTROL_MESSAGE__"] = control_message - mail_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/jennifer.bug-experimental-fixed") + mail_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/process-unchecked.bug-experimental-fixed") utils.send_mail (mail_message) if action: self.Logger.log(["setting bugs to fixed"]+bugs) @@ -327,7 +327,7 @@ The update will eventually make its way into the next released Debian distribution.""" else: Subst["__STABLE_WARNING__"] = "" - mail_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/jennifer.bug-close") + mail_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/process-unchecked.bug-close") utils.send_mail (mail_message) if action: self.Logger.log(["closing bugs"]+bugs) @@ -340,7 +340,7 @@ distribution.""" control_message += "tag %s + fixed\n" % (bug) if action and control_message != "": Subst["__CONTROL_MESSAGE__"] = control_message - mail_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/jennifer.bug-nmu-fixed") + mail_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/process-unchecked.bug-nmu-fixed") utils.send_mail (mail_message) if action: self.Logger.log(["setting bugs to fixed"]+bugs) @@ -373,7 +373,7 @@ distribution.""" Subst["__ANNOUNCE_LIST_ADDRESS__"] = list if Cnf.get("Dinstall::TrackingServer") and changes["architecture"].has_key("source"): Subst["__ANNOUNCE_LIST_ADDRESS__"] = Subst["__ANNOUNCE_LIST_ADDRESS__"] + "\nBcc: %s@%s" % (changes["source"], Cnf["Dinstall::TrackingServer"]) - mail_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/jennifer.announce") + mail_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/process-unchecked.announce") utils.send_mail (mail_message) if Cnf.FindB("Dinstall::CloseBugs"): @@ -409,7 +409,7 @@ distribution.""" if not Cnf["Dinstall::Options::No-Mail"]: Subst["__SUITE__"] = "" Subst["__SUMMARY__"] = summary - mail_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/jennifer.accepted") + mail_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/process-unchecked.accepted") utils.send_mail(mail_message) self.announce(short_summary, 1) @@ -463,13 +463,13 @@ distribution.""" file_keys = files.keys() ## Special support to enable clean auto-building of queued packages - queue_id = db_access.get_or_set_queue_id(queue) + queue_id = database.get_or_set_queue_id(queue) self.projectB.query("BEGIN WORK") for suite in changes["distribution"].keys(): if suite not in Cnf.ValueList("Dinstall::QueueBuildSuites"): continue - suite_id = db_access.get_suite_id(suite) + suite_id = database.get_suite_id(suite) dest_dir = Cnf["Dir::QueueBuild"] if Cnf.FindB("Dinstall::SecurityQueueBuild"): dest_dir = os.path.join(dest_dir, suite) @@ -547,7 +547,7 @@ distribution.""" return Subst["__SUMMARY__"] = summary - mail_message = utils.TemplateSubst(Subst,self.Cnf["Dir::Templates"]+"/jennifer.override-disparity") + mail_message = utils.TemplateSubst(Subst,self.Cnf["Dir::Templates"]+"/process-unchecked.override-disparity") utils.send_mail(mail_message) ########################################################################### @@ -644,9 +644,9 @@ distribution.""" if not manual: Subst["__REJECTOR_ADDRESS__"] = Cnf["Dinstall::MyEmailAddress"] Subst["__MANUAL_REJECT_MESSAGE__"] = "" - Subst["__CC__"] = "X-Katie-Rejection: automatic (moo)" + Subst["__CC__"] = "X-DAK-Rejection: automatic (moo)" os.write(reason_fd, reject_message) - reject_mail_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/katie.rejected") + reject_mail_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/dak.rejected") else: # Build up the rejection email user_email_address = utils.whoami() + " <%s>" % (Cnf["Dinstall::MyAdminAddress"]) @@ -654,7 +654,7 @@ distribution.""" Subst["__REJECTOR_ADDRESS__"] = user_email_address Subst["__MANUAL_REJECT_MESSAGE__"] = reject_message Subst["__CC__"] = "Cc: " + Cnf["Dinstall::MyEmailAddress"] - reject_mail_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/katie.rejected") + reject_mail_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/dak.rejected") # Write the rejection email out as the .reason file os.write(reason_fd, reject_mail_message) @@ -730,11 +730,11 @@ distribution.""" suite = self.Cnf["Suite::%s::OverrideSuite" % (suite)] # Avoid on unknown distributions - suite_id = db_access.get_suite_id(suite) + suite_id = database.get_suite_id(suite) if suite_id == -1: return None - component_id = db_access.get_component_id(component) - type_id = db_access.get_override_type_id(type) + component_id = database.get_component_id(component) + type_id = database.get_override_type_id(type) # FIXME: nasty non-US speficic hack if component.lower().startswith("non-us/"): @@ -745,8 +745,8 @@ distribution.""" result = q.getresult() # If checking for a source package fall back on the binary override type if type == "dsc" and not result: - deb_type_id = db_access.get_override_type_id("deb") - udeb_type_id = db_access.get_override_type_id("udeb") + deb_type_id = database.get_override_type_id("deb") + udeb_type_id = database.get_override_type_id("udeb") q = self.projectB.query("SELECT s.section, p.priority FROM override o, section s, priority p WHERE package = '%s' AND suite = %s AND component = %s AND (type = %s OR type = %s) AND o.section = s.id AND o.priority = p.id" % (package, suite_id, component_id, deb_type_id, udeb_type_id)) result = q.getresult() @@ -921,7 +921,7 @@ SELECT s.version, su.suite_name FROM source s, src_associations sa, suite su if i[3] != dsc_file and i[3][-(len(dsc_file)+1):] != '/'+dsc_file: ql.remove(i) - # "[katie] has not broken them. [katie] has fixed a + # "[dak] has not broken them. [dak] has fixed a # brokenness. Your crappy hack exploited a bug in # the old dinstall. # @@ -981,7 +981,7 @@ SELECT s.version, su.suite_name FROM source s, src_associations sa, suite su found = old_file suite_type = x[2] dsc_files[dsc_file]["files id"] = x[3]; # need this for updating dsc_files in install() - # See install() in katie... + # See install() in process-accepted... self.pkg.orig_tar_id = x[3] self.pkg.orig_tar_gz = old_file if suite_type == "legacy" or suite_type == "legacy-mixed": @@ -992,7 +992,7 @@ SELECT s.version, su.suite_name FROM source s, src_associations sa, suite su # Not there? Check the queue directories... in_unchecked = os.path.join(self.Cnf["Dir::Queue::Unchecked"],dsc_file) - # See process_it() in jennifer for explanation of this + # See process_it() in 'dak process-unchecked' for explanation of this if os.path.exists(in_unchecked): return (self.reject_message, in_unchecked) else: diff --git a/dak/lib/utils.py b/dak/lib/utils.py index 0c1a5ff8..4b103f53 100644 --- a/dak/lib/utils.py +++ b/dak/lib/utils.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # Utility functions -# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 James Troup +# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 James Troup # $Id: utils.py,v 1.73 2005-03-18 05:24:38 troup Exp $ ################################################################################ @@ -25,7 +25,7 @@ import codecs, commands, email.Header, os, pwd, re, select, socket, shutil, \ string, sys, tempfile, traceback import apt_pkg -import db_access +import dak.lib.database ################################################################################ @@ -54,8 +54,8 @@ file_exists_exc = "Destination file exists" sendmail_failed_exc = "Sendmail invocation failed" tried_too_hard_exc = "Tried too hard to find a free filename." -default_config = "/etc/katie/katie.conf" -default_apt_config = "/etc/katie/apt.conf" +default_config = "/etc/dak/dak.conf" +default_apt_config = "/etc/dak/apt.conf" ################################################################################ @@ -451,8 +451,8 @@ def where_am_i (): def which_conf_file (): res = socket.gethostbyaddr(socket.gethostname()) - if Cnf.get("Config::" + res[0] + "::KatieConfig"): - return Cnf["Config::" + res[0] + "::KatieConfig"] + if Cnf.get("Config::" + res[0] + "::DakConfig"): + return Cnf["Config::" + res[0] + "::DakConfig"] else: return default_config @@ -601,8 +601,8 @@ def prefix_multi_line_string(str, prefix, include_blank_lines=0): ################################################################################ def validate_changes_file_arg(filename, require_changes=1): - """'filename' is either a .changes or .katie file. If 'filename' is a -.katie file, it's changed to be the corresponding .changes file. The + """'filename' is either a .changes or .dak file. If 'filename' is a +.dak file, it's changed to be the corresponding .changes file. The function then checks if the .changes file a) exists and b) is readable and returns the .changes filename if so. If there's a problem, the next action depends on the option 'require_changes' @@ -616,7 +616,7 @@ argument: error = None orig_filename = filename - if filename.endswith(".katie"): + if filename.endswith(".dak"): filename = filename[:-6]+".changes" if not filename.endswith(".changes"): @@ -634,7 +634,7 @@ argument: elif require_changes == 0: warn("Skipping %s - %s" % (orig_filename, error)) return None - else: # We only care about the .katie file + else: # We only care about the .dak file return filename else: return filename @@ -677,7 +677,7 @@ def parse_args(Options): if Options["Suite"]: suite_ids_list = [] for suite in split_args(Options["Suite"]): - suite_id = db_access.get_suite_id(suite) + suite_id = dak.lib.database.get_suite_id(suite) if suite_id == -1: warn("suite '%s' not recognised." % (suite)) else: @@ -693,7 +693,7 @@ def parse_args(Options): if Options["Component"]: component_ids_list = [] for component in split_args(Options["Component"]): - component_id = db_access.get_component_id(component) + component_id = dak.lib.database.get_component_id(component) if component_id == -1: warn("component '%s' not recognised." % (component)) else: @@ -714,7 +714,7 @@ def parse_args(Options): if architecture == "source": check_source = 1 else: - architecture_id = db_access.get_architecture_id(architecture) + architecture_id = dak.lib.database.get_architecture_id(architecture) if architecture_id == -1: warn("architecture '%s' not recognised." % (architecture)) else: @@ -785,7 +785,7 @@ def arch_compare_sw (a, b): # Split command line arguments which can be separated by either commas # or whitespace. If dwim is set, it will complain about string ending -# in comma since this usually means someone did 'madison -a i386, m68k +# in comma since this usually means someone did 'dak ls -a i386, m68k # foo' or something and the inevitable confusion resulting from 'm68k' # being treated as an argument is undesirable. diff --git a/dak/ls.py b/dak/ls.py index 9f7b5566..c3647b3a 100755 --- a/dak/ls.py +++ b/dak/ls.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # Display information about package(s) (suite, version, etc.) -# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 James Troup -# $Id: madison,v 1.33 2005-11-15 09:50:32 ajt Exp $ +# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 James Troup # 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 @@ -28,7 +27,7 @@ ################################################################################ import os, pg, sys -import utils, db_access +import dak.lib.utils, dak.lib.database import apt_pkg ################################################################################ @@ -39,7 +38,7 @@ projectB = None ################################################################################ def usage (exit_code=0): - print """Usage: madison [OPTION] PACKAGE[...] + print """Usage: dak ls [OPTION] PACKAGE[...] Display information about PACKAGE(s). -a, --architecture=ARCH only show info for ARCH(s) @@ -61,53 +60,53 @@ ARCH, COMPONENT and SUITE can be comma (or space) separated lists, e.g. def main (): global Cnf, projectB - Cnf = utils.get_conf() - - Arguments = [('a', "architecture", "Madison::Options::Architecture", "HasArg"), - ('b', "binarytype", "Madison::Options::BinaryType", "HasArg"), - ('c', "component", "Madison::Options::Component", "HasArg"), - ('f', "format", "Madison::Options::Format", "HasArg"), - ('g', "greaterorequal", "Madison::Options::GreaterOrEqual"), - ('G', "greaterthan", "Madison::Options::GreaterThan"), - ('r', "regex", "Madison::Options::Regex"), - ('s', "suite", "Madison::Options::Suite", "HasArg"), - ('S', "source-and-binary", "Madison::Options::Source-And-Binary"), - ('h', "help", "Madison::Options::Help")] + Cnf = dak.lib.utils.get_conf() + + Arguments = [('a', "architecture", "Ls::Options::Architecture", "HasArg"), + ('b', "binarytype", "Ls::Options::BinaryType", "HasArg"), + ('c', "component", "Ls::Options::Component", "HasArg"), + ('f', "format", "Ls::Options::Format", "HasArg"), + ('g', "greaterorequal", "Ls::Options::GreaterOrEqual"), + ('G', "greaterthan", "Ls::Options::GreaterThan"), + ('r', "regex", "Ls::Options::Regex"), + ('s', "suite", "Ls::Options::Suite", "HasArg"), + ('S', "source-and-binary", "Ls::Options::Source-And-Binary"), + ('h', "help", "Ls::Options::Help")] for i in [ "architecture", "binarytype", "component", "format", "greaterorequal", "greaterthan", "regex", "suite", "source-and-binary", "help" ]: - if not Cnf.has_key("Madison::Options::%s" % (i)): - Cnf["Madison::Options::%s" % (i)] = "" + if not Cnf.has_key("Ls::Options::%s" % (i)): + Cnf["Ls::Options::%s" % (i)] = "" packages = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv) - Options = Cnf.SubTree("Madison::Options") + Options = Cnf.SubTree("Ls::Options") if Options["Help"]: usage() if not packages: - utils.fubar("need at least one package name as an argument.") + dak.lib.utils.fubar("need at least one package name as an argument.") projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - db_access.init(Cnf, projectB) + dak.lib.database.init(Cnf, projectB) # If cron.daily is running; warn the user that our output might seem strange if os.path.exists(os.path.join(Cnf["Dir::Root"], "Archive_Maintenance_In_Progress")): - utils.warn("Archive maintenance is in progress; database inconsistencies are possible.") + dak.lib.utils.warn("Archive maintenance is in progress; database inconsistencies are possible.") # Handle buildd maintenance helper options if Options["GreaterOrEqual"] or Options["GreaterThan"]: if Options["GreaterOrEqual"] and Options["GreaterThan"]: - utils.fubar("-g/--greaterorequal and -G/--greaterthan are mutually exclusive.") + dak.lib.utils.fubar("-g/--greaterorequal and -G/--greaterthan are mutually exclusive.") if not Options["Suite"]: Options["Suite"] = "unstable" # Parse -a/--architecture, -c/--component and -s/--suite (con_suites, con_architectures, con_components, check_source) = \ - utils.parse_args(Options) + dak.lib.utils.parse_args(Options) if Options["BinaryType"]: if Options["BinaryType"] != "udeb" and Options["BinaryType"] != "deb": - utils.fubar("Invalid binary type. 'udeb' and 'deb' recognised.") + dak.lib.utils.fubar("Invalid binary type. 'udeb' and 'deb' recognised.") con_bintype = "AND b.type = '%s'" % (Options["BinaryType"]) # REMOVE ME TRAMP if Options["BinaryType"] == "udeb": @@ -178,12 +177,12 @@ SELECT s.source, s.version, 'source', su.suite_name, c.name, m.name suites.sort() for suite in suites: arches = d[pkg][version][suite] - arches.sort(utils.arch_compare_sw) + arches.sort(dak.lib.utils.arch_compare_sw) if Options["Format"] == "": #normal sys.stdout.write("%10s | %10s | %13s | " % (pkg, version, suite)) sys.stdout.write(", ".join(arches)) sys.stdout.write('\n') - elif Options["Format"] == "heidi": + elif Options["Format"] == "control-suite": for arch in arches: sys.stdout.write("%s %s %s\n" % (pkg, version, arch)) if Options["GreaterOrEqual"]: diff --git a/dak/make_maintainers.py b/dak/make_maintainers.py index c1cc11d7..f60c19b7 100755 --- a/dak/make_maintainers.py +++ b/dak/make_maintainers.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # Generate Maintainers file used by e.g. the Debian Bug Tracking System -# Copyright (C) 2000, 2001, 2002, 2003, 2004 James Troup -# $Id: charisma,v 1.18 2004-06-17 15:02:02 troup Exp $ +# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 James Troup # 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 @@ -27,7 +26,7 @@ ################################################################################ import pg, sys -import db_access, utils +import dak.lib.database, dak.lib.utils import apt_pkg ################################################################################ @@ -41,7 +40,7 @@ fixed_maintainer_cache = {} ################################################################################ def usage (exit_code=0): - print """Usage: charisma [OPTION] EXTRA_FILE[...] + print """Usage: dak make-maintainers [OPTION] EXTRA_FILE[...] Generate an index of packages <=> Maintainers. -h, --help show this help and exit @@ -54,12 +53,12 @@ def fix_maintainer (maintainer): global fixed_maintainer_cache if not fixed_maintainer_cache.has_key(maintainer): - fixed_maintainer_cache[maintainer] = utils.fix_maintainer(maintainer)[0] + fixed_maintainer_cache[maintainer] = dak.lib.utils.fix_maintainer(maintainer)[0] return fixed_maintainer_cache[maintainer] def get_maintainer (maintainer): - return fix_maintainer(db_access.get_maintainer(maintainer)) + return fix_maintainer(dak.lib.database.get_maintainer(maintainer)) def get_maintainer_from_source (source_id): global maintainer_from_source_cache @@ -76,20 +75,20 @@ def get_maintainer_from_source (source_id): def main(): global Cnf, projectB - Cnf = utils.get_conf() + Cnf = dak.lib.utils.get_conf() - Arguments = [('h',"help","Charisma::Options::Help")] - if not Cnf.has_key("Charisma::Options::Help"): - Cnf["Charisma::Options::Help"] = "" + Arguments = [('h',"help","Make-Maintainers::Options::Help")] + if not Cnf.has_key("Make-Maintainers::Options::Help"): + Cnf["Make-Maintainers::Options::Help"] = "" extra_files = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv) - Options = Cnf.SubTree("Charisma::Options") + Options = Cnf.SubTree("Make-Maintainers::Options") if Options["Help"]: usage() projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - db_access.init(Cnf, projectB) + dak.lib.database.init(Cnf, projectB) for suite in Cnf.SubTree("Suite").List(): suite = suite.lower() @@ -130,9 +129,9 @@ def main(): # Process any additional Maintainer files (e.g. from non-US or pseudo packages) for filename in extra_files: - file = utils.open_file(filename) + file = dak.lib.utils.open_file(filename) for line in file.readlines(): - line = utils.re_comments.sub('', line).strip() + line = dak.lib.utils.re_comments.sub('', line).strip() if line == "": continue split = line.split() diff --git a/dak/make_overrides.py b/dak/make_overrides.py index 2517b67a..d8402564 100755 --- a/dak/make_overrides.py +++ b/dak/make_overrides.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # Output override files for apt-ftparchive and indices/ -# Copyright (C) 2000, 2001, 2002, 2004 James Troup -# $Id: denise,v 1.18 2005-11-15 09:50:32 ajt Exp $ +# Copyright (C) 2000, 2001, 2002, 2004, 2006 James Troup # 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 @@ -21,13 +20,13 @@ ################################################################################ # This is seperate because it's horribly Debian specific and I don't -# want that kind of horribleness in the otherwise generic natalie. It -# does duplicate code tho. +# want that kind of horribleness in the otherwise generic 'dak +# make-overrides'. It does duplicate code tho. ################################################################################ import pg, sys -import utils, db_access +import dak.lib.utils, dak.lib.database import apt_pkg ################################################################################ @@ -39,7 +38,7 @@ override = {} ################################################################################ def usage(exit_code=0): - print """Usage: denise + print """Usage: dak make-overrides Outputs the override tables to text files. -h, --help show this help and exit.""" @@ -50,17 +49,17 @@ Outputs the override tables to text files. def do_list(output_file, suite, component, otype): global override - suite_id = db_access.get_suite_id(suite) + suite_id = dak.lib.database.get_suite_id(suite) if suite_id == -1: - utils.fubar("Suite '%s' not recognised." % (suite)) + dak.lib.utils.fubar("Suite '%s' not recognised." % (suite)) - component_id = db_access.get_component_id(component) + component_id = dak.lib.database.get_component_id(component) if component_id == -1: - utils.fubar("Component '%s' not recognised." % (component)) + dak.lib.utils.fubar("Component '%s' not recognised." % (component)) - otype_id = db_access.get_override_type_id(otype) + otype_id = dak.lib.database.get_override_type_id(otype) if otype_id == -1: - utils.fubar("Type '%s' not recognised. (Valid types are deb, udeb and dsc)" % (otype)) + dak.lib.utils.fubar("Type '%s' not recognised. (Valid types are deb, udeb and dsc)" % (otype)) override.setdefault(suite, {}) override[suite].setdefault(component, {}) @@ -70,33 +69,33 @@ def do_list(output_file, suite, component, otype): q = projectB.query("SELECT o.package, s.section, o.maintainer FROM override o, section s WHERE o.suite = %s AND o.component = %s AND o.type = %s AND o.section = s.id ORDER BY s.section, o.package" % (suite_id, component_id, otype_id)) for i in q.getresult(): override[suite][component][otype][i[0]] = i - output_file.write(utils.result_join(i)+'\n') + output_file.write(dak.lib.utils.result_join(i)+'\n') else: q = projectB.query("SELECT o.package, p.priority, s.section, o.maintainer, p.level FROM override o, priority p, section s WHERE o.suite = %s AND o.component = %s AND o.type = %s AND o.priority = p.id AND o.section = s.id ORDER BY s.section, p.level, o.package" % (suite_id, component_id, otype_id)) for i in q.getresult(): i = i[:-1]; # Strip the priority level override[suite][component][otype][i[0]] = i - output_file.write(utils.result_join(i)+'\n') + output_file.write(dak.lib.utils.result_join(i)+'\n') ################################################################################ def main (): global Cnf, projectB, override - Cnf = utils.get_conf() - Arguments = [('h',"help","Denise::Options::Help")] + Cnf = dak.lib.utils.get_conf() + Arguments = [('h',"help","Make-Overrides::Options::Help")] for i in [ "help" ]: - if not Cnf.has_key("Denise::Options::%s" % (i)): - Cnf["Denise::Options::%s" % (i)] = "" + if not Cnf.has_key("Make-Overrides::Options::%s" % (i)): + Cnf["Make-Overrides::Options::%s" % (i)] = "" apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv) - Options = Cnf.SubTree("Denise::Options") + Options = Cnf.SubTree("Make-Overrides::Options") if Options["Help"]: usage() projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - db_access.init(Cnf, projectB) + dak.lib.database.init(Cnf, projectB) - for suite in Cnf.SubTree("Cindy::OverrideSuites").List(): + for suite in Cnf.SubTree("Check-Overrides::OverrideSuites").List(): if Cnf.has_key("Suite::%s::Untouchable" % suite) and Cnf["Suite::%s::Untouchable" % suite] != 0: continue suite = suite.lower() @@ -116,7 +115,7 @@ def main (): elif otype == "dsc": suffix = ".src" filename = "%s/override.%s.%s%s" % (Cnf["Dir::Override"], override_suite, component.replace("non-US/", ""), suffix) - output_file = utils.open_file(filename, 'w') + output_file = dak.lib.utils.open_file(filename, 'w') do_list(output_file, suite, component, otype) output_file.close() diff --git a/dak/make_suite_file_list.py b/dak/make_suite_file_list.py index 927de7ff..ca1f98b8 100755 --- a/dak/make_suite_file_list.py +++ b/dak/make_suite_file_list.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # Generate file lists used by apt-ftparchive to generate Packages and Sources files -# Copyright (C) 2000, 2001, 2002, 2003, 2004 James Troup -# $Id: jenna,v 1.29 2004-11-27 17:58:47 troup Exp $ +# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 James Troup # 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 @@ -36,7 +35,7 @@ import copy, os, pg, string, sys import apt_pkg -import claire, db_access, logging, utils +import poolize, dak.lib.database, dak.lib.logging, dak.lib.utils ################################################################################ @@ -52,7 +51,7 @@ def Dict(**dict): return dict ################################################################################ def usage (exit_code=0): - print """Usage: jenna [OPTION] + print """Usage: dak make-suite-file-list [OPTION] Write out file lists suitable for use with apt-ftparchive. -a, --architecture=ARCH only write file lists for this architecture @@ -74,7 +73,7 @@ def version_cmp(a, b): def delete_packages(delete_versions, pkg, dominant_arch, suite, dominant_version, delete_table, delete_col, packages): - suite_id = db_access.get_suite_id(suite) + suite_id = dak.lib.database.get_suite_id(suite) for version in delete_versions: delete_unique_id = version[1] if not packages.has_key(delete_unique_id): @@ -196,7 +195,7 @@ def cleanup(packages): def write_legacy_mixed_filelist(suite, list, packages, dislocated_files): # Work out the filename filename = os.path.join(Cnf["Dir::Lists"], "%s_-_all.list" % (suite)) - output = utils.open_file(filename, "w") + output = dak.lib.utils.open_file(filename, "w") # Generate the final list of files files = {} for id in list: @@ -208,7 +207,7 @@ def write_legacy_mixed_filelist(suite, list, packages, dislocated_files): else: filename = path + filename if files.has_key(filename): - utils.warn("%s (in %s) is duplicated." % (filename, suite)) + dak.lib.utils.warn("%s (in %s) is duplicated." % (filename, suite)) else: files[filename] = "" # Sort the files since apt-ftparchive doesn't @@ -229,7 +228,7 @@ def write_filelist(suite, component, arch, type, list, packages, dislocated_file elif type == "deb": arch = "binary-%s" % (arch) filename = os.path.join(Cnf["Dir::Lists"], "%s_%s_%s.list" % (suite, component, arch)) - output = utils.open_file(filename, "w") + output = dak.lib.utils.open_file(filename, "w") # Generate the final list of files files = {} for id in list: @@ -242,7 +241,7 @@ def write_filelist(suite, component, arch, type, list, packages, dislocated_file else: filename = path + filename if files.has_key(pkg): - utils.warn("%s (in %s/%s, %s) is duplicated." % (pkg, suite, component, filename)) + dak.lib.utils.warn("%s (in %s/%s, %s) is duplicated." % (pkg, suite, component, filename)) else: files[pkg] = filename # Sort the files since apt-ftparchive doesn't @@ -272,13 +271,13 @@ def write_filelists(packages, dislocated_files): if not Options["Suite"]: suites = Cnf.SubTree("Suite").List() else: - suites = utils.split_args(Options["Suite"]) + suites = dak.lib.utils.split_args(Options["Suite"]) for suite in map(string.lower, suites): d.setdefault(suite, {}) if not Options["Component"]: components = Cnf.ValueList("Suite::%s::Components" % (suite)) else: - components = utils.split_args(Options["Component"]) + components = dak.lib.utils.split_args(Options["Component"]) udeb_components = Cnf.ValueList("Suite::%s::UdebComponents" % (suite)) udeb_components = udeb_components for component in components: @@ -290,7 +289,7 @@ def write_filelists(packages, dislocated_files): if not Options["Architecture"]: architectures = Cnf.ValueList("Suite::%s::Architectures" % (suite)) else: - architectures = utils.split_args(Options["Architectures"]) + architectures = dak.lib.utils.split_args(Options["Architectures"]) for arch in map(string.lower, architectures): d[suite][component].setdefault(arch, {}) if arch == "source": @@ -310,7 +309,7 @@ def write_filelists(packages, dislocated_files): list = d[suite][component][arch][type] # If it's a binary, we need to add in the arch: all debs too if arch != "source": - archall_suite = Cnf.get("Jenna::ArchAllMap::%s" % (suite)) + archall_suite = Cnf.get("Make-Suite-File-List::ArchAllMap::%s" % (suite)) if archall_suite: list.extend(d[archall_suite][component]["all"][type]) elif d[suite][component].has_key("all") and \ @@ -340,7 +339,7 @@ def stable_dislocation_p(): if not Options["Suite"]: return 1 # Otherwise, look in what suites the user specified - suites = utils.split_args(Options["Suite"]) + suites = dak.lib.utils.split_args(Options["Suite"]) if "stable" in suites: return 1 @@ -353,19 +352,19 @@ def do_da_do_da(): # If we're only doing a subset of suites, ensure we do enough to # be able to do arch: all mapping. if Options["Suite"]: - suites = utils.split_args(Options["Suite"]) + suites = dak.lib.utils.split_args(Options["Suite"]) for suite in suites: - archall_suite = Cnf.get("Jenna::ArchAllMap::%s" % (suite)) + archall_suite = Cnf.get("Make-Suite-File-List::ArchAllMap::%s" % (suite)) if archall_suite and archall_suite not in suites: - utils.warn("Adding %s as %s maps Arch: all from it." % (archall_suite, suite)) + dak.lib.utils.warn("Adding %s as %s maps Arch: all from it." % (archall_suite, suite)) suites.append(archall_suite) Options["Suite"] = ",".join(suites) (con_suites, con_architectures, con_components, check_source) = \ - utils.parse_args(Options) + dak.lib.utils.parse_args(Options) if stable_dislocation_p(): - dislocated_files = claire.find_dislocated_stable(Cnf, projectB) + dislocated_files = symlink_dists.find_dislocated_stable(Cnf, projectB) else: dislocated_files = {} @@ -406,23 +405,23 @@ SELECT s.id, s.source, 'source', s.version, l.path, f.filename, c.name, f.id, def main(): global Cnf, projectB, Options, Logger - Cnf = utils.get_conf() - Arguments = [('a', "architecture", "Jenna::Options::Architecture", "HasArg"), - ('c', "component", "Jenna::Options::Component", "HasArg"), - ('h', "help", "Jenna::Options::Help"), - ('n', "no-delete", "Jenna::Options::No-Delete"), - ('s', "suite", "Jenna::Options::Suite", "HasArg")] + Cnf = dak.lib.utils.get_conf() + Arguments = [('a', "architecture", "Make-Suite-File-List::Options::Architecture", "HasArg"), + ('c', "component", "Make-Suite-File-List::Options::Component", "HasArg"), + ('h', "help", "Make-Suite-File-List::Options::Help"), + ('n', "no-delete", "Make-Suite-File-List::Options::No-Delete"), + ('s', "suite", "Make-Suite-File-List::Options::Suite", "HasArg")] for i in ["architecture", "component", "help", "no-delete", "suite" ]: - if not Cnf.has_key("Jenna::Options::%s" % (i)): - Cnf["Jenna::Options::%s" % (i)] = "" + if not Cnf.has_key("Make-Suite-File-List::Options::%s" % (i)): + Cnf["Make-Suite-File-List::Options::%s" % (i)] = "" apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv) - Options = Cnf.SubTree("Jenna::Options") + Options = Cnf.SubTree("Make-Suite-File-List::Options") if Options["Help"]: usage() projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - db_access.init(Cnf, projectB) - Logger = logging.Logger(Cnf, "jenna") + dak.lib.database.init(Cnf, projectB) + Logger = dak.lib.logging.Logger(Cnf, "make-suite-file-list") do_da_do_da() Logger.close() diff --git a/dak/mirror_split.py b/dak/mirror_split.py index efe930d3..63096877 100755 --- a/dak/mirror_split.py +++ b/dak/mirror_split.py @@ -2,7 +2,6 @@ # Prepare and maintain partial trees by architecture # Copyright (C) 2004, 2006 Daniel Silverstone -# $Id: billie,v 1.4 2004-11-27 16:06:42 troup Exp $ # 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 @@ -25,7 +24,7 @@ ############################################################################### import sys -import utils +import dak.lib.utils import apt_pkg from stat import S_ISDIR, S_ISLNK, S_ISREG @@ -35,26 +34,26 @@ import cPickle ## Master path is the main repository #MASTER_PATH = "/org/ftp.debian.org/scratch/dsilvers/master" -MASTER_PATH = "***Configure Billie::FTPPath Please***" -TREE_ROOT = "***Configure Billie::TreeRootPath Please***" -TREE_DB_ROOT = "***Configure Billie::TreeDatabasePath Please***" +MASTER_PATH = "***Configure Mirror-Split::FTPPath Please***" +TREE_ROOT = "***Configure Mirror-Split::TreeRootPath Please***" +TREE_DB_ROOT = "***Configure Mirror-Split::TreeDatabasePath Please***" trees = [] Cnf = None ############################################################################### -# A BillieTarget is a representation of a target. It is a set of archs, a path +# A MirrorSplitTarget is a representation of a target. It is a set of archs, a path # and whether or not the target includes source. ################## -class BillieTarget: +class MirrorSplitTarget: def __init__(self, name, archs, source): self.name = name self.root = "%s/%s" % (TREE_ROOT,name) self.archs = archs.split(",") self.source = source self.dbpath = "%s/%s.db" % (TREE_DB_ROOT,name) - self.db = BillieDB() + self.db = MirrorSplitDB() if os.path.exists( self.dbpath ): self.db.load_from_file( self.dbpath ) @@ -131,30 +130,30 @@ def applicable(path, target): ############################################################################## -# A BillieDir is a representation of a tree. +# A MirrorSplitDir is a representation of a tree. # It distinguishes files dirs and links -# Dirs are dicts of (name, BillieDir) +# Dirs are dicts of (name, MirrorSplitDir) # Files are dicts of (name, inode) # Links are dicts of (name, target) ############## -class BillieDir: +class MirrorSplitDir: def __init__(self): self.dirs = {} self.files = {} self.links = {} ############################################################################## -# A BillieDB is a container for a BillieDir... +# A MirrorSplitDB is a container for a MirrorSplitDir... ############## -class BillieDB: - ## Initialise a BillieDB as containing nothing +class MirrorSplitDB: + ## Initialise a MirrorSplitDB as containing nothing def __init__(self): - self.root = BillieDir() + self.root = MirrorSplitDir() def _internal_recurse(self, path): - bdir = BillieDir() + bdir = MirrorSplitDir() dl = os.listdir( path ) dl.sort() dirs = [] @@ -167,7 +166,7 @@ class BillieDB: elif S_ISREG(lnl[0]): bdir.files[ln] = lnl[1] else: - utils.fubar( "Confused by %s/%s -- not a dir, link or file" % + dak.lib.utils.fubar( "Confused by %s/%s -- not a dir, link or file" % ( path, ln ) ) for d in dirs: bdir.dirs[d] = self._internal_recurse( "%s/%s" % (path,d) ) @@ -178,13 +177,13 @@ class BillieDB: def init_from_dir(self, dirp): self.root = self._internal_recurse( dirp ) - ## Load this BillieDB from file + ## Load this MirrorSplitDB from file def load_from_file(self, fname): f = open(fname, "r") self.root = cPickle.load(f) f.close() - ## Save this BillieDB to a file + ## Save this MirrorSplitDB to a file def save_to_file(self, fname): f = open(fname, "w") cPickle.dump( self.root, f, 1 ) @@ -294,7 +293,7 @@ def _internal_reconcile( path, srcdir, targdir, targ ): # Do dirs for k in srcdir.dirs.keys(): if not targdir.dirs.has_key(k): - targdir.dirs[k] = BillieDir() + targdir.dirs[k] = MirrorSplitDir() #print "+D+", _pth(path,k) _internal_reconcile( _pth(path,k), srcdir.dirs[k], targdir.dirs[k], targ ) @@ -311,21 +310,21 @@ def load_config(): global TREE_DB_ROOT global trees - MASTER_PATH = Cnf["Billie::FTPPath"] - TREE_ROOT = Cnf["Billie::TreeRootPath"] - TREE_DB_ROOT = Cnf["Billie::TreeDatabasePath"] + MASTER_PATH = Cnf["Mirror-Split::FTPPath"] + TREE_ROOT = Cnf["Mirror-Split::TreeRootPath"] + TREE_DB_ROOT = Cnf["Mirror-Split::TreeDatabasePath"] - for a in Cnf.ValueList("Billie::BasicTrees"): - trees.append( BillieTarget( a, "%s,all" % a, 1 ) ) + for a in Cnf.ValueList("Mirror-Split::BasicTrees"): + trees.append( MirrorSplitTarget( a, "%s,all" % a, 1 ) ) - for n in Cnf.SubTree("Billie::CombinationTrees").List(): - archs = Cnf.ValueList("Billie::CombinationTrees::%s" % n) + for n in Cnf.SubTree("Mirror-Split::CombinationTrees").List(): + archs = Cnf.ValueList("Mirror-Split::CombinationTrees::%s" % n) source = 0 if "source" in archs: source = 1 archs.remove("source") archs = ",".join(archs) - trees.append( BillieTarget( n, archs, source ) ) + trees.append( MirrorSplitTarget( n, archs, source ) ) def do_list (): print "Master path",MASTER_PATH @@ -340,7 +339,7 @@ def do_list (): print "" def do_help (): - print """Usage: billie [OPTIONS] + print """Usage: dak mirror-split [OPTIONS] Generate hardlink trees of certain architectures -h, --help show this help and exit @@ -351,15 +350,15 @@ Generate hardlink trees of certain architectures def main (): global Cnf - Cnf = utils.get_conf() + Cnf = dak.lib.utils.get_conf() - Arguments = [('h',"help","Billie::Options::Help"), - ('l',"list","Billie::Options::List"), + Arguments = [('h',"help","Mirror-Split::Options::Help"), + ('l',"list","Mirror-Split::Options::List"), ] arguments = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv) - Cnf["Billie::Options::cake"] = "" - Options = Cnf.SubTree("Billie::Options") + Cnf["Mirror-Split::Options::cake"] = "" + Options = Cnf.SubTree("Mirror-Split::Options") print "Loading configuration..." load_config() @@ -373,7 +372,7 @@ def main (): return - src = BillieDB() + src = MirrorSplitDB() print "Scanning", MASTER_PATH src.init_from_dir(MASTER_PATH) print "Scanned" diff --git a/dak/override.py b/dak/override.py index f52ece94..8c22c23d 100755 --- a/dak/override.py +++ b/dak/override.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # Microscopic modification and query tool for overrides in projectb -# Copyright (C) 2004 Daniel Silverstone -# $Id: alicia,v 1.6 2004-11-27 17:58:13 troup Exp $ +# Copyright (C) 2004, 2006 Daniel Silverstone # 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 @@ -27,8 +26,8 @@ ################################################################################ import pg, sys -import utils, db_access -import apt_pkg, logging +import dak.lib.utils, dak.lib.database +import apt_pkg, dak.lib.logging ################################################################################ @@ -37,16 +36,16 @@ projectB = None ################################################################################ -# Shamelessly stolen from melanie. Should probably end up in utils.py +# Shamelessly stolen from 'dak rm'. Should probably end up in dak.lib.utils.py def game_over(): - answer = utils.our_raw_input("Continue (y/N)? ").lower() + answer = dak.lib.utils.our_raw_input("Continue (y/N)? ").lower() if answer != "y": print "Aborted." sys.exit(1) def usage (exit_code=0): - print """Usage: alicia [OPTIONS] package [section] [priority] + print """Usage: dak override [OPTIONS] package [section] [priority] Make microchanges or microqueries of the overrides -h, --help show this help and exit @@ -59,35 +58,35 @@ Make microchanges or microqueries of the overrides def main (): global Cnf, projectB - Cnf = utils.get_conf() + Cnf = dak.lib.utils.get_conf() - Arguments = [('h',"help","Alicia::Options::Help"), - ('d',"done","Alicia::Options::Done", "HasArg"), - ('n',"no-action","Alicia::Options::No-Action"), - ('s',"suite","Alicia::Options::Suite", "HasArg"), + Arguments = [('h',"help","Override::Options::Help"), + ('d',"done","Override::Options::Done", "HasArg"), + ('n',"no-action","Override::Options::No-Action"), + ('s',"suite","Override::Options::Suite", "HasArg"), ] for i in ["help", "no-action"]: - if not Cnf.has_key("Alicia::Options::%s" % (i)): - Cnf["Alicia::Options::%s" % (i)] = "" - if not Cnf.has_key("Alicia::Options::Suite"): - Cnf["Alicia::Options::Suite"] = "unstable" + if not Cnf.has_key("Override::Options::%s" % (i)): + Cnf["Override::Options::%s" % (i)] = "" + if not Cnf.has_key("Override::Options::Suite"): + Cnf["Override::Options::Suite"] = "unstable" arguments = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv) - Options = Cnf.SubTree("Alicia::Options") + Options = Cnf.SubTree("Override::Options") if Options["Help"]: usage() projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - db_access.init(Cnf, projectB) + dak.lib.database.init(Cnf, projectB) if not arguments: - utils.fubar("package name is a required argument.") + dak.lib.utils.fubar("package name is a required argument.") package = arguments.pop(0) suite = Options["Suite"] if arguments and len(arguments) > 2: - utils.fubar("Too many arguments") + dak.lib.utils.fubar("Too many arguments") if arguments and len(arguments) == 1: # Determine if the argument is a priority or a section... @@ -102,7 +101,7 @@ def main (): elif r[0][1] == 1: arguments = (".",arg) else: - utils.fubar("%s is not a valid section or priority" % (arg)) + dak.lib.utils.fubar("%s is not a valid section or priority" % (arg)) # Retrieve current section/priority... @@ -117,9 +116,9 @@ def main (): """ % (pg._quote(package,"str"), pg._quote(suite,"str"))) if q.ntuples() == 0: - utils.fubar("Unable to find package %s" % (package)) + dak.lib.utils.fubar("Unable to find package %s" % (package)) if q.ntuples() > 1: - utils.fubar("%s is ambiguous. Matches %d packages" % (package,q.ntuples())) + dak.lib.utils.fubar("%s is ambiguous. Matches %d packages" % (package,q.ntuples())) r = q.getresult() oldsection = r[0][1] @@ -142,14 +141,14 @@ def main (): pg._quote(newsection,"str"))) if q.ntuples() == 0: - utils.fubar("Supplied section %s is invalid" % (newsection)) + dak.lib.utils.fubar("Supplied section %s is invalid" % (newsection)) newsecid = q.getresult()[0][0] q = projectB.query("SELECT id FROM priority WHERE priority=%s" % ( pg._quote(newpriority,"str"))) if q.ntuples() == 0: - utils.fubar("Supplied priority %s is invalid" % (newpriority)) + dak.lib.utils.fubar("Supplied priority %s is invalid" % (newpriority)) newprioid = q.getresult()[0][0] if newpriority == oldpriority and newsection == oldsection: @@ -174,13 +173,13 @@ def main (): if not Options.has_key("Done"): pass - #utils.warn("No bugs to close have been specified. Noone will know you have done this.") + #dak.lib.utils.warn("No bugs to close have been specified. Noone will know you have done this.") else: print "I: Will close bug(s): %s" % (Options["Done"]) game_over() - Logger = logging.Logger(Cnf, "alicia") + Logger = dak.lib.logging.Logger(Cnf, "override") projectB.query("BEGIN WORK") # We're in "do it" mode, we have something to do... do it @@ -209,21 +208,21 @@ def main (): if Options.has_key("Done"): Subst = {} - Subst["__ALICIA_ADDRESS__"] = Cnf["Alicia::MyEmailAddress"] + Subst["__OVERRIDE_ADDRESS__"] = Cnf["Override::MyEmailAddress"] Subst["__BUG_SERVER__"] = Cnf["Dinstall::BugServer"] bcc = [] if Cnf.Find("Dinstall::Bcc") != "": bcc.append(Cnf["Dinstall::Bcc"]) - if Cnf.Find("Alicia::Bcc") != "": - bcc.append(Cnf["Alicia::Bcc"]) + if Cnf.Find("Override::Bcc") != "": + bcc.append(Cnf["Override::Bcc"]) if bcc: Subst["__BCC__"] = "Bcc: " + ", ".join(bcc) else: Subst["__BCC__"] = "X-Filler: 42" - Subst["__CC__"] = "X-Katie: alicia $Revision: 1.6 $" + Subst["__CC__"] = "X-DAK: dak override" Subst["__ADMIN_ADDRESS__"] = Cnf["Dinstall::MyAdminAddress"] Subst["__DISTRO__"] = Cnf["Dinstall::MyDistribution"] - Subst["__WHOAMI__"] = utils.whoami() + Subst["__WHOAMI__"] = dak.lib.utils.whoami() summary = "Concerning package %s...\n" % (package) summary += "Operating on the %s suite\n" % (suite) @@ -233,11 +232,11 @@ def main (): summary += "Changed section from %s to %s\n" % (oldsection,newsection) Subst["__SUMMARY__"] = summary - for bug in utils.split_args(Options["Done"]): + for bug in dak.lib.utils.split_args(Options["Done"]): Subst["__BUG_NUMBER__"] = bug - mail_message = utils.TemplateSubst( - Subst,Cnf["Dir::Templates"]+"/alicia.bug-close") - utils.send_mail(mail_message) + mail_message = dak.lib.utils.TemplateSubst( + Subst,Cnf["Dir::Templates"]+"/override.bug-close") + dak.lib.utils.send_mail(mail_message) Logger.log(["closed bug",bug]) Logger.close() diff --git a/dak/poolize.py b/dak/poolize.py index 66fe3e0b..66eda7d8 100755 --- a/dak/poolize.py +++ b/dak/poolize.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # Poolify (move packages from "legacy" type locations to pool locations) -# Copyright (C) 2000, 2001, 2002, 2003, 2004 James Troup -# $Id: catherine,v 1.19 2004-03-11 00:20:51 troup Exp $ +# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 James Troup # 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 @@ -27,7 +26,7 @@ ################################################################################ import os, pg, re, stat, sys -import utils, db_access +import dak.lib.utils, dak.lib.database import apt_pkg, apt_inst ################################################################################ @@ -40,7 +39,7 @@ re_isadeb = re.compile (r"(.+?)_(.+?)(_(.+))?\.u?deb$") ################################################################################ def usage (exit_code=0): - print """Usage: catherine [OPTIONS] + print """Usage: dak poolize [OPTIONS] Migrate packages from legacy locations into the pool. -l, --limit=AMOUNT only migrate AMOUNT Kb of packages @@ -72,7 +71,7 @@ def poolize (q, limit, verbose, no_action): legacy_filename = qid["path"]+qid["filename"] size = os.stat(legacy_filename)[stat.ST_SIZE] if (poolized_size + size) > limit and limit >= 0: - utils.warn("Hit %s limit." % (utils.size_type(limit))) + dak.lib.utils.warn("Hit %s limit." % (dak.lib.utils.size_type(limit))) break poolized_size += size poolized_count += 1 @@ -80,84 +79,84 @@ def poolize (q, limit, verbose, no_action): destination_filename = base_filename # Work out the source package name if re_isadeb.match(base_filename): - control = apt_pkg.ParseSection(apt_inst.debExtractControl(utils.open_file(legacy_filename))) + control = apt_pkg.ParseSection(apt_inst.debExtractControl(dak.lib.utils.open_file(legacy_filename))) package = control.Find("Package", "") source = control.Find("Source", package) if source.find("(") != -1: - m = utils.re_extract_src_version.match(source) + m = dak.lib.utils.re_extract_src_version.match(source) source = m.group(1) # If it's a binary, we need to also rename the file to include the architecture version = control.Find("Version", "") architecture = control.Find("Architecture", "") if package == "" or version == "" or architecture == "": - utils.fubar("%s: couldn't determine required information to rename .deb file." % (legacy_filename)) - version = utils.re_no_epoch.sub('', version) + dak.lib.utils.fubar("%s: couldn't determine required information to rename .deb file." % (legacy_filename)) + version = dak.lib.utils.re_no_epoch.sub('', version) destination_filename = "%s_%s_%s.deb" % (package, version, architecture) else: - m = utils.re_issource.match(base_filename) + m = dak.lib.utils.re_issource.match(base_filename) if m: source = m.group(1) else: - utils.fubar("expansion of source filename '%s' failed." % (legacy_filename)) + dak.lib.utils.fubar("expansion of source filename '%s' failed." % (legacy_filename)) # Work out the component name component = qid["component"] if component == "": q = projectB.query("SELECT DISTINCT(c.name) FROM override o, component c WHERE o.package = '%s' AND o.component = c.id;" % (source)) ql = q.getresult() if not ql: - utils.fubar("No override match for '%s' so I can't work out the component." % (source)) + dak.lib.utils.fubar("No override match for '%s' so I can't work out the component." % (source)) if len(ql) > 1: - utils.fubar("Multiple override matches for '%s' so I can't work out the component." % (source)) + dak.lib.utils.fubar("Multiple override matches for '%s' so I can't work out the component." % (source)) component = ql[0][0] # Work out the new location q = projectB.query("SELECT l.id FROM location l, component c WHERE c.name = '%s' AND c.id = l.component AND l.type = 'pool';" % (component)) ql = q.getresult() if len(ql) != 1: - utils.fubar("couldn't determine location ID for '%s'. [query returned %d matches, not 1 as expected]" % (source, len(ql))) + dak.lib.utils.fubar("couldn't determine location ID for '%s'. [query returned %d matches, not 1 as expected]" % (source, len(ql))) location_id = ql[0][0] # First move the files to the new location - pool_location = utils.poolify (source, component) + pool_location = dak.lib.utils.poolify (source, component) pool_filename = pool_location + destination_filename destination = Cnf["Dir::Pool"] + pool_location + destination_filename if os.path.exists(destination): - utils.fubar("'%s' already exists in the pool; serious FUBARity." % (legacy_filename)) + dak.lib.utils.fubar("'%s' already exists in the pool; serious FUBARity." % (legacy_filename)) if verbose: print "Moving: %s -> %s" % (legacy_filename, destination) if not no_action: - utils.move(legacy_filename, destination) + dak.lib.utils.move(legacy_filename, destination) # Then Update the DB's files table if verbose: print "SQL: UPDATE files SET filename = '%s', location = '%s' WHERE id = '%s'" % (pool_filename, location_id, qid["files_id"]) if not no_action: q = projectB.query("UPDATE files SET filename = '%s', location = '%s' WHERE id = '%s'" % (pool_filename, location_id, qid["files_id"])) - sys.stderr.write("Poolized %s in %s files.\n" % (utils.size_type(poolized_size), poolized_count)) + sys.stderr.write("Poolized %s in %s files.\n" % (dak.lib.utils.size_type(poolized_size), poolized_count)) ################################################################################ def main (): global Cnf, projectB - Cnf = utils.get_conf() + Cnf = dak.lib.utils.get_conf() for i in ["help", "limit", "no-action", "verbose" ]: - if not Cnf.has_key("Catherine::Options::%s" % (i)): - Cnf["Catherine::Options::%s" % (i)] = "" + if not Cnf.has_key("Poolize::Options::%s" % (i)): + Cnf["Poolize::Options::%s" % (i)] = "" - Arguments = [('h',"help","Catherine::Options::Help"), - ('l',"limit", "Catherine::Options::Limit", "HasArg"), - ('n',"no-action","Catherine::Options::No-Action"), - ('v',"verbose","Catherine::Options::Verbose")] + Arguments = [('h',"help","Poolize::Options::Help"), + ('l',"limit", "Poolize::Options::Limit", "HasArg"), + ('n',"no-action","Poolize::Options::No-Action"), + ('v',"verbose","Poolize::Options::Verbose")] apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv) - Options = Cnf.SubTree("Catherine::Options") + Options = Cnf.SubTree("Poolize::Options") if Options["Help"]: usage() projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - db_access.init(Cnf, projectB) + dak.lib.database.init(Cnf, projectB) if not Options["Limit"]: limit = -1 @@ -170,7 +169,7 @@ def main (): # Sanity check the limit argument if limit > 0 and limit < 1024: - utils.fubar("-l/--limit takes an argument with a value in kilobytes.") + dak.lib.utils.fubar("-l/--limit takes an argument with a value in kilobytes.") # Grab a list of all files not already in the pool q = projectB.query(""" diff --git a/dak/process_accepted.py b/dak/process_accepted.py index 8e48ae1f..72af3251 100755 --- a/dak/process_accepted.py +++ b/dak/process_accepted.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # Installs Debian packages from queue/accepted into the pool -# Copyright (C) 2000, 2001, 2002, 2003, 2004 James Troup -# $Id: kelly,v 1.18 2005-12-17 10:57:03 rmurray Exp $ +# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 James Troup # 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 @@ -32,19 +31,16 @@ import errno, fcntl, os, sys, time, re import apt_pkg -import db_access, katie, logging, utils +import dak.lib.database, dak.lib.queue, dak.lib.logging, dak.lib.utils ############################################################################### -# Globals -kelly_version = "$Revision: 1.18 $" - Cnf = None Options = None Logger = None Urgency_Logger = None projectB = None -Katie = None +Upload = None pkg = None reject_message = "" @@ -77,7 +73,7 @@ class Urgency_Log: os.makedirs(self.log_dir, 02775) # Open the logfile self.log_filename = "%s/.install-urgencies-%s.new" % (self.log_dir, self.timestamp) - self.log_file = utils.open_file(self.log_filename, 'w') + self.log_file = dak.lib.utils.open_file(self.log_filename, 'w') self.writes = 0 def log (self, source, version, urgency): @@ -92,7 +88,7 @@ class Urgency_Log: self.log_file.close() if self.writes: new_filename = "%s/install-urgencies-%s" % (self.log_dir, self.timestamp) - utils.move(self.log_filename, new_filename) + dak.lib.utils.move(self.log_filename, new_filename) else: os.unlink(self.log_filename) @@ -119,22 +115,22 @@ def check(): source_version = files[file]["source version"] source_package = files[file]["source package"] if not changes["architecture"].has_key("source") \ - and not Katie.source_exists(source_package, source_version, changes["distribution"].keys()): + and not Upload.source_exists(source_package, source_version, changes["distribution"].keys()): reject("no source found for %s %s (%s)." % (source_package, source_version, file)) # Version and file overwrite checks if not installing_to_stable: if files[file]["type"] == "deb": - reject(Katie.check_binary_against_db(file), "") + reject(Upload.check_binary_against_db(file), "") elif files[file]["type"] == "dsc": - reject(Katie.check_source_against_db(file), "") - (reject_msg, is_in_incoming) = Katie.check_dsc_against_db(file) + reject(Upload.check_source_against_db(file), "") + (reject_msg, is_in_incoming) = Upload.check_dsc_against_db(file) reject(reject_msg, "") # propogate in the case it is in the override tables: if changes.has_key("propdistribution"): for suite in changes["propdistribution"].keys(): - if Katie.in_override_p(files[file]["package"], files[file]["component"], suite, files[file].get("dbtype",""), file): + if Upload.in_override_p(files[file]["package"], files[file]["component"], suite, files[file].get("dbtype",""), file): propogate[suite] = 1 else: nopropogate[suite] = 1 @@ -147,22 +143,21 @@ def check(): for file in files.keys(): # Check the package is still in the override tables for suite in changes["distribution"].keys(): - if not Katie.in_override_p(files[file]["package"], files[file]["component"], suite, files[file].get("dbtype",""), file): + if not Upload.in_override_p(files[file]["package"], files[file]["component"], suite, files[file].get("dbtype",""), file): reject("%s is NEW for %s." % (file, suite)) ############################################################################### def init(): - global Cnf, Options, Katie, projectB, changes, dsc, dsc_files, files, pkg, Subst + global Cnf, Options, Upload, projectB, changes, dsc, dsc_files, files, pkg, Subst - Cnf = utils.get_conf() + Cnf = dak.lib.utils.get_conf() Arguments = [('a',"automatic","Dinstall::Options::Automatic"), ('h',"help","Dinstall::Options::Help"), ('n',"no-action","Dinstall::Options::No-Action"), ('p',"no-lock", "Dinstall::Options::No-Lock"), - ('s',"no-mail", "Dinstall::Options::No-Mail"), - ('V',"version","Dinstall::Options::Version")] + ('s',"no-mail", "Dinstall::Options::No-Mail")] for i in ["automatic", "help", "no-action", "no-lock", "no-mail", "version"]: if not Cnf.has_key("Dinstall::Options::%s" % (i)): @@ -174,26 +169,22 @@ def init(): if Options["Help"]: usage() - if Options["Version"]: - print "kelly %s" % (kelly_version) - sys.exit(0) - - Katie = katie.Katie(Cnf) - projectB = Katie.projectB + Upload = dak.lib.queue.Upload(Cnf) + projectB = Upload.projectB - changes = Katie.pkg.changes - dsc = Katie.pkg.dsc - dsc_files = Katie.pkg.dsc_files - files = Katie.pkg.files - pkg = Katie.pkg - Subst = Katie.Subst + changes = Upload.pkg.changes + dsc = Upload.pkg.dsc + dsc_files = Upload.pkg.dsc_files + files = Upload.pkg.files + pkg = Upload.pkg + Subst = Upload.Subst return changes_files ############################################################################### def usage (exit_code=0): - print """Usage: kelly [OPTION]... [CHANGES]... + print """Usage: dak process-accepted [OPTION]... [CHANGES]... -a, --automatic automatic run -h, --help show this help and exit. -n, --no-action don't do anything @@ -205,7 +196,7 @@ def usage (exit_code=0): ############################################################################### def action (): - (summary, short_summary) = Katie.build_summaries() + (summary, short_summary) = Upload.build_summaries() (prompt, answer) = ("", "XXX") if Options["No-Action"] or Options["Automatic"]: @@ -224,8 +215,8 @@ def action (): answer = 'I' while prompt.find(answer) == -1: - answer = utils.our_raw_input(prompt) - m = katie.re_default_answer.match(prompt) + answer = dak.lib.utils.our_raw_input(prompt) + m = dak.lib.queue.re_default_answer.match(prompt) if answer == "": answer = m.group(1) answer = answer[:1].upper() @@ -251,7 +242,7 @@ def do_reject (): Subst["__REJECTOR_ADDRESS__"] = Cnf["Dinstall::MyEmailAddress"] Subst["__REJECT_MESSAGE__"] = reject_message Subst["__CC__"] = "Cc: " + Cnf["Dinstall::MyEmailAddress"] - reject_mail_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/kelly.unaccept") + reject_mail_message = dak.lib.utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/process-accepted.unaccept") # Write the rejection email out as the .reason file reason_filename = os.path.basename(pkg.changes_file[:-8]) + ".reason" @@ -264,7 +255,7 @@ def do_reject (): os.write(fd, reject_mail_message) os.close(fd) - utils.send_mail(reject_mail_message) + dak.lib.utils.send_mail(reject_mail_message) Logger.log(["unaccepted", pkg.changes_file]) ############################################################################### @@ -286,19 +277,19 @@ def install (): version = dsc["version"] # NB: not files[file]["version"], that has no epoch maintainer = dsc["maintainer"] maintainer = maintainer.replace("'", "\\'") - maintainer_id = db_access.get_or_set_maintainer_id(maintainer) - fingerprint_id = db_access.get_or_set_fingerprint_id(dsc["fingerprint"]) + maintainer_id = dak.lib.database.get_or_set_maintainer_id(maintainer) + fingerprint_id = dak.lib.database.get_or_set_fingerprint_id(dsc["fingerprint"]) install_date = time.strftime("%Y-%m-%d") filename = files[file]["pool name"] + file dsc_component = files[file]["component"] 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"] = db_access.set_files_id (filename, files[file]["size"], files[file]["md5sum"], dsc_location_id) + files[file]["files id"] = dak.lib.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)) for suite in changes["distribution"].keys(): - suite_id = db_access.get_suite_id(suite) + suite_id = dak.lib.database.get_suite_id(suite) projectB.query("INSERT INTO src_associations (suite, source) VALUES (%d, currval('source_id_seq'))" % (suite_id)) # Add the source files to the DB (files and dsc_files) @@ -309,10 +300,10 @@ def install (): # files id is stored in dsc_files by check_dsc(). files_id = dsc_files[dsc_file].get("files id", None) if files_id == None: - files_id = db_access.get_files_id(filename, dsc_files[dsc_file]["size"], dsc_files[dsc_file]["md5sum"], dsc_location_id) + files_id = dak.lib.database.get_files_id(filename, dsc_files[dsc_file]["size"], dsc_files[dsc_file]["md5sum"], dsc_location_id) # FIXME: needs to check for -1/-2 and or handle exception if files_id == None: - files_id = db_access.set_files_id (filename, dsc_files[dsc_file]["size"], dsc_files[dsc_file]["md5sum"], dsc_location_id) + files_id = dak.lib.database.set_files_id (filename, dsc_files[dsc_file]["size"], dsc_files[dsc_file]["md5sum"], dsc_location_id) projectB.query("INSERT INTO dsc_files (source, file) VALUES (currval('source_id_seq'), %d)" % (files_id)) # Add the .deb files to the DB @@ -322,19 +313,19 @@ def install (): version = files[file]["version"] maintainer = files[file]["maintainer"] maintainer = maintainer.replace("'", "\\'") - maintainer_id = db_access.get_or_set_maintainer_id(maintainer) - fingerprint_id = db_access.get_or_set_fingerprint_id(changes["fingerprint"]) + maintainer_id = dak.lib.database.get_or_set_maintainer_id(maintainer) + fingerprint_id = dak.lib.database.get_or_set_fingerprint_id(changes["fingerprint"]) architecture = files[file]["architecture"] - architecture_id = db_access.get_architecture_id (architecture) + architecture_id = dak.lib.database.get_architecture_id (architecture) type = files[file]["dbtype"] source = files[file]["source package"] source_version = files[file]["source version"] filename = files[file]["pool name"] + file if not files[file].has_key("location id") or not files[file]["location id"]: - files[file]["location id"] = db_access.get_location_id(Cnf["Dir::Pool"],files[file]["component"],utils.where_am_i()) + files[file]["location id"] = dak.lib.database.get_location_id(Cnf["Dir::Pool"],files[file]["component"],dak.lib.utils.where_am_i()) if not files[file].has_key("files id") or not files[file]["files id"]: - files[file]["files id"] = db_access.set_files_id (filename, files[file]["size"], files[file]["md5sum"], files[file]["location id"]) - source_id = db_access.get_source_id (source, source_version) + files[file]["files id"] = dak.lib.database.set_files_id (filename, files[file]["size"], files[file]["md5sum"], files[file]["location id"]) + source_id = dak.lib.database.get_source_id (source, source_version) if source_id: projectB.query("INSERT INTO binaries (package, version, maintainer, source, architecture, file, type, sig_fpr) VALUES ('%s', '%s', %d, %d, %d, %d, '%s', %d)" % (package, version, maintainer_id, source_id, architecture_id, files[file]["files id"], type, fingerprint_id)) @@ -342,15 +333,15 @@ def install (): projectB.query("INSERT INTO binaries (package, version, maintainer, architecture, file, type, sig_fpr) VALUES ('%s', '%s', %d, %d, %d, '%s', %d)" % (package, version, maintainer_id, architecture_id, files[file]["files id"], type, fingerprint_id)) for suite in changes["distribution"].keys(): - suite_id = db_access.get_suite_id(suite) + suite_id = dak.lib.database.get_suite_id(suite) projectB.query("INSERT INTO bin_associations (suite, bin) VALUES (%d, currval('binaries_id_seq'))" % (suite_id)) # If the .orig.tar.gz is in a legacy directory we need to poolify # it, so that apt-get source (and anything else that goes by the # "Directory:" field in the Sources.gz file) works. - orig_tar_id = Katie.pkg.orig_tar_id - orig_tar_location = Katie.pkg.orig_tar_location - legacy_source_untouchable = Katie.pkg.legacy_source_untouchable + orig_tar_id = Upload.pkg.orig_tar_id + orig_tar_location = Upload.pkg.orig_tar_location + legacy_source_untouchable = Upload.pkg.legacy_source_untouchable if orig_tar_id and orig_tar_location == "legacy": q = projectB.query("SELECT DISTINCT ON (f.id) l.path, f.filename, f.id as files_id, df.source, df.id as dsc_files_id, f.size, f.md5sum FROM files f, dsc_files df, location l WHERE df.source IN (SELECT source FROM dsc_files WHERE file = %s) AND f.id = df.file AND l.id = f.location AND (l.type = 'legacy' OR l.type = 'legacy-mixed')" % (orig_tar_id)) qd = q.dictresult() @@ -360,10 +351,10 @@ def install (): continue # First move the files to the new location legacy_filename = qid["path"] + qid["filename"] - pool_location = utils.poolify (changes["source"], files[file]["component"]) + pool_location = dak.lib.utils.poolify (changes["source"], files[file]["component"]) pool_filename = pool_location + os.path.basename(qid["filename"]) destination = Cnf["Dir::Pool"] + pool_location - utils.move(legacy_filename, destination) + dak.lib.utils.move(legacy_filename, destination) # Then Update the DB's files table q = projectB.query("UPDATE files SET filename = '%s', location = '%s' WHERE id = '%s'" % (pool_filename, dsc_location_id, qid["files_id"])) @@ -378,54 +369,54 @@ def install (): old_filename = ql[0] + ql[1] file_size = ql[2] file_md5sum = ql[3] - new_filename = utils.poolify(changes["source"], dsc_component) + os.path.basename(old_filename) - new_files_id = db_access.get_files_id(new_filename, file_size, file_md5sum, dsc_location_id) + new_filename = dak.lib.utils.poolify(changes["source"], dsc_component) + os.path.basename(old_filename) + new_files_id = dak.lib.database.get_files_id(new_filename, file_size, file_md5sum, dsc_location_id) if new_files_id == None: - utils.copy(old_filename, Cnf["Dir::Pool"] + new_filename) - new_files_id = db_access.set_files_id(new_filename, file_size, file_md5sum, dsc_location_id) + dak.lib.utils.copy(old_filename, Cnf["Dir::Pool"] + new_filename) + new_files_id = dak.lib.database.set_files_id(new_filename, file_size, file_md5sum, dsc_location_id) projectB.query("UPDATE dsc_files SET file = %s WHERE source = %s AND file = %s" % (new_files_id, source_id, orig_tar_id)) # Install the files into the pool for file in files.keys(): destination = Cnf["Dir::Pool"] + files[file]["pool name"] + file - utils.move(file, destination) + dak.lib.utils.move(file, destination) Logger.log(["installed", file, files[file]["type"], files[file]["size"], files[file]["architecture"]]) install_bytes += float(files[file]["size"]) # Copy the .changes file across for suite which need it. copy_changes = {} - copy_katie = {} + copy_dot_dak = {} for suite in changes["distribution"].keys(): if Cnf.has_key("Suite::%s::CopyChanges" % (suite)): copy_changes[Cnf["Suite::%s::CopyChanges" % (suite)]] = "" - # and the .katie file... - if Cnf.has_key("Suite::%s::CopyKatie" % (suite)): - copy_katie[Cnf["Suite::%s::CopyKatie" % (suite)]] = "" + # and the .dak file... + if Cnf.has_key("Suite::%s::CopyDotDak" % (suite)): + copy_dot_dak[Cnf["Suite::%s::CopyDotDak" % (suite)]] = "" for dest in copy_changes.keys(): - utils.copy(pkg.changes_file, Cnf["Dir::Root"] + dest) - for dest in copy_katie.keys(): - utils.copy(Katie.pkg.changes_file[:-8]+".katie", dest) + dak.lib.utils.copy(pkg.changes_file, Cnf["Dir::Root"] + dest) + for dest in copy_dot_dak.keys(): + dak.lib.utils.copy(Upload.pkg.changes_file[:-8]+".dak", dest) projectB.query("COMMIT WORK") # Move the .changes into the 'done' directory - utils.move (pkg.changes_file, + dak.lib.utils.move (pkg.changes_file, os.path.join(Cnf["Dir::Queue::Done"], os.path.basename(pkg.changes_file))) - # Remove the .katie file - os.unlink(Katie.pkg.changes_file[:-8]+".katie") + # Remove the .dak file + os.unlink(Upload.pkg.changes_file[:-8]+".dak") if changes["architecture"].has_key("source") and Urgency_Logger: Urgency_Logger.log(dsc["source"], dsc["version"], changes["urgency"]) - # Undo the work done in katie.py(accept) to help auto-building + # Undo the work done in queue.py(accept) to help auto-building # from accepted. projectB.query("BEGIN WORK") for suite in changes["distribution"].keys(): if suite not in Cnf.ValueList("Dinstall::QueueBuildSuites"): continue now_date = time.strftime("%Y-%m-%d %H:%M") - suite_id = db_access.get_suite_id(suite) + suite_id = dak.lib.database.get_suite_id(suite) dest_dir = Cnf["Dir::QueueBuild"] if Cnf.FindB("Dinstall::SecurityQueueBuild"): dest_dir = os.path.join(dest_dir, suite) @@ -435,7 +426,7 @@ def install (): projectB.query("UPDATE queue_build SET in_queue = 'f', last_used = '%s' WHERE filename = '%s' AND suite = %s" % (now_date, dest, suite_id)) if not Cnf.FindB("Dinstall::SecurityQueueBuild"): # Update the symlink to point to the new location in the pool - pool_location = utils.poolify (changes["source"], files[file]["component"]) + pool_location = dak.lib.utils.poolify (changes["source"], files[file]["component"]) src = os.path.join(Cnf["Dir::Pool"], pool_location, os.path.basename(file)) if os.path.islink(dest): os.unlink(dest) @@ -472,11 +463,11 @@ def stable_install (summary, short_summary): q = projectB.query("SELECT id FROM source WHERE source = '%s' AND version = '%s'" % (package, version)) ql = q.getresult() if not ql: - utils.fubar("[INTERNAL ERROR] couldn't find '%s' (%s) in source table." % (package, version)) + dak.lib.utils.fubar("[INTERNAL ERROR] couldn't find '%s' (%s) in source table." % (package, version)) source_id = ql[0][0] - suite_id = db_access.get_suite_id('proposed-updates') + suite_id = dak.lib.database.get_suite_id('proposed-updates') projectB.query("DELETE FROM src_associations WHERE suite = '%s' AND source = '%s'" % (suite_id, source_id)) - suite_id = db_access.get_suite_id('stable') + suite_id = dak.lib.database.get_suite_id('stable') 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) @@ -489,14 +480,14 @@ def stable_install (summary, short_summary): q = projectB.query("SELECT b.id FROM binaries b, architecture a WHERE b.package = '%s' AND b.version = '%s' AND (a.arch_string = '%s' OR a.arch_string = 'all') AND b.architecture = a.id" % (package, version, architecture)) ql = q.getresult() if not ql: - suite_id = db_access.get_suite_id('proposed-updates') + suite_id = dak.lib.database.get_suite_id('proposed-updates') que = "SELECT b.version FROM binaries b JOIN bin_associations ba ON (b.id = ba.bin) JOIN suite su ON (ba.suite = su.id) WHERE b.package = '%s' AND (ba.suite = '%s')" % (package, suite_id) q = projectB.query(que) # Reduce the query results to a list of version numbers ql = map(lambda x: x[0], q.getresult()) if not ql: - utils.fubar("[INTERNAL ERROR] couldn't find '%s' (%s for %s architecture) in binaries table." % (package, version, architecture)) + dak.lib.utils.fubar("[INTERNAL ERROR] couldn't find '%s' (%s for %s architecture) in binaries table." % (package, version, architecture)) else: for x in ql: if re.match(re.compile(r"%s((\.0)?\.)|(\+b)\d+$" % re.escape(version)),x): @@ -504,16 +495,16 @@ def stable_install (summary, short_summary): break if not binNMU: binary_id = ql[0][0] - suite_id = db_access.get_suite_id('proposed-updates') + suite_id = dak.lib.database.get_suite_id('proposed-updates') projectB.query("DELETE FROM bin_associations WHERE suite = '%s' AND bin = '%s'" % (suite_id, binary_id)) - suite_id = db_access.get_suite_id('stable') + suite_id = dak.lib.database.get_suite_id('stable') projectB.query("INSERT INTO bin_associations (suite, bin) VALUES ('%s', '%s')" % (suite_id, binary_id)) else: del files[file] projectB.query("COMMIT WORK") - utils.move (pkg.changes_file, Cnf["Dir::Morgue"] + '/katie/' + os.path.basename(pkg.changes_file)) + dak.lib.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" @@ -521,36 +512,36 @@ def stable_install (summary, short_summary): if os.path.exists(new_changelog_filename): os.unlink (new_changelog_filename) - new_changelog = utils.open_file(new_changelog_filename, 'w') + new_changelog = dak.lib.utils.open_file(new_changelog_filename, 'w') for file in files.keys(): if files[file]["type"] == "deb": new_changelog.write("stable/%s/binary-%s/%s\n" % (files[file]["component"], files[file]["architecture"], file)) - elif utils.re_issource.match(file): + elif dak.lib.utils.re_issource.match(file): new_changelog.write("stable/%s/source/%s\n" % (files[file]["component"], file)) else: new_changelog.write("%s\n" % (file)) - chop_changes = katie.re_fdnic.sub("\n", changes["changes"]) + chop_changes = dak.lib.queue.re_fdnic.sub("\n", changes["changes"]) new_changelog.write(chop_changes + '\n\n') if os.access(changelog_filename, os.R_OK) != 0: - changelog = utils.open_file(changelog_filename) + changelog = dak.lib.utils.open_file(changelog_filename) new_changelog.write(changelog.read()) new_changelog.close() if os.access(changelog_filename, os.R_OK) != 0: os.unlink(changelog_filename) - utils.move(new_changelog_filename, changelog_filename) + dak.lib.utils.move(new_changelog_filename, changelog_filename) install_count += 1 if not Options["No-Mail"] and changes["architecture"].has_key("source"): Subst["__SUITE__"] = " into stable" Subst["__SUMMARY__"] = summary - mail_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/kelly.installed") - utils.send_mail(mail_message) - Katie.announce(short_summary, 1) + mail_message = dak.lib.utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/process-accepted.installed") + dak.lib.utils.send_mail(mail_message) + Upload.announce(short_summary, 1) - # Finally remove the .katie file - katie_file = os.path.join(Cnf["Suite::Proposed-Updates::CopyKatie"], os.path.basename(Katie.pkg.changes_file[:-8]+".katie")) - os.unlink(katie_file) + # 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")) + os.unlink(dot_dak_file) ################################################################################ @@ -568,16 +559,16 @@ def process_it (changes_file): pkg.directory = os.getcwd() if installing_to_stable: - old = Katie.pkg.changes_file - Katie.pkg.changes_file = os.path.basename(old) - os.chdir(Cnf["Suite::Proposed-Updates::CopyKatie"]) + old = Upload.pkg.changes_file + Upload.pkg.changes_file = os.path.basename(old) + os.chdir(Cnf["Suite::Proposed-Updates::CopyDotDak"]) - Katie.init_vars() - Katie.update_vars() - Katie.update_subst() + Upload.init_vars() + Upload.update_vars() + Upload.update_subst() if installing_to_stable: - Katie.pkg.changes_file = old + Upload.pkg.changes_file = old check() action() @@ -599,7 +590,7 @@ def main(): # Check that we aren't going to clash with the daily cron job if not Options["No-Action"] and os.path.exists("%s/Archive_Maintenance_In_Progress" % (Cnf["Dir::Root"])) and not Options["No-Lock"]: - utils.fubar("Archive maintenance in progress. Try again later.") + dak.lib.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: @@ -612,22 +603,22 @@ def main(): fcntl.lockf(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB) except IOError, e: if errno.errorcode[e.errno] == 'EACCES' or errno.errorcode[e.errno] == 'EAGAIN': - utils.fubar("Couldn't obtain lock; assuming another kelly is already running.") + dak.lib.utils.fubar("Couldn't obtain lock; assuming another 'dak process-accepted' is already running.") else: raise - Logger = Katie.Logger = logging.Logger(Cnf, "kelly") + Logger = Upload.Logger = dak.lib.logging.Logger(Cnf, "process-accepted") if not installing_to_stable and Cnf.get("Dir::UrgencyLog"): Urgency_Logger = Urgency_Log(Cnf) # Initialize the substitution template mapping global - bcc = "X-Katie: %s" % (kelly_version) + bcc = "X-DAK: dak process-accepted\nX-Katie: this header is obsolete" if Cnf.has_key("Dinstall::Bcc"): Subst["__BCC__"] = bcc + "\nBcc: %s" % (Cnf["Dinstall::Bcc"]) else: Subst["__BCC__"] = bcc # Sort the .changes files so that we process sourceful ones first - changes_files.sort(utils.changes_compare) + changes_files.sort(dak.lib.utils.changes_compare) # Process the changes files for changes_file in changes_files: @@ -638,7 +629,7 @@ def main(): sets = "set" if install_count > 1: sets = "sets" - sys.stderr.write("Installed %d package %s, %s.\n" % (install_count, sets, utils.size_type(int(install_bytes)))) + sys.stderr.write("Installed %d package %s, %s.\n" % (install_count, sets, dak.lib.utils.size_type(int(install_bytes)))) Logger.log(["total",install_count,install_bytes]) if not Options["No-Action"]: diff --git a/dak/process_new.py b/dak/process_new.py index e1e30789..964e50e5 100755 --- a/dak/process_new.py +++ b/dak/process_new.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # Handles NEW and BYHAND packages -# Copyright (C) 2001, 2002, 2003, 2004, 2005 James Troup -# $Id: lisa,v 1.31 2005-11-15 09:50:32 ajt Exp $ +# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 James Troup # 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 @@ -39,14 +38,12 @@ import copy, errno, os, readline, stat, sys, time import apt_pkg, apt_inst -import db_access, fernanda, katie, logging, utils +import dak.lib.database, examine_package, dak.lib.queue, dak.lib.logging, dak.lib.utils # Globals -lisa_version = "$Revision: 1.31 $" - Cnf = None Options = None -Katie = None +Upload = None projectB = None Logger = None @@ -66,7 +63,7 @@ def reject (str, prefix="Rejected: "): def recheck(): global reject_message - files = Katie.pkg.files + files = Upload.pkg.files reject_message = "" for file in files.keys(): @@ -78,19 +75,19 @@ def recheck(): if files[file]["type"] == "deb": source_version = files[file]["source version"] source_package = files[file]["source package"] - if not Katie.pkg.changes["architecture"].has_key("source") \ - and not Katie.source_exists(source_package, source_version, Katie.pkg.changes["distribution"].keys()): - source_epochless_version = utils.re_no_epoch.sub('', source_version) + if not Upload.pkg.changes["architecture"].has_key("source") \ + and not Upload.source_exists(source_package, source_version, Upload.pkg.changes["distribution"].keys()): + source_epochless_version = dak.lib.utils.re_no_epoch.sub('', source_version) dsc_filename = "%s_%s.dsc" % (source_package, source_epochless_version) if not os.path.exists(Cnf["Dir::Queue::Accepted"] + '/' + dsc_filename): reject("no source found for %s %s (%s)." % (source_package, source_version, file)) # Version and file overwrite checks if files[file]["type"] == "deb": - reject(Katie.check_binary_against_db(file)) + reject(Upload.check_binary_against_db(file)) elif files[file]["type"] == "dsc": - reject(Katie.check_source_against_db(file)) - (reject_msg, is_in_incoming) = Katie.check_dsc_against_db(file) + reject(Upload.check_source_against_db(file)) + (reject_msg, is_in_incoming) = Upload.check_dsc_against_db(file) reject(reject_msg) if reject_message: @@ -102,15 +99,15 @@ def recheck(): prompt = "[R]eject, Skip, Quit ?" while prompt.find(answer) == -1: - answer = utils.our_raw_input(prompt) - m = katie.re_default_answer.match(prompt) + answer = dak.lib.utils.our_raw_input(prompt) + m = dak.lib.queue.re_default_answer.match(prompt) if answer == "": answer = m.group(1) answer = answer[:1].upper() if answer == 'R': - Katie.do_reject(0, reject_message) - os.unlink(Katie.pkg.changes_file[:-8]+".katie") + Upload.do_reject(0, reject_message) + os.unlink(Upload.pkg.changes_file[:-8]+".dak") return 0 elif answer == 'S': return 0 @@ -162,10 +159,10 @@ def determine_new (changes, files): new[pkg]["othercomponents"] = f["othercomponents"] for suite in changes["suite"].keys(): - suite_id = db_access.get_suite_id(suite) + suite_id = dak.lib.database.get_suite_id(suite) for pkg in new.keys(): - component_id = db_access.get_component_id(new[pkg]["component"]) - type_id = db_access.get_override_type_id(new[pkg]["type"]) + component_id = dak.lib.database.get_component_id(new[pkg]["component"]) + type_id = dak.lib.database.get_override_type_id(new[pkg]["type"]) q = projectB.query("SELECT package FROM override WHERE package = '%s' AND suite = %s AND component = %s AND type = %s" % (pkg, suite_id, component_id, type_id)) ql = q.getresult() if ql: @@ -233,10 +230,10 @@ def sort_changes(changes_files): # Read in all the .changes files for filename in changes_files: try: - Katie.pkg.changes_file = filename - Katie.init_vars() - Katie.update_vars() - cache[filename] = copy.copy(Katie.pkg.changes) + Upload.pkg.changes_file = filename + Upload.init_vars() + Upload.update_vars() + cache[filename] = copy.copy(Upload.pkg.changes) cache[filename]["filename"] = filename except: sorted_list.append(filename) @@ -259,7 +256,7 @@ def sort_changes(changes_files): mtime = os.stat(d["filename"])[stat.ST_MTIME] if mtime < oldest: oldest = mtime - have_note += (d.has_key("lisa note")) + have_note += (d.has_key("process-new note")) per_source[source]["oldest"] = oldest if not have_note: per_source[source]["note_state"] = 0; # none @@ -324,8 +321,8 @@ def check_valid (new): section = new[pkg]["section"] priority = new[pkg]["priority"] type = new[pkg]["type"] - new[pkg]["section id"] = db_access.get_section_id(section) - new[pkg]["priority id"] = db_access.get_priority_id(new[pkg]["priority"]) + new[pkg]["section id"] = dak.lib.database.get_section_id(section) + new[pkg]["priority id"] = dak.lib.database.get_priority_id(new[pkg]["priority"]) # Sanity checks if (section == "debian-installer" and type != "udeb") or \ (section != "debian-installer" and type == "udeb"): @@ -356,7 +353,7 @@ def print_new (new, indexed, file=sys.stdout): line = "%-20s %-20s %-20s" % (pkg, priority, section) line = line.strip()+'\n' file.write(line) - note = Katie.pkg.changes.get("lisa note") + note = Upload.pkg.changes.get("process-new note") if note: print "*"*75 print note @@ -372,12 +369,12 @@ def get_type (f): elif f["type"] == "orig.tar.gz" or f["type"] == "tar.gz" or f["type"] == "diff.gz" or f["type"] == "dsc": type = "dsc" else: - utils.fubar("invalid type (%s) for new. Dazed, confused and sure as heck not continuing." % (type)) + dak.lib.utils.fubar("invalid type (%s) for new. Dazed, confused and sure as heck not continuing." % (type)) # Validate the override type - type_id = db_access.get_override_type_id(type) + type_id = dak.lib.database.get_override_type_id(type) if type_id == -1: - utils.fubar("invalid type (%s) for new. Say wha?" % (type)) + dak.lib.utils.fubar("invalid type (%s) for new. Say wha?" % (type)) return type @@ -394,17 +391,17 @@ def index_range (index): def edit_new (new): # Write the current data to a temporary file - temp_filename = utils.temp_filename() - temp_file = utils.open_file(temp_filename, 'w') + temp_filename = dak.lib.utils.temp_filename() + temp_file = dak.lib.utils.open_file(temp_filename, 'w') print_new (new, 0, temp_file) temp_file.close() # Spawn an editor on that file editor = os.environ.get("EDITOR","vi") result = os.system("%s %s" % (editor, temp_filename)) if result != 0: - utils.fubar ("%s invocation failed for %s." % (editor, temp_filename), result) + dak.lib.utils.fubar ("%s invocation failed for %s." % (editor, temp_filename), result) # Read the edited data back in - temp_file = utils.open_file(temp_filename) + temp_file = dak.lib.utils.open_file(temp_filename) lines = temp_file.readlines() temp_file.close() os.unlink(temp_filename) @@ -418,7 +415,7 @@ def edit_new (new): s[len(s):3] = [None] * (3-len(s)) (pkg, priority, section) = s[:3] if not new.has_key(pkg): - utils.warn("Ignoring unknown package '%s'" % (pkg)) + dak.lib.utils.warn("Ignoring unknown package '%s'" % (pkg)) else: # Strip off any invalid markers, print_new will readd them. if section.endswith("[!]"): @@ -426,8 +423,8 @@ def edit_new (new): if priority.endswith("[!]"): priority = priority[:-3] for file in new[pkg]["files"]: - Katie.pkg.files[file]["section"] = section - Katie.pkg.files[file]["priority"] = priority + Upload.pkg.files[file]["section"] = section + Upload.pkg.files[file]["priority"] = priority new[pkg]["section"] = section new[pkg]["priority"] = priority @@ -449,8 +446,8 @@ def edit_index (new, index): edit_priority = edit_section = 0 while prompt.find(answer) == -1: - answer = utils.our_raw_input(prompt) - m = katie.re_default_answer.match(prompt) + answer = dak.lib.utils.our_raw_input(prompt) + m = dak.lib.queue.re_default_answer.match(prompt) if answer == "": answer = m.group(1) answer = answer[:1].upper() @@ -469,7 +466,7 @@ def edit_index (new, index): readline.set_completer(Priorities.complete) got_priority = 0 while not got_priority: - new_priority = utils.our_raw_input("New priority: ").strip() + new_priority = dak.lib.utils.our_raw_input("New priority: ").strip() if new_priority not in Priorities.priorities: print "E: '%s' is not a valid priority, try again." % (new_priority) else: @@ -481,7 +478,7 @@ def edit_index (new, index): readline.set_completer(Sections.complete) got_section = 0 while not got_section: - new_section = utils.our_raw_input("New section: ").strip() + new_section = dak.lib.utils.our_raw_input("New section: ").strip() if new_section not in Sections.sections: print "E: '%s' is not a valid section, try again." % (new_section) else: @@ -492,8 +489,8 @@ def edit_index (new, index): readline.set_completer(None) for file in new[index]["files"]: - Katie.pkg.files[file]["section"] = section - Katie.pkg.files[file]["priority"] = priority + Upload.pkg.files[file]["section"] = section + Upload.pkg.files[file]["priority"] = priority new[index]["priority"] = priority new[index]["section"] = section return new @@ -515,12 +512,12 @@ def edit_overrides (new): got_answer = 0 while not got_answer: - answer = utils.our_raw_input(prompt) - if not utils.str_isnum(answer): + answer = dak.lib.utils.our_raw_input(prompt) + if not dak.lib.utils.str_isnum(answer): answer = answer[:1].upper() if answer == "E" or answer == "D": got_answer = 1 - elif katie.re_isanum.match (answer): + elif dak.lib.queue.re_isanum.match (answer): answer = int(answer) if (answer < 1) or (answer > index): print "%s is not a valid index (%s). Please retry." % (answer, index_range(index)) @@ -540,24 +537,24 @@ def edit_overrides (new): def edit_note(note): # Write the current data to a temporary file - temp_filename = utils.temp_filename() - temp_file = utils.open_file(temp_filename, 'w') + temp_filename = dak.lib.utils.temp_filename() + temp_file = dak.lib.utils.open_file(temp_filename, 'w') temp_file.write(note) temp_file.close() editor = os.environ.get("EDITOR","vi") answer = 'E' while answer == 'E': os.system("%s %s" % (editor, temp_filename)) - temp_file = utils.open_file(temp_filename) + temp_file = dak.lib.utils.open_file(temp_filename) note = temp_file.read().rstrip() temp_file.close() print "Note:" - print utils.prefix_multi_line_string(note," ") + print dak.lib.utils.prefix_multi_line_string(note," ") prompt = "[D]one, Edit, Abandon, Quit ?" answer = "XXX" while prompt.find(answer) == -1: - answer = utils.our_raw_input(prompt) - m = katie.re_default_answer.search(prompt) + answer = dak.lib.utils.our_raw_input(prompt) + m = dak.lib.queue.re_default_answer.search(prompt) if answer == "": answer = m.group(1) answer = answer[:1].upper() @@ -566,8 +563,8 @@ def edit_note(note): return elif answer == 'Q': sys.exit(0) - Katie.pkg.changes["lisa note"] = note - Katie.dump_vars(Cnf["Dir::Queue::New"]) + Upload.pkg.changes["process-new note"] = note + Upload.dump_vars(Cnf["Dir::Queue::New"]) ################################################################################ @@ -577,25 +574,25 @@ def check_pkg (): stdout_fd = sys.stdout try: sys.stdout = less_fd - fernanda.display_changes(Katie.pkg.changes_file) - files = Katie.pkg.files + examine_package.display_changes(Upload.pkg.changes_file) + files = Upload.pkg.files for file in files.keys(): if files[file].has_key("new"): type = files[file]["type"] if type == "deb": - fernanda.check_deb(file) + examine_package.check_deb(file) elif type == "dsc": - fernanda.check_dsc(file) + examine_package.check_dsc(file) finally: sys.stdout = stdout_fd except IOError, e: if errno.errorcode[e.errno] == 'EPIPE': - utils.warn("[fernanda] Caught EPIPE; skipping.") + dak.lib.utils.warn("[examine_package] Caught EPIPE; skipping.") pass else: raise except KeyboardInterrupt: - utils.warn("[fernanda] Caught C-c; skipping.") + dak.lib.utils.warn("[examine_package] Caught C-c; skipping.") pass ################################################################################ @@ -603,30 +600,30 @@ def check_pkg (): ## FIXME: horribly Debian specific def do_bxa_notification(): - files = Katie.pkg.files + files = Upload.pkg.files summary = "" for file in files.keys(): if files[file]["type"] == "deb": - control = apt_pkg.ParseSection(apt_inst.debExtractControl(utils.open_file(file))) + control = apt_pkg.ParseSection(apt_inst.debExtractControl(dak.lib.utils.open_file(file))) summary += "\n" summary += "Package: %s\n" % (control.Find("Package")) summary += "Description: %s\n" % (control.Find("Description")) - Katie.Subst["__BINARY_DESCRIPTIONS__"] = summary - bxa_mail = utils.TemplateSubst(Katie.Subst,Cnf["Dir::Templates"]+"/lisa.bxa_notification") - utils.send_mail(bxa_mail) + Upload.Subst["__BINARY_DESCRIPTIONS__"] = summary + bxa_mail = dak.lib.utils.TemplateSubst(Upload.Subst,Cnf["Dir::Templates"]+"/process-new.bxa_notification") + dak.lib.utils.send_mail(bxa_mail) ################################################################################ def add_overrides (new): - changes = Katie.pkg.changes - files = Katie.pkg.files + changes = Upload.pkg.changes + files = Upload.pkg.files projectB.query("BEGIN WORK") for suite in changes["suite"].keys(): - suite_id = db_access.get_suite_id(suite) + suite_id = dak.lib.database.get_suite_id(suite) for pkg in new.keys(): - component_id = db_access.get_component_id(new[pkg]["component"]) - type_id = db_access.get_override_type_id(new[pkg]["type"]) + component_id = dak.lib.database.get_component_id(new[pkg]["component"]) + type_id = dak.lib.database.get_override_type_id(new[pkg]["type"]) priority_id = new[pkg]["priority id"] section_id = new[pkg]["section id"] projectB.query("INSERT INTO override (suite, component, type, package, priority, section, maintainer) VALUES (%s, %s, %s, '%s', %s, %s, '')" % (suite_id, component_id, type_id, pkg, priority_id, section_id)) @@ -644,21 +641,21 @@ def add_overrides (new): def prod_maintainer (): # Here we prepare an editor and get them ready to prod... - temp_filename = utils.temp_filename() + temp_filename = dak.lib.utils.temp_filename() editor = os.environ.get("EDITOR","vi") answer = 'E' while answer == 'E': os.system("%s %s" % (editor, temp_filename)) - file = utils.open_file(temp_filename) + file = dak.lib.utils.open_file(temp_filename) prod_message = "".join(file.readlines()) file.close() print "Prod message:" - print utils.prefix_multi_line_string(prod_message," ",include_blank_lines=1) + print dak.lib.utils.prefix_multi_line_string(prod_message," ",include_blank_lines=1) prompt = "[P]rod, Edit, Abandon, Quit ?" answer = "XXX" while prompt.find(answer) == -1: - answer = utils.our_raw_input(prompt) - m = katie.re_default_answer.search(prompt) + answer = dak.lib.utils.our_raw_input(prompt) + m = dak.lib.queue.re_default_answer.search(prompt) if answer == "": answer = m.group(1) answer = answer[:1].upper() @@ -668,21 +665,21 @@ def prod_maintainer (): elif answer == 'Q': sys.exit(0) # Otherwise, do the proding... - user_email_address = utils.whoami() + " <%s>" % ( + user_email_address = dak.lib.utils.whoami() + " <%s>" % ( Cnf["Dinstall::MyAdminAddress"]) - Subst = Katie.Subst + Subst = Upload.Subst Subst["__FROM_ADDRESS__"] = user_email_address Subst["__PROD_MESSAGE__"] = prod_message Subst["__CC__"] = "Cc: " + Cnf["Dinstall::MyEmailAddress"] - prod_mail_message = utils.TemplateSubst( - Subst,Cnf["Dir::Templates"]+"/lisa.prod") + prod_mail_message = dak.lib.utils.TemplateSubst( + Subst,Cnf["Dir::Templates"]+"/process-new.prod") # Send the prod mail if appropriate if not Cnf["Dinstall::Options::No-Mail"]: - utils.send_mail(prod_mail_message) + dak.lib.utils.send_mail(prod_mail_message) print "Sent proding message" @@ -690,8 +687,8 @@ def prod_maintainer (): def do_new(): print "NEW\n" - files = Katie.pkg.files - changes = Katie.pkg.changes + files = Upload.pkg.files + changes = Upload.pkg.changes # Make a copy of distribution we can happily trample on changes["suite"] = copy.copy(changes["distribution"]) @@ -704,9 +701,9 @@ def do_new(): changes["suite"][override] = 1 # Validate suites for suite in changes["suite"].keys(): - suite_id = db_access.get_suite_id(suite) + suite_id = dak.lib.database.get_suite_id(suite) if suite_id == -1: - utils.fubar("%s has invalid suite '%s' (possibly overriden). say wha?" % (changes, suite)) + dak.lib.utils.fubar("%s has invalid suite '%s' (possibly overriden). say wha?" % (changes, suite)) # The main NEW processing loop done = 0 @@ -735,8 +732,8 @@ def do_new(): prompt += "Edit overrides, Check, Manual reject, Note edit, Prod, [S]kip, Quit ?" while prompt.find(answer) == -1: - answer = utils.our_raw_input(prompt) - m = katie.re_default_answer.search(prompt) + answer = dak.lib.utils.our_raw_input(prompt) + m = dak.lib.queue.re_default_answer.search(prompt) if answer == "": answer = m.group(1) answer = answer[:1].upper() @@ -748,18 +745,18 @@ def do_new(): elif answer == 'E': new = edit_overrides (new) elif answer == 'M': - aborted = Katie.do_reject(1, Options["Manual-Reject"]) + aborted = Upload.do_reject(1, Options["Manual-Reject"]) if not aborted: - os.unlink(Katie.pkg.changes_file[:-8]+".katie") + os.unlink(Upload.pkg.changes_file[:-8]+".dak") done = 1 elif answer == 'N': - edit_note(changes.get("lisa note", "")) + edit_note(changes.get("process-new note", "")) elif answer == 'P': prod_maintainer() elif answer == 'R': - confirm = utils.our_raw_input("Really clear note (y/N)? ").lower() + confirm = dak.lib.utils.our_raw_input("Really clear note (y/N)? ").lower() if confirm == "y": - del changes["lisa note"] + del changes["process-new note"] elif answer == 'S': done = 1 elif answer == 'Q': @@ -770,7 +767,7 @@ def do_new(): ################################################################################ def usage (exit_code=0): - print """Usage: lisa [OPTION]... [CHANGES]... + print """Usage: dak process-new [OPTION]... [CHANGES]... -a, --automatic automatic run -h, --help show this help and exit. -m, --manual-reject=MSG manual reject with `msg' @@ -781,36 +778,31 @@ def usage (exit_code=0): ################################################################################ def init(): - global Cnf, Options, Logger, Katie, projectB, Sections, Priorities + global Cnf, Options, Logger, Upload, projectB, Sections, Priorities - Cnf = utils.get_conf() + Cnf = dak.lib.utils.get_conf() - Arguments = [('a',"automatic","Lisa::Options::Automatic"), - ('h',"help","Lisa::Options::Help"), - ('m',"manual-reject","Lisa::Options::Manual-Reject", "HasArg"), - ('n',"no-action","Lisa::Options::No-Action"), - ('V',"version","Lisa::Options::Version")] + Arguments = [('a',"automatic","Process-New::Options::Automatic"), + ('h',"help","Process-New::Options::Help"), + ('m',"manual-reject","Process-New::Options::Manual-Reject", "HasArg"), + ('n',"no-action","Process-New::Options::No-Action")] for i in ["automatic", "help", "manual-reject", "no-action", "version"]: - if not Cnf.has_key("Lisa::Options::%s" % (i)): - Cnf["Lisa::Options::%s" % (i)] = "" + if not Cnf.has_key("Process-New::Options::%s" % (i)): + Cnf["Process-New::Options::%s" % (i)] = "" changes_files = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv) - Options = Cnf.SubTree("Lisa::Options") + Options = Cnf.SubTree("Process-New::Options") if Options["Help"]: usage() - if Options["Version"]: - print "lisa %s" % (lisa_version) - sys.exit(0) - - Katie = katie.Katie(Cnf) + Upload = dak.lib.queue.Upload(Cnf) if not Options["No-Action"]: - Logger = Katie.Logger = logging.Logger(Cnf, "lisa") + Logger = Upload.Logger = dak.lib.logging.Logger(Cnf, "process-new") - projectB = Katie.projectB + projectB = Upload.projectB Sections = Section_Completer() Priorities = Priority_Completer() @@ -823,7 +815,7 @@ def init(): def do_byhand(): done = 0 while not done: - files = Katie.pkg.files + files = Upload.pkg.files will_install = 1 byhand = [] @@ -846,8 +838,8 @@ def do_byhand(): prompt = "Manual reject, [S]kip, Quit ?" while prompt.find(answer) == -1: - answer = utils.our_raw_input(prompt) - m = katie.re_default_answer.search(prompt) + answer = dak.lib.utils.our_raw_input(prompt) + m = dak.lib.queue.re_default_answer.search(prompt) if answer == "": answer = m.group(1) answer = answer[:1].upper() @@ -857,8 +849,8 @@ def do_byhand(): for file in byhand: del files[file] elif answer == 'M': - Katie.do_reject(1, Options["Manual-Reject"]) - os.unlink(Katie.pkg.changes_file[:-8]+".katie") + Upload.do_reject(1, Options["Manual-Reject"]) + os.unlink(Upload.pkg.changes_file[:-8]+".dak") done = 1 elif answer == 'S': done = 1 @@ -873,22 +865,22 @@ def do_accept(): retry = 0 while retry < 10: try: - lock_fd = os.open(Cnf["Lisa::AcceptedLockFile"], os.O_RDONLY | os.O_CREAT | os.O_EXCL) + lock_fd = os.open(Cnf["Process-New::AcceptedLockFile"], os.O_RDONLY | os.O_CREAT | os.O_EXCL) retry = 10 except OSError, e: if errno.errorcode[e.errno] == 'EACCES' or errno.errorcode[e.errno] == 'EEXIST': retry += 1 if (retry >= 10): - utils.fubar("Couldn't obtain lock; assuming jennifer is already running.") + dak.lib.utils.fubar("Couldn't obtain lock; assuming 'dak process-unchecked' is already running.") else: print("Unable to get accepted lock (try %d of 10)" % retry) time.sleep(60) else: raise - (summary, short_summary) = Katie.build_summaries() - Katie.accept(summary, short_summary) - os.unlink(Katie.pkg.changes_file[:-8]+".katie") - os.unlink(Cnf["Lisa::AcceptedLockFile"]) + (summary, short_summary) = Upload.build_summaries() + Upload.accept(summary, short_summary) + os.unlink(Upload.pkg.changes_file[:-8]+".dak") + os.unlink(Cnf["Process-New::AcceptedLockFile"]) def check_status(files): new = byhand = 0 @@ -900,11 +892,11 @@ def check_status(files): return (new, byhand) def do_pkg(changes_file): - Katie.pkg.changes_file = changes_file - Katie.init_vars() - Katie.update_vars() - Katie.update_subst() - files = Katie.pkg.files + Upload.pkg.changes_file = changes_file + Upload.init_vars() + Upload.update_vars() + Upload.update_subst() + files = Upload.pkg.files if not recheck(): return @@ -923,14 +915,14 @@ def do_pkg(changes_file): ################################################################################ def end(): - accept_count = Katie.accept_count - accept_bytes = Katie.accept_bytes + accept_count = Upload.accept_count + accept_bytes = Upload.accept_bytes if accept_count: sets = "set" if accept_count > 1: sets = "sets" - sys.stderr.write("Accepted %d package %s, %s.\n" % (accept_count, sets, utils.size_type(int(accept_bytes)))) + sys.stderr.write("Accepted %d package %s, %s.\n" % (accept_count, sets, dak.lib.utils.size_type(int(accept_bytes)))) Logger.log(["total",accept_count,accept_bytes]) if not Options["No-Action"]: @@ -946,14 +938,14 @@ def main(): # Kill me now? **FIXME** Cnf["Dinstall::Options::No-Mail"] = "" - bcc = "X-Katie: lisa %s" % (lisa_version) + bcc = "X-DAK: dak process-new\nX-Katie: this header is obsolete" if Cnf.has_key("Dinstall::Bcc"): - Katie.Subst["__BCC__"] = bcc + "\nBcc: %s" % (Cnf["Dinstall::Bcc"]) + Upload.Subst["__BCC__"] = bcc + "\nBcc: %s" % (Cnf["Dinstall::Bcc"]) else: - Katie.Subst["__BCC__"] = bcc + Upload.Subst["__BCC__"] = bcc for changes_file in changes_files: - changes_file = utils.validate_changes_file_arg(changes_file, 0) + changes_file = dak.lib.utils.validate_changes_file_arg(changes_file, 0) if not changes_file: continue print "\n" + changes_file diff --git a/dak/process_unchecked.py b/dak/process_unchecked.py index 1d87447a..32eda9ec 100755 --- a/dak/process_unchecked.py +++ b/dak/process_unchecked.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # Checks Debian packages from Incoming -# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 James Troup -# $Id: jennifer,v 1.65 2005-12-05 05:35:47 ajt Exp $ +# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 James Troup # 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 @@ -31,7 +30,7 @@ import commands, errno, fcntl, os, re, shutil, stat, sys, time, tempfile, traceback import apt_inst, apt_pkg -import db_access, katie, logging, utils +import dak.lib.database, dak.lib.queue, dak.lib.logging, dak.lib.utils from types import * @@ -45,17 +44,15 @@ re_strip_revision = re.compile(r"-([^-]+)$") ################################################################################ # Globals -jennifer_version = "$Revision: 1.65 $" - Cnf = None Options = None Logger = None -Katie = None +Upload = None reprocess = 0 in_holding = {} -# Aliases to the real vars in the Katie class; hysterical raisins. +# Aliases to the real vars in the Upload class; hysterical raisins. reject_message = "" changes = {} dsc = {} @@ -66,19 +63,18 @@ pkg = {} ############################################################################### def init(): - global Cnf, Options, Katie, changes, dsc, dsc_files, files, pkg + global Cnf, Options, Upload, changes, dsc, dsc_files, files, pkg apt_pkg.init() Cnf = apt_pkg.newConfiguration() - apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()) + apt_pkg.ReadConfigFileISC(Cnf,dak.lib.utils.which_conf_file()) Arguments = [('a',"automatic","Dinstall::Options::Automatic"), ('h',"help","Dinstall::Options::Help"), ('n',"no-action","Dinstall::Options::No-Action"), ('p',"no-lock", "Dinstall::Options::No-Lock"), - ('s',"no-mail", "Dinstall::Options::No-Mail"), - ('V',"version","Dinstall::Options::Version")] + ('s',"no-mail", "Dinstall::Options::No-Mail")] for i in ["automatic", "help", "no-action", "no-lock", "no-mail", "override-distribution", "version"]: @@ -89,17 +85,14 @@ def init(): if Options["Help"]: usage() - elif Options["Version"]: - print "jennifer %s" % (jennifer_version) - sys.exit(0) - Katie = katie.Katie(Cnf) + Upload = dak.lib.queue.Queue(Cnf) - changes = Katie.pkg.changes - dsc = Katie.pkg.dsc - dsc_files = Katie.pkg.dsc_files - files = Katie.pkg.files - pkg = Katie.pkg + changes = Upload.pkg.changes + dsc = Upload.pkg.dsc + dsc_files = Upload.pkg.dsc_files + files = Upload.pkg.files + pkg = Upload.pkg return changes_files @@ -169,7 +162,7 @@ def clean_holding(): for file in in_holding.keys(): if os.path.exists(file): if file.find('/') != -1: - utils.fubar("WTF? clean_holding() got a file ('%s') with / in it!" % (file)) + dak.lib.utils.fubar("WTF? clean_holding() got a file ('%s') with / in it!" % (file)) else: os.unlink(file) in_holding = {} @@ -182,20 +175,20 @@ def check_changes(): # Parse the .changes field into a dictionary try: - changes.update(utils.parse_changes(filename)) - except utils.cant_open_exc: + changes.update(dak.lib.utils.parse_changes(filename)) + except dak.lib.utils.cant_open_exc: reject("%s: can't read file." % (filename)) return 0 - except utils.changes_parse_error_exc, line: + except dak.lib.utils.changes_parse_error_exc, line: reject("%s: parse error, can't grok: %s." % (filename, line)) return 0 # Parse the Files field from the .changes into another dictionary try: - files.update(utils.build_file_list(changes)) - except utils.changes_parse_error_exc, line: + files.update(dak.lib.utils.build_file_list(changes)) + except dak.lib.utils.changes_parse_error_exc, line: reject("%s: parse error, can't grok: %s." % (filename, line)) - except utils.nk_format_exc, format: + except dak.lib.utils.nk_format_exc, format: reject("%s: unknown format '%s'." % (filename, format)) return 0 @@ -219,8 +212,8 @@ def check_changes(): try: (changes["maintainer822"], changes["maintainer2047"], changes["maintainername"], changes["maintaineremail"]) = \ - utils.fix_maintainer (changes["maintainer"]) - except utils.ParseMaintError, msg: + dak.lib.utils.fix_maintainer (changes["maintainer"]) + except dak.lib.utils.ParseMaintError, msg: reject("%s: Maintainer field ('%s') failed to parse: %s" \ % (filename, changes["maintainer"], msg)) @@ -228,8 +221,8 @@ def check_changes(): try: (changes["changedby822"], changes["changedby2047"], changes["changedbyname"], changes["changedbyemail"]) = \ - utils.fix_maintainer (changes.get("changed-by", "")) - except utils.ParseMaintError, msg: + dak.lib.utils.fix_maintainer (changes.get("changed-by", "")) + except dak.lib.utils.ParseMaintError, msg: (changes["changedby822"], changes["changedby2047"], changes["changedbyname"], changes["changedbyemail"]) = \ ("", "", "", "") @@ -239,13 +232,13 @@ def check_changes(): # Ensure all the values in Closes: are numbers if changes.has_key("closes"): for i in changes["closes"].keys(): - if katie.re_isanum.match (i) == None: + if dak.lib.queue.re_isanum.match (i) == None: reject("%s: `%s' from Closes field isn't a number." % (filename, i)) # chopversion = no epoch; chopversion2 = no epoch and no revision (e.g. for .orig.tar.gz comparison) - changes["chopversion"] = utils.re_no_epoch.sub('', changes["version"]) - changes["chopversion2"] = utils.re_no_revision.sub('', changes["chopversion"]) + changes["chopversion"] = dak.lib.utils.re_no_epoch.sub('', changes["version"]) + changes["chopversion2"] = dak.lib.utils.re_no_revision.sub('', changes["chopversion"]) # Check there isn't already a changes file of the same name in one # of the queue directories. @@ -331,7 +324,7 @@ Pre-Depends on dpkg (>= 1.10.24).""" (result, output) = commands.getstatusoutput(cmd) if result != 0: reject("%s: 'ar t' invocation failed." % (filename)) - reject(utils.prefix_multi_line_string(output, " [ar output:] "), "") + reject(dak.lib.utils.prefix_multi_line_string(output, " [ar output:] "), "") chunks = output.split('\n') if len(chunks) != 3: reject("%s: found %d chunks, expected 3." % (filename, len(chunks))) @@ -362,7 +355,7 @@ Pre-Depends on dpkg (>= 1.10.24).""" def check_files(): global reprocess - archive = utils.where_am_i() + archive = dak.lib.utils.where_am_i() file_keys = files.keys() # if reprocess is 2 we've already done this and we're checking @@ -375,11 +368,11 @@ def check_files(): copy_to_holding(file) os.chdir(cwd) - # Check there isn't already a .changes or .katie file of the same name in - # the proposed-updates "CopyChanges" or "CopyKatie" storage directories. + # Check there isn't already a .changes or .dak file of the same name in + # the proposed-updates "CopyChanges" or "CopyDotDak" storage directories. # [NB: this check must be done post-suite mapping] base_filename = os.path.basename(pkg.changes_file) - katie_filename = base_filename[:-8]+".katie" + dot_dak_filename = base_filename[:-8]+".dak" for suite in changes["distribution"].keys(): copychanges = "Suite::%s::CopyChanges" % (suite) if Cnf.has_key(copychanges) and \ @@ -387,11 +380,11 @@ def check_files(): reject("%s: a file with this name already exists in %s" \ % (base_filename, Cnf[copychanges])) - copykatie = "Suite::%s::CopyKatie" % (suite) - if Cnf.has_key(copykatie) and \ - os.path.exists(Cnf[copykatie]+"/"+katie_filename): + copy_dot_dak = "Suite::%s::CopyDotDak" % (suite) + if Cnf.has_key(copy_dot_dak) and \ + os.path.exists(Cnf[copy_dot_dak]+"/"+dot_dak_filename): reject("%s: a file with this name already exists in %s" \ - % (katie_filename, Cnf[copykatie])) + % (dot_dak_filename, Cnf[copy_dot_dak])) reprocess = 0 has_binaries = 0 @@ -402,7 +395,7 @@ def check_files(): for dir in [ "Accepted", "Byhand", "New" ]: if os.path.exists(Cnf["Dir::Queue::%s" % (dir) ]+'/'+file): reject("%s file already exists in the %s directory." % (file, dir)) - if not utils.re_taint_free.match(file): + if not dak.lib.utils.re_taint_free.match(file): reject("!!WARNING!! tainted filename: '%s'." % (file)) # Check the file is readable if os.access(file,os.R_OK) == 0: @@ -420,12 +413,12 @@ def check_files(): files[file]["byhand"] = 1 files[file]["type"] = "byhand" # Checks for a binary package... - elif utils.re_isadeb.match(file): + elif dak.lib.utils.re_isadeb.match(file): has_binaries = 1 files[file]["type"] = "deb" # Extract package control information - deb_file = utils.open_file(file) + deb_file = dak.lib.utils.open_file(file) try: control = apt_pkg.ParseSection(apt_inst.debExtractControl(deb_file)) except: @@ -493,7 +486,7 @@ def check_files(): source = files[file]["source"] source_version = "" if source.find("(") != -1: - m = utils.re_extract_src_version.match(source) + m = dak.lib.utils.re_extract_src_version.match(source) source = m.group(1) source_version = m.group(2) if not source_version: @@ -502,12 +495,12 @@ def check_files(): files[file]["source version"] = source_version # Ensure the filename matches the contents of the .deb - m = utils.re_isadeb.match(file) + m = dak.lib.utils.re_isadeb.match(file) # package name file_package = m.group(1) if files[file]["package"] != file_package: reject("%s: package part of filename (%s) does not match package name in the %s (%s)." % (file, file_package, files[file]["dbtype"], files[file]["package"])) - epochless_version = utils.re_no_epoch.sub('', control.Find("Version")) + epochless_version = dak.lib.utils.re_no_epoch.sub('', control.Find("Version")) # version file_version = m.group(2) if epochless_version != file_version: @@ -525,9 +518,9 @@ def check_files(): reject("source version (%s) for %s doesn't match changes version %s." % (source_version, file, changes["version"])) else: # Check in the SQL database - if not Katie.source_exists(source_package, source_version, changes["distribution"].keys()): + if not Upload.source_exists(source_package, source_version, changes["distribution"].keys()): # Check in one of the other directories - source_epochless_version = utils.re_no_epoch.sub('', source_version) + source_epochless_version = dak.lib.utils.re_no_epoch.sub('', source_version) dsc_filename = "%s_%s.dsc" % (source_package, source_epochless_version) if os.path.exists(Cnf["Dir::Queue::Byhand"] + '/' + dsc_filename): files[file]["byhand"] = 1 @@ -536,13 +529,13 @@ def check_files(): elif not os.path.exists(Cnf["Dir::Queue::Accepted"] + '/' + dsc_filename): reject("no source found for %s %s (%s)." % (source_package, source_version, file)) # Check the version and for file overwrites - reject(Katie.check_binary_against_db(file),"") + reject(Upload.check_binary_against_db(file),"") check_deb_ar(file, control) # Checks for a source package... else: - m = utils.re_issource.match(file) + m = dak.lib.utils.re_issource.match(file) if m: has_source = 1 files[file]["package"] = m.group(1) @@ -567,7 +560,7 @@ def check_files(): # Check the signature of a .dsc file if files[file]["type"] == "dsc": - dsc["fingerprint"] = utils.check_signature(file, reject) + dsc["fingerprint"] = dak.lib.utils.check_signature(file, reject) files[file]["architecture"] = "source" @@ -598,13 +591,13 @@ def check_files(): # Validate the component component = files[file]["component"] - component_id = db_access.get_component_id(component) + component_id = dak.lib.database.get_component_id(component) if component_id == -1: reject("file '%s' has unknown component '%s'." % (file, component)) continue # See if the package is NEW - if not Katie.in_override_p(files[file]["package"], files[file]["component"], suite, files[file].get("dbtype",""), file): + if not Upload.in_override_p(files[file]["package"], files[file]["component"], suite, files[file].get("dbtype",""), file): files[file]["new"] = 1 # Validate the priority @@ -613,14 +606,14 @@ def check_files(): # Determine the location location = Cnf["Dir::Pool"] - location_id = db_access.get_location_id (location, component, archive) + location_id = dak.lib.database.get_location_id (location, component, archive) if location_id == -1: reject("[INTERNAL ERROR] couldn't determine location (Component: %s, Archive: %s)" % (component, archive)) files[file]["location id"] = location_id # Check the md5sum & size against existing files (if any) - files[file]["pool name"] = utils.poolify (changes["source"], files[file]["component"]) - files_id = db_access.get_files_id(files[file]["pool name"] + file, files[file]["size"], files[file]["md5sum"], files[file]["location id"]) + files[file]["pool name"] = dak.lib.utils.poolify (changes["source"], files[file]["component"]) + files_id = dak.lib.database.get_files_id(files[file]["pool name"] + file, files[file]["size"], files[file]["md5sum"], files[file]["location id"]) if files_id == -1: reject("INTERNAL ERROR, get_files_id() returned multiple matches for %s." % (file)) elif files_id == -2: @@ -628,7 +621,7 @@ def check_files(): files[file]["files id"] = files_id # Check for packages that have moved from one component to another - q = Katie.projectB.query(""" + q = Upload.projectB.query(""" SELECT c.name FROM binaries b, bin_associations ba, suite s, location l, component c, architecture a, files f WHERE b.package = '%s' AND s.suite_name = '%s' @@ -675,22 +668,22 @@ def check_dsc(): # Parse the .dsc file try: - dsc.update(utils.parse_changes(dsc_filename, signing_rules=1)) - except utils.cant_open_exc: + dsc.update(dak.lib.utils.parse_changes(dsc_filename, signing_rules=1)) + except dak.lib.utils.cant_open_exc: # if not -n copy_to_holding() will have done this for us... if Options["No-Action"]: reject("%s: can't read file." % (dsc_filename)) - except utils.changes_parse_error_exc, line: + except dak.lib.utils.changes_parse_error_exc, line: reject("%s: parse error, can't grok: %s." % (dsc_filename, line)) - except utils.invalid_dsc_format_exc, line: + except dak.lib.utils.invalid_dsc_format_exc, line: reject("%s: syntax error on line %s." % (dsc_filename, line)) # Build up the file list of files mentioned by the .dsc try: - dsc_files.update(utils.build_file_list(dsc, is_a_dsc=1)) - except utils.no_files_exc: + dsc_files.update(dak.lib.utils.build_file_list(dsc, is_a_dsc=1)) + except dak.lib.utils.no_files_exc: reject("%s: no Files: field." % (dsc_filename)) return 0 - except utils.changes_parse_error_exc, line: + except dak.lib.utils.changes_parse_error_exc, line: reject("%s: parse error, can't grok: %s." % (dsc_filename, line)) return 0 @@ -713,8 +706,8 @@ def check_dsc(): # Validate the Maintainer field try: - utils.fix_maintainer (dsc["maintainer"]) - except utils.ParseMaintError, msg: + dak.lib.utils.fix_maintainer (dsc["maintainer"]) + except dak.lib.utils.ParseMaintError, msg: reject("%s: Maintainer field ('%s') failed to parse: %s" \ % (dsc_filename, dsc["maintainer"], msg)) @@ -734,7 +727,7 @@ def check_dsc(): pass # Ensure the version number in the .dsc matches the version number in the .changes - epochless_dsc_version = utils.re_no_epoch.sub('', dsc["version"]) + epochless_dsc_version = dak.lib.utils.re_no_epoch.sub('', dsc["version"]) changes_version = files[dsc_filename]["version"] if epochless_dsc_version != files[dsc_filename]["version"]: reject("version ('%s') in .dsc does not match version ('%s') in .changes." % (epochless_dsc_version, changes_version)) @@ -742,7 +735,7 @@ def check_dsc(): # Ensure there is a .tar.gz in the .dsc file has_tar = 0 for f in dsc_files.keys(): - m = utils.re_issource.match(f) + m = dak.lib.utils.re_issource.match(f) if not m: reject("%s: %s in Files field not recognised as source." % (dsc_filename, f)) type = m.group(3) @@ -752,9 +745,9 @@ def check_dsc(): reject("%s: no .tar.gz or .orig.tar.gz in 'Files' field." % (dsc_filename)) # Ensure source is newer than existing source in target suites - reject(Katie.check_source_against_db(dsc_filename),"") + reject(Upload.check_source_against_db(dsc_filename),"") - (reject_msg, is_in_incoming) = Katie.check_dsc_against_db(dsc_filename) + (reject_msg, is_in_incoming) = Upload.check_dsc_against_db(dsc_filename) reject(reject_msg, "") if is_in_incoming: if not Options["No-Action"]: @@ -789,7 +782,7 @@ def get_changelog_versions(source_dir): # Create a symlink mirror of the source files in our temporary directory for f in files.keys(): - m = utils.re_issource.match(f) + m = dak.lib.utils.re_issource.match(f) if m: src = os.path.join(source_dir, f) # If a file is missing for whatever reason, give up. @@ -812,14 +805,14 @@ def get_changelog_versions(source_dir): (result, output) = commands.getstatusoutput(cmd) if (result != 0): reject("'dpkg-source -x' failed for %s [return code: %s]." % (dsc_filename, result)) - reject(utils.prefix_multi_line_string(output, " [dpkg-source output:] "), "") + reject(dak.lib.utils.prefix_multi_line_string(output, " [dpkg-source output:] "), "") return if not Cnf.Find("Dir::Queue::BTSVersionTrack"): return # Get the upstream version - upstr_version = utils.re_no_epoch.sub('', dsc["version"]) + upstr_version = dak.lib.utils.re_no_epoch.sub('', dsc["version"]) if re_strip_revision.search(upstr_version): upstr_version = re_strip_revision.sub('', upstr_version) @@ -831,7 +824,7 @@ def get_changelog_versions(source_dir): # Parse the changelog dsc["bts changelog"] = "" - changelog_file = utils.open_file(changelog_filename) + changelog_file = dak.lib.utils.open_file(changelog_filename) for line in changelog_file.readlines(): m = re_changelog_versions.match(line) if m: @@ -874,7 +867,7 @@ def check_source(): shutil.rmtree(tmpdir) except OSError, e: if errno.errorcode[e.errno] != 'EACCES': - utils.fubar("%s: couldn't remove tmp dir for source tree." % (dsc["source"])) + dak.lib.utils.fubar("%s: couldn't remove tmp dir for source tree." % (dsc["source"])) reject("%s: source tree could not be cleanly removed." % (dsc["source"])) # We probably have u-r or u-w directories so chmod everything @@ -882,10 +875,10 @@ def check_source(): cmd = "chmod -R u+rwx %s" % (tmpdir) result = os.system(cmd) if result != 0: - utils.fubar("'%s' failed with result %s." % (cmd, result)) + dak.lib.utils.fubar("'%s' failed with result %s." % (cmd, result)) shutil.rmtree(tmpdir) except: - utils.fubar("%s: couldn't remove tmp dir for source tree." % (dsc["source"])) + dak.lib.utils.fubar("%s: couldn't remove tmp dir for source tree." % (dsc["source"])) ################################################################################ @@ -905,8 +898,8 @@ def check_urgency (): def check_md5sums (): for file in files.keys(): try: - file_handle = utils.open_file(file) - except utils.cant_open_exc: + file_handle = dak.lib.utils.open_file(file) + except dak.lib.utils.cant_open_exc: continue # Check md5sum @@ -922,8 +915,8 @@ def check_md5sums (): for file in dsc_files.keys(): try: - file_handle = utils.open_file(file) - except utils.cant_open_exc: + file_handle = dak.lib.utils.open_file(file) + except dak.lib.utils.cant_open_exc: continue # Check md5sum @@ -968,7 +961,7 @@ def check_timestamps(): if files[filename]["type"] == "deb": tar.reset() try: - deb_file = utils.open_file(filename) + deb_file = dak.lib.utils.open_file(filename) apt_inst.debExtract(deb_file,tar.callback,"control.tar.gz") deb_file.seek(0) try: @@ -1034,7 +1027,7 @@ def action (): if not changes.has_key("distribution") or not isinstance(changes["distribution"], DictType): changes["distribution"] = {} - (summary, short_summary) = Katie.build_summaries() + (summary, short_summary) = Upload.build_summaries() # q-unapproved hax0ring queue_info = { @@ -1087,15 +1080,15 @@ def action (): answer = 'A' while prompt.find(answer) == -1: - answer = utils.our_raw_input(prompt) - m = katie.re_default_answer.match(prompt) + answer = dak.lib.utils.our_raw_input(prompt) + m = dak.lib.queue.re_default_answer.match(prompt) if answer == "": answer = m.group(1) answer = answer[:1].upper() if answer == 'R': os.chdir (pkg.directory) - Katie.do_reject(0, reject_message) + Upload.do_reject(0, reject_message) elif answer == 'A': accept(summary, short_summary) remove_from_unchecked() @@ -1114,21 +1107,21 @@ def remove_from_unchecked(): ################################################################################ def accept (summary, short_summary): - Katie.accept(summary, short_summary) - Katie.check_override() + Upload.accept(summary, short_summary) + Upload.check_override() ################################################################################ def move_to_dir (dest, perms=0660, changesperms=0664): - utils.move (pkg.changes_file, dest, perms=changesperms) + dak.lib.utils.move (pkg.changes_file, dest, perms=changesperms) file_keys = files.keys() for file in file_keys: - utils.move (file, dest, perms=perms) + dak.lib.utils.move (file, dest, perms=perms) ################################################################################ def is_unembargo (): - q = Katie.projectB.query( + q = Upload.projectB.query( "SELECT package FROM disembargo WHERE package = '%s' AND version = '%s'" % (changes["source"], changes["version"])) ql = q.getresult() @@ -1139,7 +1132,7 @@ def is_unembargo (): if changes["architecture"].has_key("source"): if Options["No-Action"]: return 1 - Katie.projectB.query( + Upload.projectB.query( "INSERT INTO disembargo (package, version) VALUES ('%s', '%s')" % (changes["source"], changes["version"])) return 1 @@ -1150,13 +1143,13 @@ def queue_unembargo (summary): print "Moving to UNEMBARGOED holding area." Logger.log(["Moving to unembargoed", pkg.changes_file]) - Katie.dump_vars(Cnf["Dir::Queue::Unembargoed"]) + Upload.dump_vars(Cnf["Dir::Queue::Unembargoed"]) move_to_dir(Cnf["Dir::Queue::Unembargoed"]) - Katie.queue_build("unembargoed", Cnf["Dir::Queue::Unembargoed"]) + Upload.queue_build("unembargoed", Cnf["Dir::Queue::Unembargoed"]) # Check for override disparities - Katie.Subst["__SUMMARY__"] = summary - Katie.check_override() + Upload.Subst["__SUMMARY__"] = summary + Upload.check_override() ################################################################################ @@ -1167,13 +1160,13 @@ def queue_embargo (summary): print "Moving to EMBARGOED holding area." Logger.log(["Moving to embargoed", pkg.changes_file]) - Katie.dump_vars(Cnf["Dir::Queue::Embargoed"]) + Upload.dump_vars(Cnf["Dir::Queue::Embargoed"]) move_to_dir(Cnf["Dir::Queue::Embargoed"]) - Katie.queue_build("embargoed", Cnf["Dir::Queue::Embargoed"]) + Upload.queue_build("embargoed", Cnf["Dir::Queue::Embargoed"]) # Check for override disparities - Katie.Subst["__SUMMARY__"] = summary - Katie.check_override() + Upload.Subst["__SUMMARY__"] = summary + Upload.check_override() ################################################################################ @@ -1187,12 +1180,12 @@ def do_byhand (summary): print "Moving to BYHAND holding area." Logger.log(["Moving to byhand", pkg.changes_file]) - Katie.dump_vars(Cnf["Dir::Queue::Byhand"]) + Upload.dump_vars(Cnf["Dir::Queue::Byhand"]) move_to_dir(Cnf["Dir::Queue::Byhand"]) # Check for override disparities - Katie.Subst["__SUMMARY__"] = summary - Katie.check_override() + Upload.Subst["__SUMMARY__"] = summary + Upload.check_override() ################################################################################ @@ -1203,37 +1196,37 @@ def is_new (): return 0 def acknowledge_new (summary): - Subst = Katie.Subst + Subst = Upload.Subst print "Moving to NEW holding area." Logger.log(["Moving to new", pkg.changes_file]) - Katie.dump_vars(Cnf["Dir::Queue::New"]) + Upload.dump_vars(Cnf["Dir::Queue::New"]) move_to_dir(Cnf["Dir::Queue::New"]) if not Options["No-Mail"]: print "Sending new ack." Subst["__SUMMARY__"] = summary - new_ack_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/jennifer.new") - utils.send_mail(new_ack_message) + new_ack_message = dak.lib.utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/process-unchecked.new") + dak.lib.utils.send_mail(new_ack_message) ################################################################################ # reprocess is necessary for the case of foo_1.2-1 and foo_1.2-2 in # Incoming. -1 will reference the .orig.tar.gz, but -2 will not. -# Katie.check_dsc_against_db() can find the .orig.tar.gz but it will +# Upload.check_dsc_against_db() can find the .orig.tar.gz but it will # not have processed it during it's checks of -2. If -1 has been -# deleted or otherwise not checked by jennifer, the .orig.tar.gz will -# not have been checked at all. To get round this, we force the -# .orig.tar.gz into the .changes structure and reprocess the .changes -# file. +# deleted or otherwise not checked by 'dak process-unchecked', the +# .orig.tar.gz will not have been checked at all. To get round this, +# we force the .orig.tar.gz into the .changes structure and reprocess +# the .changes file. def process_it (changes_file): global reprocess, reject_message # Reset some globals reprocess = 1 - Katie.init_vars() + Upload.init_vars() # Some defaults in case we can't fully process the .changes file changes["maintainer2047"] = Cnf["Dinstall::MyEmailAddress"] changes["changedby2047"] = Cnf["Dinstall::MyEmailAddress"] @@ -1256,7 +1249,7 @@ def process_it (changes_file): # Relativize the filename so we use the copy in holding # rather than the original... pkg.changes_file = os.path.basename(pkg.changes_file) - changes["fingerprint"] = utils.check_signature(pkg.changes_file, reject) + changes["fingerprint"] = dak.lib.utils.check_signature(pkg.changes_file, reject) if changes["fingerprint"]: valid_changes_p = check_changes() else: @@ -1271,7 +1264,7 @@ def process_it (changes_file): check_md5sums() check_urgency() check_timestamps() - Katie.update_subst(reject_message) + Upload.update_subst(reject_message) action() except SystemExit: raise @@ -1297,16 +1290,16 @@ def main(): # Ensure all the arguments we were given are .changes files for file in changes_files: if not file.endswith(".changes"): - utils.warn("Ignoring '%s' because it's not a .changes file." % (file)) + dak.lib.utils.warn("Ignoring '%s' because it's not a .changes file." % (file)) changes_files.remove(file) if changes_files == []: - utils.fubar("Need at least one .changes file as an argument.") + dak.lib.utils.fubar("Need at least one .changes file as an argument.") # Check that we aren't going to clash with the daily cron job if not Options["No-Action"] and os.path.exists("%s/daily.lock" % (Cnf["Dir::Lock"])) and not Options["No-Lock"]: - utils.fubar("Archive maintenance in progress. Try again later.") + dak.lib.utils.fubar("Archive maintenance in progress. Try again later.") # Obtain lock if not in no-action mode and initialize the log @@ -1316,21 +1309,21 @@ def main(): fcntl.lockf(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB) except IOError, e: if errno.errorcode[e.errno] == 'EACCES' or errno.errorcode[e.errno] == 'EAGAIN': - utils.fubar("Couldn't obtain lock; assuming another jennifer is already running.") + dak.lib.utils.fubar("Couldn't obtain lock; assuming another 'dak process-unchecked' is already running.") else: raise - Logger = Katie.Logger = logging.Logger(Cnf, "jennifer") + Logger = Upload.Logger = dak.lib.logging.Logger(Cnf, "process-unchecked") # debian-{devel-,}-changes@lists.debian.org toggles writes access based on this header - bcc = "X-Katie: %s" % (jennifer_version) + bcc = "X-DAK: dak process-unchecked\nX-Katie: this header is obsolete" if Cnf.has_key("Dinstall::Bcc"): - Katie.Subst["__BCC__"] = bcc + "\nBcc: %s" % (Cnf["Dinstall::Bcc"]) + Upload.Subst["__BCC__"] = bcc + "\nBcc: %s" % (Cnf["Dinstall::Bcc"]) else: - Katie.Subst["__BCC__"] = bcc + Upload.Subst["__BCC__"] = bcc # Sort the .changes files so that we process sourceful ones first - changes_files.sort(utils.changes_compare) + changes_files.sort(dak.lib.utils.changes_compare) # Process the changes files for changes_file in changes_files: @@ -1341,13 +1334,13 @@ def main(): if not Options["No-Action"]: clean_holding() - accept_count = Katie.accept_count - accept_bytes = Katie.accept_bytes + accept_count = Upload.accept_count + accept_bytes = Upload.accept_bytes if accept_count: sets = "set" if accept_count > 1: sets = "sets" - print "Accepted %d package %s, %s." % (accept_count, sets, utils.size_type(int(accept_bytes))) + print "Accepted %d package %s, %s." % (accept_count, sets, dak.lib.utils.size_type(int(accept_bytes))) Logger.log(["total",accept_count,accept_bytes]) if not Options["No-Action"]: diff --git a/dak/queue_report.py b/dak/queue_report.py index ce8afca9..f287801b 100755 --- a/dak/queue_report.py +++ b/dak/queue_report.py @@ -2,7 +2,6 @@ # Produces a report on NEW and BYHAND packages # Copyright (C) 2001, 2002, 2003, 2005, 2006 James Troup -# $Id: helena,v 1.6 2005-11-15 09:50:32 ajt Exp $ # 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 @@ -37,17 +36,17 @@ import copy, glob, os, stat, sys, time import apt_pkg -import katie, utils +import dak.lib.queue, dak.lib.utils Cnf = None -Katie = None +Upload = None direction = [] row_number = 0 ################################################################################ def usage(exit_code=0): - print """Usage: helena + print """Usage: dak queue-report Prints a report of packages in queue directories (usually new and byhand). -h, --help show this help and exit. @@ -267,10 +266,10 @@ def process_changes_files(changes_files, type): # Read in all the .changes files for filename in changes_files: try: - Katie.pkg.changes_file = filename - Katie.init_vars() - Katie.update_vars() - cache[filename] = copy.copy(Katie.pkg.changes) + Upload.pkg.changes_file = filename + Upload.init_vars() + Upload.update_vars() + cache[filename] = copy.copy(Upload.pkg.changes) cache[filename]["filename"] = filename except: break @@ -290,13 +289,13 @@ def process_changes_files(changes_files, type): have_note = 0 for d in per_source[source]["list"]: mtime = os.stat(d["filename"])[stat.ST_MTIME] - if Cnf.has_key("Helena::Options::New"): + if Cnf.has_key("Queue-Report::Options::New"): if mtime > oldest: oldest = mtime else: if mtime < oldest: oldest = mtime - have_note += (d.has_key("lisa note")) + have_note += (d.has_key("process-new note")) per_source[source]["oldest"] = oldest if not have_note: per_source[source]["note_state"] = 0; # none @@ -324,12 +323,12 @@ def process_changes_files(changes_files, type): arches = {} versions = {} for j in i[1]["list"]: - if Cnf.has_key("Helena::Options::New"): + if Cnf.has_key("Queue-Report::Options::New"): try: (maintainer["maintainer822"], maintainer["maintainer2047"], maintainer["maintainername"], maintainer["maintaineremail"]) = \ - utils.fix_maintainer (j["maintainer"]) - except utils.ParseMaintError, msg: + dak.lib.utils.fix_maintainer (j["maintainer"]) + except dak.lib.utils.ParseMaintError, msg: print "Problems while parsing maintainer address\n" maintainer["maintainername"] = "Unknown" maintainer["maintaineremail"] = "Unknown" @@ -341,7 +340,7 @@ def process_changes_files(changes_files, type): version = j["version"] versions[version] = "" arches_list = arches.keys() - arches_list.sort(utils.arch_compare_sw) + arches_list.sort(dak.lib.utils.arch_compare_sw) arch_list = " ".join(arches_list) version_list = " ".join(versions.keys()) if len(version_list) > max_version_len: @@ -359,14 +358,14 @@ def process_changes_files(changes_files, type): # Look for the options for sort and then do the sort. age = "h" - if Cnf.has_key("Helena::Options::Age"): - age = Cnf["Helena::Options::Age"] - if Cnf.has_key("Helena::Options::New"): + if Cnf.has_key("Queue-Report::Options::Age"): + age = Cnf["Queue-Report::Options::Age"] + if Cnf.has_key("Queue-Report::Options::New"): # If we produce html we always have oldest first. direction.append([4,-1,"ao"]) else: - if Cnf.has_key("Helena::Options::Sort"): - for i in Cnf["Helena::Options::Sort"].split(","): + if Cnf.has_key("Queue-Report::Options::Sort"): + for i in Cnf["Queue-Report::Options::Sort"].split(","): if i == "ao": # Age, oldest first. direction.append([4,-1,age]) @@ -391,7 +390,7 @@ def process_changes_files(changes_files, type): # have with it. (If you combine options it will simply take the last one at the moment). # Will be enhanced in the future. - if Cnf.has_key("Helena::Options::New"): + if Cnf.has_key("Queue-Report::Options::New"): direction.append([4,1,"ao"]) entries.sort(lambda x, y: sortfunc(x, y)) # Output for a html file. First table header. then table_footer. @@ -427,29 +426,29 @@ def process_changes_files(changes_files, type): ################################################################################ def main(): - global Cnf, Katie + global Cnf, Upload - Cnf = utils.get_conf() - Arguments = [('h',"help","Helena::Options::Help"), - ('n',"new","Helena::Options::New"), - ('s',"sort","Helena::Options::Sort", "HasArg"), - ('a',"age","Helena::Options::Age", "HasArg")] + Cnf = dak.lib.utils.get_conf() + Arguments = [('h',"help","Queue-Report::Options::Help"), + ('n',"new","Queue-Report::Options::New"), + ('s',"sort","Queue-Report::Options::Sort", "HasArg"), + ('a',"age","Queue-Report::Options::Age", "HasArg")] for i in [ "help" ]: - if not Cnf.has_key("Helena::Options::%s" % (i)): - Cnf["Helena::Options::%s" % (i)] = "" + if not Cnf.has_key("Queue-Report::Options::%s" % (i)): + Cnf["Queue-Report::Options::%s" % (i)] = "" apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv) - Options = Cnf.SubTree("Helena::Options") + Options = Cnf.SubTree("Queue-Report::Options") if Options["Help"]: usage() - Katie = katie.Katie(Cnf) + Upload = dak.lib.queue.Upload(Cnf) - if Cnf.has_key("Helena::Options::New"): + if Cnf.has_key("Queue-Report::Options::New"): header() - directories = Cnf.ValueList("Helena::Directories") + directories = Cnf.ValueList("Queue-Report::Directories") if not directories: directories = [ "byhand", "new" ] @@ -457,7 +456,7 @@ def main(): changes_files = glob.glob("%s/*.changes" % (Cnf["Dir::Queue::%s" % (directory)])) process_changes_files(changes_files, directory) - if Cnf.has_key("Helena::Options::New"): + if Cnf.has_key("Queue-Report::Options::New"): footer() ################################################################################ diff --git a/dak/reject_proposed_updates.py b/dak/reject_proposed_updates.py index dfcbd31e..58c7e88e 100755 --- a/dak/reject_proposed_updates.py +++ b/dak/reject_proposed_updates.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # Manually reject packages for proprosed-updates -# Copyright (C) 2001, 2002, 2003, 2004 James Troup -# $Id: lauren,v 1.4 2004-04-01 17:13:11 troup Exp $ +# Copyright (C) 2001, 2002, 2003, 2004, 2006 James Troup # 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 @@ -21,24 +20,22 @@ ################################################################################ import os, pg, sys -import db_access, katie, logging, utils +import dak.lib.database, dak.lib.queue, dak.lib.logging, dak.lib.utils import apt_pkg ################################################################################ # Globals -lauren_version = "$Revision: 1.4 $" - Cnf = None Options = None projectB = None -Katie = None +Upload = None Logger = None ################################################################################ def usage(exit_code=0): - print """Usage: lauren .CHANGES[...] + print """Usage: dak reject-proposed-updates .CHANGES[...] Manually reject the .CHANGES file(s). -h, --help show this help and exit. @@ -49,45 +46,45 @@ Manually reject the .CHANGES file(s). ################################################################################ def main(): - global Cnf, Logger, Options, projectB, Katie + global Cnf, Logger, Options, projectB, Upload - Cnf = utils.get_conf() - Arguments = [('h',"help","Lauren::Options::Help"), - ('m',"manual-reject","Lauren::Options::Manual-Reject", "HasArg"), - ('s',"no-mail", "Lauren::Options::No-Mail")] + Cnf = dak.lib.utils.get_conf() + Arguments = [('h',"help","Reject-Proposed-Updates::Options::Help"), + ('m',"manual-reject","Reject-Proposed-Updates::Options::Manual-Reject", "HasArg"), + ('s',"no-mail", "Reject-Proposed-Updates::Options::No-Mail")] for i in [ "help", "manual-reject", "no-mail" ]: - if not Cnf.has_key("Lauren::Options::%s" % (i)): - Cnf["Lauren::Options::%s" % (i)] = "" + if not Cnf.has_key("Reject-Proposed-Updates::Options::%s" % (i)): + Cnf["Reject-Proposed-Updates::Options::%s" % (i)] = "" arguments = apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv) - Options = Cnf.SubTree("Lauren::Options") + Options = Cnf.SubTree("Reject-Proposed-Updates::Options") if Options["Help"]: usage() if not arguments: - utils.fubar("need at least one .changes filename as an argument.") + dak.lib.utils.fubar("need at least one .changes filename as an argument.") projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - db_access.init(Cnf, projectB) + dak.lib.database.init(Cnf, projectB) - Katie = katie.Katie(Cnf) - Logger = Katie.Logger = logging.Logger(Cnf, "lauren") + Upload = dak.lib.queue.Upload(Cnf) + Logger = Upload.Logger = dak.lib.logging.Logger(Cnf, "reject-proposed-updates") - bcc = "X-Katie: lauren %s" % (lauren_version) + bcc = "X-DAK: dak rejected-proposed-updates\nX-Katie: this header is obsolete" if Cnf.has_key("Dinstall::Bcc"): - Katie.Subst["__BCC__"] = bcc + "\nBcc: %s" % (Cnf["Dinstall::Bcc"]) + Upload.Subst["__BCC__"] = bcc + "\nBcc: %s" % (Cnf["Dinstall::Bcc"]) else: - Katie.Subst["__BCC__"] = bcc + Upload.Subst["__BCC__"] = bcc for arg in arguments: - arg = utils.validate_changes_file_arg(arg) - Katie.pkg.changes_file = arg - Katie.init_vars() + arg = dak.lib.utils.validate_changes_file_arg(arg) + Upload.pkg.changes_file = arg + Upload.init_vars() cwd = os.getcwd() - os.chdir(Cnf["Suite::Proposed-Updates::CopyKatie"]) - Katie.update_vars() + os.chdir(Cnf["Suite::Proposed-Updates::CopyDotDak"]) + Upload.update_vars() os.chdir(cwd) - Katie.update_subst() + Upload.update_subst() print arg done = 0 @@ -96,8 +93,8 @@ def main(): answer = "XXX" while prompt.find(answer) == -1: - answer = utils.our_raw_input(prompt) - m = katie.re_default_answer.search(prompt) + answer = dak.lib.utils.our_raw_input(prompt) + m = dak.lib.queue.re_default_answer.search(prompt) if answer == "": answer = m.group(1) answer = answer[:1].upper() @@ -116,28 +113,28 @@ def main(): ################################################################################ def reject (reject_message = ""): - files = Katie.pkg.files - dsc = Katie.pkg.dsc - changes_file = Katie.pkg.changes_file + files = Upload.pkg.files + dsc = Upload.pkg.dsc + changes_file = Upload.pkg.changes_file # If we weren't given a manual rejection message, spawn an editor # so the user can add one in... if not reject_message: - temp_filename = utils.temp_filename() + temp_filename = dak.lib.utils.temp_filename() editor = os.environ.get("EDITOR","vi") answer = 'E' while answer == 'E': os.system("%s %s" % (editor, temp_filename)) - file = utils.open_file(temp_filename) + file = dak.lib.utils.open_file(temp_filename) reject_message = "".join(file.readlines()) file.close() print "Reject message:" - print utils.prefix_multi_line_string(reject_message," ", include_blank_lines=1) + print dak.lib.utils.prefix_multi_line_string(reject_message," ", include_blank_lines=1) prompt = "[R]eject, Edit, Abandon, Quit ?" answer = "XXX" while prompt.find(answer) == -1: - answer = utils.our_raw_input(prompt) - m = katie.re_default_answer.search(prompt) + answer = dak.lib.utils.our_raw_input(prompt) + m = dak.lib.queue.re_default_answer.search(prompt) if answer == "": answer = m.group(1) answer = answer[:1].upper() @@ -150,7 +147,7 @@ def reject (reject_message = ""): print "Rejecting.\n" # Reject the .changes file - Katie.force_reject([changes_file]) + Upload.force_reject([changes_file]) # Setup the .reason file reason_filename = changes_file[:-8] + ".reason" @@ -163,21 +160,21 @@ def reject (reject_message = ""): reject_fd = os.open(reject_filename, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0644) # Build up the rejection email - user_email_address = utils.whoami() + " <%s>" % (Cnf["Dinstall::MyAdminAddress"]) + user_email_address = dak.lib.utils.whoami() + " <%s>" % (Cnf["Dinstall::MyAdminAddress"]) - Katie.Subst["__REJECTOR_ADDRESS__"] = user_email_address - Katie.Subst["__MANUAL_REJECT_MESSAGE__"] = reject_message - Katie.Subst["__STABLE_REJECTOR__"] = Cnf["Lauren::StableRejector"] - Katie.Subst["__MORE_INFO_URL__"] = Cnf["Lauren::MoreInfoURL"] - Katie.Subst["__CC__"] = "Cc: " + Cnf["Dinstall::MyEmailAddress"] - reject_mail_message = utils.TemplateSubst(Katie.Subst,Cnf["Dir::Templates"]+"/lauren.stable-rejected") + Upload.Subst["__REJECTOR_ADDRESS__"] = user_email_address + Upload.Subst["__MANUAL_REJECT_MESSAGE__"] = reject_message + Upload.Subst["__STABLE_REJECTOR__"] = Cnf["Reject-Proposed-Updates::StableRejector"] + Upload.Subst["__MORE_INFO_URL__"] = Cnf["Reject-Proposed-Updates::MoreInfoURL"] + Upload.Subst["__CC__"] = "Cc: " + Cnf["Dinstall::MyEmailAddress"] + reject_mail_message = dak.lib.utils.TemplateSubst(Upload.Subst,Cnf["Dir::Templates"]+"/reject-proposed-updates.rejected") # Write the rejection email out as the .reason file os.write(reject_fd, reject_mail_message) os.close(reject_fd) # Remove the packages from proposed-updates - suite_id = db_access.get_suite_id('proposed-updates') + suite_id = dak.lib.database.get_suite_id('proposed-updates') projectB.query("BEGIN WORK") # Remove files from proposed-updates suite @@ -188,7 +185,7 @@ def reject (reject_message = ""): q = projectB.query("SELECT id FROM source WHERE source = '%s' AND version = '%s'" % (package, version)) ql = q.getresult() if not ql: - utils.fubar("reject: Couldn't find %s_%s in source table." % (package, version)) + dak.lib.utils.fubar("reject: Couldn't find %s_%s in source table." % (package, version)) source_id = ql[0][0] projectB.query("DELETE FROM src_associations WHERE suite = '%s' AND source = '%s'" % (suite_id, source_id)) elif files[file]["type"] == "deb": @@ -204,7 +201,7 @@ def reject (reject_message = ""): # newer version of the package and only do the # warn&continue thing if it finds one. if not ql: - utils.warn("reject: Couldn't find %s_%s_%s in binaries table." % (package, version, architecture)) + dak.lib.utils.warn("reject: Couldn't find %s_%s_%s in binaries table." % (package, version, architecture)) else: binary_id = ql[0][0] projectB.query("DELETE FROM bin_associations WHERE suite = '%s' AND bin = '%s'" % (suite_id, binary_id)) @@ -212,11 +209,11 @@ def reject (reject_message = ""): # Send the rejection mail if appropriate if not Options["No-Mail"]: - utils.send_mail(reject_mail_message) + dak.lib.utils.send_mail(reject_mail_message) - # Finally remove the .katie file - katie_file = os.path.join(Cnf["Suite::Proposed-Updates::CopyKatie"], os.path.basename(changes_file[:-8]+".katie")) - os.unlink(katie_file) + # Finally remove the .dak file + dot_dak_file = os.path.join(Cnf["Suite::Proposed-Updates::CopyDotDak"], os.path.basename(changes_file[:-8]+".dak")) + os.unlink(dot_dak_file) Logger.log(["rejected", changes_file]) return 0 diff --git a/dak/rm.py b/dak/rm.py index 10d1dd01..12f15eb0 100755 --- a/dak/rm.py +++ b/dak/rm.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # General purpose package removal tool for ftpmaster -# Copyright (C) 2000, 2001, 2002, 2003, 2004 James Troup -# $Id: melanie,v 1.44 2005-11-15 09:50:32 ajt Exp $ +# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 James Troup # 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 @@ -41,7 +40,7 @@ ################################################################################ import commands, os, pg, re, sys -import utils, db_access +import dak.lib.utils, dak.lib.database import apt_pkg, apt_inst ################################################################################ @@ -58,7 +57,7 @@ projectB = None ################################################################################ def usage (exit_code=0): - print """Usage: melanie [OPTIONS] PACKAGE[...] + print """Usage: dak rm [OPTIONS] PACKAGE[...] Remove PACKAGE(s) from suite(s). -a, --architecture=ARCH only act on this architecture @@ -87,7 +86,7 @@ ARCH, BUG#, COMPONENT and SUITE can be comma (or space) separated lists, e.g. # the fuck are we gonna do now? What are we gonna do?" def game_over(): - answer = utils.our_raw_input("Continue (y/N)? ").lower() + answer = dak.lib.utils.our_raw_input("Continue (y/N)? ").lower() if answer != "y": print "Aborted." sys.exit(1) @@ -107,11 +106,11 @@ def reverse_depends_check(removals, suites): for component in components: filename = "%s/dists/%s/%s/binary-%s/Packages.gz" % (Cnf["Dir::Root"], suites[0], component, architecture) # apt_pkg.ParseTagFile needs a real file handle and can't handle a GzipFile instance... - temp_filename = utils.temp_filename() + temp_filename = dak.lib.utils.temp_filename() (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename)) if (result != 0): - utils.fubar("Gunzip invocation failed!\n%s\n" % (output), result) - packages = utils.open_file(temp_filename) + dak.lib.utils.fubar("Gunzip invocation failed!\n%s\n" % (output), result) + packages = dak.lib.utils.open_file(temp_filename) Packages = apt_pkg.ParseTagFile(packages) while Packages.Step(): package = Packages.Section.Find("Package") @@ -165,19 +164,19 @@ def reverse_depends_check(removals, suites): what = "%s/%s" % (package, component) else: what = "** %s" % (package) - print "%s has an unsatisfied dependency on %s: %s" % (what, architecture, utils.pp_deps(dep)) + print "%s has an unsatisfied dependency on %s: %s" % (what, architecture, dak.lib.utils.pp_deps(dep)) dep_problem = 1 # Check source dependencies (Build-Depends and Build-Depends-Indep) for component in components: filename = "%s/dists/%s/%s/source/Sources.gz" % (Cnf["Dir::Root"], suites[0], component) # apt_pkg.ParseTagFile needs a real file handle and can't handle a GzipFile instance... - temp_filename = utils.temp_filename() + temp_filename = dak.lib.utils.temp_filename() result, output = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename)) if result != 0: sys.stderr.write("Gunzip invocation failed!\n%s\n" % (output)) sys.exit(result) - sources = utils.open_file(temp_filename, "r") + sources = dak.lib.utils.open_file(temp_filename, "r") Sources = apt_pkg.ParseTagFile(sources) while Sources.Step(): source = Sources.Section.Find("Package") @@ -202,7 +201,7 @@ def reverse_depends_check(removals, suites): source = "%s/%s" % (source, component) else: source = "** %s" % (source) - print "%s has an unsatisfied build-dependency: %s" % (source, utils.pp_deps(dep)) + print "%s has an unsatisfied build-dependency: %s" % (source, dak.lib.utils.pp_deps(dep)) dep_problem = 1 sources.close() os.unlink(temp_filename) @@ -220,57 +219,58 @@ def reverse_depends_check(removals, suites): def main (): global Cnf, Options, projectB - Cnf = utils.get_conf() - - Arguments = [('h',"help","Melanie::Options::Help"), - ('a',"architecture","Melanie::Options::Architecture", "HasArg"), - ('b',"binary", "Melanie::Options::Binary-Only"), - ('c',"component", "Melanie::Options::Component", "HasArg"), - ('C',"carbon-copy", "Melanie::Options::Carbon-Copy", "HasArg"), # Bugs to Cc - ('d',"done","Melanie::Options::Done", "HasArg"), # Bugs fixed - ('R',"rdep-check", "Melanie::Options::Rdep-Check"), - ('m',"reason", "Melanie::Options::Reason", "HasArg"), # Hysterical raisins; -m is old-dinstall option for rejection reason - ('n',"no-action","Melanie::Options::No-Action"), - ('p',"partial", "Melanie::Options::Partial"), - ('s',"suite","Melanie::Options::Suite", "HasArg"), - ('S',"source-only", "Melanie::Options::Source-Only"), + Cnf = dak.lib.utils.get_conf() + + Arguments = [('h',"help","Rm::Options::Help"), + ('a',"architecture","Rm::Options::Architecture", "HasArg"), + ('b',"binary", "Rm::Options::Binary-Only"), + ('c',"component", "Rm::Options::Component", "HasArg"), + ('C',"carbon-copy", "Rm::Options::Carbon-Copy", "HasArg"), # Bugs to Cc + ('d',"done","Rm::Options::Done", "HasArg"), # Bugs fixed + ('R',"rdep-check", "Rm::Options::Rdep-Check"), + ('m',"reason", "Rm::Options::Reason", "HasArg"), # Hysterical raisins; -m is old-dinstall option for rejection reason + ('n',"no-action","Rm::Options::No-Action"), + ('p',"partial", "Rm::Options::Partial"), + ('s',"suite","Rm::Options::Suite", "HasArg"), + ('S',"source-only", "Rm::Options::Source-Only"), ] for i in [ "architecture", "binary-only", "carbon-copy", "component", "done", "help", "no-action", "partial", "rdep-check", "reason", "source-only" ]: - if not Cnf.has_key("Melanie::Options::%s" % (i)): - Cnf["Melanie::Options::%s" % (i)] = "" - if not Cnf.has_key("Melanie::Options::Suite"): - Cnf["Melanie::Options::Suite"] = "unstable" + if not Cnf.has_key("Rm::Options::%s" % (i)): + Cnf["Rm::Options::%s" % (i)] = "" + if not Cnf.has_key("Rm::Options::Suite"): + Cnf["Rm::Options::Suite"] = "unstable" arguments = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv) - Options = Cnf.SubTree("Melanie::Options") + Options = Cnf.SubTree("Rm::Options") if Options["Help"]: usage() projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - db_access.init(Cnf, projectB) + dak.lib.database.init(Cnf, projectB) # Sanity check options if not arguments: - utils.fubar("need at least one package name as an argument.") + dak.lib.utils.fubar("need at least one package name as an argument.") if Options["Architecture"] and Options["Source-Only"]: - utils.fubar("can't use -a/--architecutre and -S/--source-only options simultaneously.") + dak.lib.utils.fubar("can't use -a/--architecutre and -S/--source-only options simultaneously.") if Options["Binary-Only"] and Options["Source-Only"]: - utils.fubar("can't use -b/--binary-only and -S/--source-only options simultaneously.") + dak.lib.utils.fubar("can't use -b/--binary-only and -S/--source-only options simultaneously.") if Options.has_key("Carbon-Copy") and not Options.has_key("Done"): - utils.fubar("can't use -C/--carbon-copy without also using -d/--done option.") + dak.lib.utils.fubar("can't use -C/--carbon-copy without also using -d/--done option.") if Options["Architecture"] and not Options["Partial"]: - utils.warn("-a/--architecture implies -p/--partial.") + dak.lib.utils.warn("-a/--architecture implies -p/--partial.") Options["Partial"] = "true" - # Force the admin to tell someone if we're not doing a rene-led removal - # (or closing a bug, which counts as telling someone). + # Force the admin to tell someone if we're not doing a 'dak + # cruft-report' inspired removal (or closing a bug, which counts + # as telling someone). if not Options["No-Action"] and not Options["Carbon-Copy"] \ - and not Options["Done"] and Options["Reason"].find("[rene]") == -1: - utils.fubar("Need a -C/--carbon-copy if not closing a bug and not doing a rene-led removal.") + and not Options["Done"] and Options["Reason"].find("[auto-cruft]") == -1: + dak.lib.utils.fubar("Need a -C/--carbon-copy if not closing a bug and not doing a cruft removal.") # Process -C/--carbon-copy # @@ -280,8 +280,8 @@ def main (): # 3) contains a '@' - assumed to be an email address, used unmofidied # carbon_copy = [] - for copy_to in utils.split_args(Options.get("Carbon-Copy")): - if utils.str_isnum(copy_to): + for copy_to in dak.lib.utils.split_args(Options.get("Carbon-Copy")): + if dak.lib.utils.str_isnum(copy_to): carbon_copy.append(copy_to + "@" + Cnf["Dinstall::BugServer"]) elif copy_to == 'package': for package in arguments: @@ -291,7 +291,7 @@ def main (): elif '@' in copy_to: carbon_copy.append(copy_to) else: - utils.fubar("Invalid -C/--carbon-copy argument '%s'; not a bug number, 'package' or email address." % (copy_to)) + dak.lib.utils.fubar("Invalid -C/--carbon-copy argument '%s'; not a bug number, 'package' or email address." % (copy_to)) if Options["Binary-Only"]: field = "b.package" @@ -300,15 +300,15 @@ def main (): con_packages = "AND %s IN (%s)" % (field, ", ".join(map(repr, arguments))) (con_suites, con_architectures, con_components, check_source) = \ - utils.parse_args(Options) + dak.lib.utils.parse_args(Options) # Additional suite checks suite_ids_list = [] - suites = utils.split_args(Options["Suite"]) - suites_list = utils.join_with_commas_and(suites) + suites = dak.lib.utils.split_args(Options["Suite"]) + suites_list = dak.lib.utils.join_with_commas_and(suites) if not Options["No-Action"]: for suite in suites: - suite_id = db_access.get_suite_id(suite) + suite_id = dak.lib.database.get_suite_id(suite) if suite_id != -1: suite_ids_list.append(suite_id) if suite == "stable": @@ -324,7 +324,7 @@ def main (): # Additional architecture checks if Options["Architecture"] and check_source: - utils.warn("'source' in -a/--argument makes no sense and is ignored.") + dak.lib.utils.warn("'source' in -a/--argument makes no sense and is ignored.") # Additional component processing over_con_components = con_components.replace("c.id", "component") @@ -362,9 +362,9 @@ def main (): for i in source_packages.keys(): filename = "/".join(source_packages[i]) try: - dsc = utils.parse_changes(filename) - except utils.cant_open_exc: - utils.warn("couldn't open '%s'." % (filename)) + dsc = dak.lib.utils.parse_changes(filename) + except dak.lib.utils.cant_open_exc: + dak.lib.utils.warn("couldn't open '%s'." % (filename)) continue for package in dsc.get("binary").split(','): package = package.strip() @@ -377,7 +377,7 @@ def main (): q = projectB.query("SELECT l.path, f.filename, b.package, b.version, a.arch_string, b.id, b.maintainer FROM binaries b, bin_associations ba, architecture a, suite su, files f, location l, component c WHERE ba.bin = b.id AND ba.suite = su.id AND b.architecture = a.id AND b.file = f.id AND f.location = l.id AND l.component = c.id %s %s %s AND b.package = '%s'" % (con_suites, con_components, con_architectures, package)) for i in q.getresult(): filename = "/".join(i[:2]) - control = apt_pkg.ParseSection(apt_inst.debExtractControl(utils.open_file(filename))) + control = apt_pkg.ParseSection(apt_inst.debExtractControl(dak.lib.utils.open_file(filename))) source = control.Find("Source", control.Find("Package")) source = re_strip_source_version.sub('', source) if source_packages.has_key(source): @@ -391,12 +391,12 @@ def main (): # If we don't have a reason; spawn an editor so the user can add one # Write the rejection email out as the .reason file if not Options["Reason"] and not Options["No-Action"]: - temp_filename = utils.temp_filename() + temp_filename = dak.lib.utils.temp_filename() editor = os.environ.get("EDITOR","vi") result = os.system("%s %s" % (editor, temp_filename)) if result != 0: - utils.fubar ("vi invocation failed for `%s'!" % (temp_filename), result) - temp_file = utils.open_file(temp_filename) + dak.lib.utils.fubar ("vi invocation failed for `%s'!" % (temp_filename), result) + temp_file = dak.lib.utils.open_file(temp_filename) for line in temp_file.readlines(): Options["Reason"] += line temp_file.close() @@ -419,7 +419,7 @@ def main (): maintainer_list = [] for maintainer_id in maintainers.keys(): - maintainer_list.append(db_access.get_maintainer(maintainer_id)) + maintainer_list.append(dak.lib.database.get_maintainer(maintainer_id)) summary = "" removals = d.keys() removals.sort() @@ -427,7 +427,7 @@ def main (): versions = d[package].keys() versions.sort(apt_pkg.VersionCompare) for version in versions: - d[package][version].sort(utils.arch_compare_sw) + d[package][version].sort(dak.lib.utils.arch_compare_sw) summary += "%10s | %10s | %s\n" % (package, version, ", ".join(d[package][version])) print "Will remove the following packages from %s:" % (suites_list) print @@ -453,11 +453,11 @@ def main (): print "Going to remove the packages now." game_over() - whoami = utils.whoami() + whoami = dak.lib.utils.whoami() date = commands.getoutput('date -R') # Log first; if it all falls apart I want a record that we at least tried. - logfile = utils.open_file(Cnf["Melanie::LogFile"], 'a') + logfile = dak.lib.utils.open_file(Cnf["Rm::LogFile"], 'a') logfile.write("=========================================================================\n") logfile.write("[Date: %s] [ftpmaster: %s]\n" % (date, whoami)) logfile.write("Removed the following packages from %s:\n\n%s" % (suites_list, summary)) @@ -467,8 +467,8 @@ def main (): logfile.write("----------------------------------------------\n") logfile.flush() - dsc_type_id = db_access.get_override_type_id('dsc') - deb_type_id = db_access.get_override_type_id('deb') + dsc_type_id = dak.lib.database.get_override_type_id('dsc') + deb_type_id = dak.lib.database.get_override_type_id('deb') # Do the actual deletion print "Deleting...", @@ -498,18 +498,18 @@ def main (): # Send the bug closing messages if Options["Done"]: Subst = {} - Subst["__MELANIE_ADDRESS__"] = Cnf["Melanie::MyEmailAddress"] + Subst["__RM_ADDRESS__"] = Cnf["Rm::MyEmailAddress"] Subst["__BUG_SERVER__"] = Cnf["Dinstall::BugServer"] bcc = [] if Cnf.Find("Dinstall::Bcc") != "": bcc.append(Cnf["Dinstall::Bcc"]) - if Cnf.Find("Melanie::Bcc") != "": - bcc.append(Cnf["Melanie::Bcc"]) + if Cnf.Find("Rm::Bcc") != "": + bcc.append(Cnf["Rm::Bcc"]) if bcc: Subst["__BCC__"] = "Bcc: " + ", ".join(bcc) else: Subst["__BCC__"] = "X-Filler: 42" - Subst["__CC__"] = "X-Katie: melanie $Revision: 1.44 $" + Subst["__CC__"] = "X-DAK: dak rm\nX-Katie: this header is obsolete" if carbon_copy: Subst["__CC__"] += "\nCc: " + ", ".join(carbon_copy) Subst["__SUITE_LIST__"] = suites_list @@ -517,14 +517,14 @@ def main (): Subst["__ADMIN_ADDRESS__"] = Cnf["Dinstall::MyAdminAddress"] Subst["__DISTRO__"] = Cnf["Dinstall::MyDistribution"] Subst["__WHOAMI__"] = whoami - whereami = utils.where_am_i() + whereami = dak.lib.utils.where_am_i() Archive = Cnf.SubTree("Archive::%s" % (whereami)) Subst["__MASTER_ARCHIVE__"] = Archive["OriginServer"] Subst["__PRIMARY_MIRROR__"] = Archive["PrimaryMirror"] - for bug in utils.split_args(Options["Done"]): + for bug in dak.lib.utils.split_args(Options["Done"]): Subst["__BUG_NUMBER__"] = bug - mail_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/melanie.bug-close") - utils.send_mail(mail_message) + mail_message = dak.lib.utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/rm.bug-close") + dak.lib.utils.send_mail(mail_message) logfile.write("=========================================================================\n") logfile.close() diff --git a/dak/security_install.py b/dak/security_install.py index eb79bb4a..2763abb3 100755 --- a/dak/security_install.py +++ b/dak/security_install.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # Wrapper for Debian Security team -# Copyright (C) 2002, 2003, 2004 James Troup -# $Id: amber,v 1.11 2005-11-26 07:52:06 ajt Exp $ +# Copyright (C) 2002, 2003, 2004, 2006 James Troup # 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 @@ -33,20 +32,20 @@ import commands, os, pwd, re, sys, time import apt_pkg -import katie, utils +import dak.lib.queue, dak.lib.utils ################################################################################ Cnf = None Options = None -Katie = None +Upload = None re_taint_free = re.compile(r"^['/;\-\+\.\s\w]+$") ################################################################################ def usage (exit_code=0): - print """Usage: amber ADV_NUMBER CHANGES_FILE[...] + print """Usage: dak security-install ADV_NUMBER CHANGES_FILE[...] Install CHANGES_FILE(s) as security advisory ADV_NUMBER -h, --help show this help and exit @@ -61,25 +60,25 @@ def do_upload(changes_files): file_list = "" suites = {} component_mapping = {} - for component in Cnf.SubTree("Amber::ComponentMappings").List(): - component_mapping[component] = Cnf["Amber::ComponentMappings::%s" % (component)] + for component in Cnf.SubTree("Security-Install::ComponentMappings").List(): + component_mapping[component] = Cnf["Security-Install::ComponentMappings::%s" % (component)] uploads = {}; # uploads[uri] = file_list changesfiles = {}; # changesfiles[uri] = file_list package_list = {} # package_list[source_name][version] - changes_files.sort(utils.changes_compare) + changes_files.sort(dak.lib.utils.changes_compare) for changes_file in changes_files: - changes_file = utils.validate_changes_file_arg(changes_file) + changes_file = dak.lib.utils.validate_changes_file_arg(changes_file) # Reset variables components = {} upload_uris = {} file_list = [] - Katie.init_vars() - # Parse the .katie file for the .changes file - Katie.pkg.changes_file = changes_file - Katie.update_vars() - files = Katie.pkg.files - changes = Katie.pkg.changes - dsc = Katie.pkg.dsc + Upload.init_vars() + # Parse the .dak file for the .changes file + Upload.pkg.changes_file = changes_file + Upload.update_vars() + files = Upload.pkg.files + changes = Upload.pkg.changes + dsc = Upload.pkg.dsc # We have the changes, now return if its amd64, to not upload them to ftp-master if changes["architecture"].has_key("amd64"): print "Not uploading amd64 part to ftp-master\n" @@ -90,7 +89,7 @@ def do_upload(changes_files): # Build the file list for this .changes file for file in files.keys(): poolname = os.path.join(Cnf["Dir::Root"], Cnf["Dir::PoolRoot"], - utils.poolify(changes["source"], files[file]["component"]), + dak.lib.utils.poolify(changes["source"], files[file]["component"]), file) file_list.append(poolname) orig_component = files[file].get("original component", files[file]["component"]) @@ -102,10 +101,10 @@ def do_upload(changes_files): upload_uris[upload_uri] = "" num_upload_uris = len(upload_uris.keys()) if num_upload_uris == 0: - utils.fubar("%s: No valid upload URI found from components (%s)." + dak.lib.utils.fubar("%s: No valid upload URI found from components (%s)." % (changes_file, ", ".join(components.keys()))) elif num_upload_uris > 1: - utils.fubar("%s: more than one upload URI (%s) from components (%s)." + dak.lib.utils.fubar("%s: more than one upload URI (%s) from components (%s)." % (changes_file, ", ".join(upload_uris.keys()), ", ".join(components.keys()))) upload_uri = upload_uris.keys()[0] @@ -141,7 +140,7 @@ def do_upload(changes_files): if not Options["No-Action"]: filename = "%s/testing-processed" % (Cnf["Dir::Log"]) - file = utils.open_file(filename, 'a') + file = dak.lib.utils.open_file(filename, 'a') for source in package_list.keys(): for version in package_list[source].keys(): file.write(" ".join([source, version])+'\n') @@ -149,34 +148,34 @@ def do_upload(changes_files): ###################################################################### # This function was originally written by aj and NIHishly merged into -# amber by me. +# 'dak security-install' by me. def make_advisory(advisory_nr, changes_files): adv_packages = [] updated_pkgs = {}; # updated_pkgs[distro][arch][file] = {path,md5,size} for arg in changes_files: - arg = utils.validate_changes_file_arg(arg) - Katie.pkg.changes_file = arg - Katie.init_vars() - Katie.update_vars() + arg = dak.lib.utils.validate_changes_file_arg(arg) + Upload.pkg.changes_file = arg + Upload.init_vars() + Upload.update_vars() - src = Katie.pkg.changes["source"] + src = Upload.pkg.changes["source"] if src not in adv_packages: adv_packages += [src] - suites = Katie.pkg.changes["distribution"].keys() + suites = Upload.pkg.changes["distribution"].keys() for suite in suites: if not updated_pkgs.has_key(suite): updated_pkgs[suite] = {} - files = Katie.pkg.files + files = Upload.pkg.files for file in files.keys(): arch = files[file]["architecture"] md5 = files[file]["md5sum"] size = files[file]["size"] poolname = Cnf["Dir::PoolRoot"] + \ - utils.poolify(src, files[file]["component"]) + dak.lib.utils.poolify(src, files[file]["component"]) if arch == "source" and file.endswith(".dsc"): dscpoolname = poolname for suite in suites: @@ -186,7 +185,7 @@ def make_advisory(advisory_nr, changes_files): "md5": md5, "size": size, "poolname": poolname } - dsc_files = Katie.pkg.dsc_files + dsc_files = Upload.pkg.dsc_files for file in dsc_files.keys(): arch = "source" if not dsc_files[file].has_key("files id"): @@ -215,14 +214,14 @@ def make_advisory(advisory_nr, changes_files): "__WHOAMI__": username, "__DATE__": time.strftime("%B %d, %Y", time.gmtime(time.time())), "__PACKAGE__": ", ".join(adv_packages), - "__KATIE_ADDRESS__": Cnf["Dinstall::MyEmailAddress"] + "__DAK_ADDRESS__": Cnf["Dinstall::MyEmailAddress"] } if Cnf.has_key("Dinstall::Bcc"): Subst["__BCC__"] = "Bcc: %s" % (Cnf["Dinstall::Bcc"]) adv = "" - archive = Cnf["Archive::%s::PrimaryMirror" % (utils.where_am_i())] + archive = Cnf["Archive::%s::PrimaryMirror" % (dak.lib.utils.where_am_i())] for suite in updated_pkgs.keys(): suite_header = "%s %s (%s)" % (Cnf["Dinstall::MyDistribution"], Cnf["Suite::%s::Version" % suite], suite) @@ -236,7 +235,7 @@ def make_advisory(advisory_nr, changes_files): arches.sort() adv += " %s was released for %s.\n\n" % ( - suite.capitalize(), utils.join_with_commas_and(arches)) + suite.capitalize(), dak.lib.utils.join_with_commas_and(arches)) for a in ["source", "all"] + arches: if not updated_pkgs[suite].has_key(a): @@ -261,29 +260,29 @@ def make_advisory(advisory_nr, changes_files): Subst["__ADVISORY_TEXT__"] = adv - adv = utils.TemplateSubst(Subst, Cnf["Dir::Templates"]+"/amber.advisory") + adv = dak.lib.utils.TemplateSubst(Subst, Cnf["Dir::Templates"]+"/security-install.advisory") if not Options["No-Action"]: - utils.send_mail (adv) + dak.lib.utils.send_mail (adv) else: print "[]" ###################################################################### def init(): - global Cnf, Katie, Options + global Cnf, Upload, Options apt_pkg.init() - Cnf = utils.get_conf() + Cnf = dak.lib.utils.get_conf() - Arguments = [('h', "help", "Amber::Options::Help"), - ('n', "no-action", "Amber::Options::No-Action")] + Arguments = [('h', "help", "Security-Install::Options::Help"), + ('n', "no-action", "Security-Install::Options::No-Action")] for i in [ "help", "no-action" ]: - Cnf["Amber::Options::%s" % (i)] = "" + Cnf["Security-Install::Options::%s" % (i)] = "" arguments = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv) - Options = Cnf.SubTree("Amber::Options") - Katie = katie.Katie(Cnf) + Options = Cnf.SubTree("Security-Install::Options") + Upload = dak.lib.queue.Upload(Cnf) if Options["Help"]: usage(0) @@ -294,17 +293,17 @@ def init(): advisory_number = arguments[0] changes_files = arguments[1:] if advisory_number.endswith(".changes"): - utils.warn("first argument must be the advisory number.") + dak.lib.utils.warn("first argument must be the advisory number.") usage(1) for file in changes_files: - file = utils.validate_changes_file_arg(file) + file = dak.lib.utils.validate_changes_file_arg(file) return (advisory_number, changes_files) ###################################################################### def yes_no(prompt): while 1: - answer = utils.our_raw_input(prompt+" ").lower() + answer = dak.lib.utils.our_raw_input(prompt+" ").lower() if answer == "y" or answer == "n": break else: @@ -315,14 +314,14 @@ def yes_no(prompt): def spawn(command): if not re_taint_free.match(command): - utils.fubar("Invalid character in \"%s\"." % (command)) + dak.lib.utils.fubar("Invalid character in \"%s\"." % (command)) if Options["No-Action"]: print "[%s]" % (command) else: (result, output) = commands.getstatusoutput(command) if (result != 0): - utils.fubar("Invocation of '%s' failed:\n%s\n" % (command, output), result) + dak.lib.utils.fubar("Invocation of '%s' failed:\n%s\n" % (command, output), result) ###################################################################### @@ -340,14 +339,14 @@ def main(): os.chdir(Cnf["Dir::Queue::Accepted"]) print "Installing packages into the archive..." - spawn("%s/kelly -pa %s" % (Cnf["Dir::Katie"], " ".join(changes_files))) - os.chdir(Cnf["Dir::Katie"]) + spawn("dak process-accepted -pa %s" % (Cnf["Dir::Dak"], " ".join(changes_files))) + os.chdir(Cnf["Dir::Dak"]) print "Updating file lists for apt-ftparchive..." - spawn("./jenna") + spawn("dak make-suite-file-list") print "Updating Packages and Sources files..." - spawn("apt-ftparchive generate %s" % (utils.which_apt_conf_file())) + spawn("apt-ftparchive generate %s" % (dak.lib.utils.which_apt_conf_file())) print "Updating Release files..." - spawn("./ziyi") + spawn("dak generate-releases") if not Options["No-Action"]: os.chdir(Cnf["Dir::Queue::Done"]) diff --git a/dak/shell.py b/dak/shell.py index 7e692ee4..8b530e30 100755 --- a/dak/shell.py +++ b/dak/shell.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # Launch dak functionality -# Copyright (c) 2005 Anthony Towns +# Copyright (c) 2005, 2006 Anthony Towns # $Id: dak,v 1.1 2005-11-17 08:47:31 ajt Exp $ # This program is free software; you can redistribute it and/or modify @@ -38,7 +38,7 @@ functionality = [ ("madison", "main"), ["madison"]), ("rm", "Remove packages from suites", "melanie"), - ("decode-dot-dak", "Display contents of a .katie file", "ashley"), + ("decode-dot-dak", "Display contents of a .dak file", "ashley"), ("override", "Query/change the overrides", "alicia"), ("install", "Install a package from accepted (security only)", diff --git a/dak/split_done.py b/dak/split_done.py index c595f68e..6b6d28fb 100755 --- a/dak/split_done.py +++ b/dak/split_done.py @@ -1,7 +1,6 @@ #!/usr/bin/env python -# Copyright (C) 2004, 2005 James Troup -# $Id: nina,v 1.2 2005-11-15 09:50:32 ajt Exp $ +# Copyright (C) 2004, 2005, 2006 James Troup # 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 @@ -20,12 +19,12 @@ ################################################################################ import glob, os, stat, time -import utils +import dak.lib.utils ################################################################################ def main(): - Cnf = utils.get_conf() + Cnf = dak.lib.utils.get_conf() count = 0 os.chdir(Cnf["Dir::Queue::Done"]) files = glob.glob("%s/*" % (Cnf["Dir::Queue::Done"])) @@ -38,7 +37,7 @@ def main(): os.makedirs(dirname) dest = dirname + '/' + os.path.basename(filename) if os.path.exists(dest): - utils.fubar("%s already exists." % (dest)) + dak.lib.utils.fubar("%s already exists." % (dest)) print "Move: %s -> %s" % (filename, dest) os.rename(filename, dest) count = count + 1 diff --git a/dak/stats.py b/dak/stats.py index bf22a774..cf810b9a 100755 --- a/dak/stats.py +++ b/dak/stats.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # Various statistical pr0nography fun and games -# Copyright (C) 2000, 2001, 2002, 2003 James Troup -# $Id: saffron,v 1.3 2005-11-15 09:50:32 ajt Exp $ +# Copyright (C) 2000, 2001, 2002, 2003, 2006 James Troup # 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 @@ -32,7 +31,7 @@ ################################################################################ import pg, sys -import utils +import dak.lib.utils import apt_pkg ################################################################################ @@ -43,12 +42,12 @@ projectB = None ################################################################################ def usage(exit_code=0): - print """Usage: saffron STAT + print """Usage: dak stats MODE Print various stats. -h, --help show this help and exit. -The following STAT modes are available: +The following MODEs are available: arch-space - displays space used by each architecture pkg-nums - displays the number of packages by suite/architecture @@ -72,11 +71,11 @@ SELECT a.arch_string as Architecture, sum(f.size) def daily_install_stats(): stats = {} - file = utils.open_file("2001-11") + file = dak.lib.utils.open_file("2001-11") for line in file.readlines(): split = line.strip().split('~') program = split[1] - if program != "katie": + if program != "katie" and program != "process-accepted": continue action = split[2] if action != "installing changes" and action != "installed": @@ -214,23 +213,23 @@ SELECT suite, count(suite) FROM src_associations GROUP BY suite;""") def main (): global Cnf, projectB - Cnf = utils.get_conf() - Arguments = [('h',"help","Saffron::Options::Help")] + Cnf = dak.lib.utils.get_conf() + Arguments = [('h',"help","Stats::Options::Help")] for i in [ "help" ]: - if not Cnf.has_key("Saffron::Options::%s" % (i)): - Cnf["Saffron::Options::%s" % (i)] = "" + if not Cnf.has_key("Stats::Options::%s" % (i)): + Cnf["Stats::Options::%s" % (i)] = "" args = apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv) - Options = Cnf.SubTree("Saffron::Options") + Options = Cnf.SubTree("Stats::Options") if Options["Help"]: usage() if len(args) < 1: - utils.warn("saffron requires at least one argument") + dak.lib.utils.warn("dak stats requires a MODE argument") usage(1) elif len(args) > 1: - utils.warn("saffron accepts only one argument") + dak.lib.utils.warn("dak stats accepts only one MODE argument") usage(1) mode = args[0].lower() @@ -243,7 +242,7 @@ def main (): elif mode == "daily-install": daily_install_stats() else: - utils.warn("unknown mode '%s'" % (mode)) + dak.lib.utils.warn("unknown mode '%s'" % (mode)) usage(1) ################################################################################ diff --git a/dak/symlink_dists.py b/dak/symlink_dists.py index cb6e2f34..82c38701 100755 --- a/dak/symlink_dists.py +++ b/dak/symlink_dists.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # 'Fix' stable to make debian-cd and dpkg -BORGiE users happy -# Copyright (C) 2000, 2001, 2002, 2003 James Troup -# $Id: claire.py,v 1.19 2003-09-07 13:52:11 troup Exp $ +# Copyright (C) 2000, 2001, 2002, 2003, 2006 James Troup # 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 @@ -30,7 +29,7 @@ ################################################################################ import os, pg, re, sys -import utils, db_access +import dak.lib.utils, dak.lib.database import apt_pkg ################################################################################ @@ -43,7 +42,7 @@ projectB = None ################################################################################ def usage (exit_code=0): - print """Usage: claire [OPTIONS] + print """Usage: dak symlink-dists [OPTIONS] Create compatibility symlinks from legacy locations to the pool. -v, --verbose explain what is being done @@ -55,7 +54,7 @@ Create compatibility symlinks from legacy locations to the pool. def fix_component_section (component, section): if component == "": - component = utils.extract_component_from_section(section)[1] + component = dak.lib.utils.extract_component_from_section(section)[1] # FIXME: ugly hacks to work around override brain damage section = re_strip_section_prefix.sub('', section) @@ -101,14 +100,14 @@ SELECT DISTINCT ON (f.id) c.name, sec.section, l.path, f.filename, f.id dest = "%sdists/%s/%s/source/%s%s" % (Cnf["Dir::Root"], codename, component, section, os.path.basename(i[3])) if not os.path.exists(dest): src = i[2]+i[3] - src = utils.clean_symlink(src, dest, Cnf["Dir::Root"]) - if Cnf.Find("Claire::Options::Verbose"): + src = dak.lib.utils.clean_symlink(src, dest, Cnf["Dir::Root"]) + if Cnf.Find("Symlink-Dists::Options::Verbose"): print src+' -> '+dest os.symlink(src, dest) dislocated_files[i[4]] = dest # Binary - architectures = filter(utils.real_arch, Cnf.ValueList("Suite::Stable::Architectures")) + architectures = filter(dak.lib.utils.real_arch, Cnf.ValueList("Suite::Stable::Architectures")) q = projectB.query(""" SELECT DISTINCT ON (f.id) c.name, a.arch_string, sec.section, b.package, b.version, l.path, f.filename, f.id @@ -135,13 +134,13 @@ SELECT DISTINCT ON (f.id) c.name, a.arch_string, sec.section, b.package, section="" architecture = i[1] package = i[3] - version = utils.re_no_epoch.sub('', i[4]) + version = dak.lib.utils.re_no_epoch.sub('', i[4]) src = i[5]+i[6] dest = "%sdists/%s/%s/binary-%s/%s%s_%s.deb" % (Cnf["Dir::Root"], codename, component, architecture, section, package, version) - src = utils.clean_symlink(src, dest, Cnf["Dir::Root"]) + src = dak.lib.utils.clean_symlink(src, dest, Cnf["Dir::Root"]) if not os.path.exists(dest): - if Cnf.Find("Claire::Options::Verbose"): + if Cnf.Find("Symlink-Dists::Options::Verbose"): print src+' -> '+dest os.symlink(src, dest) dislocated_files[i[7]] = dest @@ -150,7 +149,7 @@ SELECT DISTINCT ON (f.id) c.name, a.arch_string, sec.section, b.package, for arch in architectures: dest = "%sdists/%s/%s/binary-%s/%s%s_%s.deb" % (Cnf["Dir::Root"], codename, component, arch, section, package, version) if not os.path.exists(dest): - if Cnf.Find("Claire::Options::Verbose"): + if Cnf.Find("Symlink-Dists::Options::Verbose"): print src+' -> '+dest os.symlink(src, dest) @@ -161,23 +160,23 @@ SELECT DISTINCT ON (f.id) c.name, a.arch_string, sec.section, b.package, def main (): global Cnf, projectB - Cnf = utils.get_conf() + Cnf = dak.lib.utils.get_conf() - Arguments = [('h',"help","Claire::Options::Help"), - ('v',"verbose","Claire::Options::Verbose")] + Arguments = [('h',"help","Symlink-Dists::Options::Help"), + ('v',"verbose","Symlink-Dists::Options::Verbose")] for i in ["help", "verbose" ]: - if not Cnf.has_key("Claire::Options::%s" % (i)): - Cnf["Claire::Options::%s" % (i)] = "" + if not Cnf.has_key("Symlink-Dists::Options::%s" % (i)): + Cnf["Symlink-Dists::Options::%s" % (i)] = "" apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv) - Options = Cnf.SubTree("Claire::Options") + Options = Cnf.SubTree("Symlink-Dists::Options") if Options["Help"]: usage() projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - db_access.init(Cnf, projectB) + dak.lib.database.init(Cnf, projectB) find_dislocated_stable(Cnf, projectB) diff --git a/dak/test/003/test.py b/dak/test/003/test.py index d5c15ee0..6e3935b2 100755 --- a/dak/test/003/test.py +++ b/dak/test/003/test.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # Check utils.parse_changes()'s for handling of multi-line fields -# Copyright (C) 2000 James Troup +# Copyright (C) 2000, 2006 James Troup # $Id: test.py,v 1.2 2002-10-16 02:47:32 troup Exp $ # This program is free software; you can redistribute it and/or modify @@ -20,7 +20,7 @@ ################################################################################ -# The deal here is that for the first 6 months of katie's +# The deal here is that for the first 6 months of dak's # implementation it has been misparsing multi-line fields in .changes # files; specifically multi-line fields where there _is_ data on the # first line. So, for example: