From: James Troup Date: Wed, 17 May 2006 22:40:14 +0000 (-0500) Subject: import dak.lib.foo as foo for library modules. X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=7aaaad3135c9164390af5897925660842368660b;p=dak.git import dak.lib.foo as foo for library modules. --- diff --git a/dak/check_archive.py b/dak/check_archive.py index 65dca8c6..1e434e34 100755 --- a/dak/check_archive.py +++ b/dak/check_archive.py @@ -27,8 +27,9 @@ ################################################################################ import commands, os, pg, stat, string, sys, time -import dak.lib.database, dak.lib.utils import apt_pkg, apt_inst +import dak.lib.database as database +import dak.lib.utils as utils ################################################################################ @@ -95,11 +96,11 @@ def check_files(): filename = os.path.abspath(i[0] + i[1]) db_files[filename] = "" if os.access(filename, os.R_OK) == 0: - dak.lib.utils.warn("'%s' doesn't exist." % (filename)) + utils.warn("'%s' doesn't exist." % (filename)) filename = Cnf["Dir::Override"]+'override.unreferenced' if os.path.exists(filename): - file = dak.lib.utils.open_file(filename) + file = utils.open_file(filename) for filename in file.readlines(): filename = filename[:-1] excluded[filename] = "" @@ -109,7 +110,7 @@ def check_files(): os.path.walk(Cnf["Dir::Root"]+'pool/', process_dir, None) print - print "%s wasted..." % (dak.lib.utils.size_type(waste)) + print "%s wasted..." % (utils.size_type(waste)) ################################################################################ @@ -121,17 +122,17 @@ def check_dscs(): continue component = component.lower() list_filename = '%s%s_%s_source.list' % (Cnf["Dir::Lists"], suite, component) - list_file = dak.lib.utils.open_file(list_filename) + list_file = utils.open_file(list_filename) for line in list_file.readlines(): file = line[:-1] try: - 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)) + 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)) count += 1 if count: - dak.lib.utils.warn("Found %s invalid .dsc files." % (count)) + utils.warn("Found %s invalid .dsc files." % (count)) ################################################################################ @@ -140,7 +141,7 @@ def check_override(): print suite print "-"*len(suite) print - suite_id = dak.lib.database.get_suite_id(suite) + suite_id = 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 @@ -199,16 +200,16 @@ def check_md5sums(): db_md5sum = i[2] db_size = int(i[3]) try: - file = dak.lib.utils.open_file(filename) + file = utils.open_file(filename) except: - dak.lib.utils.warn("can't open '%s'." % (filename)) + utils.warn("can't open '%s'." % (filename)) continue md5sum = apt_pkg.md5sum(file) size = os.stat(filename)[stat.ST_SIZE] if md5sum != db_md5sum: - dak.lib.utils.warn("**WARNING** md5sum mismatch for '%s' ('%s' [current] vs. '%s' [db])." % (filename, md5sum, db_md5sum)) + utils.warn("**WARNING** md5sum mismatch for '%s' ('%s' [current] vs. '%s' [db])." % (filename, md5sum, db_md5sum)) if size != db_size: - dak.lib.utils.warn("**WARNING** size mismatch for '%s' ('%s' [current] vs. '%s' [db])." % (filename, size, db_size)) + utils.warn("**WARNING** size mismatch for '%s' ('%s' [current] vs. '%s' [db])." % (filename, size, db_size)) print "Done." @@ -234,7 +235,7 @@ def check_timestamps(): for i in ql: filename = os.path.abspath(i[0] + i[1]) if os.access(filename, os.R_OK): - file = dak.lib.utils.open_file(filename) + file = utils.open_file(filename) current_file = filename sys.stderr.write("Processing %s.\n" % (filename)) apt_inst.debExtract(file,Ent,"control.tar.gz") @@ -259,24 +260,24 @@ def check_missing_tar_gz_in_dsc(): filename = os.path.abspath(i[0] + i[1]) try: # NB: don't enforce .dsc syntax - dsc = dak.lib.utils.parse_changes(filename) + dsc = utils.parse_changes(filename) except: - dak.lib.utils.fubar("error parsing .dsc file '%s'." % (filename)) - dsc_files = dak.lib.utils.build_file_list(dsc, is_a_dsc=1) + utils.fubar("error parsing .dsc file '%s'." % (filename)) + dsc_files = utils.build_file_list(dsc, is_a_dsc=1) has_tar = 0 for file in dsc_files.keys(): - m = dak.lib.utils.re_issource.match(file) + m = utils.re_issource.match(file) if not m: - dak.lib.utils.fubar("%s not recognised as source." % (file)) + 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: - dak.lib.utils.warn("%s has no .tar.gz in the .dsc file." % (file)) + utils.warn("%s has no .tar.gz in the .dsc file." % (file)) count += 1 if count: - dak.lib.utils.warn("Found %s invalid .dsc files." % (count)) + utils.warn("Found %s invalid .dsc files." % (count)) ################################################################################ @@ -285,12 +286,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 = dak.lib.utils.temp_filename() + temp_filename = 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 = dak.lib.utils.open_file(temp_filename) + sources = utils.open_file(temp_filename) Sources = apt_pkg.ParseTagFile(sources) while Sources.Step(): source = Sources.Section.Find('Package') @@ -303,7 +304,7 @@ def validate_sources(suite, component): if directory.find("potato") == -1: print "W: %s missing." % (filename) else: - pool_location = dak.lib.utils.poolify (source, component) + pool_location = 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) @@ -311,7 +312,7 @@ def validate_sources(suite, component): # Create symlink pool_filename = os.path.normpath(pool_filename) filename = os.path.normpath(filename) - src = dak.lib.utils.clean_symlink(pool_filename, filename, Cnf["Dir::Root"]) + src = utils.clean_symlink(pool_filename, filename, Cnf["Dir::Root"]) print "Symlinking: %s -> %s" % (filename, src) #os.symlink(src, filename) sources.close() @@ -324,12 +325,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 = dak.lib.utils.temp_filename() + temp_filename = 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 = dak.lib.utils.open_file(temp_filename) + packages = utils.open_file(temp_filename) Packages = apt_pkg.ParseTagFile(packages) while Packages.Step(): filename = "%s/%s" % (Cnf["Dir::Root"], Packages.Section.Find('Filename')) @@ -372,10 +373,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: - dak.lib.utils.warn("%s: doesn't exist." % (filename)) + utils.warn("%s: doesn't exist." % (filename)) else: if os.path.islink(filename): - dak.lib.utils.warn("%s: is a symlink." % (filename)) + 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) @@ -390,7 +391,7 @@ def check_files_not_symlinks(): # (location, location_id) = locations[path] # break # if not location_id: -# dak.lib.utils.fubar("Can't find location for %s (%s)." % (dest, filename)) +# 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") @@ -402,7 +403,7 @@ def chk_bd_process_dir (unused, dirname, filenames): if not name.endswith(".dsc"): continue filename = os.path.abspath(dirname+'/'+name) - dsc = dak.lib.utils.parse_changes(filename) + dsc = utils.parse_changes(filename) for field_name in [ "build-depends", "build-depends-indep" ]: field = dsc.get(field_name) if field: @@ -422,7 +423,7 @@ def check_build_depends(): def main (): global Cnf, projectB, db_files, waste, excluded - Cnf = dak.lib.utils.get_conf() + Cnf = utils.get_conf() Arguments = [('h',"help","Check-Archive::Options::Help")] for i in [ "help" ]: if not Cnf.has_key("Check-Archive::Options::%s" % (i)): @@ -435,15 +436,15 @@ def main (): usage() if len(args) < 1: - dak.lib.utils.warn("dak check-archive requires at least one argument") + utils.warn("dak check-archive requires at least one argument") usage(1) elif len(args) > 1: - dak.lib.utils.warn("dak check-archive accepts only one argument") + 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"])) - dak.lib.database.init(Cnf, projectB) + database.init(Cnf, projectB) if mode == "md5sums": check_md5sums() @@ -466,7 +467,7 @@ def main (): elif mode == "validate-builddeps": check_build_depends() else: - dak.lib.utils.warn("unknown mode '%s'" % (mode)) + utils.warn("unknown mode '%s'" % (mode)) usage(1) ################################################################################ diff --git a/dak/check_overrides.py b/dak/check_overrides.py index 0915b8d4..9caeef4a 100755 --- a/dak/check_overrides.py +++ b/dak/check_overrides.py @@ -49,8 +49,10 @@ ################################################################################ import pg, sys, os -import dak.lib.utils, dak.lib.database, dak.lib.logging import apt_pkg +import dak.lib.database as database +import dak.lib.logging as logging +import dak.lib.utils as utils ################################################################################ @@ -82,26 +84,26 @@ def gen_blacklist(dir): def process(osuite, affected_suites, originosuite, component, type): global Logger, Options, projectB, sections, priorities - osuite_id = dak.lib.database.get_suite_id(osuite) + osuite_id = database.get_suite_id(osuite) if osuite_id == -1: - dak.lib.utils.fubar("Suite '%s' not recognised." % (osuite)) + utils.fubar("Suite '%s' not recognised." % (osuite)) originosuite_id = None if originosuite: - originosuite_id = dak.lib.database.get_suite_id(originosuite) + originosuite_id = database.get_suite_id(originosuite) if originosuite_id == -1: - dak.lib.utils.fubar("Suite '%s' not recognised." % (originosuite)) + utils.fubar("Suite '%s' not recognised." % (originosuite)) - component_id = dak.lib.database.get_component_id(component) + component_id = database.get_component_id(component) if component_id == -1: - dak.lib.utils.fubar("Component '%s' not recognised." % (component)) + utils.fubar("Component '%s' not recognised." % (component)) - type_id = dak.lib.database.get_override_type_id(type) + type_id = database.get_override_type_id(type) if type_id == -1: - 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") + utils.fubar("Type '%s' not recognised. (Valid types are deb, udeb and dsc)" % (type)) + dsc_type_id = database.get_override_type_id("dsc") + deb_type_id = database.get_override_type_id("deb") - source_priority_id = dak.lib.database.get_priority_id("source") + source_priority_id = database.get_priority_id("source") if type == "deb" or type == "udeb": packages = {} @@ -136,7 +138,7 @@ SELECT s.source FROM source s, src_associations sa, files f, location l, src_packages[package] = 1 else: if blacklist.has_key(package): - dak.lib.utils.warn("%s in incoming, not touching" % package) + 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]]) @@ -200,7 +202,7 @@ SELECT s.source FROM source s, src_associations sa, files f, location l, for package, hasoverride in src_packages.items(): if not hasoverride: - dak.lib.utils.warn("%s has no override!" % package) + utils.warn("%s has no override!" % package) else: # binary override for i in q.getresult(): @@ -209,7 +211,7 @@ SELECT s.source FROM source s, src_associations sa, files f, location l, packages[package] = 1 else: if blacklist.has_key(package): - dak.lib.utils.warn("%s in incoming, not touching" % package) + 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]]) @@ -254,7 +256,7 @@ SELECT s.source FROM source s, src_associations sa, files f, location l, for package, hasoverride in packages.items(): if not hasoverride: - dak.lib.utils.warn("%s has no override!" % package) + utils.warn("%s has no override!" % package) projectB.query("COMMIT WORK") sys.stdout.flush() @@ -265,7 +267,7 @@ SELECT s.source FROM source s, src_associations sa, files f, location l, def main (): global Logger, Options, projectB, sections, priorities - Cnf = dak.lib.utils.get_conf() + Cnf = utils.get_conf() Arguments = [('h',"help","Check-Overrides::Options::Help"), ('n',"no-action", "Check-Overrides::Options::No-Action")] @@ -279,7 +281,7 @@ def main (): usage() projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - dak.lib.database.init(Cnf, projectB) + database.init(Cnf, projectB) # init sections, priorities: q = projectB.query("SELECT id, section FROM section") @@ -290,9 +292,9 @@ def main (): priorities[i[0]] = i[1] if not Options["No-Action"]: - Logger = dak.lib.logging.Logger(Cnf, "check-overrides") + Logger = logging.Logger(Cnf, "check-overrides") else: - Logger = dak.lib.logging.Logger(Cnf, "check-overrides", 1) + Logger = logging.Logger(Cnf, "check-overrides", 1) gen_blacklist(Cnf["Dir::Queue::Accepted"]) @@ -327,7 +329,7 @@ def main (): suiteids.append(i[0]) if len(suiteids) != len(suites) or len(suiteids) < 1: - dak.lib.utils.fubar("Couldn't find id's of all suites: %s" % suites) + 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 cb2ef9bb..0dafb648 100755 --- a/dak/check_proposed_updates.py +++ b/dak/check_proposed_updates.py @@ -29,8 +29,9 @@ ################################################################################ import pg, sys, os -import dak.lib.utils, dak.lib.database import apt_pkg, apt_inst +import dak.lib.database as database +import dak.lib.utils as utils ################################################################################ @@ -78,7 +79,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." % (dak.lib.utils.pp_deps(parsed_dep)) + print "Found %s as a real package." % (utils.pp_deps(parsed_dep)) unsat = 0 break # As a virtual? @@ -86,20 +87,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." % (dak.lib.utils.pp_deps(parsed_dep)) + print "Found %s as a virtual package." % (utils.pp_deps(parsed_dep)) unsat = 0 break # As part of the same .changes? - epochless_version = dak.lib.utils.re_no_epoch.sub('', version) + epochless_version = 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." % (dak.lib.utils.pp_deps(parsed_dep)) + print "Found %s in the same upload." % (utils.pp_deps(parsed_dep)) unsat = 0 break # Not found... # [FIXME: must be a better way ... ] - error = "%s not found. [Real: " % (dak.lib.utils.pp_deps(parsed_dep)) + error = "%s not found. [Real: " % (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]) @@ -124,7 +125,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, dak.lib.utils.pp_deps(parsed_dep), dep_type)) + sys.stderr.write("MWAAP! %s: '%s' %s can not be satisifed:\n" % (filename, utils.pp_deps(parsed_dep), dep_type)) for error in unsat: sys.stderr.write(" %s\n" % (error)) pkg_unsat = 1 @@ -133,9 +134,9 @@ def check_dep (depends, dep_type, check_archs, filename, files): def check_package(filename, files): try: - control = apt_pkg.ParseSection(apt_inst.debExtractControl(dak.lib.utils.open_file(filename))) + control = apt_pkg.ParseSection(apt_inst.debExtractControl(utils.open_file(filename))) except: - dak.lib.utils.warn("%s: debExtractControl() raised %s." % (filename, sys.exc_type)) + utils.warn("%s: debExtractControl() raised %s." % (filename, sys.exc_type)) return 1 Depends = control.Find("Depends") Pre_Depends = control.Find("Pre-Depends") @@ -172,10 +173,10 @@ def pass_fail (filename, result): def check_changes (filename): try: - changes = dak.lib.utils.parse_changes(filename) - files = dak.lib.utils.build_file_list(changes) + changes = utils.parse_changes(filename) + files = utils.build_file_list(changes) except: - dak.lib.utils.warn("Error parsing changes file '%s'" % (filename)) + utils.warn("Error parsing changes file '%s'" % (filename)) return result = 0 @@ -183,7 +184,7 @@ def check_changes (filename): # Move to the pool directory cwd = os.getcwd() file = files.keys()[0] - pool_dir = Cnf["Dir::Pool"] + '/' + dak.lib.utils.poolify(changes["source"], files[file]["component"]) + pool_dir = Cnf["Dir::Pool"] + '/' + utils.poolify(changes["source"], files[file]["component"]) os.chdir(pool_dir) changes_result = 0 @@ -209,7 +210,7 @@ def check_deb (filename): ################################################################################ def check_joey (filename): - file = dak.lib.utils.open_file(filename) + file = utils.open_file(filename) cwd = os.getcwd() os.chdir("%s/dists/proposed-updates" % (Cnf["Dir::Root"])) @@ -219,10 +220,10 @@ def check_joey (filename): if line.find('install') != -1: split_line = line.split() if len(split_line) != 2: - dak.lib.utils.fubar("Parse error (not exactly 2 elements): %s" % (line)) + 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" ]: - dak.lib.utils.fubar("Unknown install type ('%s') from: %s" % (install_type, line)) + utils.fubar("Unknown install type ('%s') from: %s" % (install_type, line)) changes_filename = split_line[1] if Options["debug"]: print "Processing %s..." % (changes_filename) @@ -240,11 +241,11 @@ def parse_packages(): suite = "stable" stable = {} components = Cnf.ValueList("Suite::%s::Components" % (suite)) - architectures = filter(dak.lib.utils.real_arch, Cnf.ValueList("Suite::%s::Architectures" % (suite))) + architectures = filter(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 = dak.lib.utils.open_file(filename, 'r') + packages = utils.open_file(filename, 'r') Packages = apt_pkg.ParseTagFile(packages) while Packages.Step(): package = Packages.Section.Find('Package') @@ -266,7 +267,7 @@ def parse_packages(): def main (): global Cnf, projectB, Options - Cnf = dak.lib.utils.get_conf() + Cnf = utils.get_conf() Arguments = [('d', "debug", "Check-Proposed-Updates::Options::Debug"), ('q',"quiet","Check-Proposed-Updates::Options::Quiet"), @@ -282,10 +283,10 @@ def main (): if Options["Help"]: usage(0) if not arguments: - dak.lib.utils.fubar("need at least one package name as an argument.") + utils.fubar("need at least one package name as an argument.") projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - dak.lib.database.init(Cnf, projectB) + database.init(Cnf, projectB) print "Parsing packages files...", parse_packages() @@ -299,7 +300,7 @@ def main (): elif file.endswith(".joey"): check_joey(file) else: - dak.lib.utils.fubar("Unrecognised file type: '%s'." % (file)) + utils.fubar("Unrecognised file type: '%s'." % (file)) ####################################################################################### diff --git a/dak/clean_proposed_updates.py b/dak/clean_proposed_updates.py index 8c823b50..364e027b 100755 --- a/dak/clean_proposed_updates.py +++ b/dak/clean_proposed_updates.py @@ -20,8 +20,9 @@ ################################################################################ import os, pg, re, sys -import dak.lib.utils, dak.lib.database import apt_pkg +import dak.lib.database as database +import dak.lib.utils as utils ################################################################################ @@ -48,14 +49,14 @@ Need either changes files or an admin.txt file with a '.joey' suffix.""" def check_changes (filename): try: - changes = dak.lib.utils.parse_changes(filename) - files = dak.lib.utils.build_file_list(changes) + changes = utils.parse_changes(filename) + files = utils.build_file_list(changes) except: - dak.lib.utils.warn("Couldn't read changes file '%s'." % (filename)) + utils.warn("Couldn't read changes file '%s'." % (filename)) return num_files = len(files.keys()) for file in files.keys(): - if dak.lib.utils.re_isadeb.match(file): + if utils.re_isadeb.match(file): m = re_isdeb.match(file) pkg = m.group(1) version = m.group(2) @@ -63,7 +64,7 @@ def check_changes (filename): if Options["debug"]: print "BINARY: %s ==> %s_%s_%s" % (file, pkg, version, arch) else: - m = dak.lib.utils.re_issource.match(file) + m = utils.re_issource.match(file) if m: pkg = m.group(1) version = m.group(2) @@ -76,16 +77,16 @@ def check_changes (filename): if Options["debug"]: print "SOURCE: %s ==> %s_%s_%s" % (file, pkg, version, arch) else: - dak.lib.utils.fubar("unknown type, fix me") + utils.fubar("unknown type, fix me") if not pu.has_key(pkg): # FIXME - dak.lib.utils.warn("%s doesn't seem to exist in p-u?? (from %s [%s])" % (pkg, file, filename)) + 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 - dak.lib.utils.warn("%s doesn't seem to exist for %s in p-u?? (from %s [%s])" % (pkg, arch, file, filename)) + utils.warn("%s doesn't seem to exist for %s in p-u?? (from %s [%s])" % (pkg, arch, file, filename)) continue - pu_version = dak.lib.utils.re_no_epoch.sub('', pu[pkg][arch]) + pu_version = utils.re_no_epoch.sub('', pu[pkg][arch]) if pu_version == version: if Options["verbose"]: print "%s: ok" % (file) @@ -98,7 +99,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/" - dak.lib.utils.move(filename, dest) + utils.move(filename, dest) elif new_num_files < num_files: print "%s: lost files, MWAAP." % (filename) else: @@ -108,7 +109,7 @@ def check_changes (filename): ################################################################################ def check_joey (filename): - file = dak.lib.utils.open_file(filename) + file = utils.open_file(filename) cwd = os.getcwd() os.chdir("%s/dists/proposed-updates" % (Cnf["Dir::Root"])) @@ -118,10 +119,10 @@ def check_joey (filename): if line.find('install') != -1: split_line = line.split() if len(split_line) != 2: - dak.lib.utils.fubar("Parse error (not exactly 2 elements): %s" % (line)) + 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" ]: - dak.lib.utils.fubar("Unknown install type ('%s') from: %s" % (install_type, line)) + utils.fubar("Unknown install type ('%s') from: %s" % (install_type, line)) changes_filename = split_line[1] if Options["debug"]: print "Processing %s..." % (changes_filename) @@ -157,7 +158,7 @@ ORDER BY package, version, arch_string def main (): global Cnf, projectB, Options - Cnf = dak.lib.utils.get_conf() + Cnf = utils.get_conf() Arguments = [('d', "debug", "Clean-Proposed-Updates::Options::Debug"), ('v',"verbose","Clean-Proposed-Updates::Options::Verbose"), @@ -172,10 +173,10 @@ def main (): if Options["Help"]: usage(0) if not arguments: - dak.lib.utils.fubar("need at least one package name as an argument.") + utils.fubar("need at least one package name as an argument.") projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - dak.lib.database.init(Cnf, projectB) + database.init(Cnf, projectB) init_pu() @@ -185,7 +186,7 @@ def main (): elif file.endswith(".joey"): check_joey(file) else: - dak.lib.utils.fubar("Unrecognised file type: '%s'." % (file)) + utils.fubar("Unrecognised file type: '%s'." % (file)) ####################################################################################### diff --git a/dak/clean_queues.py b/dak/clean_queues.py index baf53d80..51d6b3b7 100755 --- a/dak/clean_queues.py +++ b/dak/clean_queues.py @@ -34,8 +34,8 @@ ################################################################################ import os, stat, sys, time -import dak.lib.utils import apt_pkg +import dak.lib.utils as utils ################################################################################ @@ -72,7 +72,7 @@ def init (): if not os.path.exists(del_dir): os.makedirs(del_dir, 02775) if not os.path.isdir(del_dir): - dak.lib.utils.fubar("%s must be a directory." % (del_dir)) + utils.fubar("%s must be a directory." % (del_dir)) # Move to the directory to clean incoming = Options["Incoming"] @@ -86,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 = dak.lib.utils.find_next_free(dest_filename, 10) - dak.lib.utils.move(file, dest_filename, 0660) + dest_filename = utils.find_next_free(dest_filename, 10) + utils.move(file, dest_filename, 0660) else: - dak.lib.utils.warn("skipping '%s', permission denied." % (os.path.basename(file))) + utils.warn("skipping '%s', permission denied." % (os.path.basename(file))) # Removes any old files. # [Used for Incoming/REJECT] @@ -125,20 +125,20 @@ def flush_orphans (): # Proces all .changes and .dsc files. for changes_filename in changes_files: try: - changes = dak.lib.utils.parse_changes(changes_filename) - files = dak.lib.utils.build_file_list(changes) + changes = utils.parse_changes(changes_filename) + files = utils.build_file_list(changes) except: - dak.lib.utils.warn("error processing '%s'; skipping it. [Got %s]" % (changes_filename, sys.exc_type)) + 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 = dak.lib.utils.parse_changes(file) - dsc_files = dak.lib.utils.build_file_list(dsc, is_a_dsc=1) + dsc = utils.parse_changes(file) + dsc_files = utils.build_file_list(dsc, is_a_dsc=1) except: - dak.lib.utils.warn("error processing '%s'; skipping it. [Got %s]" % (file, sys.exc_type)) + utils.warn("error processing '%s'; skipping it. [Got %s]" % (file, sys.exc_type)) continue # Ensure all the files we've seen aren't deleted @@ -170,7 +170,7 @@ def flush_orphans (): def main (): global Cnf, Options - Cnf = dak.lib.utils.get_conf() + Cnf = utils.get_conf() for i in ["Help", "Incoming", "No-Action", "Verbose" ]: if not Cnf.has_key("Clean-Queues::Options::%s" % (i)): diff --git a/dak/clean_suites.py b/dak/clean_suites.py index ad1d209d..7aa6bee5 100755 --- a/dak/clean_suites.py +++ b/dak/clean_suites.py @@ -30,7 +30,7 @@ import os, pg, stat, sys, time import apt_pkg -import dak.lib.utils +import dak.lib.utils as utils ################################################################################ @@ -208,7 +208,7 @@ def clean(): for i in q.getresult(): filename = i[0] + i[1] if not os.path.exists(filename): - dak.lib.utils.warn("can not find '%s'." % (filename)) + utils.warn("can not find '%s'." % (filename)) continue if os.path.isfile(filename): if os.path.islink(filename): @@ -224,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 = dak.lib.utils.find_next_free(dest_filename) + dest_filename = utils.find_next_free(dest_filename) if Options["No-Action"]: print "Cleaning %s -> %s ..." % (filename, dest_filename) else: - dak.lib.utils.move(filename, dest_filename) + utils.move(filename, dest_filename) else: - dak.lib.utils.fubar("%s is neither symlink nor file?!" % (filename)) + utils.fubar("%s is neither symlink nor file?!" % (filename)) # Delete from the 'files' table if not Options["No-Action"]: @@ -240,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, dak.lib.utils.size_type(size))) + sys.stderr.write("Cleaned %d files, %s.\n" % (count, utils.size_type(size))) ################################################################################ @@ -305,10 +305,10 @@ def clean_queue_build(): for i in q.getresult(): filename = i[0] if not os.path.exists(filename): - dak.lib.utils.warn("%s (from queue_build) doesn't exist." % (filename)) + utils.warn("%s (from queue_build) doesn't exist." % (filename)) continue if not Cnf.FindB("Dinstall::SecurityQueueBuild") and not os.path.islink(filename): - dak.lib.utils.fubar("%s (from queue_build) should be a symlink but isn't." % (filename)) + 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)) @@ -321,7 +321,7 @@ def clean_queue_build(): def main(): global Cnf, Options, projectB, delete_date, now_date - Cnf = dak.lib.utils.get_conf() + Cnf = utils.get_conf() for i in ["Help", "No-Action" ]: if not Cnf.has_key("Clean-Suites::Options::%s" % (i)): Cnf["Clean-Suites::Options::%s" % (i)] = "" diff --git a/dak/compare_suites.py b/dak/compare_suites.py index 0eb458a6..c5be2663 100755 --- a/dak/compare_suites.py +++ b/dak/compare_suites.py @@ -21,8 +21,9 @@ ################################################################################ import pg, sys -import dak.lib.utils, dak.lib.database import apt_pkg +import dak.lib.database as database +import dak.lib.utils as utils ################################################################################ @@ -43,7 +44,7 @@ Looks for fixable descrepancies between stable and unstable. def main (): global Cnf, projectB - Cnf = dak.lib.utils.get_conf() + Cnf = utils.get_conf() Arguments = [('h',"help","Compare-Suites::Options::Help")] for i in [ "help" ]: if not Cnf.has_key("Compare-Suites::Options::%s" % (i)): @@ -56,15 +57,15 @@ def main (): usage() projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - dak.lib.database.init(Cnf, projectB) + database.init(Cnf, projectB) src_suite = "stable" dst_suite = "unstable" - 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") + src_suite_id = database.get_suite_id(src_suite) + dst_suite_id = database.get_suite_id(dst_suite) + arch_all_id = database.get_architecture_id("all") + dsc_type_id = database.get_override_type_id("dsc") for arch in Cnf.ValueList("Suite::%s::Architectures" % (src_suite)): if arch == "source": @@ -76,7 +77,7 @@ def main (): if arch == "all": continue - arch_id = dak.lib.database.get_architecture_id(arch) + arch_id = 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 cf33e26f..851e8cd4 100755 --- a/dak/control_overrides.py +++ b/dak/control_overrides.py @@ -50,7 +50,7 @@ ################################################################################ import pg, sys, time -import dak.lib.utils, dak.lib.database, dak.lib.logging +import utils, database, logging import apt_pkg ################################################################################ @@ -84,17 +84,17 @@ def usage (exit_code=0): ################################################################################ def process_file (file, suite, component, type, action): - suite_id = dak.lib.database.get_suite_id(suite) + suite_id = database.get_suite_id(suite) if suite_id == -1: - dak.lib.utils.fubar("Suite '%s' not recognised." % (suite)) + utils.fubar("Suite '%s' not recognised." % (suite)) - component_id = dak.lib.database.get_component_id(component) + component_id = database.get_component_id(component) if component_id == -1: - dak.lib.utils.fubar("Component '%s' not recognised." % (component)) + utils.fubar("Component '%s' not recognised." % (component)) - type_id = dak.lib.database.get_override_type_id(type) + type_id = database.get_override_type_id(type) if type_id == -1: - dak.lib.utils.fubar("Type '%s' not recognised. (Valid types are deb, udeb and dsc.)" % (type)) + 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 @@ -116,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 = dak.lib.utils.re_comments.sub('', line).strip() + line = utils.re_comments.sub('', line).strip() if line == "": continue @@ -128,7 +128,7 @@ def process_file (file, suite, component, type, action): elif len(split_line) == 3: (package, section, maintainer_override) = split_line else: - dak.lib.utils.warn("'%s' does not break into 'package section [maintainer-override]'." % (line)) + utils.warn("'%s' does not break into 'package section [maintainer-override]'." % (line)) c_error += 1 continue priority = "source" @@ -139,23 +139,23 @@ def process_file (file, suite, component, type, action): elif len(split_line) == 4: (package, priority, section, maintainer_override) = split_line else: - dak.lib.utils.warn("'%s' does not break into 'package priority section [maintainer-override]'." % (line)) + utils.warn("'%s' does not break into 'package priority section [maintainer-override]'." % (line)) c_error += 1 continue - section_id = dak.lib.database.get_section_id(section) + section_id = database.get_section_id(section) if section_id == -1: - dak.lib.utils.warn("'%s' is not a valid section. ['%s' in suite %s, component %s]." % (section, package, suite, component)) + utils.warn("'%s' is not a valid section. ['%s' in suite %s, component %s]." % (section, package, suite, component)) c_error += 1 continue - priority_id = dak.lib.database.get_priority_id(priority) + priority_id = database.get_priority_id(priority) if priority_id == -1: - dak.lib.utils.warn("'%s' is not a valid priority. ['%s' in suite %s, component %s]." % (priority, package, suite, component)) + 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): - dak.lib.utils.warn("Can't insert duplicate entry for '%s'; ignoring all but the first. [suite %s, component %s]" % (package, suite, component)) + 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] = "" @@ -213,33 +213,33 @@ def process_file (file, suite, component, type, action): ################################################################################ def list(suite, component, type): - suite_id = dak.lib.database.get_suite_id(suite) + suite_id = database.get_suite_id(suite) if suite_id == -1: - dak.lib.utils.fubar("Suite '%s' not recognised." % (suite)) + utils.fubar("Suite '%s' not recognised." % (suite)) - component_id = dak.lib.database.get_component_id(component) + component_id = database.get_component_id(component) if component_id == -1: - dak.lib.utils.fubar("Component '%s' not recognised." % (component)) + utils.fubar("Component '%s' not recognised." % (component)) - type_id = dak.lib.database.get_override_type_id(type) + type_id = database.get_override_type_id(type) if type_id == -1: - dak.lib.utils.fubar("Type '%s' not recognised. (Valid types are deb, udeb and dsc)" % (type)) + 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 dak.lib.utils.result_join(i) + print 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 dak.lib.utils.result_join(i[:-1]) + print utils.result_join(i[:-1]) ################################################################################ def main (): global Cnf, projectB, Logger - Cnf = dak.lib.utils.get_conf() + Cnf = utils.get_conf() Arguments = [('a', "add", "Control-Overrides::Options::Add"), ('c', "component", "Control-Overrides::Options::Component", "HasArg"), ('h', "help", "Control-Overrides::Options::Help"), @@ -266,13 +266,13 @@ def main (): usage() projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - dak.lib.database.init(Cnf, projectB) + database.init(Cnf, projectB) action = None for i in [ "add", "list", "set" ]: if Cnf["Control-Overrides::Options::%s" % (i)]: if action: - dak.lib.utils.fubar("Can not perform more than one action at once.") + utils.fubar("Can not perform more than one action at once.") action = i (suite, component, type) = (Cnf["Control-Overrides::Options::Suite"], @@ -282,10 +282,10 @@ def main (): if action == "list": list(suite, component, type) else: - Logger = dak.lib.logging.Logger(Cnf, "control-overrides") + Logger = logging.Logger(Cnf, "control-overrides") if file_list: for file in file_list: - process_file(dak.lib.utils.open_file(file), suite, component, type, action) + process_file(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 35f49eb1..64e82534 100755 --- a/dak/control_suite.py +++ b/dak/control_suite.py @@ -43,7 +43,9 @@ import pg, sys import apt_pkg -import dak.lib.utils, dak.lib.database, dak.lib.logging +import dak.lib.database as database +import dak.lib.logging as logging +import dak.lib.utils as utils ####################################################################################### @@ -75,10 +77,10 @@ def get_id (package, version, architecture): ql = q.getresult() if not ql: - dak.lib.utils.warn("Couldn't find '%s~%s~%s'." % (package, version, architecture)) + utils.warn("Couldn't find '%s~%s~%s'." % (package, version, architecture)) return None if len(ql) > 1: - dak.lib.utils.warn("Found more than one match for '%s~%s~%s'." % (package, version, architecture)) + utils.warn("Found more than one match for '%s~%s~%s'." % (package, version, architecture)) return None id = ql[0][0] return id @@ -108,7 +110,7 @@ def set_suite (file, suite_id): for line in lines: split_line = line.strip().split() if len(split_line) != 3: - dak.lib.utils.warn("'%s' does not break into 'package version architecture'." % (line[:-1])) + utils.warn("'%s' does not break into 'package version architecture'." % (line[:-1])) continue key = " ".join(split_line) desired[key] = "" @@ -143,7 +145,7 @@ def set_suite (file, suite_id): def process_file (file, suite, action): - suite_id = dak.lib.database.get_suite_id(suite) + suite_id = database.get_suite_id(suite) if action == "set": set_suite (file, suite_id) @@ -156,7 +158,7 @@ def process_file (file, suite, action): for line in lines: split_line = line.strip().split() if len(split_line) != 3: - dak.lib.utils.warn("'%s' does not break into 'package version architecture'." % (line[:-1])) + utils.warn("'%s' does not break into 'package version architecture'." % (line[:-1])) continue (package, version, architecture) = split_line @@ -176,13 +178,13 @@ def process_file (file, suite, action): # Take action if action == "add": if assoication_id: - dak.lib.utils.warn("'%s~%s~%s' already exists in suite %s." % (package, version, architecture, suite)) + 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: - dak.lib.utils.warn("'%s~%s~%s' doesn't exist in suite %s." % (package, version, architecture, suite)) + 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)) @@ -197,13 +199,13 @@ def process_file (file, suite, action): # Take action if action == "add": if assoication_id: - dak.lib.utils.warn("'%s~%s~%s' already exists in suite %s." % (package, version, architecture, suite)) + 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: - dak.lib.utils.warn("'%s~%s~%s' doesn't exist in suite %s." % (package, version, architecture, suite)) + 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)) @@ -213,7 +215,7 @@ def process_file (file, suite, action): ####################################################################################### def get_list (suite): - suite_id = dak.lib.database.get_suite_id(suite) + suite_id = 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() @@ -231,7 +233,7 @@ def get_list (suite): def main (): global Cnf, projectB, Logger - Cnf = dak.lib.utils.get_conf() + Cnf = utils.get_conf() Arguments = [('a',"add","Control-Suite::Options::Add", "HasArg"), ('h',"help","Control-Suite::Options::Help"), @@ -251,35 +253,35 @@ def main (): projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"],int(Cnf["DB::Port"])) - dak.lib.database.init(Cnf, projectB) + database.init(Cnf, projectB) action = None for i in ("add", "list", "remove", "set"): 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)) + if database.get_suite_id(suite) == -1: + utils.fubar("Unknown suite '%s'." %(suite)) else: if action: - dak.lib.utils.fubar("Can only perform one action at a time.") + utils.fubar("Can only perform one action at a time.") action = i # Need an action... if action == None: - dak.lib.utils.fubar("No action specified.") + utils.fubar("No action specified.") # Safety/Sanity check if action == "set" and suite != "testing": - dak.lib.utils.fubar("Will not reset a suite other than testing.") + utils.fubar("Will not reset a suite other than testing.") if action == "list": get_list(suite) else: - Logger = dak.lib.logging.Logger(Cnf, "control-suite") + Logger = logging.Logger(Cnf, "control-suite") if file_list: for file in file_list: - process_file(dak.lib.utils.open_file(file), suite, action) + process_file(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 e13b11ce..91b3844a 100755 --- a/dak/cruft_report.py +++ b/dak/cruft_report.py @@ -28,8 +28,9 @@ ################################################################################ import commands, pg, os, string, sys, time -import dak.lib.utils, dak.lib.database import apt_pkg +import dak.lib.database as database +import dak.lib.utils as utils ################################################################################ @@ -115,7 +116,7 @@ def do_anais(architecture, binaries_list, source): ################################################################################ def do_nviu(): - experimental_id = dak.lib.database.get_suite_id("experimental") + experimental_id = database.get_suite_id("experimental") if experimental_id == -1: return # Check for packages in experimental obsoleted by versions in unstable @@ -125,7 +126,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, - dak.lib.database.get_suite_id("unstable"))) + database.get_suite_id("unstable"))) ql = q.getresult() if ql: nviu_to_remove = [] @@ -246,7 +247,7 @@ def do_obsolete_source(duplicate_bins, bin2source): def main (): global Cnf, projectB, suite_id, source_binaries, source_versions - Cnf = dak.lib.utils.get_conf() + Cnf = utils.get_conf() Arguments = [('h',"help","Cruft-Report::Options::Help"), ('m',"mode","Cruft-Report::Options::Mode", "HasArg"), @@ -271,11 +272,11 @@ def main (): elif Options["Mode"] == "full": checks = [ "nbs", "nviu", "obsolete source", "dubious nbs", "bnb", "bms", "anais" ] else: - dak.lib.utils.warn("%s is not a recognised mode - only 'full' or 'daily' are understood." % (Options["Mode"])) + 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"])) - dak.lib.database.init(Cnf, projectB) + database.init(Cnf, projectB) bin_pkgs = {} src_pkgs = {} @@ -288,7 +289,7 @@ def main (): duplicate_bins = {} suite = Options["Suite"] - suite_id = dak.lib.database.get_suite_id(suite) + suite_id = database.get_suite_id(suite) bin_not_built = {} @@ -307,12 +308,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 = dak.lib.utils.temp_filename() + temp_filename = 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 = dak.lib.utils.open_file(temp_filename) + sources = utils.open_file(temp_filename) Sources = apt_pkg.ParseTagFile(sources) while Sources.Step(): source = Sources.Section.Find('Package') @@ -352,16 +353,16 @@ def main (): # Checks based on the Packages files for component in components + ['main/debian-installer']: - architectures = filter(dak.lib.utils.real_arch, Cnf.ValueList("Suite::%s::Architectures" % (suite))) + architectures = filter(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 = dak.lib.utils.temp_filename() + temp_filename = 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 = dak.lib.utils.open_file(temp_filename) + packages = utils.open_file(temp_filename) Packages = apt_pkg.ParseTagFile(packages) while Packages.Step(): package = Packages.Section.Find('Package') @@ -378,7 +379,7 @@ def main (): bin2source[package]["version"] = version bin2source[package]["source"] = source if source.find("(") != -1: - m = dak.lib.utils.re_extract_src_version.match(source) + m = 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 84b68408..1712e4b6 100755 --- a/dak/decode_dot_dak.py +++ b/dak/decode_dot_dak.py @@ -27,9 +27,9 @@ ################################################################################ import sys -import dak.lib.queue, dak.lib.utils import apt_pkg - +import dak.lib.queue as queue +import dak.lib.utils as utils ################################################################################ @@ -43,7 +43,7 @@ Dumps the info in .dak FILE(s). ################################################################################ def main(): - Cnf = dak.lib.utils.get_conf() + Cnf = utils.get_conf() Arguments = [('h',"help","Decode-Dot-Dak::Options::Help")] for i in [ "help" ]: if not Cnf.has_key("Decode-Dot-Dak::Options::%s" % (i)): @@ -55,9 +55,9 @@ def main(): if Options["Help"]: usage() - k = dak.lib.queue.Upload(Cnf) + k = queue.Upload(Cnf) for arg in sys.argv[1:]: - arg = dak.lib.utils.validate_changes_file_arg(arg,require_changes=-1) + arg = utils.validate_changes_file_arg(arg,require_changes=-1) k.pkg.changes_file = arg print "%s:" % (arg) k.init_vars() @@ -83,7 +83,7 @@ def main(): del changes[i] print if changes: - dak.lib.utils.warn("changes still has following unrecognised keys: %s" % (changes.keys())) + utils.warn("changes still has following unrecognised keys: %s" % (changes.keys())) dsc = k.pkg.dsc print " Dsc:" @@ -94,7 +94,7 @@ def main(): del dsc[i] print if dsc: - dak.lib.utils.warn("dsc still has following unrecognised keys: %s" % (dsc.keys())) + utils.warn("dsc still has following unrecognised keys: %s" % (dsc.keys())) files = k.pkg.files print " Files:" @@ -108,7 +108,7 @@ def main(): print " %s: %s" % (i.capitalize(), files[file][i]) del files[file][i] if files[file]: - dak.lib.utils.warn("files[%s] still has following unrecognised keys: %s" % (file, files[file].keys())) + utils.warn("files[%s] still has following unrecognised keys: %s" % (file, files[file].keys())) print dsc_files = k.pkg.dsc_files @@ -125,7 +125,7 @@ def main(): print " %s: %s" % (i.capitalize(), dsc_files[file][i]) del dsc_files[file][i] if dsc_files[file]: - dak.lib.utils.warn("dsc_files[%s] still has following unrecognised keys: %s" % (file, dsc_files[file].keys())) + 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 1749bb20..a9de6fc3 100755 --- a/dak/examine_package.py +++ b/dak/examine_package.py @@ -33,9 +33,9 @@ ################################################################################ import errno, os, re, sys -import dak.lib.utils +import utils import apt_pkg, apt_inst -import pg, dak.lib.database +import pg, database ################################################################################ @@ -79,9 +79,9 @@ maintainer_colour = arch_colour Cnf = None projectB = None -Cnf = dak.lib.utils.get_conf() +Cnf = utils.get_conf() projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) -dak.lib.database.init(Cnf, projectB) +database.init(Cnf, projectB) ################################################################################ @@ -144,7 +144,7 @@ def read_control (filename): maintainer = '' arch = '' - deb_file = dak.lib.utils.open_file(filename) + deb_file = utils.open_file(filename) try: extracts = apt_inst.debExtractControl(deb_file) control = apt_pkg.ParseSection(extracts) @@ -195,9 +195,9 @@ def read_control (filename): def read_dsc (dsc_filename): dsc = {} - dsc_file = dak.lib.utils.open_file(dsc_filename) + dsc_file = utils.open_file(dsc_filename) try: - dsc = dak.lib.utils.parse_changes(dsc_filename) + dsc = utils.parse_changes(dsc_filename) except: print "can't parse control info" dsc_file.close() @@ -346,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 = dak.lib.utils.open_file (filename) + file = utils.open_file (filename) contents = "" inside_signature = 0 skip_next = 0 @@ -379,8 +379,8 @@ def display_changes (changes_filename): def check_changes (changes_filename): display_changes(changes_filename) - changes = dak.lib.utils.parse_changes (changes_filename) - files = dak.lib.utils.build_file_list(changes) + changes = utils.parse_changes (changes_filename) + files = utils.build_file_list(changes) for file in files.keys(): if file.endswith(".deb") or file.endswith(".udeb"): check_deb(file) @@ -391,7 +391,7 @@ def check_changes (changes_filename): def main (): global Cnf, projectB, db_files, waste, excluded -# Cnf = dak.lib.utils.get_conf() +# Cnf = utils.get_conf() Arguments = [('h',"help","Examine-Package::Options::Help")] for i in [ "help" ]: @@ -421,19 +421,19 @@ def main (): elif file.endswith(".dsc"): check_dsc(file) else: - dak.lib.utils.fubar("Unrecognised file type: '%s'." % (file)) + 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': - dak.lib.utils.warn("[examine-package] Caught EPIPE; skipping.") + utils.warn("[examine-package] Caught EPIPE; skipping.") pass else: raise except KeyboardInterrupt: - dak.lib.utils.warn("[examine-package] Caught C-c; skipping.") + utils.warn("[examine-package] Caught C-c; skipping.") pass ####################################################################################### diff --git a/dak/find_null_maintainers.py b/dak/find_null_maintainers.py index 574dc0b9..de5e0291 100755 --- a/dak/find_null_maintainers.py +++ b/dak/find_null_maintainers.py @@ -21,7 +21,7 @@ import ldap, pg, sys, time import apt_pkg -import dak.lib.utils +import dak.lib.utils as utils ################################################################################ @@ -50,7 +50,7 @@ def get_ldap_value(entry, value): def main(): global Cnf, projectB - Cnf = dak.lib.utils.get_conf() + Cnf = utils.get_conf() Arguments = [('h',"help","Find-Null-Maintainers::Options::Help")] for i in [ "help" ]: if not Cnf.has_key("Find-Null-Maintainers::Options::%s" % (i)): diff --git a/dak/generate_index_diffs.py b/dak/generate_index_diffs.py index de473d65..51f1653d 100755 --- a/dak/generate_index_diffs.py +++ b/dak/generate_index_diffs.py @@ -6,8 +6,8 @@ # idea and basic implementation by Anthony, some changes by Andreas # parts are stolen from 'dak generate-releases' # -# Copyright (C) 2004-6, 6 Anthony Towns -# Copyright (C) 2004-5 Andreas Barth +# Copyright (C) 2004, 2005, 2006 Anthony Towns +# Copyright (C) 2004, 2005 Andreas Barth # 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 +32,7 @@ import sys, os, tempfile import apt_pkg -import dak.lib.utils +import dak.lib.utils as utils ################################################################################ @@ -288,7 +288,7 @@ def main(): os.umask(0002) - Cnf = dak.lib.utils.get_conf() + Cnf = 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"), @@ -314,7 +314,7 @@ def main(): o.close() AptCnf = apt_pkg.newConfiguration() - apt_pkg.ReadConfigFileISC(AptCnf,dak.lib.utils.which_apt_conf_file()) + apt_pkg.ReadConfigFileISC(AptCnf,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(dak.lib.utils.which_apt_conf_file()) + aptcnf_filename = os.path.basename(utils.which_apt_conf_file()) print "ALERT: suite %s not in %s, nor untouchable!" % (suite, aptcnf_filename) continue diff --git a/dak/generate_releases.py b/dak/generate_releases.py index 6ca6d3d3..b76ab69e 100755 --- a/dak/generate_releases.py +++ b/dak/generate_releases.py @@ -23,8 +23,8 @@ ################################################################################ import sys, os, popen2, tempfile, stat, time -import dak.lib.utils import apt_pkg +import dak.lib.utils as utils ################################################################################ @@ -104,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 = dak.lib.utils.open_file(path + name) - except dak.lib.utils.cant_open_exc: + file_handle = utils.open_file(path + name) + except utils.cant_open_exc: print "ALERT: Couldn't open " + path + name else: hash = hashop(file_handle) @@ -124,7 +124,7 @@ def main (): global Cnf, AptCnf, projectB, out out = sys.stdout - Cnf = dak.lib.utils.get_conf() + Cnf = utils.get_conf() Arguments = [('h',"help","Generate-Releases::Options::Help")] for i in [ "help" ]: @@ -138,7 +138,7 @@ def main (): usage() AptCnf = apt_pkg.newConfiguration() - apt_pkg.ReadConfigFileISC(AptCnf,dak.lib.utils.which_apt_conf_file()) + apt_pkg.ReadConfigFileISC(AptCnf,utils.which_apt_conf_file()) if not suites: suites = Cnf.SubTree("Suite").List() @@ -181,7 +181,7 @@ def main (): elif AptCnf.has_key("bindirectory::%s" % (tree)): pass else: - aptcnf_filename = os.path.basename(dak.lib.utils.which_apt_conf_file()) + aptcnf_filename = os.path.basename(utils.which_apt_conf_file()) print "ALERT: suite %s not in %s, nor untouchable!" % (suite, aptcnf_filename) continue @@ -198,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(dak.lib.utils.real_arch, SuiteBlock.ValueList("Architectures"))))) + out.write("Architectures: %s\n" % (" ".join(filter(utils.real_arch, SuiteBlock.ValueList("Architectures"))))) if components: out.write("Components: %s\n" % (" ".join(components))) @@ -237,7 +237,7 @@ def main (): release = open(relpath, "w") #release = open(longsuite.replace("/","_") + "_" + arch + "_" + sec + "_Release", "w") except IOError: - dak.lib.utils.fubar("Couldn't write to " + relpath) + 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 7e271d8d..13343c2f 100755 --- a/dak/import_archive.py +++ b/dak/import_archive.py @@ -38,7 +38,8 @@ import commands, os, pg, re, sys, time import apt_pkg -import dak.lib.database, dak.lib.utils +import dak.lib.database as database +import dak.lib.utils as utils ############################################################################### @@ -92,14 +93,14 @@ def reject (str, prefix="Rejected: "): ############################################################################### def check_signature (filename): - if not dak.lib.utils.re_taint_free.match(os.path.basename(filename)): + if not 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) = dak.lib.utils.gpgv_get_status_output(cmd, status_read, status_write) + (output, status, exit_status) = utils.gpgv_get_status_output(cmd, status_read, status_write) # Process the status-fd output keywords = {} @@ -132,7 +133,7 @@ def check_signature (filename): # Now check for obviously bad things in the processed output if keywords.has_key("SIGEXPIRED"): - dak.lib.utils.warn("%s: signing key has expired." % (filename)) + 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 @@ -153,7 +154,7 @@ def check_signature (filename): reject("ascii armour of signature was corrupt in %s." % (filename)) bad = 1 if keywords.has_key("NODATA"): - dak.lib.utils.warn("no signature found for %s." % (filename)) + utils.warn("no signature found for %s." % (filename)) return "NOSIG" #reject("no signature found in %s." % (filename)) #bad = 1 @@ -165,9 +166,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(dak.lib.utils.prefix_multi_line_string(status, " [GPG status-fd output:] "), "") + reject(utils.prefix_multi_line_string(status, " [GPG status-fd output:] "), "") else: - reject(dak.lib.utils.prefix_multi_line_string(output, " [GPG output:] "), "") + reject(utils.prefix_multi_line_string(output, " [GPG output:] "), "") return None # Sanity check the good stuff we expect @@ -190,7 +191,7 @@ def check_signature (filename): bad = 1 # Finally ensure there's not something we don't recognise - known_keywords = dak.lib.utils.Dict(VALIDSIG="",SIG_ID="",GOODSIG="",BADSIG="",ERRSIG="", + known_keywords = utils.Dict(VALIDSIG="",SIG_ID="",GOODSIG="",BADSIG="",ERRSIG="", SIGEXPIRED="",KEYREVOKED="",NO_PUBKEY="",BADARMOR="", NODATA="") @@ -231,13 +232,13 @@ def update_locations (): projectB.query("DELETE FROM location") for location in Cnf.SubTree("Location").List(): SubSec = Cnf.SubTree("Location::%s" % (location)) - archive_id = dak.lib.database.get_archive_id(SubSec["archive"]) + archive_id = 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 = dak.lib.database.get_component_id(component) + component_id = 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"])) @@ -255,7 +256,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 = dak.lib.database.get_architecture_id (architecture) + architecture_id = 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(): @@ -297,7 +298,7 @@ def get_location_path(directory): try: path = q.getresult()[0][0] except: - dak.lib.utils.fubar("[import-archive] get_location_path(): Couldn't get path for %s" % (directory)) + utils.fubar("[import-archive] get_location_path(): Couldn't get path for %s" % (directory)) location_path_cache[directory] = path return path @@ -320,41 +321,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 = dak.lib.database.get_suite_id(suite) + suite_id = database.get_suite_id(suite) try: - file = dak.lib.utils.open_file (filename) - except dak.lib.utils.cant_open_exc: - dak.lib.utils.warn("can't open '%s'" % (filename)) + file = utils.open_file (filename) + except utils.cant_open_exc: + 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, dak.lib.utils.re_no_epoch.sub('', version))) + dsc_file = os.path.join(Cnf["Dir::Root"], directory, "%s_%s.dsc" % (package, 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"] + 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))) + 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))) if not os.path.exists(dsc_file): - dak.lib.utils.fubar("%s not found." % (dsc_file)) + 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 = dak.lib.database.get_or_set_fingerprint_id(fingerprint) + fingerprint_id = database.get_or_set_fingerprint_id(fingerprint) if reject_message: - dak.lib.utils.fubar("%s: %s" % (dsc_file, reject_message)) + utils.fubar("%s: %s" % (dsc_file, reject_message)) maintainer = Scanner.Section["maintainer"] maintainer = maintainer.replace("'", "\\'") - maintainer_id = dak.lib.database.get_or_set_maintainer_id(maintainer) + maintainer_id = database.get_or_set_maintainer_id(maintainer) location = get_location_path(directory.split('/')[0]) - location_id = dak.lib.database.get_location_id (location, component, archive) + location_id = 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 = dak.lib.utils.re_no_epoch.sub('', version) + no_epoch_version = 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'): @@ -403,11 +404,11 @@ def process_packages (filename, suite, component, archive): count_total = 0 count_bad = 0 suite = suite.lower() - suite_id = dak.lib.database.get_suite_id(suite) + suite_id = database.get_suite_id(suite) try: - file = dak.lib.utils.open_file (filename) - except dak.lib.utils.cant_open_exc: - dak.lib.utils.warn("can't open '%s'" % (filename)) + file = utils.open_file (filename) + except utils.cant_open_exc: + utils.warn("can't open '%s'" % (filename)) return Scanner = apt_pkg.ParseTagFile(file) while Scanner.Step() != 0: @@ -415,25 +416,25 @@ def process_packages (filename, suite, component, archive): version = Scanner.Section["version"] maintainer = Scanner.Section["maintainer"] maintainer = maintainer.replace("'", "\\'") - maintainer_id = dak.lib.database.get_or_set_maintainer_id(maintainer) + maintainer_id = database.get_or_set_maintainer_id(maintainer) architecture = Scanner.Section["architecture"] - architecture_id = dak.lib.database.get_architecture_id (architecture) + architecture_id = database.get_architecture_id (architecture) fingerprint = "NOSIG" - fingerprint_id = dak.lib.database.get_or_set_fingerprint_id(fingerprint) + fingerprint_id = 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 = dak.lib.utils.re_extract_src_version.match(source) + m = 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 = dak.lib.database.get_location_id (location, component, archive) + location_id = database.get_location_id (location, component, archive) filename = poolify (filename, location) if architecture == "all": filename = re_arch_from_filename.sub("binary-all", filename) @@ -473,10 +474,10 @@ def process_packages (filename, suite, component, archive): ############################################################################### def do_sources(sources, suite, component, server): - temp_filename = dak.lib.utils.temp_filename() + temp_filename = utils.temp_filename() (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (sources, temp_filename)) if (result != 0): - dak.lib.utils.fubar("Gunzip invocation failed!\n%s" % (output), result) + utils.fubar("Gunzip invocation failed!\n%s" % (output), result) print 'Processing '+sources+'...' process_sources (temp_filename, suite, component, server) os.unlink(temp_filename) @@ -486,7 +487,7 @@ 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 = dak.lib.utils.get_conf() + Cnf = utils.get_conf() Arguments = [('a', "action", "Import-Archive::Options::Action"), ('h', "help", "Import-Archive::Options::Help")] for i in [ "action", "help" ]: @@ -500,7 +501,7 @@ def do_da_do_da (): usage() if not Options["Action"]: - dak.lib.utils.warn("""no -a/--action given; not doing anything. + utils.warn("""no -a/--action given; not doing anything. Please read the documentation before running this script. """) usage(1) @@ -508,12 +509,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): - dak.lib.utils.fubar("psql invocation failed!\n", result) + utils.fubar("psql invocation failed!\n", result) print output projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - dak.lib.database.init (Cnf, projectB) + database.init (Cnf, projectB) print "Adding static tables from conf file..." projectB.query("BEGIN WORK") @@ -527,12 +528,12 @@ Please read the documentation before running this script. update_section() projectB.query("COMMIT WORK") - 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") + files_query_cache = utils.open_file(Cnf["Import-Archive::ExportDir"]+"files","w") + source_query_cache = utils.open_file(Cnf["Import-Archive::ExportDir"]+"source","w") + src_associations_query_cache = utils.open_file(Cnf["Import-Archive::ExportDir"]+"src_associations","w") + dsc_files_query_cache = utils.open_file(Cnf["Import-Archive::ExportDir"]+"dsc_files","w") + binaries_query_cache = utils.open_file(Cnf["Import-Archive::ExportDir"]+"binaries","w") + bin_associations_query_cache = utils.open_file(Cnf["Import-Archive::ExportDir"]+"bin_associations","w") projectB.query("BEGIN WORK") # Process Sources files to popoulate `source' and friends @@ -550,7 +551,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: - dak.lib.utils.fubar("Unknown location type ('%s')." % (type)) + utils.fubar("Unknown location type ('%s')." % (type)) # Process Packages files to populate `binaries' and friends @@ -566,7 +567,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(dak.lib.utils.real_arch, + architectures = filter(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' @@ -601,14 +602,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): - dak.lib.utils.fubar("psql invocation failed!\n%s" % (output), result) + utils.fubar("psql invocation failed!\n%s" % (output), result) return ################################################################################ def main(): - dak.lib.utils.try_with_debug(do_da_do_da) + utils.try_with_debug(do_da_do_da) ################################################################################ diff --git a/dak/import_ldap_fingerprints.py b/dak/import_ldap_fingerprints.py index 381feeb6..1e050594 100755 --- a/dak/import_ldap_fingerprints.py +++ b/dak/import_ldap_fingerprints.py @@ -46,7 +46,8 @@ import commands, ldap, pg, re, sys import apt_pkg -import dak.lib.database, dak.lib.utils +import dak.lib.database as database +import dak.lib.utils as utils ################################################################################ @@ -78,7 +79,7 @@ def get_ldap_value(entry, value): def main(): global Cnf, projectB - Cnf = dak.lib.utils.get_conf() + Cnf = utils.get_conf() Arguments = [('h',"help","Import-LDAP-Fingerprints::Options::Help")] for i in [ "help" ]: if not Cnf.has_key("Import-LDAP-Fingerprints::Options::%s" % (i)): @@ -91,7 +92,7 @@ def main(): usage() projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - dak.lib.database.init(Cnf, projectB) + database.init(Cnf, projectB) LDAPDn = Cnf["Import-LDAP-Fingerprints::LDAPDn"] LDAPServer = Cnf["Import-LDAP-Fingerprints::LDAPServer"] @@ -119,7 +120,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 = dak.lib.database.get_or_set_uid_id(uid) + uid_id = 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): @@ -129,7 +130,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: - dak.lib.utils.fubar("%s has %s in LDAP, but projectB says it should be %s." % (uid, fingerprint, existing_uid)) + 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") @@ -143,11 +144,11 @@ 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 - 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:] "))) + 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:] "))) primary_key = m.group(1) primary_key = primary_key.replace(" ","") if not ldap_fin_uid_id.has_key(primary_key): - dak.lib.utils.fubar("0x%s (from 0x%s): no UID found in LDAP" % (primary_key, fingerprint)) + 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) @@ -188,7 +189,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 = dak.lib.utils.our_raw_input("Map to which UID ? ") + uid = 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!" @@ -199,9 +200,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 = dak.lib.utils.our_raw_input(prompt).lower() + yn = utils.our_raw_input(prompt).lower() if yn == "y": - uid_id = dak.lib.database.get_or_set_uid_id(uid) + uid_id = 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 cc7ac7a2..b983e74b 100755 --- a/dak/import_users_from_passwd.py +++ b/dak/import_users_from_passwd.py @@ -30,7 +30,7 @@ ################################################################################ import pg, pwd, sys -import dak.lib.utils +import utils import apt_pkg ################################################################################ @@ -54,7 +54,7 @@ Sync PostgreSQL's users with system users. def main (): global Cnf, projectB - Cnf = dak.lib.utils.get_conf() + Cnf = utils.get_conf() Arguments = [('n', "no-action", "Import-Users-From-Passwd::Options::No-Action"), ('q', "quiet", "Import-Users-From-Passwd::Options::Quiet"), @@ -70,7 +70,7 @@ def main (): if Options["Help"]: usage() elif arguments: - dak.lib.utils.warn("dak import-users-from-passwd takes no non-option arguments.") + 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"])) diff --git a/dak/init_db.py b/dak/init_db.py index bb00eeec..928c9a04 100755 --- a/dak/init_db.py +++ b/dak/init_db.py @@ -20,8 +20,9 @@ ################################################################################ import pg, sys -import dak.lib.utils, dak.lib.database import apt_pkg +import dak.lib.database as database +import dak.lib.utils as utils ################################################################################ @@ -48,7 +49,7 @@ def get (c, i): def main (): global Cnf, projectB - Cnf = dak.lib.utils.get_conf() + Cnf = utils.get_conf() Arguments = [('h',"help","Init-DB::Options::Help")] for i in [ "help" ]: if not Cnf.has_key("Init-DB::Options::%s" % (i)): @@ -61,7 +62,7 @@ def main (): usage() projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - dak.lib.database.init(Cnf, projectB) + database.init(Cnf, projectB) # archive @@ -103,17 +104,17 @@ def main (): projectB.query("DELETE FROM location") for location in Cnf.SubTree("Location").List(): Location = Cnf.SubTree("Location::%s" % (location)) - archive_id = dak.lib.database.get_archive_id(Location["Archive"]) + archive_id = 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 = dak.lib.database.get_component_id(component) + component_id = 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: - dak.lib.utils.fubar("E: type '%s' not recognised in location %s." % (type, location)) + utils.fubar("E: type '%s' not recognised in location %s." % (type, location)) projectB.query("COMMIT WORK") # suite @@ -128,9 +129,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 = dak.lib.database.get_architecture_id (architecture) + architecture_id = database.get_architecture_id (architecture) if architecture_id < 0: - dak.lib.utils.fubar("architecture '%s' not found in architecture table for suite %s." % (architecture, suite)) + 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") diff --git a/dak/init_dirs.py b/dak/init_dirs.py index f36c4ca0..82be3463 100755 --- a/dak/init_dirs.py +++ b/dak/init_dirs.py @@ -20,8 +20,8 @@ ################################################################################ import os, sys -import dak.lib.utils import apt_pkg +import dak.lib.utils as utils ################################################################################ @@ -42,7 +42,7 @@ Creates directories for an archive based on dak.conf configuration file. def do_dir(target, config_name): if os.path.exists(target): if not os.path.isdir(target): - dak.lib.utils.fubar("%s (%s) is not a directory." % (target, config_name)) + utils.fubar("%s (%s) is not a directory." % (target, config_name)) else: print "Creating %s ..." % (target) os.makedirs(target) @@ -100,7 +100,7 @@ def create_directories(): def main (): global AptCnf, Cnf, projectB - Cnf = dak.lib.utils.get_conf() + Cnf = utils.get_conf() Arguments = [('h',"help","Init-Dirs::Options::Help")] for i in [ "help" ]: if not Cnf.has_key("Init-Dirs::Options::%s" % (i)): @@ -113,7 +113,7 @@ def main (): usage() AptCnf = apt_pkg.newConfiguration() - apt_pkg.ReadConfigFileISC(AptCnf,dak.lib.utils.which_apt_conf_file()) + apt_pkg.ReadConfigFileISC(AptCnf,utils.which_apt_conf_file()) create_directories() diff --git a/dak/ls.py b/dak/ls.py index c3647b3a..670a7412 100755 --- a/dak/ls.py +++ b/dak/ls.py @@ -27,8 +27,9 @@ ################################################################################ import os, pg, sys -import dak.lib.utils, dak.lib.database import apt_pkg +import dak.lib.database as database +import dak.lib.utils as utils ################################################################################ @@ -60,7 +61,7 @@ ARCH, COMPONENT and SUITE can be comma (or space) separated lists, e.g. def main (): global Cnf, projectB - Cnf = dak.lib.utils.get_conf() + Cnf = utils.get_conf() Arguments = [('a', "architecture", "Ls::Options::Architecture", "HasArg"), ('b', "binarytype", "Ls::Options::BinaryType", "HasArg"), @@ -84,29 +85,29 @@ def main (): if Options["Help"]: usage() if not packages: - dak.lib.utils.fubar("need at least one package name as an argument.") + utils.fubar("need at least one package name as an argument.") projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - dak.lib.database.init(Cnf, projectB) + 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")): - dak.lib.utils.warn("Archive maintenance is in progress; database inconsistencies are possible.") + 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"]: - dak.lib.utils.fubar("-g/--greaterorequal and -G/--greaterthan are mutually exclusive.") + 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) = \ - dak.lib.utils.parse_args(Options) + utils.parse_args(Options) if Options["BinaryType"]: if Options["BinaryType"] != "udeb" and Options["BinaryType"] != "deb": - dak.lib.utils.fubar("Invalid binary type. 'udeb' and 'deb' recognised.") + utils.fubar("Invalid binary type. 'udeb' and 'deb' recognised.") con_bintype = "AND b.type = '%s'" % (Options["BinaryType"]) # REMOVE ME TRAMP if Options["BinaryType"] == "udeb": @@ -177,7 +178,7 @@ 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(dak.lib.utils.arch_compare_sw) + arches.sort(utils.arch_compare_sw) if Options["Format"] == "": #normal sys.stdout.write("%10s | %10s | %13s | " % (pkg, version, suite)) sys.stdout.write(", ".join(arches)) diff --git a/dak/make_maintainers.py b/dak/make_maintainers.py index f60c19b7..36721e3a 100755 --- a/dak/make_maintainers.py +++ b/dak/make_maintainers.py @@ -26,8 +26,9 @@ ################################################################################ import pg, sys -import dak.lib.database, dak.lib.utils import apt_pkg +import dak.lib.database as database +import dak.lib.utils as utils ################################################################################ @@ -53,12 +54,12 @@ def fix_maintainer (maintainer): global fixed_maintainer_cache if not fixed_maintainer_cache.has_key(maintainer): - fixed_maintainer_cache[maintainer] = dak.lib.utils.fix_maintainer(maintainer)[0] + fixed_maintainer_cache[maintainer] = utils.fix_maintainer(maintainer)[0] return fixed_maintainer_cache[maintainer] def get_maintainer (maintainer): - return fix_maintainer(dak.lib.database.get_maintainer(maintainer)) + return fix_maintainer(database.get_maintainer(maintainer)) def get_maintainer_from_source (source_id): global maintainer_from_source_cache @@ -75,7 +76,7 @@ def get_maintainer_from_source (source_id): def main(): global Cnf, projectB - Cnf = dak.lib.utils.get_conf() + Cnf = utils.get_conf() Arguments = [('h',"help","Make-Maintainers::Options::Help")] if not Cnf.has_key("Make-Maintainers::Options::Help"): @@ -88,7 +89,7 @@ def main(): usage() projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - dak.lib.database.init(Cnf, projectB) + database.init(Cnf, projectB) for suite in Cnf.SubTree("Suite").List(): suite = suite.lower() @@ -129,9 +130,9 @@ def main(): # Process any additional Maintainer files (e.g. from non-US or pseudo packages) for filename in extra_files: - file = dak.lib.utils.open_file(filename) + file = utils.open_file(filename) for line in file.readlines(): - line = dak.lib.utils.re_comments.sub('', line).strip() + line = 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 d8402564..40ca41ed 100755 --- a/dak/make_overrides.py +++ b/dak/make_overrides.py @@ -26,8 +26,9 @@ ################################################################################ import pg, sys -import dak.lib.utils, dak.lib.database import apt_pkg +import dak.lib.database as database +import dak.lib.utils as utils ################################################################################ @@ -49,17 +50,17 @@ Outputs the override tables to text files. def do_list(output_file, suite, component, otype): global override - suite_id = dak.lib.database.get_suite_id(suite) + suite_id = database.get_suite_id(suite) if suite_id == -1: - dak.lib.utils.fubar("Suite '%s' not recognised." % (suite)) + utils.fubar("Suite '%s' not recognised." % (suite)) - component_id = dak.lib.database.get_component_id(component) + component_id = database.get_component_id(component) if component_id == -1: - dak.lib.utils.fubar("Component '%s' not recognised." % (component)) + utils.fubar("Component '%s' not recognised." % (component)) - otype_id = dak.lib.database.get_override_type_id(otype) + otype_id = database.get_override_type_id(otype) if otype_id == -1: - dak.lib.utils.fubar("Type '%s' not recognised. (Valid types are deb, udeb and dsc)" % (otype)) + utils.fubar("Type '%s' not recognised. (Valid types are deb, udeb and dsc)" % (otype)) override.setdefault(suite, {}) override[suite].setdefault(component, {}) @@ -69,20 +70,20 @@ 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(dak.lib.utils.result_join(i)+'\n') + output_file.write(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(dak.lib.utils.result_join(i)+'\n') + output_file.write(utils.result_join(i)+'\n') ################################################################################ def main (): global Cnf, projectB, override - Cnf = dak.lib.utils.get_conf() + Cnf = utils.get_conf() Arguments = [('h',"help","Make-Overrides::Options::Help")] for i in [ "help" ]: if not Cnf.has_key("Make-Overrides::Options::%s" % (i)): @@ -93,7 +94,7 @@ def main (): usage() projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - dak.lib.database.init(Cnf, projectB) + database.init(Cnf, projectB) for suite in Cnf.SubTree("Check-Overrides::OverrideSuites").List(): if Cnf.has_key("Suite::%s::Untouchable" % suite) and Cnf["Suite::%s::Untouchable" % suite] != 0: @@ -115,7 +116,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 = dak.lib.utils.open_file(filename, 'w') + output_file = 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 ca1f98b8..92081f69 100755 --- a/dak/make_suite_file_list.py +++ b/dak/make_suite_file_list.py @@ -35,7 +35,10 @@ import copy, os, pg, string, sys import apt_pkg -import poolize, dak.lib.database, dak.lib.logging, dak.lib.utils +import symlink_dists +import dak.lib.database as database +import dak.lib.logging as logging +import dak.lib.utils as utils ################################################################################ @@ -73,7 +76,7 @@ def version_cmp(a, b): def delete_packages(delete_versions, pkg, dominant_arch, suite, dominant_version, delete_table, delete_col, packages): - suite_id = dak.lib.database.get_suite_id(suite) + suite_id = database.get_suite_id(suite) for version in delete_versions: delete_unique_id = version[1] if not packages.has_key(delete_unique_id): @@ -195,7 +198,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 = dak.lib.utils.open_file(filename, "w") + output = utils.open_file(filename, "w") # Generate the final list of files files = {} for id in list: @@ -207,7 +210,7 @@ def write_legacy_mixed_filelist(suite, list, packages, dislocated_files): else: filename = path + filename if files.has_key(filename): - dak.lib.utils.warn("%s (in %s) is duplicated." % (filename, suite)) + utils.warn("%s (in %s) is duplicated." % (filename, suite)) else: files[filename] = "" # Sort the files since apt-ftparchive doesn't @@ -228,7 +231,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 = dak.lib.utils.open_file(filename, "w") + output = utils.open_file(filename, "w") # Generate the final list of files files = {} for id in list: @@ -241,7 +244,7 @@ def write_filelist(suite, component, arch, type, list, packages, dislocated_file else: filename = path + filename if files.has_key(pkg): - dak.lib.utils.warn("%s (in %s/%s, %s) is duplicated." % (pkg, suite, component, filename)) + 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 @@ -271,13 +274,13 @@ def write_filelists(packages, dislocated_files): if not Options["Suite"]: suites = Cnf.SubTree("Suite").List() else: - suites = dak.lib.utils.split_args(Options["Suite"]) + suites = 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 = dak.lib.utils.split_args(Options["Component"]) + components = utils.split_args(Options["Component"]) udeb_components = Cnf.ValueList("Suite::%s::UdebComponents" % (suite)) udeb_components = udeb_components for component in components: @@ -289,7 +292,7 @@ def write_filelists(packages, dislocated_files): if not Options["Architecture"]: architectures = Cnf.ValueList("Suite::%s::Architectures" % (suite)) else: - architectures = dak.lib.utils.split_args(Options["Architectures"]) + architectures = utils.split_args(Options["Architectures"]) for arch in map(string.lower, architectures): d[suite][component].setdefault(arch, {}) if arch == "source": @@ -339,7 +342,7 @@ def stable_dislocation_p(): if not Options["Suite"]: return 1 # Otherwise, look in what suites the user specified - suites = dak.lib.utils.split_args(Options["Suite"]) + suites = utils.split_args(Options["Suite"]) if "stable" in suites: return 1 @@ -352,16 +355,16 @@ 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 = dak.lib.utils.split_args(Options["Suite"]) + suites = utils.split_args(Options["Suite"]) for suite in suites: archall_suite = Cnf.get("Make-Suite-File-List::ArchAllMap::%s" % (suite)) if archall_suite and archall_suite not in suites: - dak.lib.utils.warn("Adding %s as %s maps Arch: all from it." % (archall_suite, suite)) + 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) = \ - dak.lib.utils.parse_args(Options) + utils.parse_args(Options) if stable_dislocation_p(): dislocated_files = symlink_dists.find_dislocated_stable(Cnf, projectB) @@ -405,7 +408,7 @@ SELECT s.id, s.source, 'source', s.version, l.path, f.filename, c.name, f.id, def main(): global Cnf, projectB, Options, Logger - Cnf = dak.lib.utils.get_conf() + Cnf = 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"), @@ -420,8 +423,8 @@ def main(): usage() projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - dak.lib.database.init(Cnf, projectB) - Logger = dak.lib.logging.Logger(Cnf, "make-suite-file-list") + database.init(Cnf, projectB) + Logger = 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 63096877..89af72fd 100755 --- a/dak/mirror_split.py +++ b/dak/mirror_split.py @@ -24,13 +24,14 @@ ############################################################################### import sys -import dak.lib.utils import apt_pkg from stat import S_ISDIR, S_ISLNK, S_ISREG import os import cPickle +import dak.lib.utils as utils + ## Master path is the main repository #MASTER_PATH = "/org/ftp.debian.org/scratch/dsilvers/master" @@ -166,7 +167,7 @@ class MirrorSplitDB: elif S_ISREG(lnl[0]): bdir.files[ln] = lnl[1] else: - dak.lib.utils.fubar( "Confused by %s/%s -- not a dir, link or file" % + 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) ) @@ -350,7 +351,7 @@ Generate hardlink trees of certain architectures def main (): global Cnf - Cnf = dak.lib.utils.get_conf() + Cnf = utils.get_conf() Arguments = [('h',"help","Mirror-Split::Options::Help"), ('l',"list","Mirror-Split::Options::List"), diff --git a/dak/override.py b/dak/override.py index 8c22c23d..10e91e45 100755 --- a/dak/override.py +++ b/dak/override.py @@ -26,8 +26,9 @@ ################################################################################ import pg, sys -import dak.lib.utils, dak.lib.database -import apt_pkg, dak.lib.logging +import apt_pkg, logging +import dak.lib.database as database +import dak.lib.utils as utils ################################################################################ @@ -36,9 +37,9 @@ projectB = None ################################################################################ -# Shamelessly stolen from 'dak rm'. Should probably end up in dak.lib.utils.py +# Shamelessly stolen from 'dak rm'. Should probably end up in utils.py def game_over(): - answer = dak.lib.utils.our_raw_input("Continue (y/N)? ").lower() + answer = utils.our_raw_input("Continue (y/N)? ").lower() if answer != "y": print "Aborted." sys.exit(1) @@ -58,7 +59,7 @@ Make microchanges or microqueries of the overrides def main (): global Cnf, projectB - Cnf = dak.lib.utils.get_conf() + Cnf = utils.get_conf() Arguments = [('h',"help","Override::Options::Help"), ('d',"done","Override::Options::Done", "HasArg"), @@ -78,15 +79,15 @@ def main (): usage() projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - dak.lib.database.init(Cnf, projectB) + database.init(Cnf, projectB) if not arguments: - dak.lib.utils.fubar("package name is a required argument.") + utils.fubar("package name is a required argument.") package = arguments.pop(0) suite = Options["Suite"] if arguments and len(arguments) > 2: - dak.lib.utils.fubar("Too many arguments") + utils.fubar("Too many arguments") if arguments and len(arguments) == 1: # Determine if the argument is a priority or a section... @@ -101,7 +102,7 @@ def main (): elif r[0][1] == 1: arguments = (".",arg) else: - dak.lib.utils.fubar("%s is not a valid section or priority" % (arg)) + utils.fubar("%s is not a valid section or priority" % (arg)) # Retrieve current section/priority... @@ -116,9 +117,9 @@ def main (): """ % (pg._quote(package,"str"), pg._quote(suite,"str"))) if q.ntuples() == 0: - dak.lib.utils.fubar("Unable to find package %s" % (package)) + utils.fubar("Unable to find package %s" % (package)) if q.ntuples() > 1: - dak.lib.utils.fubar("%s is ambiguous. Matches %d packages" % (package,q.ntuples())) + utils.fubar("%s is ambiguous. Matches %d packages" % (package,q.ntuples())) r = q.getresult() oldsection = r[0][1] @@ -141,14 +142,14 @@ def main (): pg._quote(newsection,"str"))) if q.ntuples() == 0: - dak.lib.utils.fubar("Supplied section %s is invalid" % (newsection)) + 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: - dak.lib.utils.fubar("Supplied priority %s is invalid" % (newpriority)) + utils.fubar("Supplied priority %s is invalid" % (newpriority)) newprioid = q.getresult()[0][0] if newpriority == oldpriority and newsection == oldsection: @@ -173,13 +174,13 @@ def main (): if not Options.has_key("Done"): pass - #dak.lib.utils.warn("No bugs to close have been specified. Noone will know you have done this.") + #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 = dak.lib.logging.Logger(Cnf, "override") + Logger = logging.Logger(Cnf, "override") projectB.query("BEGIN WORK") # We're in "do it" mode, we have something to do... do it @@ -222,7 +223,7 @@ def main (): Subst["__CC__"] = "X-DAK: dak override" Subst["__ADMIN_ADDRESS__"] = Cnf["Dinstall::MyAdminAddress"] Subst["__DISTRO__"] = Cnf["Dinstall::MyDistribution"] - Subst["__WHOAMI__"] = dak.lib.utils.whoami() + Subst["__WHOAMI__"] = utils.whoami() summary = "Concerning package %s...\n" % (package) summary += "Operating on the %s suite\n" % (suite) @@ -232,11 +233,11 @@ def main (): summary += "Changed section from %s to %s\n" % (oldsection,newsection) Subst["__SUMMARY__"] = summary - for bug in dak.lib.utils.split_args(Options["Done"]): + for bug in utils.split_args(Options["Done"]): Subst["__BUG_NUMBER__"] = bug - mail_message = dak.lib.utils.TemplateSubst( + mail_message = utils.TemplateSubst( Subst,Cnf["Dir::Templates"]+"/override.bug-close") - dak.lib.utils.send_mail(mail_message) + utils.send_mail(mail_message) Logger.log(["closed bug",bug]) Logger.close() diff --git a/dak/poolize.py b/dak/poolize.py index 66eda7d8..36f1b6bf 100755 --- a/dak/poolize.py +++ b/dak/poolize.py @@ -26,8 +26,9 @@ ################################################################################ import os, pg, re, stat, sys -import dak.lib.utils, dak.lib.database import apt_pkg, apt_inst +import dak.lib.database as database +import dak.lib.utils as utils ################################################################################ @@ -71,7 +72,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: - dak.lib.utils.warn("Hit %s limit." % (dak.lib.utils.size_type(limit))) + utils.warn("Hit %s limit." % (utils.size_type(limit))) break poolized_size += size poolized_count += 1 @@ -79,65 +80,65 @@ 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(dak.lib.utils.open_file(legacy_filename))) + control = apt_pkg.ParseSection(apt_inst.debExtractControl(utils.open_file(legacy_filename))) package = control.Find("Package", "") source = control.Find("Source", package) if source.find("(") != -1: - m = dak.lib.utils.re_extract_src_version.match(source) + m = 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 == "": - 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) + utils.fubar("%s: couldn't determine required information to rename .deb file." % (legacy_filename)) + version = utils.re_no_epoch.sub('', version) destination_filename = "%s_%s_%s.deb" % (package, version, architecture) else: - m = dak.lib.utils.re_issource.match(base_filename) + m = utils.re_issource.match(base_filename) if m: source = m.group(1) else: - dak.lib.utils.fubar("expansion of source filename '%s' failed." % (legacy_filename)) + 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: - dak.lib.utils.fubar("No override match for '%s' so I can't work out the component." % (source)) + utils.fubar("No override match for '%s' so I can't work out the component." % (source)) if len(ql) > 1: - dak.lib.utils.fubar("Multiple override matches for '%s' so I can't work out the component." % (source)) + 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: - dak.lib.utils.fubar("couldn't determine location ID for '%s'. [query returned %d matches, not 1 as expected]" % (source, len(ql))) + 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 = dak.lib.utils.poolify (source, component) + pool_location = utils.poolify (source, component) pool_filename = pool_location + destination_filename destination = Cnf["Dir::Pool"] + pool_location + destination_filename if os.path.exists(destination): - dak.lib.utils.fubar("'%s' already exists in the pool; serious FUBARity." % (legacy_filename)) + 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: - dak.lib.utils.move(legacy_filename, destination) + 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" % (dak.lib.utils.size_type(poolized_size), poolized_count)) + sys.stderr.write("Poolized %s in %s files.\n" % (utils.size_type(poolized_size), poolized_count)) ################################################################################ def main (): global Cnf, projectB - Cnf = dak.lib.utils.get_conf() + Cnf = utils.get_conf() for i in ["help", "limit", "no-action", "verbose" ]: if not Cnf.has_key("Poolize::Options::%s" % (i)): @@ -156,7 +157,7 @@ def main (): usage() projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - dak.lib.database.init(Cnf, projectB) + database.init(Cnf, projectB) if not Options["Limit"]: limit = -1 @@ -169,7 +170,7 @@ def main (): # Sanity check the limit argument if limit > 0 and limit < 1024: - dak.lib.utils.fubar("-l/--limit takes an argument with a value in kilobytes.") + 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 72af3251..6529707d 100755 --- a/dak/process_accepted.py +++ b/dak/process_accepted.py @@ -31,7 +31,10 @@ import errno, fcntl, os, sys, time, re import apt_pkg -import dak.lib.database, dak.lib.queue, dak.lib.logging, dak.lib.utils +import dak.lib.database as database +import dak.lib.logging as logging +import dak.lib.queue as queue +import dak.lib.utils as utils ############################################################################### @@ -73,7 +76,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 = dak.lib.utils.open_file(self.log_filename, 'w') + self.log_file = utils.open_file(self.log_filename, 'w') self.writes = 0 def log (self, source, version, urgency): @@ -88,7 +91,7 @@ class Urgency_Log: self.log_file.close() if self.writes: new_filename = "%s/install-urgencies-%s" % (self.log_dir, self.timestamp) - dak.lib.utils.move(self.log_filename, new_filename) + utils.move(self.log_filename, new_filename) else: os.unlink(self.log_filename) @@ -151,7 +154,7 @@ def check(): def init(): global Cnf, Options, Upload, projectB, changes, dsc, dsc_files, files, pkg, Subst - Cnf = dak.lib.utils.get_conf() + Cnf = utils.get_conf() Arguments = [('a',"automatic","Dinstall::Options::Automatic"), ('h',"help","Dinstall::Options::Help"), @@ -169,7 +172,7 @@ def init(): if Options["Help"]: usage() - Upload = dak.lib.queue.Upload(Cnf) + Upload = queue.Upload(Cnf) projectB = Upload.projectB changes = Upload.pkg.changes @@ -215,8 +218,8 @@ def action (): answer = 'I' while prompt.find(answer) == -1: - answer = dak.lib.utils.our_raw_input(prompt) - m = dak.lib.queue.re_default_answer.match(prompt) + answer = utils.our_raw_input(prompt) + m = queue.re_default_answer.match(prompt) if answer == "": answer = m.group(1) answer = answer[:1].upper() @@ -242,7 +245,7 @@ def do_reject (): Subst["__REJECTOR_ADDRESS__"] = Cnf["Dinstall::MyEmailAddress"] Subst["__REJECT_MESSAGE__"] = reject_message Subst["__CC__"] = "Cc: " + Cnf["Dinstall::MyEmailAddress"] - reject_mail_message = dak.lib.utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/process-accepted.unaccept") + reject_mail_message = 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" @@ -255,7 +258,7 @@ def do_reject (): os.write(fd, reject_mail_message) os.close(fd) - dak.lib.utils.send_mail(reject_mail_message) + utils.send_mail(reject_mail_message) Logger.log(["unaccepted", pkg.changes_file]) ############################################################################### @@ -277,19 +280,19 @@ def install (): version = dsc["version"] # NB: not files[file]["version"], that has no epoch maintainer = dsc["maintainer"] maintainer = maintainer.replace("'", "\\'") - maintainer_id = dak.lib.database.get_or_set_maintainer_id(maintainer) - fingerprint_id = dak.lib.database.get_or_set_fingerprint_id(dsc["fingerprint"]) + maintainer_id = database.get_or_set_maintainer_id(maintainer) + fingerprint_id = 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"] = dak.lib.database.set_files_id (filename, files[file]["size"], files[file]["md5sum"], dsc_location_id) + files[file]["files id"] = 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 = dak.lib.database.get_suite_id(suite) + suite_id = 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) @@ -300,10 +303,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 = dak.lib.database.get_files_id(filename, dsc_files[dsc_file]["size"], dsc_files[dsc_file]["md5sum"], dsc_location_id) + files_id = 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 = dak.lib.database.set_files_id (filename, dsc_files[dsc_file]["size"], dsc_files[dsc_file]["md5sum"], dsc_location_id) + files_id = 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 @@ -313,19 +316,19 @@ def install (): version = files[file]["version"] maintainer = files[file]["maintainer"] maintainer = maintainer.replace("'", "\\'") - maintainer_id = dak.lib.database.get_or_set_maintainer_id(maintainer) - fingerprint_id = dak.lib.database.get_or_set_fingerprint_id(changes["fingerprint"]) + maintainer_id = database.get_or_set_maintainer_id(maintainer) + fingerprint_id = database.get_or_set_fingerprint_id(changes["fingerprint"]) architecture = files[file]["architecture"] - architecture_id = dak.lib.database.get_architecture_id (architecture) + architecture_id = 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"] = dak.lib.database.get_location_id(Cnf["Dir::Pool"],files[file]["component"],dak.lib.utils.where_am_i()) + files[file]["location id"] = database.get_location_id(Cnf["Dir::Pool"],files[file]["component"],utils.where_am_i()) if not files[file].has_key("files id") or not files[file]["files id"]: - 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) + files[file]["files id"] = database.set_files_id (filename, files[file]["size"], files[file]["md5sum"], files[file]["location id"]) + source_id = 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)) @@ -333,7 +336,7 @@ 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 = dak.lib.database.get_suite_id(suite) + suite_id = 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 @@ -351,10 +354,10 @@ def install (): continue # First move the files to the new location legacy_filename = qid["path"] + qid["filename"] - pool_location = dak.lib.utils.poolify (changes["source"], files[file]["component"]) + pool_location = utils.poolify (changes["source"], files[file]["component"]) pool_filename = pool_location + os.path.basename(qid["filename"]) destination = Cnf["Dir::Pool"] + pool_location - dak.lib.utils.move(legacy_filename, destination) + 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"])) @@ -369,17 +372,17 @@ def install (): old_filename = ql[0] + ql[1] file_size = ql[2] file_md5sum = ql[3] - 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) + new_filename = utils.poolify(changes["source"], dsc_component) + os.path.basename(old_filename) + new_files_id = database.get_files_id(new_filename, file_size, file_md5sum, dsc_location_id) if new_files_id == None: - 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) + utils.copy(old_filename, Cnf["Dir::Pool"] + new_filename) + new_files_id = 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 - dak.lib.utils.move(file, destination) + utils.move(file, destination) Logger.log(["installed", file, files[file]["type"], files[file]["size"], files[file]["architecture"]]) install_bytes += float(files[file]["size"]) @@ -393,14 +396,14 @@ def install (): if Cnf.has_key("Suite::%s::CopyDotDak" % (suite)): copy_dot_dak[Cnf["Suite::%s::CopyDotDak" % (suite)]] = "" for dest in copy_changes.keys(): - dak.lib.utils.copy(pkg.changes_file, Cnf["Dir::Root"] + dest) + 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) + utils.copy(Upload.pkg.changes_file[:-8]+".dak", dest) projectB.query("COMMIT WORK") # Move the .changes into the 'done' directory - dak.lib.utils.move (pkg.changes_file, + utils.move (pkg.changes_file, os.path.join(Cnf["Dir::Queue::Done"], os.path.basename(pkg.changes_file))) # Remove the .dak file @@ -416,7 +419,7 @@ def install (): if suite not in Cnf.ValueList("Dinstall::QueueBuildSuites"): continue now_date = time.strftime("%Y-%m-%d %H:%M") - suite_id = dak.lib.database.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) @@ -426,7 +429,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 = dak.lib.utils.poolify (changes["source"], files[file]["component"]) + pool_location = 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) @@ -463,11 +466,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: - dak.lib.utils.fubar("[INTERNAL ERROR] couldn't find '%s' (%s) in source table." % (package, version)) + utils.fubar("[INTERNAL ERROR] couldn't find '%s' (%s) in source table." % (package, version)) source_id = ql[0][0] - suite_id = dak.lib.database.get_suite_id('proposed-updates') + suite_id = database.get_suite_id('proposed-updates') projectB.query("DELETE FROM src_associations WHERE suite = '%s' AND source = '%s'" % (suite_id, source_id)) - suite_id = dak.lib.database.get_suite_id('stable') + suite_id = 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) @@ -480,14 +483,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 = dak.lib.database.get_suite_id('proposed-updates') + suite_id = 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: - dak.lib.utils.fubar("[INTERNAL ERROR] couldn't find '%s' (%s for %s architecture) in binaries table." % (package, version, architecture)) + 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): @@ -495,16 +498,16 @@ def stable_install (summary, short_summary): break if not binNMU: binary_id = ql[0][0] - suite_id = dak.lib.database.get_suite_id('proposed-updates') + suite_id = database.get_suite_id('proposed-updates') projectB.query("DELETE FROM bin_associations WHERE suite = '%s' AND bin = '%s'" % (suite_id, binary_id)) - suite_id = dak.lib.database.get_suite_id('stable') + suite_id = 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") - dak.lib.utils.move (pkg.changes_file, Cnf["Dir::Morgue"] + '/process-accepted/' + os.path.basename(pkg.changes_file)) + 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" @@ -512,31 +515,31 @@ def stable_install (summary, short_summary): if os.path.exists(new_changelog_filename): os.unlink (new_changelog_filename) - new_changelog = dak.lib.utils.open_file(new_changelog_filename, 'w') + new_changelog = 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 dak.lib.utils.re_issource.match(file): + elif 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 = dak.lib.queue.re_fdnic.sub("\n", changes["changes"]) + chop_changes = queue.re_fdnic.sub("\n", changes["changes"]) new_changelog.write(chop_changes + '\n\n') if os.access(changelog_filename, os.R_OK) != 0: - changelog = dak.lib.utils.open_file(changelog_filename) + changelog = 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) - dak.lib.utils.move(new_changelog_filename, changelog_filename) + 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 = dak.lib.utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/process-accepted.installed") - dak.lib.utils.send_mail(mail_message) + mail_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/process-accepted.installed") + utils.send_mail(mail_message) Upload.announce(short_summary, 1) # Finally remove the .dak file @@ -590,7 +593,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"]: - dak.lib.utils.fubar("Archive maintenance in progress. Try again later.") + 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: @@ -603,10 +606,10 @@ 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': - dak.lib.utils.fubar("Couldn't obtain lock; assuming another 'dak process-accepted' is already running.") + utils.fubar("Couldn't obtain lock; assuming another 'dak process-accepted' is already running.") else: raise - Logger = Upload.Logger = dak.lib.logging.Logger(Cnf, "process-accepted") + Logger = Upload.Logger = logging.Logger(Cnf, "process-accepted") if not installing_to_stable and Cnf.get("Dir::UrgencyLog"): Urgency_Logger = Urgency_Log(Cnf) @@ -618,7 +621,7 @@ def main(): Subst["__BCC__"] = bcc # Sort the .changes files so that we process sourceful ones first - changes_files.sort(dak.lib.utils.changes_compare) + changes_files.sort(utils.changes_compare) # Process the changes files for changes_file in changes_files: @@ -629,7 +632,7 @@ def main(): sets = "set" if install_count > 1: sets = "sets" - sys.stderr.write("Installed %d package %s, %s.\n" % (install_count, sets, dak.lib.utils.size_type(int(install_bytes)))) + sys.stderr.write("Installed %d package %s, %s.\n" % (install_count, sets, 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 964e50e5..5d110f31 100755 --- a/dak/process_new.py +++ b/dak/process_new.py @@ -38,7 +38,11 @@ import copy, errno, os, readline, stat, sys, time import apt_pkg, apt_inst -import dak.lib.database, examine_package, dak.lib.queue, dak.lib.logging, dak.lib.utils +import examine_package +import dak.lib.database as database +import dak.lib.logging as logging +import dak.lib.queue as queue +import dak.lib.utils as utils # Globals Cnf = None @@ -77,7 +81,7 @@ def recheck(): source_package = files[file]["source package"] 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) + source_epochless_version = 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)) @@ -99,8 +103,8 @@ def recheck(): prompt = "[R]eject, Skip, Quit ?" while prompt.find(answer) == -1: - answer = dak.lib.utils.our_raw_input(prompt) - m = dak.lib.queue.re_default_answer.match(prompt) + answer = utils.our_raw_input(prompt) + m = queue.re_default_answer.match(prompt) if answer == "": answer = m.group(1) answer = answer[:1].upper() @@ -159,10 +163,10 @@ def determine_new (changes, files): new[pkg]["othercomponents"] = f["othercomponents"] for suite in changes["suite"].keys(): - suite_id = dak.lib.database.get_suite_id(suite) + suite_id = database.get_suite_id(suite) for pkg in new.keys(): - component_id = dak.lib.database.get_component_id(new[pkg]["component"]) - type_id = dak.lib.database.get_override_type_id(new[pkg]["type"]) + component_id = database.get_component_id(new[pkg]["component"]) + type_id = 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: @@ -321,8 +325,8 @@ def check_valid (new): section = new[pkg]["section"] priority = new[pkg]["priority"] type = new[pkg]["type"] - new[pkg]["section id"] = dak.lib.database.get_section_id(section) - new[pkg]["priority id"] = dak.lib.database.get_priority_id(new[pkg]["priority"]) + new[pkg]["section id"] = database.get_section_id(section) + new[pkg]["priority id"] = database.get_priority_id(new[pkg]["priority"]) # Sanity checks if (section == "debian-installer" and type != "udeb") or \ (section != "debian-installer" and type == "udeb"): @@ -369,12 +373,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: - dak.lib.utils.fubar("invalid type (%s) for new. Dazed, confused and sure as heck not continuing." % (type)) + utils.fubar("invalid type (%s) for new. Dazed, confused and sure as heck not continuing." % (type)) # Validate the override type - type_id = dak.lib.database.get_override_type_id(type) + type_id = database.get_override_type_id(type) if type_id == -1: - dak.lib.utils.fubar("invalid type (%s) for new. Say wha?" % (type)) + utils.fubar("invalid type (%s) for new. Say wha?" % (type)) return type @@ -391,17 +395,17 @@ def index_range (index): def edit_new (new): # Write the current data to a temporary file - temp_filename = dak.lib.utils.temp_filename() - temp_file = dak.lib.utils.open_file(temp_filename, 'w') + temp_filename = utils.temp_filename() + temp_file = 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: - dak.lib.utils.fubar ("%s invocation failed for %s." % (editor, temp_filename), result) + utils.fubar ("%s invocation failed for %s." % (editor, temp_filename), result) # Read the edited data back in - temp_file = dak.lib.utils.open_file(temp_filename) + temp_file = utils.open_file(temp_filename) lines = temp_file.readlines() temp_file.close() os.unlink(temp_filename) @@ -415,7 +419,7 @@ def edit_new (new): s[len(s):3] = [None] * (3-len(s)) (pkg, priority, section) = s[:3] if not new.has_key(pkg): - dak.lib.utils.warn("Ignoring unknown package '%s'" % (pkg)) + utils.warn("Ignoring unknown package '%s'" % (pkg)) else: # Strip off any invalid markers, print_new will readd them. if section.endswith("[!]"): @@ -446,8 +450,8 @@ def edit_index (new, index): edit_priority = edit_section = 0 while prompt.find(answer) == -1: - answer = dak.lib.utils.our_raw_input(prompt) - m = dak.lib.queue.re_default_answer.match(prompt) + answer = utils.our_raw_input(prompt) + m = queue.re_default_answer.match(prompt) if answer == "": answer = m.group(1) answer = answer[:1].upper() @@ -466,7 +470,7 @@ def edit_index (new, index): readline.set_completer(Priorities.complete) got_priority = 0 while not got_priority: - new_priority = dak.lib.utils.our_raw_input("New priority: ").strip() + new_priority = 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: @@ -478,7 +482,7 @@ def edit_index (new, index): readline.set_completer(Sections.complete) got_section = 0 while not got_section: - new_section = dak.lib.utils.our_raw_input("New section: ").strip() + new_section = 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: @@ -512,12 +516,12 @@ def edit_overrides (new): got_answer = 0 while not got_answer: - answer = dak.lib.utils.our_raw_input(prompt) - if not dak.lib.utils.str_isnum(answer): + answer = utils.our_raw_input(prompt) + if not utils.str_isnum(answer): answer = answer[:1].upper() if answer == "E" or answer == "D": got_answer = 1 - elif dak.lib.queue.re_isanum.match (answer): + elif 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)) @@ -537,24 +541,24 @@ def edit_overrides (new): def edit_note(note): # Write the current data to a temporary file - temp_filename = dak.lib.utils.temp_filename() - temp_file = dak.lib.utils.open_file(temp_filename, 'w') + temp_filename = utils.temp_filename() + temp_file = 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 = dak.lib.utils.open_file(temp_filename) + temp_file = utils.open_file(temp_filename) note = temp_file.read().rstrip() temp_file.close() print "Note:" - print dak.lib.utils.prefix_multi_line_string(note," ") + print utils.prefix_multi_line_string(note," ") prompt = "[D]one, Edit, Abandon, Quit ?" answer = "XXX" while prompt.find(answer) == -1: - answer = dak.lib.utils.our_raw_input(prompt) - m = dak.lib.queue.re_default_answer.search(prompt) + answer = utils.our_raw_input(prompt) + m = queue.re_default_answer.search(prompt) if answer == "": answer = m.group(1) answer = answer[:1].upper() @@ -587,12 +591,12 @@ def check_pkg (): sys.stdout = stdout_fd except IOError, e: if errno.errorcode[e.errno] == 'EPIPE': - dak.lib.utils.warn("[examine_package] Caught EPIPE; skipping.") + utils.warn("[examine_package] Caught EPIPE; skipping.") pass else: raise except KeyboardInterrupt: - dak.lib.utils.warn("[examine_package] Caught C-c; skipping.") + utils.warn("[examine_package] Caught C-c; skipping.") pass ################################################################################ @@ -604,13 +608,13 @@ def do_bxa_notification(): summary = "" for file in files.keys(): if files[file]["type"] == "deb": - control = apt_pkg.ParseSection(apt_inst.debExtractControl(dak.lib.utils.open_file(file))) + control = apt_pkg.ParseSection(apt_inst.debExtractControl(utils.open_file(file))) summary += "\n" summary += "Package: %s\n" % (control.Find("Package")) summary += "Description: %s\n" % (control.Find("Description")) 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) + bxa_mail = utils.TemplateSubst(Upload.Subst,Cnf["Dir::Templates"]+"/process-new.bxa_notification") + utils.send_mail(bxa_mail) ################################################################################ @@ -620,10 +624,10 @@ def add_overrides (new): projectB.query("BEGIN WORK") for suite in changes["suite"].keys(): - suite_id = dak.lib.database.get_suite_id(suite) + suite_id = database.get_suite_id(suite) for pkg in new.keys(): - component_id = dak.lib.database.get_component_id(new[pkg]["component"]) - type_id = dak.lib.database.get_override_type_id(new[pkg]["type"]) + component_id = database.get_component_id(new[pkg]["component"]) + type_id = 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)) @@ -641,21 +645,21 @@ def add_overrides (new): def prod_maintainer (): # Here we prepare an editor and get them ready to prod... - temp_filename = dak.lib.utils.temp_filename() + temp_filename = utils.temp_filename() editor = os.environ.get("EDITOR","vi") answer = 'E' while answer == 'E': os.system("%s %s" % (editor, temp_filename)) - file = dak.lib.utils.open_file(temp_filename) + file = utils.open_file(temp_filename) prod_message = "".join(file.readlines()) file.close() print "Prod message:" - print dak.lib.utils.prefix_multi_line_string(prod_message," ",include_blank_lines=1) + print 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 = dak.lib.utils.our_raw_input(prompt) - m = dak.lib.queue.re_default_answer.search(prompt) + answer = utils.our_raw_input(prompt) + m = queue.re_default_answer.search(prompt) if answer == "": answer = m.group(1) answer = answer[:1].upper() @@ -665,7 +669,7 @@ def prod_maintainer (): elif answer == 'Q': sys.exit(0) # Otherwise, do the proding... - user_email_address = dak.lib.utils.whoami() + " <%s>" % ( + user_email_address = utils.whoami() + " <%s>" % ( Cnf["Dinstall::MyAdminAddress"]) Subst = Upload.Subst @@ -674,12 +678,12 @@ def prod_maintainer (): Subst["__PROD_MESSAGE__"] = prod_message Subst["__CC__"] = "Cc: " + Cnf["Dinstall::MyEmailAddress"] - prod_mail_message = dak.lib.utils.TemplateSubst( + prod_mail_message = utils.TemplateSubst( Subst,Cnf["Dir::Templates"]+"/process-new.prod") # Send the prod mail if appropriate if not Cnf["Dinstall::Options::No-Mail"]: - dak.lib.utils.send_mail(prod_mail_message) + utils.send_mail(prod_mail_message) print "Sent proding message" @@ -701,9 +705,9 @@ def do_new(): changes["suite"][override] = 1 # Validate suites for suite in changes["suite"].keys(): - suite_id = dak.lib.database.get_suite_id(suite) + suite_id = database.get_suite_id(suite) if suite_id == -1: - dak.lib.utils.fubar("%s has invalid suite '%s' (possibly overriden). say wha?" % (changes, suite)) + utils.fubar("%s has invalid suite '%s' (possibly overriden). say wha?" % (changes, suite)) # The main NEW processing loop done = 0 @@ -732,8 +736,8 @@ def do_new(): prompt += "Edit overrides, Check, Manual reject, Note edit, Prod, [S]kip, Quit ?" while prompt.find(answer) == -1: - answer = dak.lib.utils.our_raw_input(prompt) - m = dak.lib.queue.re_default_answer.search(prompt) + answer = utils.our_raw_input(prompt) + m = queue.re_default_answer.search(prompt) if answer == "": answer = m.group(1) answer = answer[:1].upper() @@ -754,7 +758,7 @@ def do_new(): elif answer == 'P': prod_maintainer() elif answer == 'R': - confirm = dak.lib.utils.our_raw_input("Really clear note (y/N)? ").lower() + confirm = utils.our_raw_input("Really clear note (y/N)? ").lower() if confirm == "y": del changes["process-new note"] elif answer == 'S': @@ -780,7 +784,7 @@ def usage (exit_code=0): def init(): global Cnf, Options, Logger, Upload, projectB, Sections, Priorities - Cnf = dak.lib.utils.get_conf() + Cnf = utils.get_conf() Arguments = [('a',"automatic","Process-New::Options::Automatic"), ('h',"help","Process-New::Options::Help"), @@ -797,10 +801,10 @@ def init(): if Options["Help"]: usage() - Upload = dak.lib.queue.Upload(Cnf) + Upload = queue.Upload(Cnf) if not Options["No-Action"]: - Logger = Upload.Logger = dak.lib.logging.Logger(Cnf, "process-new") + Logger = Upload.Logger = logging.Logger(Cnf, "process-new") projectB = Upload.projectB @@ -838,8 +842,8 @@ def do_byhand(): prompt = "Manual reject, [S]kip, Quit ?" while prompt.find(answer) == -1: - answer = dak.lib.utils.our_raw_input(prompt) - m = dak.lib.queue.re_default_answer.search(prompt) + answer = utils.our_raw_input(prompt) + m = queue.re_default_answer.search(prompt) if answer == "": answer = m.group(1) answer = answer[:1].upper() @@ -871,7 +875,7 @@ def do_accept(): if errno.errorcode[e.errno] == 'EACCES' or errno.errorcode[e.errno] == 'EEXIST': retry += 1 if (retry >= 10): - dak.lib.utils.fubar("Couldn't obtain lock; assuming 'dak process-unchecked' is already running.") + 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) @@ -922,7 +926,7 @@ def end(): sets = "set" if accept_count > 1: sets = "sets" - sys.stderr.write("Accepted %d package %s, %s.\n" % (accept_count, sets, dak.lib.utils.size_type(int(accept_bytes)))) + sys.stderr.write("Accepted %d package %s, %s.\n" % (accept_count, sets, utils.size_type(int(accept_bytes)))) Logger.log(["total",accept_count,accept_bytes]) if not Options["No-Action"]: @@ -945,7 +949,7 @@ def main(): Upload.Subst["__BCC__"] = bcc for changes_file in changes_files: - changes_file = dak.lib.utils.validate_changes_file_arg(changes_file, 0) + changes_file = 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 32eda9ec..39a7ed18 100755 --- a/dak/process_unchecked.py +++ b/dak/process_unchecked.py @@ -30,7 +30,10 @@ import commands, errno, fcntl, os, re, shutil, stat, sys, time, tempfile, traceback import apt_inst, apt_pkg -import dak.lib.database, dak.lib.queue, dak.lib.logging, dak.lib.utils +import dak.lib.database as database +import dak.lib.logging as logging +import dak.lib.queue as queue +import dak.lib.utils as utils from types import * @@ -68,7 +71,7 @@ def init(): apt_pkg.init() Cnf = apt_pkg.newConfiguration() - apt_pkg.ReadConfigFileISC(Cnf,dak.lib.utils.which_conf_file()) + apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()) Arguments = [('a',"automatic","Dinstall::Options::Automatic"), ('h',"help","Dinstall::Options::Help"), @@ -86,7 +89,7 @@ def init(): if Options["Help"]: usage() - Upload = dak.lib.queue.Queue(Cnf) + Upload = queue.Queue(Cnf) changes = Upload.pkg.changes dsc = Upload.pkg.dsc @@ -162,7 +165,7 @@ def clean_holding(): for file in in_holding.keys(): if os.path.exists(file): if file.find('/') != -1: - dak.lib.utils.fubar("WTF? clean_holding() got a file ('%s') with / in it!" % (file)) + utils.fubar("WTF? clean_holding() got a file ('%s') with / in it!" % (file)) else: os.unlink(file) in_holding = {} @@ -175,20 +178,20 @@ def check_changes(): # Parse the .changes field into a dictionary try: - changes.update(dak.lib.utils.parse_changes(filename)) - except dak.lib.utils.cant_open_exc: + changes.update(utils.parse_changes(filename)) + except utils.cant_open_exc: reject("%s: can't read file." % (filename)) return 0 - except dak.lib.utils.changes_parse_error_exc, line: + except 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(dak.lib.utils.build_file_list(changes)) - except dak.lib.utils.changes_parse_error_exc, line: + files.update(utils.build_file_list(changes)) + except utils.changes_parse_error_exc, line: reject("%s: parse error, can't grok: %s." % (filename, line)) - except dak.lib.utils.nk_format_exc, format: + except utils.nk_format_exc, format: reject("%s: unknown format '%s'." % (filename, format)) return 0 @@ -212,8 +215,8 @@ def check_changes(): try: (changes["maintainer822"], changes["maintainer2047"], changes["maintainername"], changes["maintaineremail"]) = \ - dak.lib.utils.fix_maintainer (changes["maintainer"]) - except dak.lib.utils.ParseMaintError, msg: + utils.fix_maintainer (changes["maintainer"]) + except utils.ParseMaintError, msg: reject("%s: Maintainer field ('%s') failed to parse: %s" \ % (filename, changes["maintainer"], msg)) @@ -221,8 +224,8 @@ def check_changes(): try: (changes["changedby822"], changes["changedby2047"], changes["changedbyname"], changes["changedbyemail"]) = \ - dak.lib.utils.fix_maintainer (changes.get("changed-by", "")) - except dak.lib.utils.ParseMaintError, msg: + utils.fix_maintainer (changes.get("changed-by", "")) + except utils.ParseMaintError, msg: (changes["changedby822"], changes["changedby2047"], changes["changedbyname"], changes["changedbyemail"]) = \ ("", "", "", "") @@ -232,13 +235,13 @@ def check_changes(): # Ensure all the values in Closes: are numbers if changes.has_key("closes"): for i in changes["closes"].keys(): - if dak.lib.queue.re_isanum.match (i) == None: + if 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"] = dak.lib.utils.re_no_epoch.sub('', changes["version"]) - changes["chopversion2"] = dak.lib.utils.re_no_revision.sub('', changes["chopversion"]) + changes["chopversion"] = utils.re_no_epoch.sub('', changes["version"]) + changes["chopversion2"] = 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. @@ -324,7 +327,7 @@ Pre-Depends on dpkg (>= 1.10.24).""" (result, output) = commands.getstatusoutput(cmd) if result != 0: reject("%s: 'ar t' invocation failed." % (filename)) - reject(dak.lib.utils.prefix_multi_line_string(output, " [ar output:] "), "") + reject(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))) @@ -355,7 +358,7 @@ Pre-Depends on dpkg (>= 1.10.24).""" def check_files(): global reprocess - archive = dak.lib.utils.where_am_i() + archive = utils.where_am_i() file_keys = files.keys() # if reprocess is 2 we've already done this and we're checking @@ -395,7 +398,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 dak.lib.utils.re_taint_free.match(file): + if not 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: @@ -413,12 +416,12 @@ def check_files(): files[file]["byhand"] = 1 files[file]["type"] = "byhand" # Checks for a binary package... - elif dak.lib.utils.re_isadeb.match(file): + elif utils.re_isadeb.match(file): has_binaries = 1 files[file]["type"] = "deb" # Extract package control information - deb_file = dak.lib.utils.open_file(file) + deb_file = utils.open_file(file) try: control = apt_pkg.ParseSection(apt_inst.debExtractControl(deb_file)) except: @@ -486,7 +489,7 @@ def check_files(): source = files[file]["source"] source_version = "" if source.find("(") != -1: - m = dak.lib.utils.re_extract_src_version.match(source) + m = utils.re_extract_src_version.match(source) source = m.group(1) source_version = m.group(2) if not source_version: @@ -495,12 +498,12 @@ def check_files(): files[file]["source version"] = source_version # Ensure the filename matches the contents of the .deb - m = dak.lib.utils.re_isadeb.match(file) + m = 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 = dak.lib.utils.re_no_epoch.sub('', control.Find("Version")) + epochless_version = utils.re_no_epoch.sub('', control.Find("Version")) # version file_version = m.group(2) if epochless_version != file_version: @@ -520,7 +523,7 @@ def check_files(): # Check in the SQL database if not Upload.source_exists(source_package, source_version, changes["distribution"].keys()): # Check in one of the other directories - source_epochless_version = dak.lib.utils.re_no_epoch.sub('', source_version) + source_epochless_version = 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 @@ -535,7 +538,7 @@ def check_files(): # Checks for a source package... else: - m = dak.lib.utils.re_issource.match(file) + m = utils.re_issource.match(file) if m: has_source = 1 files[file]["package"] = m.group(1) @@ -560,7 +563,7 @@ def check_files(): # Check the signature of a .dsc file if files[file]["type"] == "dsc": - dsc["fingerprint"] = dak.lib.utils.check_signature(file, reject) + dsc["fingerprint"] = utils.check_signature(file, reject) files[file]["architecture"] = "source" @@ -591,7 +594,7 @@ def check_files(): # Validate the component component = files[file]["component"] - component_id = dak.lib.database.get_component_id(component) + component_id = database.get_component_id(component) if component_id == -1: reject("file '%s' has unknown component '%s'." % (file, component)) continue @@ -606,14 +609,14 @@ def check_files(): # Determine the location location = Cnf["Dir::Pool"] - location_id = dak.lib.database.get_location_id (location, component, archive) + location_id = 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"] = 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"]) + files[file]["pool name"] = utils.poolify (changes["source"], files[file]["component"]) + files_id = 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: @@ -668,22 +671,22 @@ def check_dsc(): # Parse the .dsc file try: - dsc.update(dak.lib.utils.parse_changes(dsc_filename, signing_rules=1)) - except dak.lib.utils.cant_open_exc: + dsc.update(utils.parse_changes(dsc_filename, signing_rules=1)) + except 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 dak.lib.utils.changes_parse_error_exc, line: + except utils.changes_parse_error_exc, line: reject("%s: parse error, can't grok: %s." % (dsc_filename, line)) - except dak.lib.utils.invalid_dsc_format_exc, line: + except 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(dak.lib.utils.build_file_list(dsc, is_a_dsc=1)) - except dak.lib.utils.no_files_exc: + dsc_files.update(utils.build_file_list(dsc, is_a_dsc=1)) + except utils.no_files_exc: reject("%s: no Files: field." % (dsc_filename)) return 0 - except dak.lib.utils.changes_parse_error_exc, line: + except utils.changes_parse_error_exc, line: reject("%s: parse error, can't grok: %s." % (dsc_filename, line)) return 0 @@ -706,8 +709,8 @@ def check_dsc(): # Validate the Maintainer field try: - dak.lib.utils.fix_maintainer (dsc["maintainer"]) - except dak.lib.utils.ParseMaintError, msg: + utils.fix_maintainer (dsc["maintainer"]) + except utils.ParseMaintError, msg: reject("%s: Maintainer field ('%s') failed to parse: %s" \ % (dsc_filename, dsc["maintainer"], msg)) @@ -727,7 +730,7 @@ def check_dsc(): pass # Ensure the version number in the .dsc matches the version number in the .changes - epochless_dsc_version = dak.lib.utils.re_no_epoch.sub('', dsc["version"]) + epochless_dsc_version = 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)) @@ -735,7 +738,7 @@ def check_dsc(): # Ensure there is a .tar.gz in the .dsc file has_tar = 0 for f in dsc_files.keys(): - m = dak.lib.utils.re_issource.match(f) + m = 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) @@ -782,7 +785,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 = dak.lib.utils.re_issource.match(f) + m = utils.re_issource.match(f) if m: src = os.path.join(source_dir, f) # If a file is missing for whatever reason, give up. @@ -805,14 +808,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(dak.lib.utils.prefix_multi_line_string(output, " [dpkg-source output:] "), "") + reject(utils.prefix_multi_line_string(output, " [dpkg-source output:] "), "") return if not Cnf.Find("Dir::Queue::BTSVersionTrack"): return # Get the upstream version - upstr_version = dak.lib.utils.re_no_epoch.sub('', dsc["version"]) + upstr_version = utils.re_no_epoch.sub('', dsc["version"]) if re_strip_revision.search(upstr_version): upstr_version = re_strip_revision.sub('', upstr_version) @@ -824,7 +827,7 @@ def get_changelog_versions(source_dir): # Parse the changelog dsc["bts changelog"] = "" - changelog_file = dak.lib.utils.open_file(changelog_filename) + changelog_file = utils.open_file(changelog_filename) for line in changelog_file.readlines(): m = re_changelog_versions.match(line) if m: @@ -867,7 +870,7 @@ def check_source(): shutil.rmtree(tmpdir) except OSError, e: if errno.errorcode[e.errno] != 'EACCES': - dak.lib.utils.fubar("%s: couldn't remove tmp dir for source tree." % (dsc["source"])) + 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 @@ -875,10 +878,10 @@ def check_source(): cmd = "chmod -R u+rwx %s" % (tmpdir) result = os.system(cmd) if result != 0: - dak.lib.utils.fubar("'%s' failed with result %s." % (cmd, result)) + utils.fubar("'%s' failed with result %s." % (cmd, result)) shutil.rmtree(tmpdir) except: - dak.lib.utils.fubar("%s: couldn't remove tmp dir for source tree." % (dsc["source"])) + utils.fubar("%s: couldn't remove tmp dir for source tree." % (dsc["source"])) ################################################################################ @@ -898,8 +901,8 @@ def check_urgency (): def check_md5sums (): for file in files.keys(): try: - file_handle = dak.lib.utils.open_file(file) - except dak.lib.utils.cant_open_exc: + file_handle = utils.open_file(file) + except utils.cant_open_exc: continue # Check md5sum @@ -915,8 +918,8 @@ def check_md5sums (): for file in dsc_files.keys(): try: - file_handle = dak.lib.utils.open_file(file) - except dak.lib.utils.cant_open_exc: + file_handle = utils.open_file(file) + except utils.cant_open_exc: continue # Check md5sum @@ -961,7 +964,7 @@ def check_timestamps(): if files[filename]["type"] == "deb": tar.reset() try: - deb_file = dak.lib.utils.open_file(filename) + deb_file = utils.open_file(filename) apt_inst.debExtract(deb_file,tar.callback,"control.tar.gz") deb_file.seek(0) try: @@ -1080,8 +1083,8 @@ def action (): answer = 'A' while prompt.find(answer) == -1: - answer = dak.lib.utils.our_raw_input(prompt) - m = dak.lib.queue.re_default_answer.match(prompt) + answer = utils.our_raw_input(prompt) + m = queue.re_default_answer.match(prompt) if answer == "": answer = m.group(1) answer = answer[:1].upper() @@ -1113,10 +1116,10 @@ def accept (summary, short_summary): ################################################################################ def move_to_dir (dest, perms=0660, changesperms=0664): - dak.lib.utils.move (pkg.changes_file, dest, perms=changesperms) + utils.move (pkg.changes_file, dest, perms=changesperms) file_keys = files.keys() for file in file_keys: - dak.lib.utils.move (file, dest, perms=perms) + utils.move (file, dest, perms=perms) ################################################################################ @@ -1207,8 +1210,8 @@ def acknowledge_new (summary): if not Options["No-Mail"]: print "Sending new ack." Subst["__SUMMARY__"] = summary - new_ack_message = dak.lib.utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/process-unchecked.new") - dak.lib.utils.send_mail(new_ack_message) + new_ack_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/process-unchecked.new") + utils.send_mail(new_ack_message) ################################################################################ @@ -1249,7 +1252,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"] = dak.lib.utils.check_signature(pkg.changes_file, reject) + changes["fingerprint"] = utils.check_signature(pkg.changes_file, reject) if changes["fingerprint"]: valid_changes_p = check_changes() else: @@ -1290,16 +1293,16 @@ def main(): # Ensure all the arguments we were given are .changes files for file in changes_files: if not file.endswith(".changes"): - dak.lib.utils.warn("Ignoring '%s' because it's not a .changes file." % (file)) + utils.warn("Ignoring '%s' because it's not a .changes file." % (file)) changes_files.remove(file) if changes_files == []: - dak.lib.utils.fubar("Need at least one .changes file as an argument.") + 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"]: - dak.lib.utils.fubar("Archive maintenance in progress. Try again later.") + utils.fubar("Archive maintenance in progress. Try again later.") # Obtain lock if not in no-action mode and initialize the log @@ -1309,10 +1312,10 @@ 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': - dak.lib.utils.fubar("Couldn't obtain lock; assuming another 'dak process-unchecked' is already running.") + utils.fubar("Couldn't obtain lock; assuming another 'dak process-unchecked' is already running.") else: raise - Logger = Upload.Logger = dak.lib.logging.Logger(Cnf, "process-unchecked") + Logger = Upload.Logger = logging.Logger(Cnf, "process-unchecked") # debian-{devel-,}-changes@lists.debian.org toggles writes access based on this header bcc = "X-DAK: dak process-unchecked\nX-Katie: this header is obsolete" @@ -1323,7 +1326,7 @@ def main(): # Sort the .changes files so that we process sourceful ones first - changes_files.sort(dak.lib.utils.changes_compare) + changes_files.sort(utils.changes_compare) # Process the changes files for changes_file in changes_files: @@ -1340,7 +1343,7 @@ def main(): sets = "set" if accept_count > 1: sets = "sets" - print "Accepted %d package %s, %s." % (accept_count, sets, dak.lib.utils.size_type(int(accept_bytes))) + print "Accepted %d package %s, %s." % (accept_count, sets, 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 f287801b..a8ae08d4 100755 --- a/dak/queue_report.py +++ b/dak/queue_report.py @@ -36,7 +36,8 @@ import copy, glob, os, stat, sys, time import apt_pkg -import dak.lib.queue, dak.lib.utils +import dak.lib.queue as queue +import dak.lib.utils as utils Cnf = None Upload = None @@ -327,8 +328,8 @@ def process_changes_files(changes_files, type): try: (maintainer["maintainer822"], maintainer["maintainer2047"], maintainer["maintainername"], maintainer["maintaineremail"]) = \ - dak.lib.utils.fix_maintainer (j["maintainer"]) - except dak.lib.utils.ParseMaintError, msg: + utils.fix_maintainer (j["maintainer"]) + except utils.ParseMaintError, msg: print "Problems while parsing maintainer address\n" maintainer["maintainername"] = "Unknown" maintainer["maintaineremail"] = "Unknown" @@ -340,7 +341,7 @@ def process_changes_files(changes_files, type): version = j["version"] versions[version] = "" arches_list = arches.keys() - arches_list.sort(dak.lib.utils.arch_compare_sw) + arches_list.sort(utils.arch_compare_sw) arch_list = " ".join(arches_list) version_list = " ".join(versions.keys()) if len(version_list) > max_version_len: @@ -428,7 +429,7 @@ def process_changes_files(changes_files, type): def main(): global Cnf, Upload - Cnf = dak.lib.utils.get_conf() + Cnf = utils.get_conf() Arguments = [('h',"help","Queue-Report::Options::Help"), ('n',"new","Queue-Report::Options::New"), ('s',"sort","Queue-Report::Options::Sort", "HasArg"), @@ -443,7 +444,7 @@ def main(): if Options["Help"]: usage() - Upload = dak.lib.queue.Upload(Cnf) + Upload = queue.Upload(Cnf) if Cnf.has_key("Queue-Report::Options::New"): header() diff --git a/dak/reject_proposed_updates.py b/dak/reject_proposed_updates.py index 58c7e88e..d50923ce 100755 --- a/dak/reject_proposed_updates.py +++ b/dak/reject_proposed_updates.py @@ -20,8 +20,11 @@ ################################################################################ import os, pg, sys -import dak.lib.database, dak.lib.queue, dak.lib.logging, dak.lib.utils import apt_pkg +import dak.lib.database as database +import dak.lib.logging as logging +import dak.lib.queue as queue +import dak.lib.utils as utils ################################################################################ @@ -48,7 +51,7 @@ Manually reject the .CHANGES file(s). def main(): global Cnf, Logger, Options, projectB, Upload - Cnf = dak.lib.utils.get_conf() + Cnf = 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")] @@ -62,13 +65,13 @@ def main(): if Options["Help"]: usage() if not arguments: - dak.lib.utils.fubar("need at least one .changes filename as an argument.") + utils.fubar("need at least one .changes filename as an argument.") projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - dak.lib.database.init(Cnf, projectB) + database.init(Cnf, projectB) - Upload = dak.lib.queue.Upload(Cnf) - Logger = Upload.Logger = dak.lib.logging.Logger(Cnf, "reject-proposed-updates") + Upload = queue.Upload(Cnf) + Logger = Upload.Logger = logging.Logger(Cnf, "reject-proposed-updates") bcc = "X-DAK: dak rejected-proposed-updates\nX-Katie: this header is obsolete" if Cnf.has_key("Dinstall::Bcc"): @@ -77,7 +80,7 @@ def main(): Upload.Subst["__BCC__"] = bcc for arg in arguments: - arg = dak.lib.utils.validate_changes_file_arg(arg) + arg = utils.validate_changes_file_arg(arg) Upload.pkg.changes_file = arg Upload.init_vars() cwd = os.getcwd() @@ -93,8 +96,8 @@ def main(): answer = "XXX" while prompt.find(answer) == -1: - answer = dak.lib.utils.our_raw_input(prompt) - m = dak.lib.queue.re_default_answer.search(prompt) + answer = utils.our_raw_input(prompt) + m = queue.re_default_answer.search(prompt) if answer == "": answer = m.group(1) answer = answer[:1].upper() @@ -120,21 +123,21 @@ def reject (reject_message = ""): # 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 = dak.lib.utils.temp_filename() + temp_filename = utils.temp_filename() editor = os.environ.get("EDITOR","vi") answer = 'E' while answer == 'E': os.system("%s %s" % (editor, temp_filename)) - file = dak.lib.utils.open_file(temp_filename) + file = utils.open_file(temp_filename) reject_message = "".join(file.readlines()) file.close() print "Reject message:" - print dak.lib.utils.prefix_multi_line_string(reject_message," ", include_blank_lines=1) + print 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 = dak.lib.utils.our_raw_input(prompt) - m = dak.lib.queue.re_default_answer.search(prompt) + answer = utils.our_raw_input(prompt) + m = queue.re_default_answer.search(prompt) if answer == "": answer = m.group(1) answer = answer[:1].upper() @@ -160,21 +163,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 = dak.lib.utils.whoami() + " <%s>" % (Cnf["Dinstall::MyAdminAddress"]) + user_email_address = utils.whoami() + " <%s>" % (Cnf["Dinstall::MyAdminAddress"]) 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") + reject_mail_message = 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 = dak.lib.database.get_suite_id('proposed-updates') + suite_id = database.get_suite_id('proposed-updates') projectB.query("BEGIN WORK") # Remove files from proposed-updates suite @@ -185,7 +188,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: - dak.lib.utils.fubar("reject: Couldn't find %s_%s in source table." % (package, version)) + 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": @@ -201,7 +204,7 @@ def reject (reject_message = ""): # newer version of the package and only do the # warn&continue thing if it finds one. if not ql: - dak.lib.utils.warn("reject: Couldn't find %s_%s_%s in binaries table." % (package, version, architecture)) + 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)) @@ -209,7 +212,7 @@ def reject (reject_message = ""): # Send the rejection mail if appropriate if not Options["No-Mail"]: - dak.lib.utils.send_mail(reject_mail_message) + utils.send_mail(reject_mail_message) # Finally remove the .dak file dot_dak_file = os.path.join(Cnf["Suite::Proposed-Updates::CopyDotDak"], os.path.basename(changes_file[:-8]+".dak")) diff --git a/dak/rm.py b/dak/rm.py index 12f15eb0..af649527 100755 --- a/dak/rm.py +++ b/dak/rm.py @@ -40,8 +40,9 @@ ################################################################################ import commands, os, pg, re, sys -import dak.lib.utils, dak.lib.database import apt_pkg, apt_inst +import dak.lib.database as database +import dak.lib.utils as utils ################################################################################ @@ -86,7 +87,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 = dak.lib.utils.our_raw_input("Continue (y/N)? ").lower() + answer = utils.our_raw_input("Continue (y/N)? ").lower() if answer != "y": print "Aborted." sys.exit(1) @@ -106,11 +107,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 = dak.lib.utils.temp_filename() + temp_filename = utils.temp_filename() (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename)) if (result != 0): - dak.lib.utils.fubar("Gunzip invocation failed!\n%s\n" % (output), result) - packages = dak.lib.utils.open_file(temp_filename) + utils.fubar("Gunzip invocation failed!\n%s\n" % (output), result) + packages = utils.open_file(temp_filename) Packages = apt_pkg.ParseTagFile(packages) while Packages.Step(): package = Packages.Section.Find("Package") @@ -164,19 +165,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, dak.lib.utils.pp_deps(dep)) + print "%s has an unsatisfied dependency on %s: %s" % (what, architecture, 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 = dak.lib.utils.temp_filename() + temp_filename = 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 = dak.lib.utils.open_file(temp_filename, "r") + sources = utils.open_file(temp_filename, "r") Sources = apt_pkg.ParseTagFile(sources) while Sources.Step(): source = Sources.Section.Find("Package") @@ -201,7 +202,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, dak.lib.utils.pp_deps(dep)) + print "%s has an unsatisfied build-dependency: %s" % (source, utils.pp_deps(dep)) dep_problem = 1 sources.close() os.unlink(temp_filename) @@ -219,7 +220,7 @@ def reverse_depends_check(removals, suites): def main (): global Cnf, Options, projectB - Cnf = dak.lib.utils.get_conf() + Cnf = utils.get_conf() Arguments = [('h',"help","Rm::Options::Help"), ('a',"architecture","Rm::Options::Architecture", "HasArg"), @@ -250,19 +251,19 @@ def main (): usage() projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - dak.lib.database.init(Cnf, projectB) + database.init(Cnf, projectB) # Sanity check options if not arguments: - dak.lib.utils.fubar("need at least one package name as an argument.") + utils.fubar("need at least one package name as an argument.") if Options["Architecture"] and Options["Source-Only"]: - dak.lib.utils.fubar("can't use -a/--architecutre and -S/--source-only options simultaneously.") + utils.fubar("can't use -a/--architecutre and -S/--source-only options simultaneously.") if Options["Binary-Only"] and Options["Source-Only"]: - dak.lib.utils.fubar("can't use -b/--binary-only and -S/--source-only options simultaneously.") + 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"): - dak.lib.utils.fubar("can't use -C/--carbon-copy without also using -d/--done option.") + utils.fubar("can't use -C/--carbon-copy without also using -d/--done option.") if Options["Architecture"] and not Options["Partial"]: - dak.lib.utils.warn("-a/--architecture implies -p/--partial.") + utils.warn("-a/--architecture implies -p/--partial.") Options["Partial"] = "true" # Force the admin to tell someone if we're not doing a 'dak @@ -270,7 +271,7 @@ def main (): # as telling someone). if not Options["No-Action"] and not Options["Carbon-Copy"] \ 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.") + utils.fubar("Need a -C/--carbon-copy if not closing a bug and not doing a cruft removal.") # Process -C/--carbon-copy # @@ -280,8 +281,8 @@ def main (): # 3) contains a '@' - assumed to be an email address, used unmofidied # carbon_copy = [] - for copy_to in dak.lib.utils.split_args(Options.get("Carbon-Copy")): - if dak.lib.utils.str_isnum(copy_to): + for copy_to in utils.split_args(Options.get("Carbon-Copy")): + if utils.str_isnum(copy_to): carbon_copy.append(copy_to + "@" + Cnf["Dinstall::BugServer"]) elif copy_to == 'package': for package in arguments: @@ -291,7 +292,7 @@ def main (): elif '@' in copy_to: carbon_copy.append(copy_to) else: - dak.lib.utils.fubar("Invalid -C/--carbon-copy argument '%s'; not a bug number, 'package' or email address." % (copy_to)) + 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 +301,15 @@ def main (): con_packages = "AND %s IN (%s)" % (field, ", ".join(map(repr, arguments))) (con_suites, con_architectures, con_components, check_source) = \ - dak.lib.utils.parse_args(Options) + utils.parse_args(Options) # Additional suite checks suite_ids_list = [] - suites = dak.lib.utils.split_args(Options["Suite"]) - suites_list = dak.lib.utils.join_with_commas_and(suites) + suites = utils.split_args(Options["Suite"]) + suites_list = utils.join_with_commas_and(suites) if not Options["No-Action"]: for suite in suites: - suite_id = dak.lib.database.get_suite_id(suite) + suite_id = database.get_suite_id(suite) if suite_id != -1: suite_ids_list.append(suite_id) if suite == "stable": @@ -324,7 +325,7 @@ def main (): # Additional architecture checks if Options["Architecture"] and check_source: - dak.lib.utils.warn("'source' in -a/--argument makes no sense and is ignored.") + 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 +363,9 @@ def main (): for i in source_packages.keys(): filename = "/".join(source_packages[i]) try: - dsc = dak.lib.utils.parse_changes(filename) - except dak.lib.utils.cant_open_exc: - dak.lib.utils.warn("couldn't open '%s'." % (filename)) + dsc = utils.parse_changes(filename) + except utils.cant_open_exc: + utils.warn("couldn't open '%s'." % (filename)) continue for package in dsc.get("binary").split(','): package = package.strip() @@ -377,7 +378,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(dak.lib.utils.open_file(filename))) + control = apt_pkg.ParseSection(apt_inst.debExtractControl(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 +392,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 = dak.lib.utils.temp_filename() + temp_filename = utils.temp_filename() editor = os.environ.get("EDITOR","vi") result = os.system("%s %s" % (editor, temp_filename)) if result != 0: - dak.lib.utils.fubar ("vi invocation failed for `%s'!" % (temp_filename), result) - temp_file = dak.lib.utils.open_file(temp_filename) + utils.fubar ("vi invocation failed for `%s'!" % (temp_filename), result) + temp_file = utils.open_file(temp_filename) for line in temp_file.readlines(): Options["Reason"] += line temp_file.close() @@ -419,7 +420,7 @@ def main (): maintainer_list = [] for maintainer_id in maintainers.keys(): - maintainer_list.append(dak.lib.database.get_maintainer(maintainer_id)) + maintainer_list.append(database.get_maintainer(maintainer_id)) summary = "" removals = d.keys() removals.sort() @@ -427,7 +428,7 @@ def main (): versions = d[package].keys() versions.sort(apt_pkg.VersionCompare) for version in versions: - d[package][version].sort(dak.lib.utils.arch_compare_sw) + d[package][version].sort(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 +454,11 @@ def main (): print "Going to remove the packages now." game_over() - whoami = dak.lib.utils.whoami() + whoami = utils.whoami() date = commands.getoutput('date -R') # Log first; if it all falls apart I want a record that we at least tried. - logfile = dak.lib.utils.open_file(Cnf["Rm::LogFile"], 'a') + logfile = 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 +468,8 @@ def main (): logfile.write("----------------------------------------------\n") logfile.flush() - dsc_type_id = dak.lib.database.get_override_type_id('dsc') - deb_type_id = dak.lib.database.get_override_type_id('deb') + dsc_type_id = database.get_override_type_id('dsc') + deb_type_id = database.get_override_type_id('deb') # Do the actual deletion print "Deleting...", @@ -517,14 +518,14 @@ def main (): Subst["__ADMIN_ADDRESS__"] = Cnf["Dinstall::MyAdminAddress"] Subst["__DISTRO__"] = Cnf["Dinstall::MyDistribution"] Subst["__WHOAMI__"] = whoami - whereami = dak.lib.utils.where_am_i() + whereami = utils.where_am_i() Archive = Cnf.SubTree("Archive::%s" % (whereami)) Subst["__MASTER_ARCHIVE__"] = Archive["OriginServer"] Subst["__PRIMARY_MIRROR__"] = Archive["PrimaryMirror"] - for bug in dak.lib.utils.split_args(Options["Done"]): + for bug in utils.split_args(Options["Done"]): Subst["__BUG_NUMBER__"] = bug - mail_message = dak.lib.utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/rm.bug-close") - dak.lib.utils.send_mail(mail_message) + mail_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/rm.bug-close") + utils.send_mail(mail_message) logfile.write("=========================================================================\n") logfile.close() diff --git a/dak/security_install.py b/dak/security_install.py index 2763abb3..a5853aae 100755 --- a/dak/security_install.py +++ b/dak/security_install.py @@ -32,7 +32,8 @@ import commands, os, pwd, re, sys, time import apt_pkg -import dak.lib.queue, dak.lib.utils +import dak.lib.queue as queue +import dak.lib.utils as utils ################################################################################ @@ -65,9 +66,9 @@ def do_upload(changes_files): uploads = {}; # uploads[uri] = file_list changesfiles = {}; # changesfiles[uri] = file_list package_list = {} # package_list[source_name][version] - changes_files.sort(dak.lib.utils.changes_compare) + changes_files.sort(utils.changes_compare) for changes_file in changes_files: - changes_file = dak.lib.utils.validate_changes_file_arg(changes_file) + changes_file = utils.validate_changes_file_arg(changes_file) # Reset variables components = {} upload_uris = {} @@ -89,7 +90,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"], - dak.lib.utils.poolify(changes["source"], files[file]["component"]), + utils.poolify(changes["source"], files[file]["component"]), file) file_list.append(poolname) orig_component = files[file].get("original component", files[file]["component"]) @@ -101,10 +102,10 @@ def do_upload(changes_files): upload_uris[upload_uri] = "" num_upload_uris = len(upload_uris.keys()) if num_upload_uris == 0: - dak.lib.utils.fubar("%s: No valid upload URI found from components (%s)." + utils.fubar("%s: No valid upload URI found from components (%s)." % (changes_file, ", ".join(components.keys()))) elif num_upload_uris > 1: - dak.lib.utils.fubar("%s: more than one upload URI (%s) from components (%s)." + 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] @@ -140,7 +141,7 @@ def do_upload(changes_files): if not Options["No-Action"]: filename = "%s/testing-processed" % (Cnf["Dir::Log"]) - file = dak.lib.utils.open_file(filename, 'a') + file = utils.open_file(filename, 'a') for source in package_list.keys(): for version in package_list[source].keys(): file.write(" ".join([source, version])+'\n') @@ -155,7 +156,7 @@ def make_advisory(advisory_nr, changes_files): updated_pkgs = {}; # updated_pkgs[distro][arch][file] = {path,md5,size} for arg in changes_files: - arg = dak.lib.utils.validate_changes_file_arg(arg) + arg = utils.validate_changes_file_arg(arg) Upload.pkg.changes_file = arg Upload.init_vars() Upload.update_vars() @@ -175,7 +176,7 @@ def make_advisory(advisory_nr, changes_files): md5 = files[file]["md5sum"] size = files[file]["size"] poolname = Cnf["Dir::PoolRoot"] + \ - dak.lib.utils.poolify(src, files[file]["component"]) + utils.poolify(src, files[file]["component"]) if arch == "source" and file.endswith(".dsc"): dscpoolname = poolname for suite in suites: @@ -221,7 +222,7 @@ def make_advisory(advisory_nr, changes_files): Subst["__BCC__"] = "Bcc: %s" % (Cnf["Dinstall::Bcc"]) adv = "" - archive = Cnf["Archive::%s::PrimaryMirror" % (dak.lib.utils.where_am_i())] + archive = Cnf["Archive::%s::PrimaryMirror" % (utils.where_am_i())] for suite in updated_pkgs.keys(): suite_header = "%s %s (%s)" % (Cnf["Dinstall::MyDistribution"], Cnf["Suite::%s::Version" % suite], suite) @@ -235,7 +236,7 @@ def make_advisory(advisory_nr, changes_files): arches.sort() adv += " %s was released for %s.\n\n" % ( - suite.capitalize(), dak.lib.utils.join_with_commas_and(arches)) + suite.capitalize(), utils.join_with_commas_and(arches)) for a in ["source", "all"] + arches: if not updated_pkgs[suite].has_key(a): @@ -260,9 +261,9 @@ def make_advisory(advisory_nr, changes_files): Subst["__ADVISORY_TEXT__"] = adv - adv = dak.lib.utils.TemplateSubst(Subst, Cnf["Dir::Templates"]+"/security-install.advisory") + adv = utils.TemplateSubst(Subst, Cnf["Dir::Templates"]+"/security-install.advisory") if not Options["No-Action"]: - dak.lib.utils.send_mail (adv) + utils.send_mail (adv) else: print "[]" @@ -272,7 +273,7 @@ def init(): global Cnf, Upload, Options apt_pkg.init() - Cnf = dak.lib.utils.get_conf() + Cnf = utils.get_conf() Arguments = [('h', "help", "Security-Install::Options::Help"), ('n', "no-action", "Security-Install::Options::No-Action")] @@ -282,7 +283,7 @@ def init(): arguments = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv) Options = Cnf.SubTree("Security-Install::Options") - Upload = dak.lib.queue.Upload(Cnf) + Upload = queue.Upload(Cnf) if Options["Help"]: usage(0) @@ -293,17 +294,17 @@ def init(): advisory_number = arguments[0] changes_files = arguments[1:] if advisory_number.endswith(".changes"): - dak.lib.utils.warn("first argument must be the advisory number.") + utils.warn("first argument must be the advisory number.") usage(1) for file in changes_files: - file = dak.lib.utils.validate_changes_file_arg(file) + file = utils.validate_changes_file_arg(file) return (advisory_number, changes_files) ###################################################################### def yes_no(prompt): while 1: - answer = dak.lib.utils.our_raw_input(prompt+" ").lower() + answer = utils.our_raw_input(prompt+" ").lower() if answer == "y" or answer == "n": break else: @@ -314,14 +315,14 @@ def yes_no(prompt): def spawn(command): if not re_taint_free.match(command): - dak.lib.utils.fubar("Invalid character in \"%s\"." % (command)) + utils.fubar("Invalid character in \"%s\"." % (command)) if Options["No-Action"]: print "[%s]" % (command) else: (result, output) = commands.getstatusoutput(command) if (result != 0): - dak.lib.utils.fubar("Invocation of '%s' failed:\n%s\n" % (command, output), result) + utils.fubar("Invocation of '%s' failed:\n%s\n" % (command, output), result) ###################################################################### @@ -344,7 +345,7 @@ def main(): print "Updating file lists for apt-ftparchive..." spawn("dak make-suite-file-list") print "Updating Packages and Sources files..." - spawn("apt-ftparchive generate %s" % (dak.lib.utils.which_apt_conf_file())) + spawn("apt-ftparchive generate %s" % (utils.which_apt_conf_file())) print "Updating Release files..." spawn("dak generate-releases") diff --git a/dak/split_done.py b/dak/split_done.py index 6b6d28fb..79510762 100755 --- a/dak/split_done.py +++ b/dak/split_done.py @@ -19,12 +19,12 @@ ################################################################################ import glob, os, stat, time -import dak.lib.utils +import utils ################################################################################ def main(): - Cnf = dak.lib.utils.get_conf() + Cnf = utils.get_conf() count = 0 os.chdir(Cnf["Dir::Queue::Done"]) files = glob.glob("%s/*" % (Cnf["Dir::Queue::Done"])) @@ -37,7 +37,7 @@ def main(): os.makedirs(dirname) dest = dirname + '/' + os.path.basename(filename) if os.path.exists(dest): - dak.lib.utils.fubar("%s already exists." % (dest)) + 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 cf810b9a..3ff2caef 100755 --- a/dak/stats.py +++ b/dak/stats.py @@ -31,8 +31,8 @@ ################################################################################ import pg, sys -import dak.lib.utils import apt_pkg +import dak.lib.utils as utils ################################################################################ @@ -71,7 +71,7 @@ SELECT a.arch_string as Architecture, sum(f.size) def daily_install_stats(): stats = {} - file = dak.lib.utils.open_file("2001-11") + file = utils.open_file("2001-11") for line in file.readlines(): split = line.strip().split('~') program = split[1] @@ -213,7 +213,7 @@ SELECT suite, count(suite) FROM src_associations GROUP BY suite;""") def main (): global Cnf, projectB - Cnf = dak.lib.utils.get_conf() + Cnf = utils.get_conf() Arguments = [('h',"help","Stats::Options::Help")] for i in [ "help" ]: if not Cnf.has_key("Stats::Options::%s" % (i)): @@ -226,10 +226,10 @@ def main (): usage() if len(args) < 1: - dak.lib.utils.warn("dak stats requires a MODE argument") + utils.warn("dak stats requires a MODE argument") usage(1) elif len(args) > 1: - dak.lib.utils.warn("dak stats accepts only one MODE argument") + utils.warn("dak stats accepts only one MODE argument") usage(1) mode = args[0].lower() @@ -242,7 +242,7 @@ def main (): elif mode == "daily-install": daily_install_stats() else: - dak.lib.utils.warn("unknown mode '%s'" % (mode)) + utils.warn("unknown mode '%s'" % (mode)) usage(1) ################################################################################ diff --git a/dak/symlink_dists.py b/dak/symlink_dists.py index 82c38701..1e986f87 100755 --- a/dak/symlink_dists.py +++ b/dak/symlink_dists.py @@ -29,8 +29,9 @@ ################################################################################ import os, pg, re, sys -import dak.lib.utils, dak.lib.database import apt_pkg +import dak.lib.database as database +import dak.lib.utils as utils ################################################################################ @@ -54,7 +55,7 @@ Create compatibility symlinks from legacy locations to the pool. def fix_component_section (component, section): if component == "": - component = dak.lib.utils.extract_component_from_section(section)[1] + component = utils.extract_component_from_section(section)[1] # FIXME: ugly hacks to work around override brain damage section = re_strip_section_prefix.sub('', section) @@ -100,14 +101,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 = dak.lib.utils.clean_symlink(src, dest, Cnf["Dir::Root"]) + src = 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(dak.lib.utils.real_arch, Cnf.ValueList("Suite::Stable::Architectures")) + architectures = filter(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 @@ -134,11 +135,11 @@ SELECT DISTINCT ON (f.id) c.name, a.arch_string, sec.section, b.package, section="" architecture = i[1] package = i[3] - version = dak.lib.utils.re_no_epoch.sub('', i[4]) + version = 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 = dak.lib.utils.clean_symlink(src, dest, Cnf["Dir::Root"]) + src = utils.clean_symlink(src, dest, Cnf["Dir::Root"]) if not os.path.exists(dest): if Cnf.Find("Symlink-Dists::Options::Verbose"): print src+' -> '+dest @@ -160,7 +161,7 @@ SELECT DISTINCT ON (f.id) c.name, a.arch_string, sec.section, b.package, def main (): global Cnf, projectB - Cnf = dak.lib.utils.get_conf() + Cnf = utils.get_conf() Arguments = [('h',"help","Symlink-Dists::Options::Help"), ('v',"verbose","Symlink-Dists::Options::Verbose")] @@ -176,7 +177,7 @@ def main (): projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - dak.lib.database.init(Cnf, projectB) + database.init(Cnf, projectB) find_dislocated_stable(Cnf, projectB)