From: Joerg Jaspert Date: Sat, 3 May 2008 23:23:29 +0000 (+0200) Subject: Merge the cleanup branch, part 1 X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=a41f36505ff2297d3455c8b6ca846d0f2ffce5de;hp=795bf82dd7abd38a25833a667dc3876935c24563;p=dak.git Merge the cleanup branch, part 1 --- diff --git a/ChangeLog b/ChangeLog index 8c5ed420..b5c129b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,40 @@ +2008-05-04 Joerg Jaspert + + * dak/check_proposed_updates.py: Import stuff from daklib as + "import daklib.foo as foo" + * dak/clean_proposed_updates.py: likewise + * dak/clean_queues.py: likewise + + * dak/check_archive.py (check_files_not_symlinks): Remove + long-time unused and commented code. Import stuff from daklib as + "import daklib.foo as foo" + +2008-05-03 Joerg Jaspert + + * dak/examine_package.py: clean up pychecker warnings (merged with + Thomas changes to the NEW display) + +2008-05-03 Mark Hymers + + * dak/check_archive.py: clean up pychecker warnings + * dak/check_overrides.py: likewise + * dak/check_proposed_updates.py: likewise + * dak/clean_proposed_updates.py: likewise + * dak/clean_queues.py: likewise + * dak/control_overrides.py: likewise + * dak/control_suite.py: likewise + * dak/decode_dot_dak.py: likewise + * dak/examine_package.py: likewise + * dak/process_new.py: likewise + * dak/process_unchecked.py: likewise + * dak/queue_report.py: likewise + * dak/reject_proposed_updates.py: likewise + * dak/security_install.py: likewise + * dak/show_new.py: likewise + * dak/stats.py: likewise + * dak/symlink_dists.py: likewise + * dak/transitions.py: likewise + 2008-05-03 Joerg Jaspert * config/debian/cron.daily: Rename to diff --git a/dak/check_archive.py b/dak/check_archive.py old mode 100644 new mode 100755 index ba208dd7..c00aa08b --- a/dak/check_archive.py +++ b/dak/check_archive.py @@ -28,8 +28,8 @@ import commands, os, pg, stat, sys, time import apt_pkg, apt_inst -import daklib.database -import daklib.utils +import daklib.database as database +import daklib.utils as utils ################################################################################ @@ -105,8 +105,8 @@ def check_files(): filename = Cnf["Dir::Override"]+'override.unreferenced' if os.path.exists(filename): - file = daklib.utils.open_file(filename) - for filename in file.readlines(): + f = utils.open_file(filename) + for filename in f.readlines(): filename = filename[:-1] excluded[filename] = "" @@ -115,7 +115,7 @@ def check_files(): os.path.walk(Cnf["Dir::Root"]+'pool/', process_dir, None) print - print "%s wasted..." % (daklib.utils.size_type(waste)) + print "%s wasted..." % (utils.size_type(waste)) ################################################################################ @@ -127,17 +127,17 @@ def check_dscs(): continue component = component.lower() list_filename = '%s%s_%s_source.list' % (Cnf["Dir::Lists"], suite, component) - list_file = daklib.utils.open_file(list_filename) + list_file = utils.open_file(list_filename) for line in list_file.readlines(): - file = line[:-1] + f = line[:-1] try: - daklib.utils.parse_changes(file, signing_rules=1) - except daklib.utils.invalid_dsc_format_exc, line: - daklib.utils.warn("syntax error in .dsc file '%s', line %s." % (file, line)) + utils.parse_changes(f, signing_rules=1) + except utils.invalid_dsc_format_exc, line: + utils.warn("syntax error in .dsc file '%s', line %s." % (f, line)) count += 1 if count: - daklib.utils.warn("Found %s invalid .dsc files." % (count)) + utils.warn("Found %s invalid .dsc files." % (count)) ################################################################################ @@ -146,7 +146,7 @@ def check_override(): print suite print "-"*len(suite) print - suite_id = daklib.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 @@ -205,16 +205,16 @@ def check_md5sums(): db_md5sum = i[2] db_size = int(i[3]) try: - file = daklib.utils.open_file(filename) + f = utils.open_file(filename) except: - daklib.utils.warn("can't open '%s'." % (filename)) + utils.warn("can't open '%s'." % (filename)) continue - md5sum = apt_pkg.md5sum(file) + md5sum = apt_pkg.md5sum(f) size = os.stat(filename)[stat.ST_SIZE] if md5sum != db_md5sum: - daklib.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: - daklib.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." @@ -240,12 +240,12 @@ def check_timestamps(): for i in ql: filename = os.path.abspath(i[0] + i[1]) if os.access(filename, os.R_OK): - file = daklib.utils.open_file(filename) + f = utils.open_file(filename) current_file = filename sys.stderr.write("Processing %s.\n" % (filename)) - apt_inst.debExtract(file,Ent,"control.tar.gz") - file.seek(0) - apt_inst.debExtract(file,Ent,"data.tar.gz") + apt_inst.debExtract(f, Ent, "control.tar.gz") + f.seek(0) + apt_inst.debExtract(f, Ent, "data.tar.gz") count += 1 print "Checked %d files (out of %d)." % (count, len(db_files.keys())) @@ -265,24 +265,24 @@ def check_missing_tar_gz_in_dsc(): filename = os.path.abspath(i[0] + i[1]) try: # NB: don't enforce .dsc syntax - dsc = daklib.utils.parse_changes(filename) + dsc = utils.parse_changes(filename) except: - daklib.utils.fubar("error parsing .dsc file '%s'." % (filename)) - dsc_files = daklib.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 = daklib.utils.re_issource.match(file) + for f in dsc_files.keys(): + m = utils.re_issource.match(f) if not m: - daklib.utils.fubar("%s not recognised as source." % (file)) - type = m.group(3) - if type == "orig.tar.gz" or type == "tar.gz": + utils.fubar("%s not recognised as source." % (f)) + ftype = m.group(3) + if ftype == "orig.tar.gz" or ftype == "tar.gz": has_tar = 1 if not has_tar: - daklib.utils.warn("%s has no .tar.gz in the .dsc file." % (file)) + utils.warn("%s has no .tar.gz in the .dsc file." % (f)) count += 1 if count: - daklib.utils.warn("Found %s invalid .dsc files." % (count)) + utils.warn("Found %s invalid .dsc files." % (count)) ################################################################################ @@ -291,12 +291,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 = daklib.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 = daklib.utils.open_file(temp_filename) + sources = utils.open_file(temp_filename) Sources = apt_pkg.ParseTagFile(sources) while Sources.Step(): source = Sources.Section.Find('Package') @@ -309,7 +309,7 @@ def validate_sources(suite, component): if directory.find("potato") == -1: print "W: %s missing." % (filename) else: - pool_location = daklib.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) @@ -317,7 +317,7 @@ def validate_sources(suite, component): # Create symlink pool_filename = os.path.normpath(pool_filename) filename = os.path.normpath(filename) - src = daklib.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() @@ -330,12 +330,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 = daklib.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 = daklib.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')) @@ -367,39 +367,13 @@ def check_files_not_symlinks(): print "done. (%d seconds)" % (int(time.time()-before)) q_files = q.getresult() -# locations = {} -# q = projectB.query("SELECT l.path, c.name, l.id FROM location l, component c WHERE l.component = c.id") -# for i in q.getresult(): -# path = os.path.normpath(i[0] + i[1]) -# locations[path] = (i[0], i[2]) - -# q = projectB.query("BEGIN WORK") for i in q_files: filename = os.path.normpath(i[0] + i[1]) -# file_id = i[2] if os.access(filename, os.R_OK) == 0: - daklib.utils.warn("%s: doesn't exist." % (filename)) + utils.warn("%s: doesn't exist." % (filename)) else: if os.path.islink(filename): - daklib.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) -# if not os.path.isabs(dest): -# dest = os.path.normpath(os.path.join(os.path.dirname(filename), dest)) -# print "--> %s" % (dest) -# # Determine suitable location ID -# # [in what must be the suckiest way possible?] -# location_id = None -# for path in locations.keys(): -# if dest.find(path) == 0: -# (location, location_id) = locations[path] -# break -# if not location_id: -# daklib.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") + utils.warn("%s: is a symlink." % (filename)) ################################################################################ @@ -408,7 +382,7 @@ def chk_bd_process_dir (unused, dirname, filenames): if not name.endswith(".dsc"): continue filename = os.path.abspath(dirname+'/'+name) - dsc = daklib.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: @@ -428,7 +402,7 @@ def check_build_depends(): def main (): global Cnf, projectB, db_files, waste, excluded - Cnf = daklib.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)): @@ -441,15 +415,15 @@ def main (): usage() if len(args) < 1: - daklib.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: - daklib.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"])) - daklib.database.init(Cnf, projectB) + database.init(Cnf, projectB) if mode == "md5sums": check_md5sums() @@ -472,7 +446,7 @@ def main (): elif mode == "validate-builddeps": check_build_depends() else: - daklib.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 ecbaa75b..cdab6449 100644 --- a/dak/check_overrides.py +++ b/dak/check_overrides.py @@ -50,9 +50,9 @@ import pg, sys, os import apt_pkg -import daklib.database -import daklib.logging -import daklib.utils +import daklib.database as database +import daklib.logging as logging +import daklib.utils as utils ################################################################################ @@ -84,26 +84,25 @@ def gen_blacklist(dir): def process(osuite, affected_suites, originosuite, component, type): global Logger, Options, projectB, sections, priorities - osuite_id = daklib.database.get_suite_id(osuite) + osuite_id = database.get_suite_id(osuite) if osuite_id == -1: - daklib.utils.fubar("Suite '%s' not recognised." % (osuite)) + utils.fubar("Suite '%s' not recognised." % (osuite)) originosuite_id = None if originosuite: - originosuite_id = daklib.database.get_suite_id(originosuite) + originosuite_id = database.get_suite_id(originosuite) if originosuite_id == -1: - daklib.utils.fubar("Suite '%s' not recognised." % (originosuite)) + utils.fubar("Suite '%s' not recognised." % (originosuite)) - component_id = daklib.database.get_component_id(component) + component_id = database.get_component_id(component) if component_id == -1: - daklib.utils.fubar("Component '%s' not recognised." % (component)) + utils.fubar("Component '%s' not recognised." % (component)) - type_id = daklib.database.get_override_type_id(type) + type_id = database.get_override_type_id(type) if type_id == -1: - daklib.utils.fubar("Type '%s' not recognised. (Valid types are deb, udeb and dsc)" % (type)) - dsc_type_id = daklib.database.get_override_type_id("dsc") - deb_type_id = daklib.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") - source_priority_id = daklib.database.get_priority_id("source") + source_priority_id = database.get_priority_id("source") if type == "deb" or type == "udeb": packages = {} @@ -138,7 +137,7 @@ SELECT s.source FROM source s, src_associations sa, files f, location l, src_packages[package] = 1 else: if blacklist.has_key(package): - daklib.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]]) @@ -202,7 +201,7 @@ SELECT s.source FROM source s, src_associations sa, files f, location l, for package, hasoverride in src_packages.items(): if not hasoverride: - daklib.utils.warn("%s has no override!" % package) + utils.warn("%s has no override!" % package) else: # binary override for i in q.getresult(): @@ -211,7 +210,7 @@ SELECT s.source FROM source s, src_associations sa, files f, location l, packages[package] = 1 else: if blacklist.has_key(package): - daklib.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]]) @@ -256,7 +255,7 @@ SELECT s.source FROM source s, src_associations sa, files f, location l, for package, hasoverride in packages.items(): if not hasoverride: - daklib.utils.warn("%s has no override!" % package) + utils.warn("%s has no override!" % package) projectB.query("COMMIT WORK") sys.stdout.flush() @@ -267,7 +266,7 @@ SELECT s.source FROM source s, src_associations sa, files f, location l, def main (): global Logger, Options, projectB, sections, priorities - Cnf = daklib.utils.get_conf() + Cnf = utils.get_conf() Arguments = [('h',"help","Check-Overrides::Options::Help"), ('n',"no-action", "Check-Overrides::Options::No-Action")] @@ -281,7 +280,7 @@ def main (): usage() projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - daklib.database.init(Cnf, projectB) + database.init(Cnf, projectB) # init sections, priorities: q = projectB.query("SELECT id, section FROM section") @@ -292,9 +291,9 @@ def main (): priorities[i[0]] = i[1] if not Options["No-Action"]: - Logger = daklib.logging.Logger(Cnf, "check-overrides") + Logger = logging.Logger(Cnf, "check-overrides") else: - Logger = daklib.logging.Logger(Cnf, "check-overrides", 1) + Logger = logging.Logger(Cnf, "check-overrides", 1) gen_blacklist(Cnf["Dir::Queue::Accepted"]) @@ -329,7 +328,7 @@ def main (): suiteids.append(i[0]) if len(suiteids) != len(suites) or len(suiteids) < 1: - daklib.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 old mode 100644 new mode 100755 index 529f0a07..a4e7c0cb --- a/dak/check_proposed_updates.py +++ b/dak/check_proposed_updates.py @@ -30,8 +30,8 @@ import pg, sys, os import apt_pkg, apt_inst -import daklib.database -import daklib.utils +import daklib.database as database +import daklib.utils as utils ################################################################################ @@ -79,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." % (daklib.utils.pp_deps(parsed_dep)) + print "Found %s as a real package." % (utils.pp_deps(parsed_dep)) unsat = 0 break # As a virtual? @@ -87,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." % (daklib.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 = daklib.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." % (daklib.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: " % (daklib.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]) @@ -125,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, daklib.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 @@ -134,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(daklib.utils.open_file(filename))) + control = apt_pkg.ParseSection(apt_inst.debExtractControl(utils.open_file(filename))) except: - daklib.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") @@ -173,26 +173,26 @@ def pass_fail (filename, result): def check_changes (filename): try: - changes = daklib.utils.parse_changes(filename) - files = daklib.utils.build_file_list(changes) + changes = utils.parse_changes(filename) + files = utils.build_file_list(changes) except: - daklib.utils.warn("Error parsing changes file '%s'" % (filename)) + utils.warn("Error parsing changes file '%s'" % (filename)) return result = 0 # Move to the pool directory cwd = os.getcwd() - file = files.keys()[0] - pool_dir = Cnf["Dir::Pool"] + '/' + daklib.utils.poolify(changes["source"], files[file]["component"]) + f = files.keys()[0] + pool_dir = Cnf["Dir::Pool"] + '/' + utils.poolify(changes["source"], files[f]["component"]) os.chdir(pool_dir) changes_result = 0 - for file in files.keys(): - if file.endswith(".deb"): - result = check_package(file, files) + for f in files.keys(): + if f.endswith(".deb"): + result = check_package(f, files) if Options["verbose"]: - pass_fail(file, result) + pass_fail(f, result) changes_result += result pass_fail (filename, changes_result) @@ -210,25 +210,25 @@ def check_deb (filename): ################################################################################ def check_joey (filename): - file = daklib.utils.open_file(filename) + f = utils.open_file(filename) cwd = os.getcwd() os.chdir("%s/dists/proposed-updates" % (Cnf["Dir::Root"])) - for line in file.readlines(): + for line in f.readlines(): line = line.rstrip() if line.find('install') != -1: split_line = line.split() if len(split_line) != 2: - daklib.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" ]: - daklib.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) check_changes(changes_filename) - file.close() + f.close() os.chdir(cwd) @@ -241,11 +241,11 @@ def parse_packages(): suite = "stable" stable = {} components = Cnf.ValueList("Suite::%s::Components" % (suite)) - architectures = filter(daklib.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 = daklib.utils.open_file(filename, 'r') + packages = utils.open_file(filename, 'r') Packages = apt_pkg.ParseTagFile(packages) while Packages.Step(): package = Packages.Section.Find('Package') @@ -267,7 +267,7 @@ def parse_packages(): def main (): global Cnf, projectB, Options - Cnf = daklib.utils.get_conf() + Cnf = utils.get_conf() Arguments = [('d', "debug", "Check-Proposed-Updates::Options::Debug"), ('q',"quiet","Check-Proposed-Updates::Options::Quiet"), @@ -283,24 +283,24 @@ def main (): if Options["Help"]: usage(0) if not arguments: - daklib.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"])) - daklib.database.init(Cnf, projectB) + database.init(Cnf, projectB) print "Parsing packages files...", parse_packages() print "done." - for file in arguments: - if file.endswith(".changes"): - check_changes(file) - elif file.endswith(".deb"): - check_deb(file) - elif file.endswith(".joey"): - check_joey(file) + for f in arguments: + if f.endswith(".changes"): + check_changes(f) + elif f.endswith(".deb"): + check_deb(f) + elif f.endswith(".joey"): + check_joey(f) else: - daklib.utils.fubar("Unrecognised file type: '%s'." % (file)) + utils.fubar("Unrecognised file type: '%s'." % (f)) ####################################################################################### diff --git a/dak/clean_proposed_updates.py b/dak/clean_proposed_updates.py old mode 100644 new mode 100755 index 02032b12..fc063ddb --- a/dak/clean_proposed_updates.py +++ b/dak/clean_proposed_updates.py @@ -21,8 +21,8 @@ import os, pg, re, sys import apt_pkg -import daklib.database -import daklib.utils +import daklib.database as database +import daklib.utils as utils ################################################################################ @@ -49,58 +49,58 @@ Need either changes files or an admin.txt file with a '.joey' suffix.""" def check_changes (filename): try: - changes = daklib.utils.parse_changes(filename) - files = daklib.utils.build_file_list(changes) + changes = utils.parse_changes(filename) + files = utils.build_file_list(changes) except: - daklib.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 daklib.utils.re_isadeb.match(file): - m = re_isdeb.match(file) + for f in files.keys(): + if utils.re_isadeb.match(f): + m = re_isdeb.match(f) pkg = m.group(1) version = m.group(2) arch = m.group(3) if Options["debug"]: - print "BINARY: %s ==> %s_%s_%s" % (file, pkg, version, arch) + print "BINARY: %s ==> %s_%s_%s" % (f, pkg, version, arch) else: - m = daklib.utils.re_issource.match(file) + m = utils.re_issource.match(f) if m: pkg = m.group(1) version = m.group(2) - type = m.group(3) - if type != "dsc": - del files[file] + ftype = m.group(3) + if ftype != "dsc": + del files[f] num_files -= 1 continue arch = "source" if Options["debug"]: - print "SOURCE: %s ==> %s_%s_%s" % (file, pkg, version, arch) + print "SOURCE: %s ==> %s_%s_%s" % (f, pkg, version, arch) else: - daklib.utils.fubar("unknown type, fix me") + utils.fubar("unknown type, fix me") if not pu.has_key(pkg): # FIXME - daklib.utils.warn("%s doesn't seem to exist in %s?? (from %s [%s])" % (pkg, Options["suite"], file, filename)) + utils.warn("%s doesn't seem to exist in %s?? (from %s [%s])" % (pkg, Options["suite"], f, filename)) continue if not pu[pkg].has_key(arch): # FIXME - daklib.utils.warn("%s doesn't seem to exist for %s in %s?? (from %s [%s])" % (pkg, arch, Options["suite"], file, filename)) + utils.warn("%s doesn't seem to exist for %s in %s?? (from %s [%s])" % (pkg, arch, Options["suite"], f, filename)) continue - pu_version = daklib.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) + print "%s: ok" % (f) else: if Options["verbose"]: - print "%s: superseded, removing. [%s]" % (file, pu_version) - del files[file] + print "%s: superseded, removing. [%s]" % (f, pu_version) + del files[f] new_num_files = len(files.keys()) if new_num_files == 0: print "%s: no files left, superseded by %s" % (filename, pu_version) dest = Cnf["Dir::Morgue"] + "/misc/" if not Options["no-action"]: - daklib.utils.move(filename, dest) + utils.move(filename, dest) elif new_num_files < num_files: print "%s: lost files, MWAAP." % (filename) else: @@ -110,20 +110,20 @@ def check_changes (filename): ################################################################################ def check_joey (filename): - file = daklib.utils.open_file(filename) + f = utils.open_file(filename) cwd = os.getcwd() os.chdir("%s/dists/%s" % (Cnf["Dir::Root"]), Options["suite"]) - for line in file.readlines(): + for line in f.readlines(): line = line.rstrip() if line.find('install') != -1: split_line = line.split() if len(split_line) != 2: - daklib.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" ]: - daklib.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) @@ -159,7 +159,7 @@ ORDER BY package, version, arch_string def main (): global Cnf, projectB, Options - Cnf = daklib.utils.get_conf() + Cnf = utils.get_conf() Arguments = [('d', "debug", "Clean-Proposed-Updates::Options::Debug"), ('v', "verbose", "Clean-Proposed-Updates::Options::Verbose"), @@ -180,20 +180,20 @@ def main (): if Options["Help"]: usage(0) if not arguments: - daklib.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"])) - daklib.database.init(Cnf, projectB) + database.init(Cnf, projectB) init_pu() - for file in arguments: - if file.endswith(".changes"): - check_changes(file) - elif file.endswith(".joey"): - check_joey(file) + for f in arguments: + if f.endswith(".changes"): + check_changes(f) + elif f.endswith(".joey"): + check_joey(f) else: - daklib.utils.fubar("Unrecognised file type: '%s'." % (file)) + utils.fubar("Unrecognised file type: '%s'." % (f)) ####################################################################################### diff --git a/dak/clean_queues.py b/dak/clean_queues.py old mode 100644 new mode 100755 index 43f8ffb4..30e0baf1 --- a/dak/clean_queues.py +++ b/dak/clean_queues.py @@ -35,7 +35,7 @@ import os, stat, sys, time import apt_pkg -import daklib.utils +import daklib.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): - daklib.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"] @@ -81,32 +81,32 @@ def init (): os.chdir(incoming) # Remove a file to the morgue -def remove (file): - if os.access(file, os.R_OK): - dest_filename = del_dir + '/' + os.path.basename(file) +def remove (f): + if os.access(f, os.R_OK): + dest_filename = del_dir + '/' + os.path.basename(f) # If the destination file exists; try to find another filename to use if os.path.exists(dest_filename): - dest_filename = daklib.utils.find_next_free(dest_filename, 10) - daklib.utils.move(file, dest_filename, 0660) + dest_filename = utils.find_next_free(dest_filename, 10) + utils.move(f, dest_filename, 0660) else: - daklib.utils.warn("skipping '%s', permission denied." % (os.path.basename(file))) + utils.warn("skipping '%s', permission denied." % (os.path.basename(f))) # Removes any old files. # [Used for Incoming/REJECT] # def flush_old (): - for file in os.listdir('.'): - if os.path.isfile(file): - if os.stat(file)[stat.ST_MTIME] < delete_date: + for f in os.listdir('.'): + if os.path.isfile(f): + if os.stat(f)[stat.ST_MTIME] < delete_date: if Options["No-Action"]: - print "I: Would delete '%s'." % (os.path.basename(file)) + print "I: Would delete '%s'." % (os.path.basename(f)) else: if Options["Verbose"]: - print "Removing '%s' (to '%s')." % (os.path.basename(file), del_dir) - remove(file) + print "Removing '%s' (to '%s')." % (os.path.basename(f), del_dir) + remove(f) else: if Options["Verbose"]: - print "Skipping, too new, '%s'." % (os.path.basename(file)) + print "Skipping, too new, '%s'." % (os.path.basename(f)) # Removes any files which are old orphans (not associated with a valid .changes file). # [Used for Incoming] @@ -125,20 +125,20 @@ def flush_orphans (): # Proces all .changes and .dsc files. for changes_filename in changes_files: try: - changes = daklib.utils.parse_changes(changes_filename) - files = daklib.utils.build_file_list(changes) + changes = utils.parse_changes(changes_filename) + files = utils.build_file_list(changes) except: - daklib.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"): + for f in files.keys(): + if f.endswith(".dsc"): try: - dsc = daklib.utils.parse_changes(file) - dsc_files = daklib.utils.build_file_list(dsc, is_a_dsc=1) + dsc = utils.parse_changes(f) + dsc_files = utils.build_file_list(dsc, is_a_dsc=1) except: - daklib.utils.warn("error processing '%s'; skipping it. [Got %s]" % (file, sys.exc_type)) + utils.warn("error processing '%s'; skipping it. [Got %s]" % (f, sys.exc_type)) continue # Ensure all the files we've seen aren't deleted @@ -153,24 +153,24 @@ def flush_orphans (): # Anthing left at this stage is not referenced by a .changes (or # a .dsc) and should be deleted if old enough. - for file in all_files.keys(): - if os.stat(file)[stat.ST_MTIME] < delete_date: + for f in all_files.keys(): + if os.stat(f)[stat.ST_MTIME] < delete_date: if Options["No-Action"]: - print "I: Would delete '%s'." % (os.path.basename(file)) + print "I: Would delete '%s'." % (os.path.basename(f)) else: if Options["Verbose"]: - print "Removing '%s' (to '%s')." % (os.path.basename(file), del_dir) - remove(file) + print "Removing '%s' (to '%s')." % (os.path.basename(f), del_dir) + remove(f) else: if Options["Verbose"]: - print "Skipping, too new, '%s'." % (os.path.basename(file)) + print "Skipping, too new, '%s'." % (os.path.basename(f)) ################################################################################ def main (): global Cnf, Options - Cnf = daklib.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/control_overrides.py b/dak/control_overrides.py index 2b1c0e09..9ea1cd60 100644 --- a/dak/control_overrides.py +++ b/dak/control_overrides.py @@ -51,7 +51,9 @@ import pg, sys, time import apt_pkg -import daklib.utils, daklib.database, daklib.logging +import daklib.utils as utils +import daklib.database as database +import daklib.logging as logging ################################################################################ @@ -84,17 +86,17 @@ def usage (exit_code=0): ################################################################################ def process_file (file, suite, component, type, action): - suite_id = daklib.database.get_suite_id(suite) + suite_id = database.get_suite_id(suite) if suite_id == -1: - daklib.utils.fubar("Suite '%s' not recognised." % (suite)) + utils.fubar("Suite '%s' not recognised." % (suite)) - component_id = daklib.database.get_component_id(component) + component_id = database.get_component_id(component) if component_id == -1: - daklib.utils.fubar("Component '%s' not recognised." % (component)) + utils.fubar("Component '%s' not recognised." % (component)) - type_id = daklib.database.get_override_type_id(type) + type_id = database.get_override_type_id(type) if type_id == -1: - daklib.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 +118,7 @@ def process_file (file, suite, component, type, action): start_time = time.time() projectB.query("BEGIN WORK") for line in file.readlines(): - line = daklib.utils.re_comments.sub('', line).strip() + line = utils.re_comments.sub('', line).strip() if line == "": continue @@ -128,7 +130,7 @@ def process_file (file, suite, component, type, action): elif len(split_line) == 3: (package, section, maintainer_override) = split_line else: - daklib.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 +141,23 @@ def process_file (file, suite, component, type, action): elif len(split_line) == 4: (package, priority, section, maintainer_override) = split_line else: - daklib.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 = daklib.database.get_section_id(section) + section_id = database.get_section_id(section) if section_id == -1: - daklib.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 = daklib.database.get_priority_id(priority) + priority_id = database.get_priority_id(priority) if priority_id == -1: - daklib.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): - daklib.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] = "" @@ -212,34 +214,34 @@ def process_file (file, suite, component, type, action): ################################################################################ -def list(suite, component, type): - suite_id = daklib.database.get_suite_id(suite) +def list_overrides(suite, component, type): + suite_id = database.get_suite_id(suite) if suite_id == -1: - daklib.utils.fubar("Suite '%s' not recognised." % (suite)) + utils.fubar("Suite '%s' not recognised." % (suite)) - component_id = daklib.database.get_component_id(component) + component_id = database.get_component_id(component) if component_id == -1: - daklib.utils.fubar("Component '%s' not recognised." % (component)) + utils.fubar("Component '%s' not recognised." % (component)) - type_id = daklib.database.get_override_type_id(type) + type_id = database.get_override_type_id(type) if type_id == -1: - daklib.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 daklib.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 daklib.utils.result_join(i[:-1]) + print utils.result_join(i[:-1]) ################################################################################ def main (): global Cnf, projectB, Logger - Cnf = daklib.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,31 +268,31 @@ def main (): usage() projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - daklib.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: - daklib.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"], - Cnf["Control-Overrides::Options::Component"], - Cnf["Control-Overrides::Options::Type"]) + (suite, component, otype) = (Cnf["Control-Overrides::Options::Suite"], + Cnf["Control-Overrides::Options::Component"], + Cnf["Control-Overrides::Options::Type"]) if action == "list": - list(suite, component, type) + list_overrides(suite, component, otype) else: if Cnf.has_key("Suite::%s::Untouchable" % suite) and Cnf["Suite::%s::Untouchable" % suite] != 0: - daklib.utils.fubar("%s: suite is untouchable" % suite) + utils.fubar("%s: suite is untouchable" % suite) - Logger = daklib.logging.Logger(Cnf, "control-overrides") + Logger = logging.Logger(Cnf, "control-overrides") if file_list: - for file in file_list: - process_file(daklib.utils.open_file(file), suite, component, type, action) + for f in file_list: + process_file(utils.open_file(f), suite, component, otype, action) else: - process_file(sys.stdin, suite, component, type, action) + process_file(sys.stdin, suite, component, otype, action) Logger.close() ####################################################################################### diff --git a/dak/control_suite.py b/dak/control_suite.py index 5291b595..63a0386b 100644 --- a/dak/control_suite.py +++ b/dak/control_suite.py @@ -43,9 +43,9 @@ import pg, sys import apt_pkg -import daklib.database -import daklib.logging -import daklib.utils +import daklib.database as database +import daklib.logging as logging +import daklib.utils as utils ####################################################################################### @@ -77,13 +77,12 @@ def get_id (package, version, architecture): ql = q.getresult() if not ql: - daklib.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: - daklib.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 + return ql[0][0] ####################################################################################### @@ -110,7 +109,7 @@ def set_suite (file, suite_id): for line in lines: split_line = line.strip().split() if len(split_line) != 3: - daklib.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] = "" @@ -119,25 +118,25 @@ def set_suite (file, suite_id): for key in current.keys(): if not desired.has_key(key): (package, version, architecture) = key.split() - id = current[key] + pkid = current[key] if architecture == "source": - q = projectB.query("DELETE FROM src_associations WHERE id = %s" % (id)) + q = projectB.query("DELETE FROM src_associations WHERE id = %s" % (pkid)) else: - q = projectB.query("DELETE FROM bin_associations WHERE id = %s" % (id)) - Logger.log(["removed",key,id]) + q = projectB.query("DELETE FROM bin_associations WHERE id = %s" % (pkid)) + Logger.log(["removed", key, pkid]) # Check to see which packages need added and add them for key in desired.keys(): if not current.has_key(key): (package, version, architecture) = key.split() - id = get_id (package, version, architecture) - if not id: + pkid = get_id (package, version, architecture) + if not pkid: continue if architecture == "source": - q = projectB.query("INSERT INTO src_associations (suite, source) VALUES (%s, %s)" % (suite_id, id)) + q = projectB.query("INSERT INTO src_associations (suite, source) VALUES (%s, %s)" % (suite_id, pkid)) else: - q = projectB.query("INSERT INTO bin_associations (suite, bin) VALUES (%s, %s)" % (suite_id, id)) - Logger.log(["added",key,id]) + q = projectB.query("INSERT INTO bin_associations (suite, bin) VALUES (%s, %s)" % (suite_id, pkid)) + Logger.log(["added", key, pkid]) projectB.query("COMMIT WORK") @@ -145,7 +144,7 @@ def set_suite (file, suite_id): def process_file (file, suite, action): - suite_id = daklib.database.get_suite_id(suite) + suite_id = database.get_suite_id(suite) if action == "set": set_suite (file, suite_id) @@ -158,18 +157,18 @@ def process_file (file, suite, action): for line in lines: split_line = line.strip().split() if len(split_line) != 3: - daklib.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 - id = get_id(package, version, architecture) - if not id: + pkid = get_id(package, version, architecture) + if not pkid: continue if architecture == "source": # Find the existing assoications ID, if any - q = projectB.query("SELECT id FROM src_associations WHERE suite = %s and source = %s" % (suite_id, id)) + q = projectB.query("SELECT id FROM src_associations WHERE suite = %s and source = %s" % (suite_id, pkid)) ql = q.getresult() if not ql: assoication_id = None @@ -178,19 +177,19 @@ def process_file (file, suite, action): # Take action if action == "add": if assoication_id: - daklib.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)) + q = projectB.query("INSERT INTO src_associations (suite, source) VALUES (%s, %s)" % (suite_id, pkid)) elif action == "remove": if assoication_id == None: - daklib.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)) else: # Find the existing assoications ID, if any - q = projectB.query("SELECT id FROM bin_associations WHERE suite = %s and bin = %s" % (suite_id, id)) + q = projectB.query("SELECT id FROM bin_associations WHERE suite = %s and bin = %s" % (suite_id, pkid)) ql = q.getresult() if not ql: assoication_id = None @@ -199,13 +198,13 @@ def process_file (file, suite, action): # Take action if action == "add": if assoication_id: - daklib.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)) + q = projectB.query("INSERT INTO bin_associations (suite, bin) VALUES (%s, %s)" % (suite_id, pkid)) elif action == "remove": if assoication_id == None: - daklib.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)) @@ -215,7 +214,7 @@ def process_file (file, suite, action): ####################################################################################### def get_list (suite): - suite_id = daklib.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() @@ -233,7 +232,7 @@ def get_list (suite): def main (): global Cnf, projectB, Logger - Cnf = daklib.utils.get_conf() + Cnf = utils.get_conf() Arguments = [('a',"add","Control-Suite::Options::Add", "HasArg"), ('h',"help","Control-Suite::Options::Help"), @@ -253,35 +252,35 @@ def main (): projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"],int(Cnf["DB::Port"])) - daklib.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 daklib.database.get_suite_id(suite) == -1: - daklib.utils.fubar("Unknown suite '%s'." %(suite)) + if database.get_suite_id(suite) == -1: + utils.fubar("Unknown suite '%s'." %(suite)) else: if action: - daklib.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: - daklib.utils.fubar("No action specified.") + utils.fubar("No action specified.") # Safety/Sanity check if action == "set" and suite not in ["testing", "etch-m68k"]: - daklib.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 = daklib.logging.Logger(Cnf, "control-suite") + Logger = logging.Logger(Cnf, "control-suite") if file_list: - for file in file_list: - process_file(daklib.utils.open_file(file), suite, action) + for f in file_list: + process_file(utils.open_file(f), suite, action) else: process_file(sys.stdin, suite, action) Logger.close() diff --git a/dak/decode_dot_dak.py b/dak/decode_dot_dak.py index b6cee445..d4373641 100644 --- a/dak/decode_dot_dak.py +++ b/dak/decode_dot_dak.py @@ -28,8 +28,8 @@ import sys import apt_pkg -import daklib.queue -import daklib.utils +import daklib.queue as queue +import daklib.utils as utils ################################################################################ @@ -43,7 +43,7 @@ Dumps the info in .dak FILE(s). ################################################################################ def main(): - Cnf = daklib.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 = daklib.queue.Upload(Cnf) + k = queue.Upload(Cnf) for arg in sys.argv[1:]: - arg = daklib.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: - daklib.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,38 +94,38 @@ def main(): del dsc[i] print if dsc: - daklib.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:" - for file in files.keys(): - print " %s:" % (file) + for f in files.keys(): + print " %s:" % (f) for i in [ "package", "version", "architecture", "type", "size", "md5sum", "component", "location id", "source package", "source version", "maintainer", "dbtype", "files id", "new", "section", "priority", "pool name" ]: - if files[file].has_key(i): - print " %s: %s" % (i.capitalize(), files[file][i]) - del files[file][i] - if files[file]: - daklib.utils.warn("files[%s] still has following unrecognised keys: %s" % (file, files[file].keys())) + if files[f].has_key(i): + print " %s: %s" % (i.capitalize(), files[f][i]) + del files[f][i] + if files[f]: + utils.warn("files[%s] still has following unrecognised keys: %s" % (f, files[f].keys())) print dsc_files = k.pkg.dsc_files print " Dsc Files:" - for file in dsc_files.keys(): - print " %s:" % (file) + for f in dsc_files.keys(): + print " %s:" % (f) # Mandatory fields for i in [ "size", "md5sum" ]: - print " %s: %s" % (i.capitalize(), dsc_files[file][i]) - del dsc_files[file][i] + print " %s: %s" % (i.capitalize(), dsc_files[f][i]) + del dsc_files[f][i] # Optional fields for i in [ "files id" ]: - if dsc_files[file].has_key(i): - print " %s: %s" % (i.capitalize(), dsc_files[file][i]) - del dsc_files[file][i] - if dsc_files[file]: - daklib.utils.warn("dsc_files[%s] still has following unrecognised keys: %s" % (file, dsc_files[file].keys())) + if dsc_files[f].has_key(i): + print " %s: %s" % (i.capitalize(), dsc_files[f][i]) + del dsc_files[f][i] + if dsc_files[f]: + utils.warn("dsc_files[%s] still has following unrecognised keys: %s" % (f, dsc_files[f].keys())) ################################################################################ diff --git a/dak/examine_package.py b/dak/examine_package.py old mode 100644 new mode 100755 index b9ac9af3..3161428d --- a/dak/examine_package.py +++ b/dak/examine_package.py @@ -395,18 +395,18 @@ def do_lintian (filename): def get_copyright (deb_filename): package = re_package.sub(r'\1', deb_filename) o = os.popen("dpkg-deb -c %s | egrep 'usr(/share)?/doc/[^/]*/copyright' | awk '{print $6}' | head -n 1" % (deb_filename)) - copyright = o.read()[:-1] + cright = o.read()[:-1] - if copyright == "": + if cright == "": return formatted_text("WARNING: No copyright found, please check package manually.") - doc_directory = re_doc_directory.sub(r'\1', copyright) + doc_directory = re_doc_directory.sub(r'\1', cright) if package != doc_directory: return formatted_text("WARNING: wrong doc directory (expected %s, got %s)." % (package, doc_directory)) - o = os.popen("dpkg-deb --fsys-tarfile %s | tar xvOf - %s 2>/dev/null" % (deb_filename, copyright)) - copyright = o.read() - copyrightmd5 = md5.md5(copyright).hexdigest() + o = os.popen("dpkg-deb --fsys-tarfile %s | tar xvOf - %s 2>/dev/null" % (deb_filename, cright)) + cright = o.read() + copyrightmd5 = md5.md5(cright).hexdigest() res = "" if printed_copyrights.has_key(copyrightmd5) and printed_copyrights[copyrightmd5] != "%s (%s)" % (package, deb_filename): @@ -414,7 +414,7 @@ def get_copyright (deb_filename): (printed_copyrights[copyrightmd5])) else: printed_copyrights[copyrightmd5] = "%s (%s)" % (package, deb_filename) - return res+formatted_text(copyright) + return res+formatted_text(cright) def check_dsc (dsc_filename): (dsc) = read_changes_or_dsc(dsc_filename) @@ -491,11 +491,11 @@ def check_changes (changes_filename): changes = daklib.utils.parse_changes (changes_filename) files = daklib.utils.build_file_list(changes) - for file in files.keys(): - if file.endswith(".deb") or file.endswith(".udeb"): - check_deb(file) - if file.endswith(".dsc"): - check_dsc(file) + for f in files.keys(): + if f.endswith(".deb") or f.endswith(".udeb"): + check_deb(f) + if f.endswith(".dsc"): + check_dsc(f) # else: => byhand def main (): @@ -518,7 +518,7 @@ def main (): stdout_fd = sys.stdout - for file in args: + for f in args: try: if not Options["Html-Output"]: # Pipe output for each argument through less @@ -526,14 +526,14 @@ def main (): # -R added to display raw control chars for colour sys.stdout = less_fd try: - if file.endswith(".changes"): - check_changes(file) - elif file.endswith(".deb") or file.endswith(".udeb"): + if f.endswith(".changes"): + check_changes(f) + elif f.endswith(".deb") or f.endswith(".udeb"): check_deb(file) - elif file.endswith(".dsc"): - check_dsc(file) + elif f.endswith(".dsc"): + check_dsc(f) else: - daklib.utils.fubar("Unrecognised file type: '%s'." % (file)) + daklib.utils.fubar("Unrecognised file type: '%s'." % (f)) finally: if not Options["Html-Output"]: # Reset stdout here so future less invocations aren't FUBAR diff --git a/dak/process_new.py b/dak/process_new.py index 37a902ae..22469ad7 100644 --- a/dak/process_new.py +++ b/dak/process_new.py @@ -70,15 +70,15 @@ def recheck(): files = Upload.pkg.files reject_message = "" - for file in files.keys(): + for f in files.keys(): # The .orig.tar.gz can disappear out from under us is it's a # duplicate of one in the archive. - if not files.has_key(file): + if not files.has_key(f): continue # Check that the source still exists - if files[file]["type"] == "deb": - source_version = files[file]["source version"] - source_package = files[file]["source package"] + if files[f]["type"] == "deb": + source_version = files[f]["source version"] + source_package = files[f]["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 = daklib.utils.re_no_epoch.sub('', source_version) @@ -89,14 +89,14 @@ def recheck(): if os.path.exists(Cnf["Dir::Queue::%s" % (q)] + '/' + dsc_filename): found = 1 if not found: - reject("no source found for %s %s (%s)." % (source_package, source_version, file)) + reject("no source found for %s %s (%s)." % (source_package, source_version, f)) # Version and file overwrite checks - if files[file]["type"] == "deb": - reject(Upload.check_binary_against_db(file)) - elif files[file]["type"] == "dsc": - reject(Upload.check_source_against_db(file)) - (reject_msg, is_in_incoming) = Upload.check_dsc_against_db(file) + if files[f]["type"] == "deb": + reject(Upload.check_binary_against_db(f)) + elif files[f]["type"] == "dsc": + reject(Upload.check_source_against_db(f)) + (reject_msg, is_in_incoming) = Upload.check_dsc_against_db(f) reject(reject_msg, "") if reject_message.find("Rejected") != -1: @@ -332,9 +332,9 @@ def edit_new (new): section = section[:-3] if priority.endswith("[!]"): priority = priority[:-3] - for file in new[pkg]["files"]: - Upload.pkg.files[file]["section"] = section - Upload.pkg.files[file]["priority"] = priority + for f in new[pkg]["files"]: + Upload.pkg.files[f]["section"] = section + Upload.pkg.files[f]["priority"] = priority new[pkg]["section"] = section new[pkg]["priority"] = priority @@ -343,13 +343,13 @@ def edit_new (new): def edit_index (new, index): priority = new[index]["priority"] section = new[index]["section"] - type = new[index]["type"] + ftype = new[index]["type"] done = 0 while not done: print "\t".join([index, priority, section]) answer = "XXX" - if type != "dsc": + if ftype != "dsc": prompt = "[B]oth, Priority, Section, Done ? " else: prompt = "[S]ection, Done ? " @@ -398,9 +398,9 @@ def edit_index (new, index): # Reset the readline completer readline.set_completer(None) - for file in new[index]["files"]: - Upload.pkg.files[file]["section"] = section - Upload.pkg.files[file]["priority"] = priority + for f in new[index]["files"]: + Upload.pkg.files[f]["section"] = section + Upload.pkg.files[f]["priority"] = priority new[index]["priority"] = priority new[index]["section"] = section return new @@ -487,17 +487,17 @@ def check_pkg (): sys.stdout = less_fd examine_package.display_changes(Upload.pkg.changes_file) files = Upload.pkg.files - for file in files.keys(): - if files[file].has_key("new"): - type = files[file]["type"] - if type == "deb": - examine_package.check_deb(file) - elif type == "dsc": - examine_package.check_dsc(file) + for f in files.keys(): + if files[f].has_key("new"): + ftype = files[f]["type"] + if ftype == "deb": + examine_package.check_deb(f) + elif ftype == "dsc": + examine_package.check_dsc(f) finally: sys.stdout = stdout_fd except IOError, e: - if errno.errorcode[e.errno] == 'EPIPE': + if e.errno == errno.EPIPE: daklib.utils.warn("[examine_package] Caught EPIPE; skipping.") pass else: @@ -513,9 +513,9 @@ def check_pkg (): def do_bxa_notification(): files = Upload.pkg.files summary = "" - for file in files.keys(): - if files[file]["type"] == "deb": - control = apt_pkg.ParseSection(apt_inst.debExtractControl(daklib.utils.open_file(file))) + for f in files.keys(): + if files[f]["type"] == "deb": + control = apt_pkg.ParseSection(apt_inst.debExtractControl(daklib.utils.open_file(f))) summary += "\n" summary += "Package: %s\n" % (control.Find("Package")) summary += "Description: %s\n" % (control.Find("Description")) @@ -538,9 +538,9 @@ def add_overrides (new): 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)) - for file in new[pkg]["files"]: - if files[file].has_key("new"): - del files[file]["new"] + for f in new[pkg]["files"]: + if files[f].has_key("new"): + del files[f]["new"] del new[pkg] projectB.query("COMMIT WORK") @@ -557,9 +557,9 @@ def prod_maintainer (): answer = 'E' while answer == 'E': os.system("%s %s" % (editor, temp_filename)) - file = daklib.utils.open_file(temp_filename) - prod_message = "".join(file.readlines()) - file.close() + f = daklib.utils.open_file(temp_filename) + prod_message = "".join(f.readlines()) + f.close() print "Prod message:" print daklib.utils.prefix_multi_line_string(prod_message," ",include_blank_lines=1) prompt = "[P]rod, Edit, Abandon, Quit ?" @@ -742,13 +742,13 @@ def do_byhand(): will_install = 1 byhand = [] - for file in files.keys(): - if files[file]["type"] == "byhand": - if os.path.exists(file): - print "W: %s still present; please process byhand components and try again." % (file) + for f in files.keys(): + if files[f]["type"] == "byhand": + if os.path.exists(f): + print "W: %s still present; please process byhand components and try again." % (f) will_install = 0 else: - byhand.append(file) + byhand.append(f) answer = "XXXX" if Options["No-Action"]: @@ -769,8 +769,8 @@ def do_byhand(): if answer == 'A': done = 1 - for file in byhand: - del files[file] + for f in byhand: + del files[f] elif answer == 'M': Upload.do_reject(1, Options["Manual-Reject"]) os.unlink(Upload.pkg.changes_file[:-8]+".dak") @@ -787,10 +787,10 @@ def get_accept_lock(): retry = 0 while retry < 10: try: - lock_fd = os.open(Cnf["Process-New::AcceptedLockFile"], os.O_RDONLY | os.O_CREAT | os.O_EXCL) + os.open(Cnf["Process-New::AcceptedLockFile"], os.O_RDONLY | os.O_CREAT | os.O_EXCL) retry = 10 except OSError, e: - if errno.errorcode[e.errno] == 'EACCES' or errno.errorcode[e.errno] == 'EEXIST': + if e.errno == errno.EACCES or e.errno == errno.EEXIST: retry += 1 if (retry >= 10): daklib.utils.fubar("Couldn't obtain lock; assuming 'dak process-unchecked' is already running.") @@ -803,8 +803,8 @@ def get_accept_lock(): def move_to_dir (dest, perms=0660, changesperms=0664): daklib.utils.move (Upload.pkg.changes_file, dest, perms=changesperms) file_keys = Upload.pkg.files.keys() - for file in file_keys: - daklib.utils.move (file, dest, perms=perms) + for f in file_keys: + daklib.utils.move (f, dest, perms=perms) def do_accept(): print "ACCEPT" @@ -824,10 +824,10 @@ def do_accept(): def check_status(files): new = byhand = 0 - for file in files.keys(): - if files[file]["type"] == "byhand": + for f in files.keys(): + if files[f]["type"] == "byhand": byhand = 1 - elif files[file].has_key("new"): + elif files[f].has_key("new"): new = 1 return (new, byhand) @@ -910,7 +910,6 @@ def comment_reject(changes_file, comments): Upload.init_vars() Upload.update_vars() Upload.update_subst() - files = Upload.pkg.files if not recheck(): pass # dak has its own reasons to reject as well, which is fine diff --git a/dak/process_unchecked.py b/dak/process_unchecked.py index abf53fd1..b1845617 100644 --- a/dak/process_unchecked.py +++ b/dak/process_unchecked.py @@ -30,9 +30,9 @@ import commands, errno, fcntl, os, re, shutil, stat, sys, time, tempfile, traceback import apt_inst, apt_pkg -import daklib.database -import daklib.logging -import daklib.queue +import daklib.database as database +import daklib.logging as logging +import daklib.queue as queue import daklib.utils from types import * @@ -91,7 +91,7 @@ def init(): if Options["Help"]: usage() - Upload = daklib.queue.Upload(Cnf) + Upload = queue.Upload(Cnf) changes = Upload.pkg.changes dsc = Upload.pkg.dsc @@ -164,12 +164,12 @@ def clean_holding(): cwd = os.getcwd() os.chdir(Cnf["Dir::Queue::Holding"]) - for file in in_holding.keys(): - if os.path.exists(file): - if file.find('/') != -1: - daklib.utils.fubar("WTF? clean_holding() got a file ('%s') with / in it!" % (file)) + for f in in_holding.keys(): + if os.path.exists(f): + if f.find('/') != -1: + daklib.utils.fubar("WTF? clean_holding() got a file ('%s') with / in it!" % (f)) else: - os.unlink(file) + os.unlink(f) in_holding = {} os.chdir(cwd) @@ -245,7 +245,7 @@ def check_changes(): # Ensure all the values in Closes: are numbers if changes.has_key("closes"): for i in changes["closes"].keys(): - if daklib.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)) @@ -256,9 +256,9 @@ def check_changes(): # Check there isn't already a changes file of the same name in one # of the queue directories. base_filename = os.path.basename(filename) - for dir in [ "Accepted", "Byhand", "Done", "New", "ProposedUpdates", "OldProposedUpdates" ]: - if os.path.exists(Cnf["Dir::Queue::%s" % (dir) ]+'/'+base_filename): - reject("%s: a file with this name already exists in the %s directory." % (base_filename, dir)) + for d in [ "Accepted", "Byhand", "Done", "New", "ProposedUpdates", "OldProposedUpdates" ]: + if os.path.exists(Cnf["Dir::Queue::%s" % (d) ]+'/'+base_filename): + reject("%s: a file with this name already exists in the %s directory." % (base_filename, d)) # Check the .changes is non-empty if not files: @@ -273,20 +273,20 @@ def check_distributions(): "Check and map the Distribution field of a .changes file." # Handle suite mappings - for map in Cnf.ValueList("SuiteMappings"): - args = map.split() - type = args[0] - if type == "map" or type == "silent-map": + for m in Cnf.ValueList("SuiteMappings"): + args = m.split() + mtype = args[0] + if mtype == "map" or mtype == "silent-map": (source, dest) = args[1:3] if changes["distribution"].has_key(source): del changes["distribution"][source] changes["distribution"][dest] = 1 - if type != "silent-map": + if mtype != "silent-map": reject("Mapping %s to %s." % (source, dest),"") if changes.has_key("distribution-version"): if changes["distribution-version"].has_key(source): changes["distribution-version"][source]=dest - elif type == "map-unreleased": + elif mtype == "map-unreleased": (source, dest) = args[1:3] if changes["distribution"].has_key(source): for arch in changes["architecture"].keys(): @@ -295,16 +295,16 @@ def check_distributions(): del changes["distribution"][source] changes["distribution"][dest] = 1 break - elif type == "ignore": + elif mtype == "ignore": suite = args[1] if changes["distribution"].has_key(suite): del changes["distribution"][suite] reject("Ignoring %s as a target suite." % (suite), "Warning: ") - elif type == "reject": + elif mtype == "reject": suite = args[1] if changes["distribution"].has_key(suite): reject("Uploads to %s are not accepted." % (suite)) - elif type == "propup-version": + elif mtype == "propup-version": # give these as "uploaded-to(non-mapped) suites-to-add-when-upload-obsoletes" # # changes["distribution-version"] looks like: {'testing': 'testing-proposed-updates'} @@ -323,7 +323,7 @@ def check_distributions(): ################################################################################ -def check_deb_ar(filename, control): +def check_deb_ar(filename): """Sanity check the ar of a .deb, i.e. that there is: o debian-binary @@ -360,8 +360,8 @@ def check_files(): if not Options["No-Action"] and reprocess < 2: cwd = os.getcwd() os.chdir(pkg.directory) - for file in file_keys: - copy_to_holding(file) + for f in file_keys: + copy_to_holding(f) os.chdir(cwd) # Check there isn't already a .changes or .dak file of the same name in @@ -386,40 +386,40 @@ def check_files(): has_binaries = 0 has_source = 0 - for file in file_keys: + for f in file_keys: # Ensure the file does not already exist in one of the accepted directories - for dir in [ "Accepted", "Byhand", "New", "ProposedUpdates", "OldProposedUpdates", "Embargoed", "Unembargoed" ]: - if not Cnf.has_key("Dir::Queue::%s" % (dir)): continue - if os.path.exists(Cnf["Dir::Queue::%s" % (dir) ]+'/'+file): - reject("%s file already exists in the %s directory." % (file, dir)) - if not daklib.utils.re_taint_free.match(file): - reject("!!WARNING!! tainted filename: '%s'." % (file)) + for d in [ "Accepted", "Byhand", "New", "ProposedUpdates", "OldProposedUpdates", "Embargoed", "Unembargoed" ]: + if not Cnf.has_key("Dir::Queue::%s" % (d)): continue + if os.path.exists(Cnf["Dir::Queue::%s" % (d) ] + '/' + f): + reject("%s file already exists in the %s directory." % (f, d)) + if not daklib.utils.re_taint_free.match(f): + reject("!!WARNING!! tainted filename: '%s'." % (f)) # Check the file is readable - if os.access(file,os.R_OK) == 0: + if os.access(f, os.R_OK) == 0: # When running in -n, copy_to_holding() won't have # generated the reject_message, so we need to. if Options["No-Action"]: - if os.path.exists(file): - reject("Can't read `%s'. [permission denied]" % (file)) + if os.path.exists(f): + reject("Can't read `%s'. [permission denied]" % (f)) else: - reject("Can't read `%s'. [file not found]" % (file)) - files[file]["type"] = "unreadable" + reject("Can't read `%s'. [file not found]" % (f)) + files[f]["type"] = "unreadable" continue # If it's byhand skip remaining checks - if files[file]["section"] == "byhand" or files[file]["section"][:4] == "raw-": - files[file]["byhand"] = 1 - files[file]["type"] = "byhand" + if files[f]["section"] == "byhand" or files[f]["section"][:4] == "raw-": + files[f]["byhand"] = 1 + files[f]["type"] = "byhand" # Checks for a binary package... - elif daklib.utils.re_isadeb.match(file): + elif daklib.utils.re_isadeb.match(f): has_binaries = 1 - files[file]["type"] = "deb" + files[f]["type"] = "deb" # Extract package control information - deb_file = daklib.utils.open_file(file) + deb_file = daklib.utils.open_file(f) try: control = apt_pkg.ParseSection(apt_inst.debExtractControl(deb_file)) except: - reject("%s: debExtractControl() raised %s." % (file, sys.exc_type)) + reject("%s: debExtractControl() raised %s." % (f, sys.exc_type)) deb_file.close() # Can't continue, none of the checks on control would work. continue @@ -428,23 +428,23 @@ def check_files(): # Check for mandatory fields for field in [ "Package", "Architecture", "Version" ]: if control.Find(field) == None: - reject("%s: No %s field in control." % (file, field)) + reject("%s: No %s field in control." % (f, field)) # Can't continue continue # Ensure the package name matches the one give in the .changes if not changes["binary"].has_key(control.Find("Package", "")): - reject("%s: control file lists name as `%s', which isn't in changes file." % (file, control.Find("Package", ""))) + reject("%s: control file lists name as `%s', which isn't in changes file." % (f, control.Find("Package", ""))) # Validate the package field package = control.Find("Package") if not re_valid_pkg_name.match(package): - reject("%s: invalid package name '%s'." % (file, package)) + reject("%s: invalid package name '%s'." % (f, package)) # Validate the version field version = control.Find("Version") if not re_valid_version.match(version): - reject("%s: invalid version number '%s'." % (file, version)) + reject("%s: invalid version number '%s'." % (f, version)) # Ensure the architecture of the .deb is one we know about. default_suite = Cnf.get("Dinstall::DefaultSuite", "Unstable") @@ -455,76 +455,76 @@ def check_files(): # Ensure the architecture of the .deb is one of the ones # listed in the .changes. if not changes["architecture"].has_key(architecture): - reject("%s: control file lists arch as `%s', which isn't in changes file." % (file, architecture)) + reject("%s: control file lists arch as `%s', which isn't in changes file." % (f, architecture)) # Sanity-check the Depends field depends = control.Find("Depends") if depends == '': - reject("%s: Depends field is empty." % (file)) + reject("%s: Depends field is empty." % (f)) # Sanity-check the Provides field provides = control.Find("Provides") if provides: provide = re_spacestrip.sub('', provides) if provide == '': - reject("%s: Provides field is empty." % (file)) + reject("%s: Provides field is empty." % (f)) prov_list = provide.split(",") for prov in prov_list: if not re_valid_pkg_name.match(prov): - reject("%s: Invalid Provides field content %s." % (file, prov)) + reject("%s: Invalid Provides field content %s." % (f, prov)) # Check the section & priority match those given in the .changes (non-fatal) - if control.Find("Section") and files[file]["section"] != "" and files[file]["section"] != control.Find("Section"): - reject("%s control file lists section as `%s', but changes file has `%s'." % (file, control.Find("Section", ""), files[file]["section"]), "Warning: ") - if control.Find("Priority") and files[file]["priority"] != "" and files[file]["priority"] != control.Find("Priority"): - reject("%s control file lists priority as `%s', but changes file has `%s'." % (file, control.Find("Priority", ""), files[file]["priority"]),"Warning: ") - - files[file]["package"] = package - files[file]["architecture"] = architecture - files[file]["version"] = version - files[file]["maintainer"] = control.Find("Maintainer", "") - if file.endswith(".udeb"): - files[file]["dbtype"] = "udeb" - elif file.endswith(".deb"): - files[file]["dbtype"] = "deb" + if control.Find("Section") and files[f]["section"] != "" and files[f]["section"] != control.Find("Section"): + reject("%s control file lists section as `%s', but changes file has `%s'." % (f, control.Find("Section", ""), files[f]["section"]), "Warning: ") + if control.Find("Priority") and files[f]["priority"] != "" and files[f]["priority"] != control.Find("Priority"): + reject("%s control file lists priority as `%s', but changes file has `%s'." % (f, control.Find("Priority", ""), files[f]["priority"]),"Warning: ") + + files[f]["package"] = package + files[f]["architecture"] = architecture + files[f]["version"] = version + files[f]["maintainer"] = control.Find("Maintainer", "") + if f.endswith(".udeb"): + files[f]["dbtype"] = "udeb" + elif f.endswith(".deb"): + files[f]["dbtype"] = "deb" else: - reject("%s is neither a .deb or a .udeb." % (file)) - files[file]["source"] = control.Find("Source", files[file]["package"]) + reject("%s is neither a .deb or a .udeb." % (f)) + files[f]["source"] = control.Find("Source", files[f]["package"]) # Get the source version - source = files[file]["source"] + source = files[f]["source"] source_version = "" if source.find("(") != -1: m = daklib.utils.re_extract_src_version.match(source) source = m.group(1) source_version = m.group(2) if not source_version: - source_version = files[file]["version"] - files[file]["source package"] = source - files[file]["source version"] = source_version + source_version = files[f]["version"] + files[f]["source package"] = source + files[f]["source version"] = source_version # Ensure the filename matches the contents of the .deb - m = daklib.utils.re_isadeb.match(file) + m = daklib.utils.re_isadeb.match(f) # 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"])) + if files[f]["package"] != file_package: + reject("%s: package part of filename (%s) does not match package name in the %s (%s)." % (f, file_package, files[f]["dbtype"], files[f]["package"])) epochless_version = daklib.utils.re_no_epoch.sub('', control.Find("Version")) # version file_version = m.group(2) if epochless_version != file_version: - reject("%s: version part of filename (%s) does not match package version in the %s (%s)." % (file, file_version, files[file]["dbtype"], epochless_version)) + reject("%s: version part of filename (%s) does not match package version in the %s (%s)." % (f, file_version, files[f]["dbtype"], epochless_version)) # architecture file_architecture = m.group(3) - if files[file]["architecture"] != file_architecture: - reject("%s: architecture part of filename (%s) does not match package architecture in the %s (%s)." % (file, file_architecture, files[file]["dbtype"], files[file]["architecture"])) + if files[f]["architecture"] != file_architecture: + reject("%s: architecture part of filename (%s) does not match package architecture in the %s (%s)." % (f, file_architecture, files[f]["dbtype"], files[f]["architecture"])) # Check for existent source - source_version = files[file]["source version"] - source_package = files[file]["source package"] + source_version = files[f]["source version"] + source_package = files[f]["source package"] if changes["architecture"].has_key("source"): if source_version != changes["version"]: - reject("source version (%s) for %s doesn't match changes version %s." % (source_version, file, changes["version"])) + reject("source version (%s) for %s doesn't match changes version %s." % (source_version, f, changes["version"])) else: # Check in the SQL database if not Upload.source_exists(source_package, source_version, changes["distribution"].keys()): @@ -532,9 +532,9 @@ def check_files(): source_epochless_version = daklib.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 + files[f]["byhand"] = 1 elif os.path.exists(Cnf["Dir::Queue::New"] + '/' + dsc_filename): - files[file]["new"] = 1 + files[f]["new"] = 1 else: dsc_file_exists = 0 for myq in ["Accepted", "Embargoed", "Unembargoed", "ProposedUpdates", "OldProposedUpdates"]: @@ -543,98 +543,98 @@ def check_files(): dsc_file_exists = 1 break if not dsc_file_exists: - reject("no source found for %s %s (%s)." % (source_package, source_version, file)) + reject("no source found for %s %s (%s)." % (source_package, source_version, f)) # Check the version and for file overwrites - reject(Upload.check_binary_against_db(file),"") + reject(Upload.check_binary_against_db(f),"") - check_deb_ar(file, control) + check_deb_ar(f) # Checks for a source package... else: - m = daklib.utils.re_issource.match(file) + m = daklib.utils.re_issource.match(f) if m: has_source = 1 - files[file]["package"] = m.group(1) - files[file]["version"] = m.group(2) - files[file]["type"] = m.group(3) + files[f]["package"] = m.group(1) + files[f]["version"] = m.group(2) + files[f]["type"] = m.group(3) # Ensure the source package name matches the Source filed in the .changes - if changes["source"] != files[file]["package"]: - reject("%s: changes file doesn't say %s for Source" % (file, files[file]["package"])) + if changes["source"] != files[f]["package"]: + reject("%s: changes file doesn't say %s for Source" % (f, files[f]["package"])) # Ensure the source version matches the version in the .changes file - if files[file]["type"] == "orig.tar.gz": + if files[f]["type"] == "orig.tar.gz": changes_version = changes["chopversion2"] else: changes_version = changes["chopversion"] - if changes_version != files[file]["version"]: - reject("%s: should be %s according to changes file." % (file, changes_version)) + if changes_version != files[f]["version"]: + reject("%s: should be %s according to changes file." % (f, changes_version)) # Ensure the .changes lists source in the Architecture field if not changes["architecture"].has_key("source"): - reject("%s: changes file doesn't list `source' in Architecture field." % (file)) + reject("%s: changes file doesn't list `source' in Architecture field." % (f)) # Check the signature of a .dsc file - if files[file]["type"] == "dsc": - dsc["fingerprint"] = daklib.utils.check_signature(file, reject) + if files[f]["type"] == "dsc": + dsc["fingerprint"] = daklib.utils.check_signature(f, reject) - files[file]["architecture"] = "source" + files[f]["architecture"] = "source" # Not a binary or source package? Assume byhand... else: - files[file]["byhand"] = 1 - files[file]["type"] = "byhand" + files[f]["byhand"] = 1 + files[f]["type"] = "byhand" # Per-suite file checks - files[file]["oldfiles"] = {} + files[f]["oldfiles"] = {} for suite in changes["distribution"].keys(): # Skip byhand - if files[file].has_key("byhand"): + if files[f].has_key("byhand"): continue # Handle component mappings - for map in Cnf.ValueList("ComponentMappings"): - (source, dest) = map.split() - if files[file]["component"] == source: - files[file]["original component"] = source - files[file]["component"] = dest + for m in Cnf.ValueList("ComponentMappings"): + (source, dest) = m.split() + if files[f]["component"] == source: + files[f]["original component"] = source + files[f]["component"] = dest # Ensure the component is valid for the target suite if Cnf.has_key("Suite:%s::Components" % (suite)) and \ - files[file]["component"] not in Cnf.ValueList("Suite::%s::Components" % (suite)): - reject("unknown component `%s' for suite `%s'." % (files[file]["component"], suite)) + files[f]["component"] not in Cnf.ValueList("Suite::%s::Components" % (suite)): + reject("unknown component `%s' for suite `%s'." % (files[f]["component"], suite)) continue # Validate the component - component = files[file]["component"] - component_id = daklib.database.get_component_id(component) + component = files[f]["component"] + component_id = database.get_component_id(component) if component_id == -1: - reject("file '%s' has unknown component '%s'." % (file, component)) + reject("file '%s' has unknown component '%s'." % (f, component)) continue # See if the package is NEW - if not Upload.in_override_p(files[file]["package"], files[file]["component"], suite, files[file].get("dbtype",""), file): - files[file]["new"] = 1 + if not Upload.in_override_p(files[f]["package"], files[f]["component"], suite, files[f].get("dbtype",""), f): + files[f]["new"] = 1 # Validate the priority - if files[file]["priority"].find('/') != -1: - reject("file '%s' has invalid priority '%s' [contains '/']." % (file, files[file]["priority"])) + if files[f]["priority"].find('/') != -1: + reject("file '%s' has invalid priority '%s' [contains '/']." % (f, files[f]["priority"])) # Determine the location location = Cnf["Dir::Pool"] - location_id = daklib.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 + files[f]["location id"] = location_id # Check the md5sum & size against existing files (if any) - files[file]["pool name"] = daklib.utils.poolify (changes["source"], files[file]["component"]) - files_id = daklib.database.get_files_id(files[file]["pool name"] + file, files[file]["size"], files[file]["md5sum"], files[file]["location id"]) + files[f]["pool name"] = daklib.utils.poolify (changes["source"], files[f]["component"]) + files_id = database.get_files_id(files[f]["pool name"] + f, files[f]["size"], files[f]["md5sum"], files[f]["location id"]) if files_id == -1: - reject("INTERNAL ERROR, get_files_id() returned multiple matches for %s." % (file)) + reject("INTERNAL ERROR, get_files_id() returned multiple matches for %s." % (f)) elif files_id == -2: - reject("md5sum and/or size mismatch on existing copy of %s." % (file)) - files[file]["files id"] = files_id + reject("md5sum and/or size mismatch on existing copy of %s." % (f)) + files[f]["files id"] = files_id # Check for packages that have moved from one component to another q = Upload.projectB.query(""" @@ -644,11 +644,11 @@ SELECT c.name FROM binaries b, bin_associations ba, suite s, location l, AND (a.arch_string = '%s' OR a.arch_string = 'all') AND ba.bin = b.id AND ba.suite = s.id AND b.architecture = a.id AND f.location = l.id AND l.component = c.id AND b.file = f.id""" - % (files[file]["package"], suite, - files[file]["architecture"])) + % (files[f]["package"], suite, + files[f]["architecture"])) ql = q.getresult() if ql: - files[file]["othercomponents"] = ql[0][0] + files[f]["othercomponents"] = ql[0][0] # If the .changes file says it has source, it must have source. if changes["architecture"].has_key("source"): @@ -669,13 +669,13 @@ def check_dsc(): # Find the .dsc dsc_filename = None - for file in files.keys(): - if files[file]["type"] == "dsc": + for f in files.keys(): + if files[f]["type"] == "dsc": if dsc_filename: reject("can not process a .changes file with multiple .dsc's.") return 0 else: - dsc_filename = file + dsc_filename = f # If there isn't one, we have nothing to do. (We have reject()ed the upload already) if not dsc_filename: @@ -755,8 +755,8 @@ def check_dsc(): if not m: reject("%s: %s in Files field not recognised as source." % (dsc_filename, f)) continue - type = m.group(3) - if type == "orig.tar.gz" or type == "tar.gz": + ftype = m.group(3) + if ftype == "orig.tar.gz" or ftype == "tar.gz": has_tar = 1 if not has_tar: reject("%s: no .tar.gz or .orig.tar.gz in 'Files' field." % (dsc_filename)) @@ -789,9 +789,9 @@ def get_changelog_versions(source_dir): # Find the .dsc (again) dsc_filename = None - for file in files.keys(): - if files[file]["type"] == "dsc": - dsc_filename = file + for f in files.keys(): + if files[f]["type"] == "dsc": + dsc_filename = f # If there isn't one, we have nothing to do. (We have reject()ed the upload already) if not dsc_filename: @@ -805,8 +805,8 @@ def get_changelog_versions(source_dir): # If a file is missing for whatever reason, give up. if not os.path.exists(src): return - type = m.group(3) - if type == "orig.tar.gz" and pkg.orig_tar_gz: + ftype = m.group(3) + if ftype == "orig.tar.gz" and pkg.orig_tar_gz: continue dest = os.path.join(os.getcwd(), f) os.symlink(src, dest) @@ -865,11 +865,11 @@ def check_source(): # Create a temporary directory to extract the source into if Options["No-Action"]: - tmpdir = tempfile.mktemp() + tmpdir = tempfile.mkdtemp() else: # We're in queue/holding and can create a random directory. tmpdir = "%s" % (os.getpid()) - os.mkdir(tmpdir) + os.mkdir(tmpdir) # Move into the temporary directory cwd = os.getcwd() @@ -962,31 +962,31 @@ def check_hashes (): ################################################################################ -def check_hash (where, files, key, testfn, basedict = None): +def check_hash (where, lfiles, key, testfn, basedict = None): if basedict: - for file in basedict.keys(): - if file not in files: - reject("%s: no %s checksum" % (file, key)) + for f in basedict.keys(): + if f not in lfiles: + reject("%s: no %s checksum" % (f, key)) - for file in files.keys(): - if basedict and file not in basedict: - reject("%s: extraneous entry in %s checksums" % (file, key)) + for f in lfiles.keys(): + if basedict and f not in basedict: + reject("%s: extraneous entry in %s checksums" % (f, key)) try: - file_handle = daklib.utils.open_file(file) + file_handle = daklib.utils.open_file(f) except daklib.utils.cant_open_exc: continue # Check hash - if testfn(file_handle) != files[file][key]: - reject("%s: %s check failed." % (file, key)) + if testfn(file_handle) != lfiles[f][key]: + reject("%s: %s check failed." % (f, key)) file_handle.close() # Check size - actual_size = os.stat(file)[stat.ST_SIZE] - size = int(files[file]["size"]) + actual_size = os.stat(f)[stat.ST_SIZE] + size = int(lfiles[f]["size"]) if size != actual_size: reject("%s: actual file size (%s) does not match size (%s) in %s" - % (file, actual_size, size, where)) + % (f, actual_size, size, where)) ################################################################################ @@ -1104,7 +1104,7 @@ def check_signed_by_key(): check_suites = changes["distribution"].keys() if "unstable" not in check_suites: check_suites.append("unstable") for suite in check_suites: - suite_id = daklib.database.get_suite_id(suite) + suite_id = database.get_suite_id(suite) q = Upload.projectB.query("SELECT s.id FROM source s JOIN src_associations sa ON (s.id = sa.source) WHERE s.source = '%s' AND sa.suite = %d" % (changes["source"], suite_id)) for si in q.getresult(): if si[0] not in source_ids: source_ids.append(si[0]) @@ -1125,17 +1125,17 @@ def check_signed_by_key(): for b in changes["binary"].keys(): for suite in changes["distribution"].keys(): - suite_id = daklib.database.get_suite_id(suite) + suite_id = database.get_suite_id(suite) q = Upload.projectB.query("SELECT DISTINCT s.source FROM source s JOIN binaries b ON (s.id = b.source) JOIN bin_associations ba On (b.id = ba.bin) WHERE b.package = '%s' AND ba.suite = %s" % (b, suite_id)) for s in q.getresult(): if s[0] != changes["source"]: reject("%s may not hijack %s from source package %s in suite %s" % (uid, b, s, suite)) - for file in files.keys(): - if files[file].has_key("byhand"): - reject("%s may not upload BYHAND file %s" % (uid, file)) - if files[file].has_key("new"): - reject("%s may not upload NEW file %s" % (uid, file)) + for f in files.keys(): + if files[f].has_key("byhand"): + reject("%s may not upload BYHAND file %s" % (uid, f)) + if files[f].has_key("new"): + reject("%s may not upload NEW file %s" % (uid, f)) # The remaining checks only apply to binary-only uploads right now if changes["architecture"].has_key("source"): @@ -1151,8 +1151,8 @@ def check_signed_by_key(): if restrictions.Exists("Components"): restricted_components = restrictions.SubTree("Components").ValueList() is_restricted = False - for file in files: - if files[file]["component"] in restricted_components: + for f in files: + if files[f]["component"] in restricted_components: is_restricted = True break if not is_restricted: @@ -1188,9 +1188,9 @@ def upload_too_new(): file_list = pkg.files.keys() file_list.extend(pkg.dsc_files.keys()) file_list.append(pkg.changes_file) - for file in file_list: + for f in file_list: try: - last_modified = time.time()-os.path.getmtime(file) + last_modified = time.time()-os.path.getmtime(f) if last_modified < int(Cnf["Dinstall::SkipTime"]): too_new = 1 break @@ -1242,21 +1242,21 @@ def action (): if Options["Automatic"]: answer = 'R' else: - queue = None + qu = None for q in queues: if queue_info[q]["is"](): - queue = q + qu = q break - if queue: + if qu: print "%s for %s\n%s%s" % ( - queue.upper(), ", ".join(changes["distribution"].keys()), + qu.upper(), ", ".join(changes["distribution"].keys()), reject_message, summary), - queuekey = queue[0].upper() + queuekey = qu[0].upper() if queuekey in "RQSA": queuekey = "D" prompt = "[D]ivert, Skip, Quit ?" else: - prompt = "[%s]%s, Skip, Quit ?" % (queuekey, queue[1:].lower()) + prompt = "[%s]%s, Skip, Quit ?" % (queuekey, qu[1:].lower()) if Options["Automatic"]: answer = queuekey else: @@ -1267,7 +1267,7 @@ def action (): while prompt.find(answer) == -1: answer = daklib.utils.our_raw_input(prompt) - m = daklib.queue.re_default_answer.match(prompt) + m = queue.re_default_answer.match(prompt) if answer == "": answer = m.group(1) answer = answer[:1].upper() @@ -1279,15 +1279,15 @@ def action (): accept(summary, short_summary) remove_from_unchecked() elif answer == queuekey: - queue_info[queue]["process"](summary, short_summary) + queue_info[qu]["process"](summary, short_summary) remove_from_unchecked() elif answer == 'Q': sys.exit(0) def remove_from_unchecked(): os.chdir (pkg.directory) - for file in files.keys(): - os.unlink(file) + for f in files.keys(): + os.unlink(f) os.unlink(pkg.changes_file) ################################################################################ @@ -1301,8 +1301,8 @@ def accept (summary, short_summary): def move_to_dir (dest, perms=0660, changesperms=0664): daklib.utils.move (pkg.changes_file, dest, perms=changesperms) file_keys = files.keys() - for file in file_keys: - daklib.utils.move (file, dest, perms=perms) + for f in file_keys: + daklib.utils.move (f, dest, perms=perms) ################################################################################ @@ -1367,7 +1367,7 @@ def is_stableupdate (): return 0 if not changes["architecture"].has_key("source"): - pusuite = daklib.database.get_suite_id("proposed-updates") + pusuite = database.get_suite_id("proposed-updates") q = Upload.projectB.query( "SELECT S.source FROM source s JOIN src_associations sa ON (s.id = sa.source) WHERE s.source = '%s' AND s.version = '%s' AND sa.suite = %d" % (changes["source"], changes["version"], pusuite)) @@ -1396,7 +1396,7 @@ def is_oldstableupdate (): return 0 if not changes["architecture"].has_key("source"): - pusuite = daklib.database.get_suite_id("oldstable-proposed-updates") + pusuite = database.get_suite_id("oldstable-proposed-updates") q = Upload.projectB.query( "SELECT S.source FROM source s JOIN src_associations sa ON (s.id = sa.source) WHERE s.source = '%s' AND s.version = '%s' AND sa.suite = %d" % (changes["source"], changes["version"], pusuite)) @@ -1423,27 +1423,27 @@ def do_oldstableupdate (summary, short_summary): def is_autobyhand (): all_auto = 1 any_auto = 0 - for file in files.keys(): - if files[file].has_key("byhand"): + for f in files.keys(): + if files[f].has_key("byhand"): any_auto = 1 # filename is of form "PKG_VER_ARCH.EXT" where PKG, VER and ARCH # don't contain underscores, and ARCH doesn't contain dots. # further VER matches the .changes Version:, and ARCH should be in # the .changes Architecture: list. - if file.count("_") < 2: + if f.count("_") < 2: all_auto = 0 continue - (pkg, ver, archext) = file.split("_", 2) + (pckg, ver, archext) = f.split("_", 2) if archext.count(".") < 1 or changes["version"] != ver: all_auto = 0 continue ABH = Cnf.SubTree("AutomaticByHandPackages") - if not ABH.has_key(pkg) or \ - ABH["%s::Source" % (pkg)] != changes["source"]: - print "not match %s %s" % (pkg, changes["source"]) + if not ABH.has_key(pckg) or \ + ABH["%s::Source" % (pckg)] != changes["source"]: + print "not match %s %s" % (pckg, changes["source"]) all_auto = 0 continue @@ -1452,32 +1452,32 @@ def is_autobyhand (): all_auto = 0 continue - files[file]["byhand-arch"] = arch - files[file]["byhand-script"] = ABH["%s::Script" % (pkg)] + files[f]["byhand-arch"] = arch + files[f]["byhand-script"] = ABH["%s::Script" % (pckg)] return any_auto and all_auto def do_autobyhand (summary, short_summary): print "Attempting AUTOBYHAND." byhandleft = 0 - for file in files.keys(): - byhandfile = file - if not files[file].has_key("byhand"): + for f in files.keys(): + byhandfile = f + if not files[f].has_key("byhand"): continue - if not files[file].has_key("byhand-script"): + if not files[f].has_key("byhand-script"): byhandleft = 1 continue os.system("ls -l %s" % byhandfile) result = os.system("%s %s %s %s %s" % ( - files[file]["byhand-script"], byhandfile, - changes["version"], files[file]["byhand-arch"], + files[f]["byhand-script"], byhandfile, + changes["version"], files[f]["byhand-arch"], os.path.abspath(pkg.changes_file))) if result == 0: os.unlink(byhandfile) - del files[file] + del files[f] else: - print "Error processing %s, left as byhand." % (file) + print "Error processing %s, left as byhand." % (f) byhandleft = 1 if byhandleft: @@ -1488,8 +1488,8 @@ def do_autobyhand (summary, short_summary): ################################################################################ def is_byhand (): - for file in files.keys(): - if files[file].has_key("byhand"): + for f in files.keys(): + if files[f].has_key("byhand"): return 1 return 0 @@ -1507,8 +1507,8 @@ def do_byhand (summary, short_summary): ################################################################################ def is_new (): - for file in files.keys(): - if files[file].has_key("new"): + for f in files.keys(): + if files[f].has_key("new"): return 1 return 0 @@ -1606,10 +1606,10 @@ def main(): Options["Automatic"] = "" # Ensure all the arguments we were given are .changes files - for file in changes_files: - if not file.endswith(".changes"): - daklib.utils.warn("Ignoring '%s' because it's not a .changes file." % (file)) - changes_files.remove(file) + for f in changes_files: + if not f.endswith(".changes"): + daklib.utils.warn("Ignoring '%s' because it's not a .changes file." % (f)) + changes_files.remove(f) if changes_files == []: daklib.utils.fubar("Need at least one .changes file as an argument.") @@ -1630,7 +1630,7 @@ def main(): daklib.utils.fubar("Couldn't obtain lock; assuming another 'dak process-unchecked' is already running.") else: raise - Logger = Upload.Logger = daklib.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: $Revision: 1.65 $" diff --git a/dak/queue_report.py b/dak/queue_report.py index af3bc58d..f1e5287f 100644 --- a/dak/queue_report.py +++ b/dak/queue_report.py @@ -36,8 +36,8 @@ import copy, glob, os, stat, sys, time import apt_pkg -import daklib.queue -import daklib.utils +import daklib.queue as queue +import daklib.utils as utils Cnf = None Upload = None @@ -309,7 +309,6 @@ def process_changes_files(changes_files, type): maint="" distribution="" closes="" - source_exists="" for i in per_source_items: last_modified = time.time()-i[1]["oldest"] source = i[1]["list"][0]["source"] @@ -322,8 +321,8 @@ def process_changes_files(changes_files, type): try: (maintainer["maintainer822"], maintainer["maintainer2047"], maintainer["maintainername"], maintainer["maintaineremail"]) = \ - daklib.utils.fix_maintainer (j["maintainer"]) - except daklib.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" @@ -335,7 +334,7 @@ def process_changes_files(changes_files, type): version = j["version"] versions[version] = "" arches_list = arches.keys() - arches_list.sort(daklib.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: @@ -423,7 +422,7 @@ def process_changes_files(changes_files, type): def main(): global Cnf, Upload - Cnf = daklib.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"), @@ -438,7 +437,7 @@ def main(): if Options["Help"]: usage() - Upload = daklib.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 d04dbeb3..060ad513 100644 --- a/dak/reject_proposed_updates.py +++ b/dak/reject_proposed_updates.py @@ -21,10 +21,10 @@ import os, pg, sys import apt_pkg -import daklib.database -import daklib.logging -import daklib.queue -import daklib.utils +import daklib.database as database +import daklib.logging as logging +import daklib.queue as queue +import daklib.utils as utils ################################################################################ @@ -51,7 +51,7 @@ Manually reject the .CHANGES file(s). def main(): global Cnf, Logger, Options, projectB, Upload - Cnf = daklib.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")] @@ -65,13 +65,13 @@ def main(): if Options["Help"]: usage() if not arguments: - daklib.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"])) - daklib.database.init(Cnf, projectB) + database.init(Cnf, projectB) - Upload = daklib.queue.Upload(Cnf) - Logger = Upload.Logger = daklib.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: lauren $Revision: 1.4 $" if Cnf.has_key("Dinstall::Bcc"): @@ -80,7 +80,7 @@ def main(): Upload.Subst["__BCC__"] = bcc for arg in arguments: - arg = daklib.utils.validate_changes_file_arg(arg) + arg = utils.validate_changes_file_arg(arg) Upload.pkg.changes_file = arg Upload.init_vars() cwd = os.getcwd() @@ -96,8 +96,8 @@ def main(): answer = "XXX" while prompt.find(answer) == -1: - answer = daklib.utils.our_raw_input(prompt) - m = daklib.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() @@ -123,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 = daklib.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 = daklib.utils.open_file(temp_filename) - reject_message = "".join(file.readlines()) - file.close() + f = utils.open_file(temp_filename) + reject_message = "".join(f.readlines()) + f.close() print "Reject message:" - print daklib.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 = daklib.utils.our_raw_input(prompt) - m = daklib.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() @@ -163,38 +163,38 @@ 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 = daklib.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 = daklib.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 = daklib.database.get_suite_id('proposed-updates') + suite_id = database.get_suite_id('proposed-updates') projectB.query("BEGIN WORK") # Remove files from proposed-updates suite - for file in files.keys(): - if files[file]["type"] == "dsc": + for f in files.keys(): + if files[f]["type"] == "dsc": package = dsc["source"] - version = dsc["version"]; # NB: not files[file]["version"], that has no epoch + version = dsc["version"]; # NB: not files[f]["version"], that has no epoch q = projectB.query("SELECT id FROM source WHERE source = '%s' AND version = '%s'" % (package, version)) ql = q.getresult() if not ql: - daklib.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": - package = files[file]["package"] - version = files[file]["version"] - architecture = files[file]["architecture"] + elif files[f]["type"] == "deb": + package = files[f]["package"] + version = files[f]["version"] + architecture = files[f]["architecture"] 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() @@ -204,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: - daklib.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)) @@ -212,7 +212,7 @@ def reject (reject_message = ""): # Send the rejection mail if appropriate if not Options["No-Mail"]: - daklib.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/security_install.py b/dak/security_install.py index bf549158..34efeb4c 100644 --- a/dak/security_install.py +++ b/dak/security_install.py @@ -32,7 +32,7 @@ import commands, os, pwd, re, sys, time import apt_pkg -import daklib.queue +import daklib.queue as queue import daklib.utils ################################################################################ @@ -85,12 +85,12 @@ def do_upload(changes_files): print "Not uploading amd64 part to ftp-master\n" continue # Build the file list for this .changes file - for file in files.keys(): + for f in files.keys(): poolname = os.path.join(Cnf["Dir::Root"], Cnf["Dir::PoolRoot"], - daklib.utils.poolify(changes["source"], files[file]["component"]), - file) + daklib.utils.poolify(changes["source"], files[f]["component"]), + f) file_list.append(poolname) - orig_component = files[file].get("original component", files[file]["component"]) + orig_component = files[f].get("original component", files[f]["component"]) components[orig_component] = "" # Determine the upload uri for this .changes file for component in components.keys(): @@ -138,11 +138,11 @@ def do_upload(changes_files): if not Options["No-Action"]: filename = "%s/testing-processed" % (Cnf["Dir::Log"]) - file = daklib.utils.open_file(filename, 'a') + f = daklib.utils.open_file(filename, 'a') for source in package_list.keys(): for version in package_list[source].keys(): - file.write(" ".join([source, version])+'\n') - file.close() + f.write(" ".join([source, version])+'\n') + f.close() ###################################################################### # This function was originally written by aj and NIHishly merged into @@ -168,35 +168,35 @@ def make_advisory(advisory_nr, changes_files): updated_pkgs[suite] = {} files = Upload.pkg.files - for file in files.keys(): - arch = files[file]["architecture"] - md5 = files[file]["md5sum"] - size = files[file]["size"] + for f in files.keys(): + arch = files[f]["architecture"] + md5 = files[f]["md5sum"] + size = files[f]["size"] poolname = Cnf["Dir::PoolRoot"] + \ - daklib.utils.poolify(src, files[file]["component"]) - if arch == "source" and file.endswith(".dsc"): + daklib.utils.poolify(src, files[f]["component"]) + if arch == "source" and f.endswith(".dsc"): dscpoolname = poolname for suite in suites: if not updated_pkgs[suite].has_key(arch): updated_pkgs[suite][arch] = {} - updated_pkgs[suite][arch][file] = { + updated_pkgs[suite][arch][f] = { "md5": md5, "size": size, "poolname": poolname } dsc_files = Upload.pkg.dsc_files - for file in dsc_files.keys(): + for f in dsc_files.keys(): arch = "source" - if not dsc_files[file].has_key("files id"): + if not dsc_files[f].has_key("files id"): continue # otherwise, it's already in the pool and needs to be # listed specially - md5 = dsc_files[file]["md5sum"] - size = dsc_files[file]["size"] + md5 = dsc_files[f]["md5sum"] + size = dsc_files[f]["size"] for suite in suites: if not updated_pkgs[suite].has_key(arch): updated_pkgs[suite][arch] = {} - updated_pkgs[suite][arch][file] = { + updated_pkgs[suite][arch][f] = { "md5": md5, "size": size, "poolname": dscpoolname } @@ -247,12 +247,12 @@ def make_advisory(advisory_nr, changes_files): adv += " %s architecture (%s)\n\n" % (a, Cnf["Architectures::%s" % a]) - for file in updated_pkgs[suite][a].keys(): + for f in updated_pkgs[suite][a].keys(): adv += " http://%s/%s%s\n" % ( - archive, updated_pkgs[suite][a][file]["poolname"], file) + archive, updated_pkgs[suite][a][f]["poolname"], f) adv += " Size/MD5 checksum: %8s %s\n" % ( - updated_pkgs[suite][a][file]["size"], - updated_pkgs[suite][a][file]["md5"]) + updated_pkgs[suite][a][f]["size"], + updated_pkgs[suite][a][f]["md5"]) adv += "\n" adv = adv.rstrip() @@ -280,7 +280,7 @@ def init(): arguments = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv) Options = Cnf.SubTree("Security-Install::Options") - Upload = daklib.queue.Upload(Cnf) + Upload = queue.Upload(Cnf) if Options["Help"]: usage(0) @@ -293,8 +293,8 @@ def init(): if advisory_number.endswith(".changes"): daklib.utils.warn("first argument must be the advisory number.") usage(1) - for file in changes_files: - file = daklib.utils.validate_changes_file_arg(file) + for f in changes_files: + f = daklib.utils.validate_changes_file_arg(f) return (advisory_number, changes_files) ###################################################################### @@ -332,8 +332,8 @@ def main(): if not Options["No-Action"]: print "About to install the following files: " - for file in changes_files: - print " %s" % (file) + for f in changes_files: + print " %s" % (f) answer = yes_no("Continue (Y/n)?") if answer == "n": sys.exit(0) diff --git a/dak/show_new.py b/dak/show_new.py old mode 100644 new mode 100755 index 2596f864..a18847cc --- a/dak/show_new.py +++ b/dak/show_new.py @@ -29,7 +29,7 @@ import copy, os, sys, time import apt_pkg import examine_package import daklib.database -import daklib.queue +import daklib.queue as queue import daklib.utils # Globals @@ -149,7 +149,7 @@ def do_pkg(changes_file): changes["suite"] = copy.copy(changes["distribution"]) # Find out what's new - new = daklib.queue.determine_new(changes, files, projectB, 0) + new = queue.determine_new(changes, files, projectB, 0) stdout_fd = sys.stdout @@ -168,7 +168,7 @@ def do_pkg(changes_file): html_header(changes["source"], filestoexamine) - daklib.queue.check_valid(new) + queue.check_valid(new) examine_package.display_changes(Upload.pkg.changes_file) for fn in filter(lambda fn: fn.endswith(".dsc"), filestoexamine): @@ -210,7 +210,7 @@ def init(): if Options["help"]: usage() - Upload = daklib.queue.Upload(Cnf) + Upload = queue.Upload(Cnf) projectB = Upload.projectB @@ -233,8 +233,8 @@ def main(): do_pkg (changes_file) files = set(os.listdir(Cnf["Show-New::HTMLPath"])) to_delete = filter(lambda x: x.endswith(".html"), files.difference(sources)) - for file in to_delete: - os.remove(os.path.join(Cnf["Show-New::HTMLPath"],file)) + for f in to_delete: + os.remove(os.path.join(Cnf["Show-New::HTMLPath"],f)) ################################################################################ diff --git a/dak/stats.py b/dak/stats.py index bf84efe9..0f1629e6 100644 --- a/dak/stats.py +++ b/dak/stats.py @@ -71,8 +71,8 @@ SELECT a.arch_string as Architecture, sum(f.size) def daily_install_stats(): stats = {} - file = daklib.utils.open_file("2001-11") - for line in file.readlines(): + f = daklib.utils.open_file("2001-11") + for line in f.readlines(): split = line.strip().split('|') program = split[1] if program != "katie" and program != "process-accepted": @@ -140,15 +140,15 @@ def number_of_packages(): q = projectB.query("SELECT id, suite_name FROM suite") suite_ql = q.getresult() for i in suite_ql: - (id, name) = i - suites[id] = name - suite_ids[name] = id + (sid, name) = i + suites[sid] = name + suite_ids[name] = sid # Build up architecture mapping q = projectB.query("SELECT id, arch_string FROM architecture") for i in q.getresult(): - (id, name) = i - arches[id] = name - arch_ids[name] = id + (aid, name) = i + arches[aid] = name + arch_ids[name] = aid # Pre-create the dictionary for suite_id in suites.keys(): d[suite_id] = {} diff --git a/dak/symlink_dists.py b/dak/symlink_dists.py index 6656ab6d..35f55183 100644 --- a/dak/symlink_dists.py +++ b/dak/symlink_dists.py @@ -68,13 +68,13 @@ def fix_component_section (component, section): ################################################################################ -def find_dislocated_stable(Cnf, projectB): +def find_dislocated_stable(Conf, DBConn): dislocated_files = {} - codename = Cnf["Suite::Stable::Codename"] + codename = Conf["Suite::Stable::Codename"] # Source - q = projectB.query(""" + q = DBConn.query(""" SELECT DISTINCT ON (f.id) c.name, sec.section, l.path, f.filename, f.id FROM component c, override o, section sec, source s, files f, location l, dsc_files df, suite su, src_associations sa, files f2, location l2 @@ -95,20 +95,20 @@ SELECT DISTINCT ON (f.id) c.name, sec.section, l.path, f.filename, f.id # AND NOT EXISTS (SELECT 1 FROM location l WHERE l.component IS NOT NULL AND f.location = l.id) for i in q.getresult(): (component, section) = fix_component_section(i[0], i[1]) - if Cnf.FindB("Dinstall::LegacyStableHasNoSections"): + if Conf.FindB("Dinstall::LegacyStableHasNoSections"): section="" - dest = "%sdists/%s/%s/source/%s%s" % (Cnf["Dir::Root"], codename, component, section, os.path.basename(i[3])) + dest = "%sdists/%s/%s/source/%s%s" % (Conf["Dir::Root"], codename, component, section, os.path.basename(i[3])) if not os.path.exists(dest): src = i[2]+i[3] - src = daklib.utils.clean_symlink(src, dest, Cnf["Dir::Root"]) - if Cnf.Find("Symlink-Dists::Options::Verbose"): + src = daklib.utils.clean_symlink(src, dest, Conf["Dir::Root"]) + if Conf.Find("Symlink-Dists::Options::Verbose"): print src+' -> '+dest os.symlink(src, dest) dislocated_files[i[4]] = dest # Binary - architectures = filter(daklib.utils.real_arch, Cnf.ValueList("Suite::Stable::Architectures")) - q = projectB.query(""" + architectures = filter(daklib.utils.real_arch, Conf.ValueList("Suite::Stable::Architectures")) + q = DBConn.query(""" SELECT DISTINCT ON (f.id) c.name, a.arch_string, sec.section, b.package, b.version, l.path, f.filename, f.id FROM architecture a, bin_associations ba, binaries b, component c, files f, @@ -130,26 +130,26 @@ SELECT DISTINCT ON (f.id) c.name, a.arch_string, sec.section, b.package, # (SELECT 1 FROM location l WHERE l.component IS NOT NULL AND f.location = l.id) for i in q.getresult(): (component, section) = fix_component_section(i[0], i[2]) - if Cnf.FindB("Dinstall::LegacyStableHasNoSections"): + if Conf.FindB("Dinstall::LegacyStableHasNoSections"): section="" architecture = i[1] package = i[3] version = daklib.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 = daklib.utils.clean_symlink(src, dest, Cnf["Dir::Root"]) + dest = "%sdists/%s/%s/binary-%s/%s%s_%s.deb" % (Conf["Dir::Root"], codename, component, architecture, section, package, version) + src = daklib.utils.clean_symlink(src, dest, Conf["Dir::Root"]) if not os.path.exists(dest): - if Cnf.Find("Symlink-Dists::Options::Verbose"): + if Conf.Find("Symlink-Dists::Options::Verbose"): print src+' -> '+dest os.symlink(src, dest) dislocated_files[i[7]] = dest # Add per-arch symlinks for arch: all debs if architecture == "all": for arch in architectures: - dest = "%sdists/%s/%s/binary-%s/%s%s_%s.deb" % (Cnf["Dir::Root"], codename, component, arch, section, package, version) + dest = "%sdists/%s/%s/binary-%s/%s%s_%s.deb" % (Conf["Dir::Root"], codename, component, arch, section, package, version) if not os.path.exists(dest): - if Cnf.Find("Symlink-Dists::Options::Verbose"): + if Conf.Find("Symlink-Dists::Options::Verbose"): print src+' -> '+dest os.symlink(src, dest) diff --git a/dak/transitions.py b/dak/transitions.py index 5636624f..374beabb 100644 --- a/dak/transitions.py +++ b/dak/transitions.py @@ -183,9 +183,9 @@ def load_transitions(trans_file): ##################################### #### This may run within sudo !! #### ##################################### -def lock_file(file): +def lock_file(f): for retry in range(10): - lock_fd = os.open(file, os.O_RDWR | os.O_CREAT) + lock_fd = os.open(f, os.O_RDWR | os.O_CREAT) try: fcntl.lockf(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB) return lock_fd @@ -197,7 +197,7 @@ def lock_file(file): else: raise - daklib.utils.fubar("Couldn't obtain lock for %s." % (lockfile)) + daklib.utils.fubar("Couldn't obtain lock for %s." % (f)) ################################################################################