#!/usr/bin/env python
-# Installs Debian packaes
+# Installs Debian packages
# Copyright (C) 2000, 2001 James Troup <james@nocrew.org>
-# $Id: katie,v 1.61 2001-11-04 20:42:38 troup Exp $
+# $Id: katie,v 1.62 2001-11-04 22:41:31 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
legacy_source_untouchable = {};
Subst = {};
nmu = None;
-katie_version = "$Revision: 1.61 $";
+katie_version = "$Revision: 1.62 $";
###############################################################################
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 != "":
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
# 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.
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;
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];
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:
#####################################################################################################################
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():
if files[file].has_key("byhand"):
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
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';
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,;
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');
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');
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:
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));
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));
# 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;
# Populate the DB
# Copyright (C) 2000, 2001 James Troup <james@nocrew.org>
-# $Id: neve,v 1.5 2001-09-14 17:15:39 troup Exp $
+# $Id: neve,v 1.6 2001-11-04 22:41:31 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
projectB.query("DELETE FROM suite")
for suite in Cnf.SubTree("Suite").List():
SubSec = Cnf.SubTree("Suite::%s" %(suite))
- projectB.query("INSERT INTO suite (suite_name, version, origin, description) VALUES ('%s', '%s', '%s', '%s')"
- % (string.lower(suite), SubSec["Version"], SubSec["Origin"], SubSec["Description"]))
+ projectB.query("INSERT INTO suite (suite_name) VALUES ('%s')" % string.lower(suite));
+ for i in ("Version", "Origin", "Description"):
+ if SubSec.has_key(i):
+ projectB.query("UPDATE suite SET %s = '%s' WHERE suite_name = '%s'" % (string.lower(i), SubSec[i], string.lower(suite)))
for architecture in Cnf.SubTree("Suite::%s::Architectures" % (suite)).List():
architecture_id = db_access.get_architecture_id (architecture);
projectB.query("INSERT INTO suite_architectures (suite, architecture) VALUES (currval('suite_id_seq'), %d)" % (architecture_id));
if suite == 'stable':
testing_id = db_access.get_suite_id("testing");
try:
- file = utils.open_file (filename, "r")
+ file = utils.open_file (filename);
except utils.cant_open_exc:
print "WARNING: can't open '%s'" % (filename);
return;
if suite == "stable":
testing_id = db_access.get_suite_id("testing");
try:
- file = utils.open_file (filename, "r")
+ file = utils.open_file (filename);
except utils.cant_open_exc:
print "WARNING: can't open '%s'" % (filename);
return;
print "Re-Creating DB..."
(result, output) = commands.getstatusoutput("psql -f init_pool.sql")
if (result != 0):
- sys.exit(2)
+ utils.fubar("psql invocation failed!\n", result);
print output
projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]), None, None, 'postgres')