X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=katie;h=ca28f4019aefc85711a3d2c6ad33cbdc19de043c;hb=fc1e81cf87861694e19b96afa8dd849dd967343c;hp=fa600e60a8bc47acbbec82b5606a64c08a37c599;hpb=c7ce079ad8627242b78e817208b7a77e781341d5;p=dak.git diff --git a/katie b/katie index fa600e60..ca28f401 100755 --- a/katie +++ b/katie @@ -1,8 +1,8 @@ #!/usr/bin/env python -# Installs Debian packaes +# Installs Debian packages # Copyright (C) 2000, 2001 James Troup -# $Id: katie,v 1.61 2001-11-04 20:42:38 troup Exp $ +# $Id: katie,v 1.65 2001-11-19 02:02:53 troup Exp $ # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -70,17 +70,14 @@ orig_tar_location = ""; legacy_source_untouchable = {}; Subst = {}; nmu = None; -katie_version = "$Revision: 1.61 $"; +katie_version = "$Revision: 1.65 $"; ############################################################################### def init(): global Cnf, Options; - apt_pkg.init(); - - Cnf = apt_pkg.newConfiguration(); - apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); + Cnf = utils.get_conf() Arguments = [('a',"automatic","Dinstall::Options::Automatic"), ('h',"help","Dinstall::Options::Help"), @@ -94,7 +91,8 @@ def init(): for i in ["automatic", "help", "ack-new", "manual-reject", "no-action", "no-lock", "no-mail", "override-distribution", "version"]: - Cnf["Dinstall::Options::%s" % (i)] = ""; + if not Cnf.has_key("Dinstall::Options::%s" % (i)): + Cnf["Dinstall::Options::%s" % (i)] = ""; changes_files = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv); Options = Cnf.SubTree("Dinstall::Options") @@ -135,7 +133,7 @@ class nmu_p: self.group_maint = {}; if Cnf.get("Dinstall::GroupOverrideFilename"): filename = Cnf["Dir::OverrideDir"] + Cnf["Dinstall::GroupOverrideFilename"]; - file = utils.open_file(filename, 'r'); + file = utils.open_file(filename); for line in file.readlines(): line = string.strip(utils.re_comments.sub('', line)); if line != "": @@ -301,7 +299,7 @@ def check_changes(filename): reject_message = reject_message + "Rejected: `%s' from Closes field isn't a number.\n" % (i) # Ensure there _is_ a target distribution - if changes["distribution"].keys() == []: + if not changes["distribution"].keys(): reject_message = reject_message + "Rejected: huh? Distribution field is empty in changes file.\n"; # Map frozen to unstable if frozen doesn't exist @@ -395,7 +393,7 @@ def check_files(): # Extract package information using dpkg-deb try: - control = apt_pkg.ParseSection(apt_inst.debExtractControl(utils.open_file(file,"r"))) + control = apt_pkg.ParseSection(apt_inst.debExtractControl(utils.open_file(file))); except: reject_message = reject_message + "Rejected: %s: debExtractControl() raised %s.\n" % (file, sys.exc_type); # Can't continue, none of the checks on control would work. @@ -670,7 +668,7 @@ def check_dsc (): if len(ql) > 1: for i in ql: old_file = i[0] + i[1]; - actual_md5 = apt_pkg.md5sum(utils.open_file(old_file,"r")); + actual_md5 = apt_pkg.md5sum(utils.open_file(old_file)); actual_size = os.stat(old_file)[stat.ST_SIZE]; if actual_md5 == dsc_files[dsc_file]["md5sum"] and actual_size == int(dsc_files[dsc_file]["size"]): x = i; @@ -678,7 +676,7 @@ def check_dsc (): legacy_source_untouchable[i[3]] = ""; old_file = x[0] + x[1]; - actual_md5 = apt_pkg.md5sum(utils.open_file(old_file,"r")); + actual_md5 = apt_pkg.md5sum(utils.open_file(old_file)); actual_size = os.stat(old_file)[stat.ST_SIZE]; found = old_file; suite_type = x[2]; @@ -750,7 +748,7 @@ def check_md5sums (): for file in files.keys(): try: - file_handle = utils.open_file(file,"r"); + file_handle = utils.open_file(file); except utils.cant_open_exc: pass; else: @@ -821,21 +819,23 @@ def update_subst (changes_filename): ##################################################################################################################### def action (changes_filename): - byhand = confirm = suites = summary = new = ""; + byhand = summary = new = ""; # changes["distribution"] may not exist in corner cases # (e.g. unreadable changes files) if not changes.has_key("distribution") or not isinstance(changes["distribution"], DictType): changes["distribution"] = {}; + confirm = [] + suites = [] for suite in changes["distribution"].keys(): if Cnf.has_key("Suite::%s::Confirm"): - confirm = confirm + suite + ", " - suites = suites + suite + ", " - confirm = confirm[:-2] - suites = suites[:-2] + confirm.append(suite) + suites.append(suite) - for file in files.keys(): + file_keys = files.keys(); + file_keys.sort(); + for file in file_keys: if files[file].has_key("byhand"): byhand = 1 summary = summary + file + " byhand\n" @@ -845,7 +845,7 @@ def action (changes_filename): if files[file].has_key("othercomponents"): summary = summary + "WARNING: Already present in %s distribution.\n" % (files[file]["othercomponents"]) if files[file]["type"] == "deb": - summary = summary + apt_pkg.ParseSection(apt_inst.debExtractControl(utils.open_file(file,"r")))["Description"] + '\n'; + summary = summary + apt_pkg.ParseSection(apt_inst.debExtractControl(utils.open_file(file)))["Description"] + '\n'; else: files[file]["pool name"] = utils.poolify (changes["source"], files[file]["component"]) destination = Cnf["Dir::PoolRoot"] + files[file]["pool name"] + file @@ -879,7 +879,7 @@ def action (changes_filename): if Options["Automatic"]: answer = 'R'; elif new: - print "NEW to %s\n%s%s" % (suites, reject_message, summary),; + print "NEW to %s\n%s%s" % (string.join(suites, ", "), reject_message, summary),; prompt = "[S]kip, New ack, Manual reject, Quit ?"; if Options["Automatic"] and Options["Ack-New"]: answer = 'N'; @@ -887,7 +887,7 @@ def action (changes_filename): print "BYHAND\n" + reject_message + summary,; prompt = "[I]nstall, Manual reject, Skip, Quit ?"; elif confirm: - print "CONFIRM to %s\n%s%s" % (confirm, reject_message, summary), + print "CONFIRM to %s\n%s%s" % (string.join(confirm, ", "), reject_message, summary), prompt = "[I]nstall, Manual reject, Skip, Quit ?"; else: print "INSTALL\n" + reject_message + summary,; @@ -1082,7 +1082,7 @@ def stable_install (changes_filename, summary, short_summary): version = dsc["version"] # NB: not files[file]["version"], that has no epoch q = projectB.query("SELECT id FROM source WHERE source = '%s' AND version = '%s'" % (package, version)) ql = q.getresult() - if ql == []: + if not ql: utils.fubar("[INTERNAL ERROR] couldn't find '%s' (%s) in source table." % (package, version)); source_id = ql[0][0]; suite_id = db_access.get_suite_id('proposed-updates'); @@ -1099,7 +1099,7 @@ def stable_install (changes_filename, summary, short_summary): architecture = files[file]["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() - if ql == []: + if not ql: utils.fubar("[INTERNAL ERROR] couldn't find '%s' (%s for %s architecture) in binaries table." % (package, version, architecture)); binary_id = ql[0][0]; suite_id = db_access.get_suite_id('proposed-updates'); @@ -1131,7 +1131,7 @@ def stable_install (changes_filename, summary, short_summary): chop_changes = re_fdnic.sub("\n", changes["changes"]); new_changelog.write(chop_changes + '\n\n'); if os.access(changelog_filename, os.R_OK) != 0: - changelog = utils.open_file(changelog_filename, 'r'); + changelog = utils.open_file(changelog_filename); new_changelog.write(changelog.read()); new_changelog.close(); if os.access(changelog_filename, os.R_OK) != 0: @@ -1181,7 +1181,7 @@ def reject (changes_filename, manual_reject_mail_filename): version = dsc["version"]; # NB: not files[file]["version"], that has no epoch q = projectB.query("SELECT id FROM source WHERE source = '%s' AND version = '%s'" % (package, version)); ql = q.getresult(); - if ql == []: + if not ql: utils.fubar("[INTERNAL ERROR] 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)); @@ -1191,7 +1191,7 @@ def reject (changes_filename, manual_reject_mail_filename): architecture = files[file]["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(); - if ql == []: + if not ql: utils.fubar("[INTERNAL ERROR] couldn't find '%s' (%s for %s architecture) in binaries table." % (package, version, architecture)); binary_id = ql[0][0]; projectB.query("DELETE FROM bin_associations WHERE suite = '%s' AND bin = '%s'" % (suite_id, binary_id)); @@ -1422,7 +1422,7 @@ def main(): # Read in the list of already-acknowledged NEW packages if not os.path.exists(Cnf["Dinstall::NewAckList"]): utils.touch_file(Cnf["Dinstall::NewAckList"]); - new_ack_list = utils.open_file(Cnf["Dinstall::NewAckList"],'r'); + new_ack_list = utils.open_file(Cnf["Dinstall::NewAckList"]); new_ack_old = {}; for line in new_ack_list.readlines(): new_ack_old[line[:-1]] = 1;