提交 30413cf0 编写于 作者: J James Troup

Globally remove trailing semi-colon damage.

上级 a1692ffe
此差异已折叠。
......@@ -47,14 +47,14 @@
################################################################################
import pg, sys, os;
import utils, db_access, logging;
import apt_pkg;
import pg, sys, os
import utils, db_access, logging
import apt_pkg
################################################################################
Options = None;
projectB = None;
Options = None
projectB = None
Logger = None
sections = {}
priorities = {}
......@@ -79,58 +79,58 @@ def gen_blacklist(dir):
blacklist[entry] = 1
def process(osuite, affected_suites, originosuite, component, type):
global Logger, Options, projectB, sections, priorities;
global Logger, Options, projectB, sections, priorities
osuite_id = db_access.get_suite_id(osuite);
osuite_id = db_access.get_suite_id(osuite)
if osuite_id == -1:
utils.fubar("Suite '%s' not recognised." % (osuite));
utils.fubar("Suite '%s' not recognised." % (osuite))
originosuite_id = None
if originosuite:
originosuite_id = db_access.get_suite_id(originosuite);
originosuite_id = db_access.get_suite_id(originosuite)
if originosuite_id == -1:
utils.fubar("Suite '%s' not recognised." % (originosuite));
utils.fubar("Suite '%s' not recognised." % (originosuite))
component_id = db_access.get_component_id(component);
component_id = db_access.get_component_id(component)
if component_id == -1:
utils.fubar("Component '%s' not recognised." % (component));
utils.fubar("Component '%s' not recognised." % (component))
type_id = db_access.get_override_type_id(type);
type_id = db_access.get_override_type_id(type)
if type_id == -1:
utils.fubar("Type '%s' not recognised. (Valid types are deb, udeb and dsc)" % (type));
dsc_type_id = db_access.get_override_type_id("dsc");
utils.fubar("Type '%s' not recognised. (Valid types are deb, udeb and dsc)" % (type))
dsc_type_id = db_access.get_override_type_id("dsc")
deb_type_id = db_access.get_override_type_id("deb")
source_priority_id = db_access.get_priority_id("source")
if type == "deb" or type == "udeb":
packages = {};
packages = {}
q = projectB.query("""
SELECT b.package FROM binaries b, bin_associations ba, files f,
location l, component c
WHERE b.type = '%s' AND b.id = ba.bin AND f.id = b.file AND l.id = f.location
AND c.id = l.component AND ba.suite IN (%s) AND c.id = %s
""" % (type, ",".join(map(str,affected_suites)), component_id));
""" % (type, ",".join(map(str,affected_suites)), component_id))
for i in q.getresult():
packages[i[0]] = 0;
packages[i[0]] = 0
src_packages = {};
src_packages = {}
q = projectB.query("""
SELECT s.source FROM source s, src_associations sa, files f, location l,
component c
WHERE s.id = sa.source AND f.id = s.file AND l.id = f.location
AND c.id = l.component AND sa.suite IN (%s) AND c.id = %s
""" % (",".join(map(str,affected_suites)), component_id));
""" % (",".join(map(str,affected_suites)), component_id))
for i in q.getresult():
src_packages[i[0]] = 0;
src_packages[i[0]] = 0
# -----------
# Drop unused overrides
q = projectB.query("SELECT package, priority, section, maintainer FROM override WHERE suite = %s AND component = %s AND type = %s" % (osuite_id, component_id, type_id));
projectB.query("BEGIN WORK");
q = projectB.query("SELECT package, priority, section, maintainer FROM override WHERE suite = %s AND component = %s AND type = %s" % (osuite_id, component_id, type_id))
projectB.query("BEGIN WORK")
if type == "dsc":
for i in q.getresult():
package = i[0];
package = i[0]
if src_packages.has_key(package):
src_packages[package] = 1
else:
......@@ -142,12 +142,12 @@ SELECT s.source FROM source s, src_associations sa, files f, location l,
if not Options["No-Action"]:
projectB.query("""DELETE FROM override WHERE package =
'%s' AND suite = %s AND component = %s AND type =
%s""" % (package, osuite_id, component_id, type_id));
%s""" % (package, osuite_id, component_id, type_id))
# create source overrides based on binary overrides, as source
# overrides not always get created
q = projectB.query(""" SELECT package, priority, section,
maintainer FROM override WHERE suite = %s AND component = %s
""" % (osuite_id, component_id));
""" % (osuite_id, component_id))
for i in q.getresult():
package = i[0]
if not src_packages.has_key(package) or src_packages[package]:
......@@ -161,7 +161,7 @@ SELECT s.source FROM source s, src_associations sa, files f, location l,
component, priority, section, type, maintainer) VALUES
('%s', %s, %s, %s, %s, %s, '%s')""" % (package,
osuite_id, component_id, source_priority_id, i[2],
dsc_type_id, i[3]));
dsc_type_id, i[3]))
# Check whether originosuite has an override for us we can
# copy
if originosuite:
......@@ -172,7 +172,7 @@ SELECT s.source FROM source s, src_associations sa, files f, location l,
target.suite=%s AND origin.component = target.component AND origin.type =
target.type) WHERE origin.suite = %s AND origin.component = %s
AND origin.type = %s""" %
(osuite_id, originosuite_id, component_id, type_id));
(osuite_id, originosuite_id, component_id, type_id))
for i in q.getresult():
package = i[0]
if not src_packages.has_key(package) or src_packages[package]:
......@@ -184,7 +184,7 @@ SELECT s.source FROM source s, src_associations sa, files f, location l,
maintainer='%s' WHERE package='%s' AND
suite=%s AND component=%s AND type=%s""" %
(i[2], i[3], package, osuite_id, component_id,
dsc_type_id));
dsc_type_id))
continue
# we can copy
src_packages[package] = 1
......@@ -195,7 +195,7 @@ SELECT s.source FROM source s, src_associations sa, files f, location l,
component, priority, section, type, maintainer) VALUES
('%s', %s, %s, %s, %s, %s, '%s')""" % (package,
osuite_id, component_id, source_priority_id, i[2],
dsc_type_id, i[3]));
dsc_type_id, i[3]))
for package, hasoverride in src_packages.items():
if not hasoverride:
......@@ -203,7 +203,7 @@ SELECT s.source FROM source s, src_associations sa, files f, location l,
else: # binary override
for i in q.getresult():
package = i[0];
package = i[0]
if packages.has_key(package):
packages[package] = 1
else:
......@@ -215,7 +215,7 @@ SELECT s.source FROM source s, src_associations sa, files f, location l,
if not Options["No-Action"]:
projectB.query("""DELETE FROM override WHERE package =
'%s' AND suite = %s AND component = %s AND type =
%s""" % (package, osuite_id, component_id, type_id));
%s""" % (package, osuite_id, component_id, type_id))
# Check whether originosuite has an override for us we can
# copy
......@@ -227,7 +227,7 @@ SELECT s.source FROM source s, src_associations sa, files f, location l,
target.suite=%s AND origin.component = target.component AND
origin.type = target.type) WHERE origin.suite = %s AND
origin.component = %s AND origin.type = %s""" % (osuite_id,
originosuite_id, component_id, type_id));
originosuite_id, component_id, type_id))
for i in q.getresult():
package = i[0]
if not packages.has_key(package) or packages[package]:
......@@ -240,7 +240,7 @@ SELECT s.source FROM source s, src_associations sa, files f, location l,
maintainer='%s' WHERE package='%s' AND
suite=%s AND component=%s AND type=%s""" %
(i[1], i[2], i[3], package, osuite_id,
component_id, type_id));
component_id, type_id))
continue
# we can copy
packages[package] = 1
......@@ -249,36 +249,36 @@ SELECT s.source FROM source s, src_associations sa, files f, location l,
if not Options["No-Action"]:
projectB.query("""INSERT INTO override (package, suite,
component, priority, section, type, maintainer) VALUES
('%s', %s, %s, %s, %s, %s, '%s')""" % (package, osuite_id, component_id, i[1], i[2], type_id, i[3]));
('%s', %s, %s, %s, %s, %s, '%s')""" % (package, osuite_id, component_id, i[1], i[2], type_id, i[3]))
for package, hasoverride in packages.items():
if not hasoverride:
utils.warn("%s has no override!" % package)
projectB.query("COMMIT WORK");
projectB.query("COMMIT WORK")
sys.stdout.flush()
################################################################################
def main ():
global Logger, Options, projectB, sections, priorities;
global Logger, Options, projectB, sections, priorities
Cnf = utils.get_conf()
Arguments = [('h',"help","Cindy::Options::Help"),
('n',"no-action", "Cindy::Options::No-Action")];
('n',"no-action", "Cindy::Options::No-Action")]
for i in [ "help", "no-action" ]:
if not Cnf.has_key("Cindy::Options::%s" % (i)):
Cnf["Cindy::Options::%s" % (i)] = "";
apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv);
Cnf["Cindy::Options::%s" % (i)] = ""
apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv)
Options = Cnf.SubTree("Cindy::Options")
if Options["Help"]:
usage();
usage()
projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]));
db_access.init(Cnf, projectB);
projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
db_access.init(Cnf, projectB)
# init sections, priorities:
q = projectB.query("SELECT id, section FROM section")
......@@ -304,13 +304,13 @@ def main ():
originosuite = None
originremark = ""
try:
originosuite = Cnf["Cindy::OverrideSuites::%s::OriginSuite" % osuite];
originosuite = Cnf["Cindy::OverrideSuites::%s::OriginSuite" % osuite]
originosuite = originosuite.lower()
originremark = " taking missing from %s" % originosuite
except KeyError:
pass
print "Processing %s%s..." % (osuite, originremark);
print "Processing %s%s..." % (osuite, originremark)
# Get a list of all suites that use the override file of 'osuite'
ocodename = Cnf["Suite::%s::codename" % osuite]
suites = []
......@@ -338,9 +338,9 @@ def main ():
otypes = ["dsc"] + otypes
for otype in otypes:
print "Processing %s [%s - %s] using %s..." \
% (osuite, component, otype, suites);
% (osuite, component, otype, suites)
sys.stdout.flush()
process(osuite, suiteids, originosuite, component, otype);
process(osuite, suiteids, originosuite, component, otype)
Logger.close()
......
......@@ -29,18 +29,18 @@
################################################################################
import pg, sys, os;
import pg, sys, os
import utils, db_access
import apt_pkg, apt_inst;
import apt_pkg, apt_inst
################################################################################
Cnf = None;
projectB = None;
Options = None;
stable = {};
stable_virtual = {};
architectures = None;
Cnf = None
projectB = None
Options = None
stable = {}
stable_virtual = {}
architectures = None
################################################################################
......@@ -59,105 +59,105 @@ Need either changes files, deb files or an admin.txt file with a '.joey' suffix.
def d_test (dict, key, positive, negative):
if not dict:
return negative;
return negative
if dict.has_key(key):
return positive;
return positive
else:
return negative;
return negative
################################################################################
def check_dep (depends, dep_type, check_archs, filename, files):
pkg_unsat = 0;
pkg_unsat = 0
for arch in check_archs:
for parsed_dep in apt_pkg.ParseDepends(depends):
unsat = [];
unsat = []
for atom in parsed_dep:
(dep, version, constraint) = atom;
(dep, version, constraint) = atom
# As a real package?
if stable.has_key(dep):
if stable[dep].has_key(arch):
if apt_pkg.CheckDep(stable[dep][arch], constraint, version):
if Options["debug"]:
print "Found %s as a real package." % (utils.pp_deps(parsed_dep));
unsat = 0;
break;
print "Found %s as a real package." % (utils.pp_deps(parsed_dep))
unsat = 0
break
# As a virtual?
if stable_virtual.has_key(dep):
if stable_virtual[dep].has_key(arch):
if not constraint and not version:
if Options["debug"]:
print "Found %s as a virtual package." % (utils.pp_deps(parsed_dep));
unsat = 0;
break;
print "Found %s as a virtual package." % (utils.pp_deps(parsed_dep))
unsat = 0
break
# As part of the same .changes?
epochless_version = utils.re_no_epoch.sub('', version)
dep_filename = "%s_%s_%s.deb" % (dep, epochless_version, arch);
dep_filename = "%s_%s_%s.deb" % (dep, epochless_version, arch)
if files.has_key(dep_filename):
if Options["debug"]:
print "Found %s in the same upload." % (utils.pp_deps(parsed_dep));
unsat = 0;
break;
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: " % (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]);
error += "%s:%s:%s" % (dep, arch, stable[dep][arch])
else:
error += "%s:-:-" % (dep);
error += "%s:-:-" % (dep)
else:
error += "-:-:-";
error += ", Virtual: ";
error += "-:-:-"
error += ", Virtual: "
if stable_virtual.has_key(dep):
if stable_virtual[dep].has_key(arch):
error += "%s:%s" % (dep, arch);
error += "%s:%s" % (dep, arch)
else:
error += "%s:-";
error += "%s:-"
else:
error += "-:-";
error += ", Upload: ";
error += "-:-"
error += ", Upload: "
if files.has_key(dep_filename):
error += "yes";
error += "yes"
else:
error += "no";
error += "]";
unsat.append(error);
error += "no"
error += "]"
unsat.append(error)
if unsat:
sys.stderr.write("MWAAP! %s: '%s' %s can not be satisifed:\n" % (filename, utils.pp_deps(parsed_dep), dep_type));
sys.stderr.write("MWAAP! %s: '%s' %s can not be satisifed:\n" % (filename, utils.pp_deps(parsed_dep), dep_type))
for error in unsat:
sys.stderr.write(" %s\n" % (error));
pkg_unsat = 1;
sys.stderr.write(" %s\n" % (error))
pkg_unsat = 1
return pkg_unsat;
return pkg_unsat
def check_package(filename, files):
try:
control = apt_pkg.ParseSection(apt_inst.debExtractControl(utils.open_file(filename)));
control = apt_pkg.ParseSection(apt_inst.debExtractControl(utils.open_file(filename)))
except:
utils.warn("%s: debExtractControl() raised %s." % (filename, sys.exc_type));
return 1;
Depends = control.Find("Depends");
Pre_Depends = control.Find("Pre-Depends");
#Recommends = control.Find("Recommends");
pkg_arch = control.Find("Architecture");
base_file = os.path.basename(filename);
utils.warn("%s: debExtractControl() raised %s." % (filename, sys.exc_type))
return 1
Depends = control.Find("Depends")
Pre_Depends = control.Find("Pre-Depends")
#Recommends = control.Find("Recommends")
pkg_arch = control.Find("Architecture")
base_file = os.path.basename(filename)
if pkg_arch == "all":
check_archs = architectures;
check_archs = architectures
else:
check_archs = [pkg_arch];
check_archs = [pkg_arch]
pkg_unsat = 0;
pkg_unsat = 0
if Pre_Depends:
pkg_unsat += check_dep(Pre_Depends, "pre-dependency", check_archs, base_file, files);
pkg_unsat += check_dep(Pre_Depends, "pre-dependency", check_archs, base_file, files)
if Depends:
pkg_unsat += check_dep(Depends, "dependency", check_archs, base_file, files);
pkg_unsat += check_dep(Depends, "dependency", check_archs, base_file, files)
#if Recommends:
#pkg_unsat += check_dep(Recommends, "recommendation", check_archs, base_file, files);
#pkg_unsat += check_dep(Recommends, "recommendation", check_archs, base_file, files)
return pkg_unsat;
return pkg_unsat
################################################################################
......@@ -165,142 +165,142 @@ def pass_fail (filename, result):
if not Options["quiet"]:
print "%s:" % (os.path.basename(filename)),
if result:
print "FAIL";
print "FAIL"
else:
print "ok";
print "ok"
################################################################################
def check_changes (filename):
try:
changes = utils.parse_changes(filename);
files = utils.build_file_list(changes);
changes = utils.parse_changes(filename)
files = utils.build_file_list(changes)
except:
utils.warn("Error parsing changes file '%s'" % (filename));
return;
utils.warn("Error parsing changes file '%s'" % (filename))
return
result = 0;
result = 0
# Move to the pool directory
cwd = os.getcwd();
file = files.keys()[0];
pool_dir = Cnf["Dir::Pool"] + '/' + utils.poolify(changes["source"], files[file]["component"]);
os.chdir(pool_dir);
cwd = os.getcwd()
file = files.keys()[0]
pool_dir = Cnf["Dir::Pool"] + '/' + utils.poolify(changes["source"], files[file]["component"])
os.chdir(pool_dir)
changes_result = 0;
changes_result = 0
for file in files.keys():
if file.endswith(".deb"):
result = check_package(file, files);
result = check_package(file, files)
if Options["verbose"]:
pass_fail(file, result);
changes_result += result;
pass_fail(file, result)
changes_result += result
pass_fail (filename, changes_result);
pass_fail (filename, changes_result)
# Move back
os.chdir(cwd);
os.chdir(cwd)
################################################################################
def check_deb (filename):
result = check_package(filename, {});
pass_fail(filename, result);
result = check_package(filename, {})
pass_fail(filename, result)
################################################################################
def check_joey (filename):
file = utils.open_file(filename);
file = utils.open_file(filename)
cwd = os.getcwd();
os.chdir("%s/dists/proposed-updates" % (Cnf["Dir::Root"]));
cwd = os.getcwd()
os.chdir("%s/dists/proposed-updates" % (Cnf["Dir::Root"]))
for line in file.readlines():
line = line.rstrip();
line = line.rstrip()
if line.find('install') != -1:
split_line = line.split();
split_line = line.split()
if len(split_line) != 2:
utils.fubar("Parse error (not exactly 2 elements): %s" % (line));
install_type = split_line[0];
utils.fubar("Parse error (not exactly 2 elements): %s" % (line))
install_type = split_line[0]
if install_type not in [ "install", "install-u", "sync-install" ]:
utils.fubar("Unknown install type ('%s') from: %s" % (install_type, line));
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();
print "Processing %s..." % (changes_filename)
check_changes(changes_filename)
file.close()
os.chdir(cwd);
os.chdir(cwd)
################################################################################
def parse_packages():
global stable, stable_virtual, architectures;
global stable, stable_virtual, architectures
# Parse the Packages files (since it's a sub-second operation on auric)
suite = "stable";
stable = {};
components = Cnf.ValueList("Suite::%s::Components" % (suite));
architectures = filter(utils.real_arch, Cnf.ValueList("Suite::%s::Architectures" % (suite)));
suite = "stable"
stable = {}
components = Cnf.ValueList("Suite::%s::Components" % (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 = utils.open_file(filename, 'r');
Packages = apt_pkg.ParseTagFile(packages);
filename = "%s/dists/%s/%s/binary-%s/Packages" % (Cnf["Dir::Root"], suite, component, architecture)
packages = utils.open_file(filename, 'r')
Packages = apt_pkg.ParseTagFile(packages)
while Packages.Step():
package = Packages.Section.Find('Package');
version = Packages.Section.Find('Version');
provides = Packages.Section.Find('Provides');
package = Packages.Section.Find('Package')
version = Packages.Section.Find('Version')
provides = Packages.Section.Find('Provides')
if not stable.has_key(package):
stable[package] = {};
stable[package][architecture] = version;
stable[package] = {}
stable[package][architecture] = version
if provides:
for virtual_pkg in provides.split(","):
virtual_pkg = virtual_pkg.strip();
virtual_pkg = virtual_pkg.strip()
if not stable_virtual.has_key(virtual_pkg):
stable_virtual[virtual_pkg] = {};
stable_virtual[virtual_pkg][architecture] = "NA";
stable_virtual[virtual_pkg] = {}
stable_virtual[virtual_pkg][architecture] = "NA"
packages.close()
################################################################################
def main ():
global Cnf, projectB, Options;
global Cnf, projectB, Options
Cnf = utils.get_conf()
Arguments = [('d', "debug", "Jeri::Options::Debug"),
('q',"quiet","Jeri::Options::Quiet"),
('v',"verbose","Jeri::Options::Verbose"),
('h',"help","Jeri::Options::Help")];
('h',"help","Jeri::Options::Help")]
for i in [ "debug", "quiet", "verbose", "help" ]:
if not Cnf.has_key("Jeri::Options::%s" % (i)):
Cnf["Jeri::Options::%s" % (i)] = "";
Cnf["Jeri::Options::%s" % (i)] = ""
arguments = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv);
arguments = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv)
Options = Cnf.SubTree("Jeri::Options")
if Options["Help"]:
usage(0);
usage(0)
if not arguments:
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"]));
db_access.init(Cnf, projectB);
projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
db_access.init(Cnf, projectB)
print "Parsing packages files...",
parse_packages();
print "done.";
parse_packages()
print "done."
for file in arguments:
if file.endswith(".changes"):
check_changes(file);
check_changes(file)
elif file.endswith(".deb"):
check_deb(file);
check_deb(file)
elif file.endswith(".joey"):
check_joey(file);
check_joey(file)
else:
utils.fubar("Unrecognised file type: '%s'." % (file));
utils.fubar("Unrecognised file type: '%s'." % (file))
#######################################################################################
......
......@@ -20,18 +20,18 @@
################################################################################
import os, pg, re, sys;
import utils, db_access;
import apt_pkg;
import os, pg, re, sys
import utils, db_access
import apt_pkg
################################################################################
Cnf = None;
projectB = None;
Options = None;
pu = {};
Cnf = None
projectB = None
Options = None
pu = {}
re_isdeb = re.compile (r"^(.+)_(.+?)_(.+?).u?deb$");
re_isdeb = re.compile (r"^(.+)_(.+?)_(.+?).u?deb$")
################################################################################
......@@ -49,91 +49,91 @@ Need either changes files or an admin.txt file with a '.joey' suffix."""
def check_changes (filename):
try:
changes = utils.parse_changes(filename);
files = utils.build_file_list(changes);
changes = utils.parse_changes(filename)
files = utils.build_file_list(changes)
except:
utils.warn("Couldn't read changes file '%s'." % (filename));
return;
num_files = len(files.keys());
utils.warn("Couldn't read changes file '%s'." % (filename))
return
num_files = len(files.keys())
for file in files.keys():
if utils.re_isadeb.match(file):
m = re_isdeb.match(file);
pkg = m.group(1);
version = m.group(2);
arch = m.group(3);
m = re_isdeb.match(file)
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" % (file, pkg, version, arch)
else:
m = utils.re_issource.match(file)
if m:
pkg = m.group(1);
version = m.group(2);
type = m.group(3);
pkg = m.group(1)
version = m.group(2)
type = m.group(3)
if type != "dsc":
del files[file];
num_files -= 1;
continue;
arch = "source";
del files[file]
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" % (file, pkg, version, arch)
else:
utils.fubar("unknown type, fix me");
utils.fubar("unknown type, fix me")
if not pu.has_key(pkg):
# FIXME
utils.warn("%s doesn't seem to exist in p-u?? (from %s [%s])" % (pkg, file, filename));
continue;
utils.warn("%s doesn't seem to exist in p-u?? (from %s [%s])" % (pkg, file, filename))
continue
if not pu[pkg].has_key(arch):
# FIXME
utils.warn("%s doesn't seem to exist for %s in p-u?? (from %s [%s])" % (pkg, arch, file, filename));
continue;
pu_version = utils.re_no_epoch.sub('', pu[pkg][arch]);
utils.warn("%s doesn't seem to exist for %s in p-u?? (from %s [%s])" % (pkg, arch, file, filename))
continue
pu_version = utils.re_no_epoch.sub('', pu[pkg][arch])
if pu_version == version:
if Options["verbose"]:
print "%s: ok" % (file);
print "%s: ok" % (file)
else:
if Options["verbose"]:
print "%s: superseded, removing. [%s]" % (file, pu_version);
del files[file];
print "%s: superseded, removing. [%s]" % (file, pu_version)
del files[file]
new_num_files = len(files.keys());
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/";
utils.move(filename, dest);
print "%s: no files left, superseded by %s" % (filename, pu_version)
dest = Cnf["Dir::Morgue"] + "/misc/"
utils.move(filename, dest)
elif new_num_files < num_files:
print "%s: lost files, MWAAP." % (filename);
print "%s: lost files, MWAAP." % (filename)
else:
if Options["verbose"]:
print "%s: ok" % (filename);
print "%s: ok" % (filename)
################################################################################
def check_joey (filename):
file = utils.open_file(filename);
file = utils.open_file(filename)
cwd = os.getcwd();
os.chdir("%s/dists/proposed-updates" % (Cnf["Dir::Root"]));
cwd = os.getcwd()
os.chdir("%s/dists/proposed-updates" % (Cnf["Dir::Root"]))
for line in file.readlines():
line = line.rstrip();
line = line.rstrip()
if line.find('install') != -1:
split_line = line.split();
split_line = line.split()
if len(split_line) != 2:
utils.fubar("Parse error (not exactly 2 elements): %s" % (line));
install_type = split_line[0];
utils.fubar("Parse error (not exactly 2 elements): %s" % (line))
install_type = split_line[0]
if install_type not in [ "install", "install-u", "sync-install" ]:
utils.fubar("Unknown install type ('%s') from: %s" % (install_type, line));
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);
print "Processing %s..." % (changes_filename)
check_changes(changes_filename)
os.chdir(cwd);
os.chdir(cwd)
################################################################################
def init_pu ():
global pu;
global pu
q = projectB.query("""
SELECT b.package, b.version, a.arch_string
......@@ -144,49 +144,49 @@ UNION SELECT s.source, s.version, 'source'
FROM src_associations sa, source s, suite su
WHERE s.id = sa.source AND sa.suite = su.id
AND su.suite_name = 'proposed-updates'
ORDER BY package, version, arch_string;
""");
ql = q.getresult();
ORDER BY package, version, arch_string
""")
ql = q.getresult()
for i in ql:
pkg = i[0];
version = i[1];
arch = i[2];
pkg = i[0]
version = i[1]
arch = i[2]
if not pu.has_key(pkg):
pu[pkg] = {};
pu[pkg][arch] = version;
pu[pkg] = {}
pu[pkg][arch] = version
def main ():
global Cnf, projectB, Options;
global Cnf, projectB, Options
Cnf = utils.get_conf()
Arguments = [('d', "debug", "Halle::Options::Debug"),
('v',"verbose","Halle::Options::Verbose"),
('h',"help","Halle::Options::Help")];
('h',"help","Halle::Options::Help")]
for i in [ "debug", "verbose", "help" ]:
if not Cnf.has_key("Halle::Options::%s" % (i)):
Cnf["Halle::Options::%s" % (i)] = "";
Cnf["Halle::Options::%s" % (i)] = ""
arguments = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv);
arguments = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv)
Options = Cnf.SubTree("Halle::Options")
if Options["Help"]:
usage(0);
usage(0)
if not arguments:
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"]));
db_access.init(Cnf, projectB);
projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
db_access.init(Cnf, projectB)
init_pu();
init_pu()
for file in arguments:
if file.endswith(".changes"):
check_changes(file);
check_changes(file)
elif file.endswith(".joey"):
check_joey(file);
check_joey(file)
else:
utils.fubar("Unrecognised file type: '%s'." % (file));
utils.fubar("Unrecognised file type: '%s'." % (file))
#######################################################################################
......
......@@ -34,16 +34,16 @@
################################################################################
import os, stat, sys, time;
import utils;
import apt_pkg;
import os, stat, sys, time
import utils
import apt_pkg
################################################################################
Cnf = None;
Options = None;
del_dir = None;
delete_date = None;
Cnf = None
Options = None
del_dir = None
delete_date = None
################################################################################
......@@ -62,35 +62,35 @@ Clean out incoming directories.
################################################################################
def init ():
global delete_date, del_dir;
global delete_date, del_dir
delete_date = int(time.time())-(int(Options["Days"])*84600);
delete_date = int(time.time())-(int(Options["Days"])*84600)
# Ensure a directory exists to remove files to
if not Options["No-Action"]:
date = time.strftime("%Y-%m-%d");
del_dir = Cnf["Dir::Morgue"] + '/' + Cnf["Shania::MorgueSubDir"] + '/' + date;
date = time.strftime("%Y-%m-%d")
del_dir = Cnf["Dir::Morgue"] + '/' + Cnf["Shania::MorgueSubDir"] + '/' + date
if not os.path.exists(del_dir):
os.makedirs(del_dir, 02775);
os.makedirs(del_dir, 02775)
if not os.path.isdir(del_dir):
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"];
incoming = Options["Incoming"]
if incoming == "":
incoming = Cnf["Dir::Queue::Unchecked"];
os.chdir(incoming);
incoming = Cnf["Dir::Queue::Unchecked"]
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);
dest_filename = del_dir + '/' + os.path.basename(file)
# If the destination file exists; try to find another filename to use
if os.path.exists(dest_filename):
dest_filename = utils.find_next_free(dest_filename, 10);
utils.move(file, dest_filename, 0660);
dest_filename = utils.find_next_free(dest_filename, 10)
utils.move(file, dest_filename, 0660)
else:
utils.warn("skipping '%s', permission denied." % (os.path.basename(file)));
utils.warn("skipping '%s', permission denied." % (os.path.basename(file)))
# Removes any old files.
# [Used for Incoming/REJECT]
......@@ -100,111 +100,111 @@ def flush_old ():
if os.path.isfile(file):
if os.stat(file)[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(file))
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(file), del_dir)
remove(file)
else:
if Options["Verbose"]:
print "Skipping, too new, '%s'." % (os.path.basename(file));
print "Skipping, too new, '%s'." % (os.path.basename(file))
# Removes any files which are old orphans (not associated with a valid .changes file).
# [Used for Incoming]
#
def flush_orphans ():
all_files = {};
changes_files = [];
all_files = {}
changes_files = []
# Build up the list of all files in the directory
for i in os.listdir('.'):
if os.path.isfile(i):
all_files[i] = 1;
all_files[i] = 1
if i.endswith(".changes"):
changes_files.append(i);
changes_files.append(i)
# Proces all .changes and .dsc files.
for changes_filename in changes_files:
try:
changes = utils.parse_changes(changes_filename);
files = utils.build_file_list(changes);
changes = utils.parse_changes(changes_filename)
files = utils.build_file_list(changes)
except:
utils.warn("error processing '%s'; skipping it. [Got %s]" % (changes_filename, sys.exc_type));
continue;
utils.warn("error processing '%s'; skipping it. [Got %s]" % (changes_filename, sys.exc_type))
continue
dsc_files = {};
dsc_files = {}
for file in files.keys():
if file.endswith(".dsc"):
try:
dsc = utils.parse_changes(file);
dsc_files = utils.build_file_list(dsc, is_a_dsc=1);
dsc = utils.parse_changes(file)
dsc_files = utils.build_file_list(dsc, is_a_dsc=1)
except:
utils.warn("error processing '%s'; skipping it. [Got %s]" % (file, sys.exc_type));
continue;
utils.warn("error processing '%s'; skipping it. [Got %s]" % (file, sys.exc_type))
continue
# Ensure all the files we've seen aren't deleted
keys = [];
keys = []
for i in (files.keys(), dsc_files.keys(), [changes_filename]):
keys.extend(i);
keys.extend(i)
for key in keys:
if all_files.has_key(key):
if Options["Verbose"]:
print "Skipping, has parents, '%s'." % (key);
del all_files[key];
print "Skipping, has parents, '%s'." % (key)
del all_files[key]
# 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:
if Options["No-Action"]:
print "I: Would delete '%s'." % (os.path.basename(file));
print "I: Would delete '%s'." % (os.path.basename(file))
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(file), del_dir)
remove(file)
else:
if Options["Verbose"]:
print "Skipping, too new, '%s'." % (os.path.basename(file));
print "Skipping, too new, '%s'." % (os.path.basename(file))
################################################################################
def main ():
global Cnf, Options;
global Cnf, Options
Cnf = utils.get_conf()
for i in ["Help", "Incoming", "No-Action", "Verbose" ]:
if not Cnf.has_key("Shania::Options::%s" % (i)):
Cnf["Shania::Options::%s" % (i)] = "";
Cnf["Shania::Options::%s" % (i)] = ""
if not Cnf.has_key("Shania::Options::Days"):
Cnf["Shania::Options::Days"] = "14";
Cnf["Shania::Options::Days"] = "14"
Arguments = [('h',"help","Shania::Options::Help"),
('d',"days","Shania::Options::Days", "IntLevel"),
('i',"incoming","Shania::Options::Incoming", "HasArg"),
('n',"no-action","Shania::Options::No-Action"),
('v',"verbose","Shania::Options::Verbose")];
('v',"verbose","Shania::Options::Verbose")]
apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv);
apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv)
Options = Cnf.SubTree("Shania::Options")
if Options["Help"]:
usage();
usage()
init();
init()
if Options["Verbose"]:
print "Processing incoming..."
flush_orphans();
flush_orphans()
reject = Cnf["Dir::Queue::Reject"]
if os.path.exists(reject) and os.path.isdir(reject):
if Options["Verbose"]:
print "Processing incoming/REJECT..."
os.chdir(reject);
flush_old();
os.chdir(reject)
flush_old()
#######################################################################################
if __name__ == '__main__':
main();
main()
......@@ -35,9 +35,9 @@ import utils
################################################################################
projectB = None;
Cnf = None;
Options = None;
projectB = None
Cnf = None
Options = None
now_date = None; # mark newly "deleted" things as deleted "now"
delete_date = None; # delete things marked "deleted" earler than this
......@@ -54,7 +54,7 @@ Clean old packages from suites.
################################################################################
def check_binaries():
global delete_date, now_date;
global delete_date, now_date
print "Checking for orphaned binary packages..."
......@@ -63,33 +63,33 @@ def check_binaries():
q = projectB.query("""
SELECT b.file FROM binaries b, files f
WHERE f.last_used IS NULL AND b.file = f.id
AND NOT EXISTS (SELECT 1 FROM bin_associations ba WHERE ba.bin = b.id)""");
ql = q.getresult();
AND NOT EXISTS (SELECT 1 FROM bin_associations ba WHERE ba.bin = b.id)""")
ql = q.getresult()
projectB.query("BEGIN WORK");
projectB.query("BEGIN WORK")
for i in ql:
file_id = i[0];
file_id = i[0]
projectB.query("UPDATE files SET last_used = '%s' WHERE id = %s AND last_used IS NULL" % (now_date, file_id))
projectB.query("COMMIT WORK");
projectB.query("COMMIT WORK")
# Check for any binaries which are marked for eventual deletion
# but are now used again.
q = projectB.query("""
SELECT b.file FROM binaries b, files f
WHERE f.last_used IS NOT NULL AND f.id = b.file
AND EXISTS (SELECT 1 FROM bin_associations ba WHERE ba.bin = b.id)""");
ql = q.getresult();
AND EXISTS (SELECT 1 FROM bin_associations ba WHERE ba.bin = b.id)""")
ql = q.getresult()
projectB.query("BEGIN WORK");
projectB.query("BEGIN WORK")
for i in ql:
file_id = i[0];
projectB.query("UPDATE files SET last_used = NULL WHERE id = %s" % (file_id));
projectB.query("COMMIT WORK");
file_id = i[0]
projectB.query("UPDATE files SET last_used = NULL WHERE id = %s" % (file_id))
projectB.query("COMMIT WORK")
########################################
def check_sources():
global delete_date, now_date;
global delete_date, now_date
print "Checking for orphaned source packages..."
......@@ -99,29 +99,29 @@ def check_sources():
SELECT s.id, s.file FROM source s, files f
WHERE f.last_used IS NULL AND s.file = f.id
AND NOT EXISTS (SELECT 1 FROM src_associations sa WHERE sa.source = s.id)
AND NOT EXISTS (SELECT 1 FROM binaries b WHERE b.source = s.id)""");
AND NOT EXISTS (SELECT 1 FROM binaries b WHERE b.source = s.id)""")
#### XXX: this should ignore cases where the files for the binary b
#### have been marked for deletion (so the delay between bins go
#### byebye and sources go byebye is 0 instead of StayOfExecution)
ql = q.getresult();
ql = q.getresult()
projectB.query("BEGIN WORK");
projectB.query("BEGIN WORK")
for i in ql:
source_id = i[0];
dsc_file_id = i[1];
source_id = i[0]
dsc_file_id = i[1]
# Mark the .dsc file for deletion
projectB.query("UPDATE files SET last_used = '%s' WHERE id = %s AND last_used IS NULL" % (now_date, dsc_file_id))
# Mark all other files references by .dsc too if they're not used by anyone else
x = projectB.query("SELECT f.id FROM files f, dsc_files d WHERE d.source = %s AND d.file = f.id" % (source_id));
x = projectB.query("SELECT f.id FROM files f, dsc_files d WHERE d.source = %s AND d.file = f.id" % (source_id))
for j in x.getresult():
file_id = j[0];
y = projectB.query("SELECT id FROM dsc_files d WHERE d.file = %s" % (file_id));
file_id = j[0]
y = projectB.query("SELECT id FROM dsc_files d WHERE d.file = %s" % (file_id))
if len(y.getresult()) == 1:
projectB.query("UPDATE files SET last_used = '%s' WHERE id = %s AND last_used IS NULL" % (now_date, file_id));
projectB.query("COMMIT WORK");
projectB.query("UPDATE files SET last_used = '%s' WHERE id = %s AND last_used IS NULL" % (now_date, file_id))
projectB.query("COMMIT WORK")
# Check for any sources which are marked for deletion but which
# are now used again.
......@@ -130,44 +130,44 @@ SELECT s.id, s.file FROM source s, files f
SELECT f.id FROM source s, files f, dsc_files df
WHERE f.last_used IS NOT NULL AND s.id = df.source AND df.file = f.id
AND ((EXISTS (SELECT 1 FROM src_associations sa WHERE sa.source = s.id))
OR (EXISTS (SELECT 1 FROM binaries b WHERE b.source = s.id)))""");
OR (EXISTS (SELECT 1 FROM binaries b WHERE b.source = s.id)))""")
#### XXX: this should also handle deleted binaries specially (ie, not
#### reinstate sources because of them
ql = q.getresult();
ql = q.getresult()
# Could be done in SQL; but left this way for hysterical raisins
# [and freedom to innovate don'cha know?]
projectB.query("BEGIN WORK");
projectB.query("BEGIN WORK")
for i in ql:
file_id = i[0];
projectB.query("UPDATE files SET last_used = NULL WHERE id = %s" % (file_id));
projectB.query("COMMIT WORK");
file_id = i[0]
projectB.query("UPDATE files SET last_used = NULL WHERE id = %s" % (file_id))
projectB.query("COMMIT WORK")
########################################
def check_files():
global delete_date, now_date;
global delete_date, now_date
# FIXME: this is evil; nothing should ever be in this state. if
# they are, it's a bug and the files should not be auto-deleted.
return;
return
print "Checking for unused files..."
q = projectB.query("""
SELECT id FROM files f
WHERE NOT EXISTS (SELECT 1 FROM binaries b WHERE b.file = f.id)
AND NOT EXISTS (SELECT 1 FROM dsc_files df WHERE df.file = f.id)""");
AND NOT EXISTS (SELECT 1 FROM dsc_files df WHERE df.file = f.id)""")
projectB.query("BEGIN WORK");
projectB.query("BEGIN WORK")
for i in q.getresult():
file_id = i[0];
projectB.query("UPDATE files SET last_used = '%s' WHERE id = %s" % (now_date, file_id));
projectB.query("COMMIT WORK");
file_id = i[0]
projectB.query("UPDATE files SET last_used = '%s' WHERE id = %s" % (now_date, file_id))
projectB.query("COMMIT WORK")
def clean_binaries():
global delete_date, now_date;
global delete_date, now_date
# We do this here so that the binaries we remove will have their
# source also removed (if possible).
......@@ -176,72 +176,72 @@ def clean_binaries():
# buys anything keeping this separate
print "Cleaning binaries from the DB..."
if not Options["No-Action"]:
before = time.time();
sys.stdout.write("[Deleting from binaries table... ");
sys.stderr.write("DELETE FROM binaries WHERE EXISTS (SELECT 1 FROM files WHERE binaries.file = files.id AND files.last_used <= '%s')\n" % (delete_date));
projectB.query("DELETE FROM binaries WHERE EXISTS (SELECT 1 FROM files WHERE binaries.file = files.id AND files.last_used <= '%s')" % (delete_date));
sys.stdout.write("done. (%d seconds)]\n" % (int(time.time()-before)));
before = time.time()
sys.stdout.write("[Deleting from binaries table... ")
sys.stderr.write("DELETE FROM binaries WHERE EXISTS (SELECT 1 FROM files WHERE binaries.file = files.id AND files.last_used <= '%s')\n" % (delete_date))
projectB.query("DELETE FROM binaries WHERE EXISTS (SELECT 1 FROM files WHERE binaries.file = files.id AND files.last_used <= '%s')" % (delete_date))
sys.stdout.write("done. (%d seconds)]\n" % (int(time.time()-before)))
########################################
def clean():
global delete_date, now_date;
count = 0;
size = 0;
global delete_date, now_date
count = 0
size = 0
print "Cleaning out packages..."
date = time.strftime("%Y-%m-%d");
dest = Cnf["Dir::Morgue"] + '/' + Cnf["Rhona::MorgueSubDir"] + '/' + date;
date = time.strftime("%Y-%m-%d")
dest = Cnf["Dir::Morgue"] + '/' + Cnf["Rhona::MorgueSubDir"] + '/' + date
if not os.path.exists(dest):
os.mkdir(dest);
os.mkdir(dest)
# Delete from source
if not Options["No-Action"]:
before = time.time();
sys.stdout.write("[Deleting from source table... ");
projectB.query("DELETE FROM dsc_files WHERE EXISTS (SELECT 1 FROM source s, files f, dsc_files df WHERE f.last_used <= '%s' AND s.file = f.id AND s.id = df.source AND df.id = dsc_files.id)" % (delete_date));
projectB.query("DELETE FROM source WHERE EXISTS (SELECT 1 FROM files WHERE source.file = files.id AND files.last_used <= '%s')" % (delete_date));
sys.stdout.write("done. (%d seconds)]\n" % (int(time.time()-before)));
before = time.time()
sys.stdout.write("[Deleting from source table... ")
projectB.query("DELETE FROM dsc_files WHERE EXISTS (SELECT 1 FROM source s, files f, dsc_files df WHERE f.last_used <= '%s' AND s.file = f.id AND s.id = df.source AND df.id = dsc_files.id)" % (delete_date))
projectB.query("DELETE FROM source WHERE EXISTS (SELECT 1 FROM files WHERE source.file = files.id AND files.last_used <= '%s')" % (delete_date))
sys.stdout.write("done. (%d seconds)]\n" % (int(time.time()-before)))
# Delete files from the pool
q = projectB.query("SELECT l.path, f.filename FROM location l, files f WHERE f.last_used <= '%s' AND l.id = f.location" % (delete_date));
q = projectB.query("SELECT l.path, f.filename FROM location l, files f WHERE f.last_used <= '%s' AND l.id = f.location" % (delete_date))
for i in q.getresult():
filename = i[0] + i[1];
filename = i[0] + i[1]
if not os.path.exists(filename):
utils.warn("can not find '%s'." % (filename));
continue;
utils.warn("can not find '%s'." % (filename))
continue
if os.path.isfile(filename):
if os.path.islink(filename):
count += 1;
count += 1
if Options["No-Action"]:
print "Removing symlink %s..." % (filename);
print "Removing symlink %s..." % (filename)
else:
os.unlink(filename);
os.unlink(filename)
else:
size += os.stat(filename)[stat.ST_SIZE];
count += 1;
size += os.stat(filename)[stat.ST_SIZE]
count += 1
dest_filename = dest + '/' + os.path.basename(filename);
dest_filename = dest + '/' + os.path.basename(filename)
# If the destination file exists; try to find another filename to use
if os.path.exists(dest_filename):
dest_filename = utils.find_next_free(dest_filename);
dest_filename = utils.find_next_free(dest_filename)
if Options["No-Action"]:
print "Cleaning %s -> %s ..." % (filename, dest_filename);
print "Cleaning %s -> %s ..." % (filename, dest_filename)
else:
utils.move(filename, dest_filename);
utils.move(filename, dest_filename)
else:
utils.fubar("%s is neither symlink nor file?!" % (filename));
utils.fubar("%s is neither symlink nor file?!" % (filename))
# Delete from the 'files' table
if not Options["No-Action"]:
before = time.time();
sys.stdout.write("[Deleting from files table... ");
projectB.query("DELETE FROM files WHERE last_used <= '%s'" % (delete_date));
sys.stdout.write("done. (%d seconds)]\n" % (int(time.time()-before)));
before = time.time()
sys.stdout.write("[Deleting from files table... ")
projectB.query("DELETE FROM files WHERE last_used <= '%s'" % (delete_date))
sys.stdout.write("done. (%d seconds)]\n" % (int(time.time()-before)))
if count > 0:
sys.stderr.write("Cleaned %d files, %s.\n" % (count, utils.size_type(size)));
sys.stderr.write("Cleaned %d files, %s.\n" % (count, utils.size_type(size)))
################################################################################
......@@ -251,20 +251,20 @@ def clean_maintainers():
q = projectB.query("""
SELECT m.id FROM maintainer m
WHERE NOT EXISTS (SELECT 1 FROM binaries b WHERE b.maintainer = m.id)
AND NOT EXISTS (SELECT 1 FROM source s WHERE s.maintainer = m.id)""");
ql = q.getresult();
AND NOT EXISTS (SELECT 1 FROM source s WHERE s.maintainer = m.id)""")
ql = q.getresult()
count = 0;
projectB.query("BEGIN WORK");
count = 0
projectB.query("BEGIN WORK")
for i in ql:
maintainer_id = i[0];
maintainer_id = i[0]
if not Options["No-Action"]:
projectB.query("DELETE FROM maintainer WHERE id = %s" % (maintainer_id));
count += 1;
projectB.query("COMMIT WORK");
projectB.query("DELETE FROM maintainer WHERE id = %s" % (maintainer_id))
count += 1
projectB.query("COMMIT WORK")
if count > 0:
sys.stderr.write("Cleared out %d maintainer entries.\n" % (count));
sys.stderr.write("Cleared out %d maintainer entries.\n" % (count))
################################################################################
......@@ -274,81 +274,81 @@ def clean_fingerprints():
q = projectB.query("""
SELECT f.id FROM fingerprint f
WHERE NOT EXISTS (SELECT 1 FROM binaries b WHERE b.sig_fpr = f.id)
AND NOT EXISTS (SELECT 1 FROM source s WHERE s.sig_fpr = f.id)""");
ql = q.getresult();
AND NOT EXISTS (SELECT 1 FROM source s WHERE s.sig_fpr = f.id)""")
ql = q.getresult()
count = 0;
projectB.query("BEGIN WORK");
count = 0
projectB.query("BEGIN WORK")
for i in ql:
fingerprint_id = i[0];
fingerprint_id = i[0]
if not Options["No-Action"]:
projectB.query("DELETE FROM fingerprint WHERE id = %s" % (fingerprint_id));
count += 1;
projectB.query("COMMIT WORK");
projectB.query("DELETE FROM fingerprint WHERE id = %s" % (fingerprint_id))
count += 1
projectB.query("COMMIT WORK")
if count > 0:
sys.stderr.write("Cleared out %d fingerprint entries.\n" % (count));
sys.stderr.write("Cleared out %d fingerprint entries.\n" % (count))
################################################################################
def clean_queue_build():
global now_date;
global now_date
if not Cnf.ValueList("Dinstall::QueueBuildSuites") or Options["No-Action"]:
return;
return
print "Cleaning out queue build symlinks..."
our_delete_date = time.strftime("%Y-%m-%d %H:%M", time.localtime(time.time()-int(Cnf["Rhona::QueueBuildStayOfExecution"])));
count = 0;
our_delete_date = time.strftime("%Y-%m-%d %H:%M", time.localtime(time.time()-int(Cnf["Rhona::QueueBuildStayOfExecution"])))
count = 0
q = projectB.query("SELECT filename FROM queue_build WHERE last_used <= '%s'" % (our_delete_date));
q = projectB.query("SELECT filename FROM queue_build WHERE last_used <= '%s'" % (our_delete_date))
for i in q.getresult():
filename = i[0];
filename = i[0]
if not os.path.exists(filename):
utils.warn("%s (from queue_build) doesn't exist." % (filename));
continue;
utils.warn("%s (from queue_build) doesn't exist." % (filename))
continue
if not Cnf.FindB("Dinstall::SecurityQueueBuild") and not os.path.islink(filename):
utils.fubar("%s (from queue_build) should be a symlink but isn't." % (filename));
os.unlink(filename);
count += 1;
projectB.query("DELETE FROM queue_build WHERE last_used <= '%s'" % (our_delete_date));
utils.fubar("%s (from queue_build) should be a symlink but isn't." % (filename))
os.unlink(filename)
count += 1
projectB.query("DELETE FROM queue_build WHERE last_used <= '%s'" % (our_delete_date))
if count:
sys.stderr.write("Cleaned %d queue_build files.\n" % (count));
sys.stderr.write("Cleaned %d queue_build files.\n" % (count))
################################################################################
def main():
global Cnf, Options, projectB, delete_date, now_date;
global Cnf, Options, projectB, delete_date, now_date
Cnf = utils.get_conf()
for i in ["Help", "No-Action" ]:
if not Cnf.has_key("Rhona::Options::%s" % (i)):
Cnf["Rhona::Options::%s" % (i)] = "";
Cnf["Rhona::Options::%s" % (i)] = ""
Arguments = [('h',"help","Rhona::Options::Help"),
('n',"no-action","Rhona::Options::No-Action")];
('n',"no-action","Rhona::Options::No-Action")]
apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv);
apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv)
Options = Cnf.SubTree("Rhona::Options")
if Options["Help"]:
usage();
usage()
projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]));
projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
now_date = time.strftime("%Y-%m-%d %H:%M");
delete_date = time.strftime("%Y-%m-%d %H:%M", time.localtime(time.time()-int(Cnf["Rhona::StayOfExecution"])));
now_date = time.strftime("%Y-%m-%d %H:%M")
delete_date = time.strftime("%Y-%m-%d %H:%M", time.localtime(time.time()-int(Cnf["Rhona::StayOfExecution"])))
check_binaries();
clean_binaries();
check_sources();
check_files();
clean();
clean_maintainers();
clean_fingerprints();
clean_queue_build();
check_binaries()
clean_binaries()
check_sources()
check_files()
clean()
clean_maintainers()
clean_fingerprints()
clean_queue_build()
################################################################################
......
......@@ -21,14 +21,14 @@
################################################################################
import pg, sys;
import utils, db_access;
import apt_pkg;
import pg, sys
import utils, db_access
import apt_pkg
################################################################################
Cnf = None;
projectB = None;
Cnf = None
projectB = None
################################################################################
......@@ -42,42 +42,42 @@ Looks for fixable descrepancies between stable and unstable.
################################################################################
def main ():
global Cnf, projectB;
global Cnf, projectB
Cnf = utils.get_conf();
Arguments = [('h',"help","Andrea::Options::Help")];
Cnf = utils.get_conf()
Arguments = [('h',"help","Andrea::Options::Help")]
for i in [ "help" ]:
if not Cnf.has_key("Andrea::Options::%s" % (i)):
Cnf["Andrea::Options::%s" % (i)] = "";
Cnf["Andrea::Options::%s" % (i)] = ""
apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv);
apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv)
Options = Cnf.SubTree("Andrea::Options")
if Options["Help"]:
usage();
usage()
projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]));
db_access.init(Cnf, projectB);
projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
db_access.init(Cnf, projectB)
src_suite = "stable";
dst_suite = "unstable";
src_suite = "stable"
dst_suite = "unstable"
src_suite_id = db_access.get_suite_id(src_suite);
dst_suite_id = db_access.get_suite_id(dst_suite);
arch_all_id = db_access.get_architecture_id("all");
dsc_type_id = db_access.get_override_type_id("dsc");
src_suite_id = db_access.get_suite_id(src_suite)
dst_suite_id = db_access.get_suite_id(dst_suite)
arch_all_id = db_access.get_architecture_id("all")
dsc_type_id = db_access.get_override_type_id("dsc")
for arch in Cnf.ValueList("Suite::%s::Architectures" % (src_suite)):
if arch == "source":
continue;
continue
# Arch: all doesn't work; consider packages which go from
# arch: all to arch: any, e.g. debconf... needs more checks
# and thought later.
if arch == "all":
continue;
arch_id = db_access.get_architecture_id(arch);
continue
arch_id = db_access.get_architecture_id(arch)
q = projectB.query("""
SELECT b_src.package, b_src.version, a.arch_string
FROM binaries b_src, bin_associations ba, override o, architecture a
......@@ -91,9 +91,9 @@ SELECT b_src.package, b_src.version, a.arch_string
(SELECT 1 FROM bin_associations ba3, binaries b2
WHERE ba3.bin = b2.id AND ba3.suite = %s AND b2.package = b_dst.package))
ORDER BY b_src.package;"""
% (src_suite_id, arch_id, dst_suite_id, dsc_type_id, arch_id, arch_all_id, dst_suite_id, dst_suite_id));
% (src_suite_id, arch_id, dst_suite_id, dsc_type_id, arch_id, arch_all_id, dst_suite_id, dst_suite_id))
for i in q.getresult():
print " ".join(i);
print " ".join(i)
#######################################################################################
......
......@@ -50,15 +50,15 @@
################################################################################
import pg, sys, time;
import utils, db_access, logging;
import apt_pkg;
import pg, sys, time
import utils, db_access, logging
import apt_pkg
################################################################################
Cnf = None;
projectB = None;
Logger = None;
Cnf = None
projectB = None
Logger = None
################################################################################
......@@ -85,162 +85,162 @@ def usage (exit_code=0):
################################################################################
def process_file (file, suite, component, type, action):
suite_id = db_access.get_suite_id(suite);
suite_id = db_access.get_suite_id(suite)
if suite_id == -1:
utils.fubar("Suite '%s' not recognised." % (suite));
utils.fubar("Suite '%s' not recognised." % (suite))
component_id = db_access.get_component_id(component);
component_id = db_access.get_component_id(component)
if component_id == -1:
utils.fubar("Component '%s' not recognised." % (component));
utils.fubar("Component '%s' not recognised." % (component))
type_id = db_access.get_override_type_id(type);
type_id = db_access.get_override_type_id(type)
if type_id == -1:
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
# minutes while 6000 select+inserts are run needlessly isn't cool.
original = {};
new = {};
c_skipped = 0;
c_added = 0;
c_updated = 0;
c_removed = 0;
c_error = 0;
original = {}
new = {}
c_skipped = 0
c_added = 0
c_updated = 0
c_removed = 0
c_error = 0
q = projectB.query("SELECT o.package, o.priority, o.section, o.maintainer, p.priority, s.section 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"
% (suite_id, component_id, type_id));
% (suite_id, component_id, type_id))
for i in q.getresult():
original[i[0]] = i[1:];
original[i[0]] = i[1:]
start_time = time.time();
projectB.query("BEGIN WORK");
start_time = time.time()
projectB.query("BEGIN WORK")
for line in file.readlines():
line = utils.re_comments.sub('', line).strip();
line = utils.re_comments.sub('', line).strip()
if line == "":
continue;
continue
maintainer_override = None;
maintainer_override = None
if type == "dsc":
split_line = line.split(None, 2);
split_line = line.split(None, 2)
if len(split_line) == 2:
(package, section) = split_line;
(package, section) = split_line
elif len(split_line) == 3:
(package, section, maintainer_override) = split_line;
(package, section, maintainer_override) = split_line
else:
utils.warn("'%s' does not break into 'package section [maintainer-override]'." % (line));
c_error += 1;
continue;
priority = "source";
utils.warn("'%s' does not break into 'package section [maintainer-override]'." % (line))
c_error += 1
continue
priority = "source"
else: # binary or udeb
split_line = line.split(None, 3);
split_line = line.split(None, 3)
if len(split_line) == 3:
(package, priority, section) = split_line;
(package, priority, section) = split_line
elif len(split_line) == 4:
(package, priority, section, maintainer_override) = split_line;
(package, priority, section, maintainer_override) = split_line
else:
utils.warn("'%s' does not break into 'package priority section [maintainer-override]'." % (line));
c_error += 1;
continue;
utils.warn("'%s' does not break into 'package priority section [maintainer-override]'." % (line))
c_error += 1
continue
section_id = db_access.get_section_id(section);
section_id = db_access.get_section_id(section)
if section_id == -1:
utils.warn("'%s' is not a valid section. ['%s' in suite %s, component %s]." % (section, package, suite, component));
c_error += 1;
continue;
priority_id = db_access.get_priority_id(priority);
utils.warn("'%s' is not a valid section. ['%s' in suite %s, component %s]." % (section, package, suite, component))
c_error += 1
continue
priority_id = db_access.get_priority_id(priority)
if priority_id == -1:
utils.warn("'%s' is not a valid priority. ['%s' in suite %s, component %s]." % (priority, package, suite, component));
c_error += 1;
continue;
utils.warn("'%s' is not a valid priority. ['%s' in suite %s, component %s]." % (priority, package, suite, component))
c_error += 1
continue
if new.has_key(package):
utils.warn("Can't insert duplicate entry for '%s'; ignoring all but the first. [suite %s, component %s]" % (package, suite, component));
c_error += 1;
continue;
new[package] = "";
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] = ""
if original.has_key(package):
(old_priority_id, old_section_id, old_maintainer_override, old_priority, old_section) = original[package];
(old_priority_id, old_section_id, old_maintainer_override, old_priority, old_section) = original[package]
if action == "add" or old_priority_id == priority_id and \
old_section_id == section_id and \
((old_maintainer_override == maintainer_override) or \
(old_maintainer_override == "" and maintainer_override == None)):
# If it's unchanged or we're in 'add only' mode, ignore it
c_skipped += 1;
continue;
c_skipped += 1
continue
else:
# If it's changed, delete the old one so we can
# reinsert it with the new information
c_updated += 1;
c_updated += 1
projectB.query("DELETE FROM override WHERE suite = %s AND component = %s AND package = '%s' AND type = %s"
% (suite_id, component_id, package, type_id));
% (suite_id, component_id, package, type_id))
# Log changes
if old_priority_id != priority_id:
Logger.log(["changed priority",package,old_priority,priority]);
Logger.log(["changed priority",package,old_priority,priority])
if old_section_id != section_id:
Logger.log(["changed section",package,old_section,section]);
Logger.log(["changed section",package,old_section,section])
if old_maintainer_override != maintainer_override:
Logger.log(["changed maintainer override",package,old_maintainer_override,maintainer_override]);
update_p = 1;
Logger.log(["changed maintainer override",package,old_maintainer_override,maintainer_override])
update_p = 1
else:
c_added += 1;
update_p = 0;
c_added += 1
update_p = 0
if maintainer_override:
projectB.query("INSERT INTO override (suite, component, type, package, priority, section, maintainer) VALUES (%s, %s, %s, '%s', %s, %s, '%s')"
% (suite_id, component_id, type_id, package, priority_id, section_id, maintainer_override));
% (suite_id, component_id, type_id, package, priority_id, section_id, maintainer_override))
else:
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, package, priority_id, section_id));
% (suite_id, component_id, type_id, package, priority_id, section_id))
if not update_p:
Logger.log(["new override",suite,component,type,package,priority,section,maintainer_override]);
Logger.log(["new override",suite,component,type,package,priority,section,maintainer_override])
if not action == "add":
# Delete any packages which were removed
for package in original.keys():
if not new.has_key(package):
projectB.query("DELETE FROM override WHERE suite = %s AND component = %s AND package = '%s' AND type = %s"
% (suite_id, component_id, package, type_id));
c_removed += 1;
Logger.log(["removed override",suite,component,type,package]);
% (suite_id, component_id, package, type_id))
c_removed += 1
Logger.log(["removed override",suite,component,type,package])
projectB.query("COMMIT WORK");
projectB.query("COMMIT WORK")
if not Cnf["Natalie::Options::Quiet"]:
print "Done in %d seconds. [Updated = %d, Added = %d, Removed = %d, Skipped = %d, Errors = %d]" % (int(time.time()-start_time), c_updated, c_added, c_removed, c_skipped, c_error);
Logger.log(["set complete",c_updated, c_added, c_removed, c_skipped, c_error]);
print "Done in %d seconds. [Updated = %d, Added = %d, Removed = %d, Skipped = %d, Errors = %d]" % (int(time.time()-start_time), c_updated, c_added, c_removed, c_skipped, c_error)
Logger.log(["set complete",c_updated, c_added, c_removed, c_skipped, c_error])
################################################################################
def list(suite, component, type):
suite_id = db_access.get_suite_id(suite);
suite_id = db_access.get_suite_id(suite)
if suite_id == -1:
utils.fubar("Suite '%s' not recognised." % (suite));
utils.fubar("Suite '%s' not recognised." % (suite))
component_id = db_access.get_component_id(component);
component_id = db_access.get_component_id(component)
if component_id == -1:
utils.fubar("Component '%s' not recognised." % (component));
utils.fubar("Component '%s' not recognised." % (component))
type_id = db_access.get_override_type_id(type);
type_id = db_access.get_override_type_id(type)
if type_id == -1:
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));
q = projectB.query("SELECT o.package, s.section, o.maintainer FROM override o, section s WHERE o.suite = %s AND o.component = %s AND o.type = %s AND o.section = s.id ORDER BY s.section, o.package" % (suite_id, component_id, type_id))
for i in q.getresult():
print utils.result_join(i);
print 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));
q = projectB.query("SELECT o.package, p.priority, s.section, o.maintainer, p.level FROM override o, priority p, section s WHERE o.suite = %s AND o.component = %s AND o.type = %s AND o.priority = p.id AND o.section = s.id ORDER BY s.section, p.level, o.package" % (suite_id, component_id, type_id))
for i in q.getresult():
print utils.result_join(i[:-1]);
print utils.result_join(i[:-1])
################################################################################
def main ():
global Cnf, projectB, Logger;
global Cnf, projectB, Logger
Cnf = utils.get_conf();
Cnf = utils.get_conf()
Arguments = [('a', "add", "Natalie::Options::Add"),
('c', "component", "Natalie::Options::Component", "HasArg"),
('h', "help", "Natalie::Options::Help"),
......@@ -248,46 +248,46 @@ def main ():
('q', "quiet", "Natalie::Options::Quiet"),
('s', "suite", "Natalie::Options::Suite", "HasArg"),
('S', "set", "Natalie::Options::Set"),
('t', "type", "Natalie::Options::Type", "HasArg")];
('t', "type", "Natalie::Options::Type", "HasArg")]
# Default arguments
for i in [ "add", "help", "list", "quiet", "set" ]:
if not Cnf.has_key("Natalie::Options::%s" % (i)):
Cnf["Natalie::Options::%s" % (i)] = "";
Cnf["Natalie::Options::%s" % (i)] = ""
if not Cnf.has_key("Natalie::Options::Component"):
Cnf["Natalie::Options::Component"] = "main";
Cnf["Natalie::Options::Component"] = "main"
if not Cnf.has_key("Natalie::Options::Suite"):
Cnf["Natalie::Options::Suite"] = "unstable";
Cnf["Natalie::Options::Suite"] = "unstable"
if not Cnf.has_key("Natalie::Options::Type"):
Cnf["Natalie::Options::Type"] = "deb";
Cnf["Natalie::Options::Type"] = "deb"
file_list = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv);
file_list = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv)
if Cnf["Natalie::Options::Help"]:
usage();
usage()
projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]));
db_access.init(Cnf, projectB);
projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
db_access.init(Cnf, projectB)
action = None;
action = None
for i in [ "add", "list", "set" ]:
if Cnf["Natalie::Options::%s" % (i)]:
if action:
utils.fubar("Can not perform more than one action at once.");
action = i;
utils.fubar("Can not perform more than one action at once.")
action = i
(suite, component, type) = (Cnf["Natalie::Options::Suite"], Cnf["Natalie::Options::Component"], Cnf["Natalie::Options::Type"])
if action == "list":
list(suite, component, type);
list(suite, component, type)
else:
Logger = logging.Logger(Cnf, "natalie");
Logger = logging.Logger(Cnf, "natalie")
if file_list:
for file in file_list:
process_file(utils.open_file(file), suite, component, type, action);
process_file(utils.open_file(file), suite, component, type, action)
else:
process_file(sys.stdin, suite, component, type, action);
Logger.close();
process_file(sys.stdin, suite, component, type, action)
Logger.close()
#######################################################################################
......
......@@ -42,15 +42,15 @@
#######################################################################################
import pg, sys;
import apt_pkg;
import utils, db_access, logging;
import pg, sys
import apt_pkg
import utils, db_access, logging
#######################################################################################
Cnf = None;
projectB = None;
Logger = None;
Cnf = None
projectB = None
Logger = None
################################################################################
......@@ -74,163 +74,163 @@ def get_id (package, version, architecture):
else:
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();
ql = q.getresult()
if not ql:
utils.warn("Couldn't find '%s~%s~%s'." % (package, version, architecture));
return None;
utils.warn("Couldn't find '%s~%s~%s'." % (package, version, architecture))
return None
if len(ql) > 1:
utils.warn("Found more than one match for '%s~%s~%s'." % (package, version, architecture));
return None;
id = ql[0][0];
return id;
utils.warn("Found more than one match for '%s~%s~%s'." % (package, version, architecture))
return None
id = ql[0][0]
return id
#######################################################################################
def set_suite (file, suite_id):
lines = file.readlines();
lines = file.readlines()
projectB.query("BEGIN WORK");
projectB.query("BEGIN WORK")
# Build up a dictionary of what is currently in the suite
current = {};
q = projectB.query("SELECT b.package, b.version, a.arch_string, ba.id 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();
current = {}
q = projectB.query("SELECT b.package, b.version, a.arch_string, ba.id 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()
for i in ql:
key = " ".join(i[:3]);
current[key] = i[3];
q = projectB.query("SELECT s.source, s.version, sa.id FROM source s, src_associations sa WHERE sa.suite = %s AND sa.source = s.id" % (suite_id));
ql = q.getresult();
key = " ".join(i[:3])
current[key] = i[3]
q = projectB.query("SELECT s.source, s.version, sa.id FROM source s, src_associations sa WHERE sa.suite = %s AND sa.source = s.id" % (suite_id))
ql = q.getresult()
for i in ql:
key = " ".join(i[:2]) + " source";
current[key] = i[2];
key = " ".join(i[:2]) + " source"
current[key] = i[2]
# Build up a dictionary of what should be in the suite
desired = {};
desired = {}
for line in lines:
split_line = line.strip().split();
split_line = line.strip().split()
if len(split_line) != 3:
utils.warn("'%s' does not break into 'package version architecture'." % (line[:-1]));
continue;
key = " ".join(split_line);
desired[key] = "";
utils.warn("'%s' does not break into 'package version architecture'." % (line[:-1]))
continue
key = " ".join(split_line)
desired[key] = ""
# Check to see which packages need removed and remove them
for key in current.keys():
if not desired.has_key(key):
(package, version, architecture) = key.split();
id = current[key];
(package, version, architecture) = key.split()
id = 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" % (id))
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" % (id))
Logger.log(["removed",key,id])
# 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);
(package, version, architecture) = key.split()
id = get_id (package, version, architecture)
if not id:
continue;
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, id))
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, id))
Logger.log(["added",key,id])
projectB.query("COMMIT WORK");
projectB.query("COMMIT WORK")
#######################################################################################
def process_file (file, suite, action):
suite_id = db_access.get_suite_id(suite);
suite_id = db_access.get_suite_id(suite)
if action == "set":
set_suite (file, suite_id);
return;
set_suite (file, suite_id)
return
lines = file.readlines();
lines = file.readlines()
projectB.query("BEGIN WORK");
projectB.query("BEGIN WORK")
for line in lines:
split_line = line.strip().split();
split_line = line.strip().split()
if len(split_line) != 3:
utils.warn("'%s' does not break into 'package version architecture'." % (line[:-1]));
continue;
utils.warn("'%s' does not break into 'package version architecture'." % (line[:-1]))
continue
(package, version, architecture) = split_line;
(package, version, architecture) = split_line
id = get_id(package, version, architecture);
id = get_id(package, version, architecture)
if not id:
continue;
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));
ql = q.getresult();
q = projectB.query("SELECT id FROM src_associations WHERE suite = %s and source = %s" % (suite_id, id))
ql = q.getresult()
if not ql:
assoication_id = None;
assoication_id = None
else:
assoication_id = ql[0][0];
assoication_id = ql[0][0]
# Take action
if action == "add":
if assoication_id:
utils.warn("'%s~%s~%s' already exists in suite %s." % (package, version, architecture, suite));
continue;
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, id))
elif action == "remove":
if assoication_id == None:
utils.warn("'%s~%s~%s' doesn't exist in suite %s." % (package, version, architecture, suite));
continue;
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));
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));
ql = q.getresult();
q = projectB.query("SELECT id FROM bin_associations WHERE suite = %s and bin = %s" % (suite_id, id))
ql = q.getresult()
if not ql:
assoication_id = None;
assoication_id = None
else:
assoication_id = ql[0][0];
assoication_id = ql[0][0]
# Take action
if action == "add":
if assoication_id:
utils.warn("'%s~%s~%s' already exists in suite %s." % (package, version, architecture, suite));
continue;
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, id))
elif action == "remove":
if assoication_id == None:
utils.warn("'%s~%s~%s' doesn't exist in suite %s." % (package, version, architecture, suite));
continue;
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));
q = projectB.query("DELETE FROM bin_associations WHERE id = %s" % (assoication_id))
projectB.query("COMMIT WORK");
projectB.query("COMMIT WORK")
#######################################################################################
def get_list (suite):
suite_id = db_access.get_suite_id(suite);
suite_id = db_access.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();
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()
for i in ql:
print " ".join(i);
print " ".join(i)
# List source
q = projectB.query("SELECT s.source, s.version FROM source s, src_associations sa WHERE sa.suite = %s AND sa.source = s.id" % (suite_id));
ql = q.getresult();
q = projectB.query("SELECT s.source, s.version FROM source s, src_associations sa WHERE sa.suite = %s AND sa.source = s.id" % (suite_id))
ql = q.getresult()
for i in ql:
print " ".join(i) + " source";
print " ".join(i) + " source"
#######################################################################################
def main ():
global Cnf, projectB, Logger;
global Cnf, projectB, Logger
Cnf = utils.get_conf()
......@@ -238,52 +238,52 @@ def main ():
('h',"help","Heidi::Options::Help"),
('l',"list","Heidi::Options::List","HasArg"),
('r',"remove", "Heidi::Options::Remove", "HasArg"),
('s',"set", "Heidi::Options::Set", "HasArg")];
('s',"set", "Heidi::Options::Set", "HasArg")]
for i in ["add", "help", "list", "remove", "set", "version" ]:
if not Cnf.has_key("Heidi::Options::%s" % (i)):
Cnf["Heidi::Options::%s" % (i)] = "";
Cnf["Heidi::Options::%s" % (i)] = ""
file_list = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv);
file_list = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv)
Options = Cnf.SubTree("Heidi::Options")
if Options["Help"]:
usage();
usage()
projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"],int(Cnf["DB::Port"]));
projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"],int(Cnf["DB::Port"]))
db_access.init(Cnf, projectB);
db_access.init(Cnf, projectB)
action = None;
action = None
for i in ("add", "list", "remove", "set"):
if Cnf["Heidi::Options::%s" % (i)] != "":
suite = Cnf["Heidi::Options::%s" % (i)];
suite = Cnf["Heidi::Options::%s" % (i)]
if db_access.get_suite_id(suite) == -1:
utils.fubar("Unknown suite '%s'." %(suite));
utils.fubar("Unknown suite '%s'." %(suite))
else:
if action:
utils.fubar("Can only perform one action at a time.");
action = i;
utils.fubar("Can only perform one action at a time.")
action = i
# Need an action...
if action == None:
utils.fubar("No action specified.");
utils.fubar("No action specified.")
# Safety/Sanity check
if action == "set" and suite != "testing":
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);
get_list(suite)
else:
Logger = logging.Logger(Cnf, "heidi");
Logger = logging.Logger(Cnf, "heidi")
if file_list:
for file in file_list:
process_file(utils.open_file(file), suite, action);
process_file(utils.open_file(file), suite, action)
else:
process_file(sys.stdin, suite, action);
Logger.close();
process_file(sys.stdin, suite, action)
Logger.close()
#######################################################################################
......
此差异已折叠。
......@@ -27,9 +27,9 @@
################################################################################
import sys;
import katie, utils;
import apt_pkg;
import sys
import katie, utils
import apt_pkg
################################################################################
......@@ -45,88 +45,88 @@ Dumps the info in .katie FILE(s).
def main():
Cnf = utils.get_conf()
Arguments = [('h',"help","Ashley::Options::Help")];
Arguments = [('h',"help","Ashley::Options::Help")]
for i in [ "help" ]:
if not Cnf.has_key("Ashley::Options::%s" % (i)):
Cnf["Ashley::Options::%s" % (i)] = "";
Cnf["Ashley::Options::%s" % (i)] = ""
apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv);
apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv)
Options = Cnf.SubTree("Ashley::Options")
if Options["Help"]:
usage();
usage()
k = katie.Katie(Cnf);
k = katie.Katie(Cnf)
for arg in sys.argv[1:]:
arg = utils.validate_changes_file_arg(arg,require_changes=-1);
k.pkg.changes_file = arg;
print "%s:" % (arg);
k.init_vars();
k.update_vars();
changes = k.pkg.changes;
print " Changes:";
arg = utils.validate_changes_file_arg(arg,require_changes=-1)
k.pkg.changes_file = arg
print "%s:" % (arg)
k.init_vars()
k.update_vars()
changes = k.pkg.changes
print " Changes:"
# Mandatory changes fields
for i in [ "source", "version", "maintainer", "urgency", "changedby822",
"changedby2047", "changedbyname", "maintainer822",
"maintainer2047", "maintainername", "maintaineremail",
"fingerprint", "changes" ]:
print " %s: %s" % (i.capitalize(), changes[i]);
del changes[i];
print " %s: %s" % (i.capitalize(), changes[i])
del changes[i]
# Mandatory changes lists
for i in [ "distribution", "architecture", "closes" ]:
print " %s: %s" % (i.capitalize(), " ".join(changes[i].keys()));
del changes[i];
print " %s: %s" % (i.capitalize(), " ".join(changes[i].keys()))
del changes[i]
# Optional changes fields
for i in [ "changed-by", "filecontents", "format" ]:
if changes.has_key(i):
print " %s: %s" % (i.capitalize(), changes[i]);
del changes[i];
print;
print " %s: %s" % (i.capitalize(), changes[i])
del changes[i]
print
if changes:
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:";
dsc = k.pkg.dsc
print " Dsc:"
for i in [ "source", "version", "maintainer", "fingerprint", "uploaders",
"bts changelog" ]:
if dsc.has_key(i):
print " %s: %s" % (i.capitalize(), dsc[i]);
del dsc[i];
print;
print " %s: %s" % (i.capitalize(), dsc[i])
del dsc[i]
print
if dsc:
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;
files = k.pkg.files
print " Files:"
for file in files.keys():
print " %s:" % (file);
print " %s:" % (file)
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];
print " %s: %s" % (i.capitalize(), files[file][i])
del files[file][i]
if files[file]:
utils.warn("files[%s] still has following unrecognised keys: %s" % (file, files[file].keys()));
print;
utils.warn("files[%s] still has following unrecognised keys: %s" % (file, files[file].keys()))
print
dsc_files = k.pkg.dsc_files;
print " Dsc Files:";
dsc_files = k.pkg.dsc_files
print " Dsc Files:"
for file in dsc_files.keys():
print " %s:" % (file);
print " %s:" % (file)
# 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[file][i])
del dsc_files[file][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];
print " %s: %s" % (i.capitalize(), dsc_files[file][i])
del dsc_files[file][i]
if dsc_files[file]:
utils.warn("dsc_files[%s] still has following unrecognised keys: %s" % (file, dsc_files[file].keys()));
utils.warn("dsc_files[%s] still has following unrecognised keys: %s" % (file, dsc_files[file].keys()))
################################################################################
......
......@@ -40,8 +40,8 @@ import pg, db_access
################################################################################
re_package = re.compile(r"^(.+?)_.*");
re_doc_directory = re.compile(r".*/doc/([^/]*).*");
re_package = re.compile(r"^(.+?)_.*")
re_doc_directory = re.compile(r".*/doc/([^/]*).*")
re_contrib = re.compile('^contrib/')
re_nonfree = re.compile('^non\-free/')
......@@ -61,28 +61,28 @@ re_spacestrip = re.compile('(\s)')
# Colour definitions
# Main
main_colour = "\033[36m";
main_colour = "\033[36m"
# Contrib
contrib_colour = "\033[33m";
contrib_colour = "\033[33m"
# Non-Free
nonfree_colour = "\033[31m";
nonfree_colour = "\033[31m"
# Arch
arch_colour = "\033[32m";
arch_colour = "\033[32m"
# End
end_colour = "\033[0m";
end_colour = "\033[0m"
# Bold
bold_colour = "\033[1m";
bold_colour = "\033[1m"
# Bad maintainer
maintainer_colour = arch_colour;
maintainer_colour = arch_colour
################################################################################
Cnf = None;
projectB = None;
Cnf = None
projectB = None
Cnf = utils.get_conf()
projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
db_access.init(Cnf, projectB);
db_access.init(Cnf, projectB)
################################################################################
......@@ -107,67 +107,67 @@ def get_depends_parts(depend) :
return d_parts
def get_or_list(depend) :
or_list = depend.split("|");
or_list = depend.split("|")
return or_list
def get_comma_list(depend) :
dep_list = depend.split(",");
dep_list = depend.split(",")
return dep_list
def split_depends (d_str) :
# creates a list of lists of dictionaries of depends (package,version relation)
d_str = re_spacestrip.sub('',d_str);
depends_tree = [];
d_str = re_spacestrip.sub('',d_str)
depends_tree = []
# first split depends string up amongs comma delimiter
dep_list = get_comma_list(d_str);
d = 0;
dep_list = get_comma_list(d_str)
d = 0
while d < len(dep_list):
# put depends into their own list
depends_tree.append([dep_list[d]]);
d += 1;
d = 0;
depends_tree.append([dep_list[d]])
d += 1
d = 0
while d < len(depends_tree):
k = 0;
k = 0
# split up Or'd depends into a multi-item list
depends_tree[d] = get_or_list(depends_tree[d][0]);
depends_tree[d] = get_or_list(depends_tree[d][0])
while k < len(depends_tree[d]):
# split depends into {package, version relation}
depends_tree[d][k] = get_depends_parts(depends_tree[d][k]);
k += 1;
d += 1;
return depends_tree;
depends_tree[d][k] = get_depends_parts(depends_tree[d][k])
k += 1
d += 1
return depends_tree
def read_control (filename):
recommends = [];
depends = [];
section = '';
maintainer = '';
arch = '';
recommends = []
depends = []
section = ''
maintainer = ''
arch = ''
deb_file = utils.open_file(filename);
deb_file = utils.open_file(filename)
try:
extracts = apt_inst.debExtractControl(deb_file);
control = apt_pkg.ParseSection(extracts);
extracts = apt_inst.debExtractControl(deb_file)
control = apt_pkg.ParseSection(extracts)
except:
print "can't parse control info";
control = '';
print "can't parse control info"
control = ''
deb_file.close();
deb_file.close()
control_keys = control.keys();
control_keys = control.keys()
if control.has_key("Depends"):
depends_str = control.Find("Depends");
depends_str = control.Find("Depends")
# create list of dependancy lists
depends = split_depends(depends_str);
depends = split_depends(depends_str)
if control.has_key("Recommends"):
recommends_str = control.Find("Recommends");
recommends = split_depends(recommends_str);
recommends_str = control.Find("Recommends")
recommends = split_depends(recommends_str)
if control.has_key("Section"):
section_str = control.Find("Section");
section_str = control.Find("Section")
c_match = re_contrib.search(section_str)
nf_match = re_nonfree.search(section_str)
......@@ -189,78 +189,78 @@ def read_control (filename):
localhost = re_localhost.search(maintainer)
if localhost:
#highlight bad email
maintainer = maintainer_colour + maintainer + end_colour;
maintainer = maintainer_colour + maintainer + end_colour
return (control, control_keys, section, depends, recommends, arch, maintainer)
def read_dsc (dsc_filename):
dsc = {};
dsc = {}
dsc_file = utils.open_file(dsc_filename);
dsc_file = utils.open_file(dsc_filename)
try:
dsc = utils.parse_changes(dsc_filename);
dsc = utils.parse_changes(dsc_filename)
except:
print "can't parse control info"
dsc_file.close();
dsc_file.close()
filecontents = strip_pgp_signature(dsc_filename);
filecontents = strip_pgp_signature(dsc_filename)
if dsc.has_key("build-depends"):
builddep = split_depends(dsc["build-depends"]);
builddepstr = create_depends_string(builddep);
filecontents = re_builddep.sub("Build-Depends: "+builddepstr, filecontents);
builddep = split_depends(dsc["build-depends"])
builddepstr = create_depends_string(builddep)
filecontents = re_builddep.sub("Build-Depends: "+builddepstr, filecontents)
if dsc.has_key("build-depends-indep"):
builddepindstr = create_depends_string(split_depends(dsc["build-depends-indep"]));
filecontents = re_builddepind.sub("Build-Depends-Indep: "+builddepindstr, filecontents);
builddepindstr = create_depends_string(split_depends(dsc["build-depends-indep"]))
filecontents = re_builddepind.sub("Build-Depends-Indep: "+builddepindstr, filecontents)
if dsc.has_key("architecture") :
if (dsc["architecture"] != "any"):
newarch = arch_colour + dsc["architecture"] + end_colour;
filecontents = re_arch.sub("Architecture: " + newarch, filecontents);
newarch = arch_colour + dsc["architecture"] + end_colour
filecontents = re_arch.sub("Architecture: " + newarch, filecontents)
return filecontents;
return filecontents
def create_depends_string (depends_tree):
# just look up unstable for now. possibly pull from .changes later
suite = "unstable";
result = "";
comma_count = 1;
suite = "unstable"
result = ""
comma_count = 1
for l in depends_tree:
if (comma_count >= 2):
result += ", ";
result += ", "
or_count = 1
for d in l:
if (or_count >= 2 ):
result += " | "
# doesn't do version lookup yet.
q = projectB.query("SELECT DISTINCT(b.package), b.version, c.name, su.suite_name FROM binaries b, files fi, location l, component c, bin_associations ba, suite su WHERE b.package='%s' AND b.file = fi.id AND fi.location = l.id AND l.component = c.id AND ba.bin=b.id AND ba.suite = su.id AND su.suite_name='%s' ORDER BY b.version desc" % (d['name'], suite));
ql = q.getresult();
q = projectB.query("SELECT DISTINCT(b.package), b.version, c.name, su.suite_name FROM binaries b, files fi, location l, component c, bin_associations ba, suite su WHERE b.package='%s' AND b.file = fi.id AND fi.location = l.id AND l.component = c.id AND ba.bin=b.id AND ba.suite = su.id AND su.suite_name='%s' ORDER BY b.version desc" % (d['name'], suite))
ql = q.getresult()
if ql:
i = ql[0];
i = ql[0]
if i[2] == "contrib":
result += contrib_colour + d['name'];
result += contrib_colour + d['name']
elif i[2] == "non-free":
result += nonfree_colour + d['name'];
result += nonfree_colour + d['name']
else :
result += main_colour + d['name'];
result += main_colour + d['name']
if d['version'] != '' :
result += " (%s)" % (d['version']);
result += end_colour;
result += " (%s)" % (d['version'])
result += end_colour
else:
result += bold_colour + d['name'];
result += bold_colour + d['name']
if d['version'] != '' :
result += " (%s)" % (d['version']);
result += end_colour;
or_count += 1;
comma_count += 1;
return result;
result += " (%s)" % (d['version'])
result += end_colour
or_count += 1
comma_count += 1
return result
def output_deb_info(filename):
(control, control_keys, section, depends, recommends, arch, maintainer) = read_control(filename);
(control, control_keys, section, depends, recommends, arch, maintainer) = read_control(filename)
if control == '':
print "no control info"
......@@ -268,174 +268,174 @@ def output_deb_info(filename):
for key in control_keys :
output = " " + key + ": "
if key == 'Depends':
output += create_depends_string(depends);
output += create_depends_string(depends)
elif key == 'Recommends':
output += create_depends_string(recommends);
output += create_depends_string(recommends)
elif key == 'Section':
output += section;
output += section
elif key == 'Architecture':
output += arch;
output += arch
elif key == 'Maintainer':
output += maintainer;
output += maintainer
elif key == 'Description':
desc = control.Find(key);
desc = re_newlinespace.sub('\n ', desc);
output += desc;
desc = control.Find(key)
desc = re_newlinespace.sub('\n ', desc)
output += desc
else:
output += control.Find(key);
print output;
output += control.Find(key)
print output
def do_command (command, filename):
o = os.popen("%s %s" % (command, filename));
print o.read();
o = os.popen("%s %s" % (command, filename))
print o.read()
def print_copyright (deb_filename):
package = re_package.sub(r'\1', deb_filename);
o = os.popen("ar p %s data.tar.gz | tar tzvf - | egrep 'usr(/share)?/doc/[^/]*/copyright' | awk '{ print $6 }' | head -n 1" % (deb_filename));
copyright = o.read()[:-1];
package = re_package.sub(r'\1', deb_filename)
o = os.popen("ar p %s data.tar.gz | tar tzvf - | egrep 'usr(/share)?/doc/[^/]*/copyright' | awk '{ print $6 }' | head -n 1" % (deb_filename))
copyright = o.read()[:-1]
if copyright == "":
print "WARNING: No copyright found, please check package manually."
return;
return
doc_directory = re_doc_directory.sub(r'\1', copyright);
doc_directory = re_doc_directory.sub(r'\1', copyright)
if package != doc_directory:
print "WARNING: wrong doc directory (expected %s, got %s)." % (package, doc_directory);
return;
print "WARNING: wrong doc directory (expected %s, got %s)." % (package, doc_directory)
return
o = os.popen("ar p %s data.tar.gz | tar xzOf - %s" % (deb_filename, copyright));
print o.read();
o = os.popen("ar p %s data.tar.gz | tar xzOf - %s" % (deb_filename, copyright))
print o.read()
def check_dsc (dsc_filename):
print "---- .dsc file for %s ----" % (dsc_filename);
print "---- .dsc file for %s ----" % (dsc_filename)
(dsc) = read_dsc(dsc_filename)
print dsc
def check_deb (deb_filename):
filename = os.path.basename(deb_filename);
filename = os.path.basename(deb_filename)
if filename.endswith(".udeb"):
is_a_udeb = 1;
is_a_udeb = 1
else:
is_a_udeb = 0;
is_a_udeb = 0
print "---- control file for %s ----" % (filename);
#do_command ("dpkg -I", deb_filename);
print "---- control file for %s ----" % (filename)
#do_command ("dpkg -I", deb_filename)
output_deb_info(deb_filename)
if is_a_udeb:
print "---- skipping lintian check for deb ----";
print ;
print "---- skipping lintian check for deb ----"
print
else:
print "---- lintian check for %s ----" % (filename);
do_command ("lintian", deb_filename);
print "---- linda check for %s ----" % (filename);
do_command ("linda", deb_filename);
print "---- lintian check for %s ----" % (filename)
do_command ("lintian", deb_filename)
print "---- linda check for %s ----" % (filename)
do_command ("linda", deb_filename)
print "---- contents of %s ----" % (filename);
do_command ("dpkg -c", deb_filename);
print "---- contents of %s ----" % (filename)
do_command ("dpkg -c", deb_filename)
if is_a_udeb:
print "---- skipping copyright for deb ----";
print "---- skipping copyright for deb ----"
else:
print "---- copyright of %s ----" % (filename);
print_copyright(deb_filename);
print "---- copyright of %s ----" % (filename)
print_copyright(deb_filename)
print "---- file listing of %s ----" % (filename);
do_command ("ls -l", deb_filename);
print "---- file listing of %s ----" % (filename)
do_command ("ls -l", deb_filename)
# Read a file, strip the signature and return the modified contents as
# a string.
def strip_pgp_signature (filename):
file = utils.open_file (filename);
contents = "";
inside_signature = 0;
skip_next = 0;
file = utils.open_file (filename)
contents = ""
inside_signature = 0
skip_next = 0
for line in file.readlines():
if line[:-1] == "":
continue;
continue
if inside_signature:
continue;
continue
if skip_next:
skip_next = 0;
continue;
skip_next = 0
continue
if line.startswith("-----BEGIN PGP SIGNED MESSAGE"):
skip_next = 1;
continue;
skip_next = 1
continue
if line.startswith("-----BEGIN PGP SIGNATURE"):
inside_signature = 1;
continue;
inside_signature = 1
continue
if line.startswith("-----END PGP SIGNATURE"):
inside_signature = 0;
continue;
contents += line;
file.close();
return contents;
inside_signature = 0
continue
contents += line
file.close()
return contents
# Display the .changes [without the signature]
def display_changes (changes_filename):
print "---- .changes file for %s ----" % (changes_filename);
print strip_pgp_signature(changes_filename);
print "---- .changes file for %s ----" % (changes_filename)
print strip_pgp_signature(changes_filename)
def check_changes (changes_filename):
display_changes(changes_filename);
display_changes(changes_filename)
changes = utils.parse_changes (changes_filename);
files = utils.build_file_list(changes);
changes = utils.parse_changes (changes_filename)
files = utils.build_file_list(changes)
for file in files.keys():
if file.endswith(".deb") or file.endswith(".udeb"):
check_deb(file);
check_deb(file)
if file.endswith(".dsc"):
check_dsc(file);
check_dsc(file)
# else: => byhand
def main ():
global Cnf, projectB, db_files, waste, excluded;
global Cnf, projectB, db_files, waste, excluded
# Cnf = utils.get_conf()
Arguments = [('h',"help","Fernanda::Options::Help")];
Arguments = [('h',"help","Fernanda::Options::Help")]
for i in [ "help" ]:
if not Cnf.has_key("Frenanda::Options::%s" % (i)):
Cnf["Fernanda::Options::%s" % (i)] = "";
Cnf["Fernanda::Options::%s" % (i)] = ""
args = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv);
args = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv)
Options = Cnf.SubTree("Fernanda::Options")
if Options["Help"]:
usage();
usage()
stdout_fd = sys.stdout;
stdout_fd = sys.stdout
for file in args:
try:
# Pipe output for each argument through less
less_fd = os.popen("less -R -", 'w', 0);
less_fd = os.popen("less -R -", 'w', 0)
# -R added to display raw control chars for colour
sys.stdout = less_fd;
sys.stdout = less_fd
try:
if file.endswith(".changes"):
check_changes(file);
check_changes(file)
elif file.endswith(".deb") or file.endswith(".udeb"):
check_deb(file);
check_deb(file)
elif file.endswith(".dsc"):
check_dsc(file);
check_dsc(file)
else:
utils.fubar("Unrecognised file type: '%s'." % (file));
utils.fubar("Unrecognised file type: '%s'." % (file))
finally:
# Reset stdout here so future less invocations aren't FUBAR
less_fd.close();
sys.stdout = stdout_fd;
less_fd.close()
sys.stdout = stdout_fd
except IOError, e:
if errno.errorcode[e.errno] == 'EPIPE':
utils.warn("[fernanda] Caught EPIPE; skipping.");
pass;
utils.warn("[fernanda] Caught EPIPE; skipping.")
pass
else:
raise;
raise
except KeyboardInterrupt:
utils.warn("[fernanda] Caught C-c; skipping.");
pass;
utils.warn("[fernanda] Caught C-c; skipping.")
pass
#######################################################################################
......
......@@ -20,14 +20,14 @@
################################################################################
import ldap, pg, sys, time;
import apt_pkg;
import utils;
import ldap, pg, sys, time
import apt_pkg
import utils
################################################################################
Cnf = None;
projectB = None;
Cnf = None
projectB = None
################################################################################
......@@ -41,54 +41,54 @@ Checks for users with no packages in the archive
################################################################################
def get_ldap_value(entry, value):
ret = entry.get(value);
ret = entry.get(value)
if not ret:
return "";
return ""
else:
# FIXME: what about > 0 ?
return ret[0];
return ret[0]
def main():
global Cnf, projectB;
global Cnf, projectB
Cnf = utils.get_conf()
Arguments = [('h',"help","Rosamund::Options::Help")];
Arguments = [('h',"help","Rosamund::Options::Help")]
for i in [ "help" ]:
if not Cnf.has_key("Rosamund::Options::%s" % (i)):
Cnf["Rosamund::Options::%s" % (i)] = "";
Cnf["Rosamund::Options::%s" % (i)] = ""
apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv);
apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv)
Options = Cnf.SubTree("Rosamund::Options")
if Options["Help"]:
usage();
usage()
projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]));
projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
before = time.time();
sys.stderr.write("[Getting info from the LDAP server...");
LDAPDn = Cnf["Emilie::LDAPDn"];
LDAPServer = Cnf["Emilie::LDAPServer"];
l = ldap.open(LDAPServer);
l.simple_bind_s("","");
before = time.time()
sys.stderr.write("[Getting info from the LDAP server...")
LDAPDn = Cnf["Emilie::LDAPDn"]
LDAPServer = Cnf["Emilie::LDAPServer"]
l = ldap.open(LDAPServer)
l.simple_bind_s("","")
Attrs = l.search_s(LDAPDn, ldap.SCOPE_ONELEVEL,
"(&(keyfingerprint=*)(gidnumber=%s))" % (Cnf["Julia::ValidGID"]),
["uid", "cn", "mn", "sn", "createtimestamp"]);
sys.stderr.write("done. (%d seconds)]\n" % (int(time.time()-before)));
["uid", "cn", "mn", "sn", "createtimestamp"])
sys.stderr.write("done. (%d seconds)]\n" % (int(time.time()-before)))
db_uid = {};
db_unstable_uid = {};
db_uid = {}
db_unstable_uid = {}
before = time.time();
sys.stderr.write("[Getting UID info for entire archive...");
q = projectB.query("SELECT DISTINCT u.uid FROM uid u, fingerprint f WHERE f.uid = u.id;");
sys.stderr.write("done. (%d seconds)]\n" % (int(time.time()-before)));
before = time.time()
sys.stderr.write("[Getting UID info for entire archive...")
q = projectB.query("SELECT DISTINCT u.uid FROM uid u, fingerprint f WHERE f.uid = u.id;")
sys.stderr.write("done. (%d seconds)]\n" % (int(time.time()-before)))
for i in q.getresult():
db_uid[i[0]] = "";
db_uid[i[0]] = ""
before = time.time();
sys.stderr.write("[Getting UID info for unstable...");
before = time.time()
sys.stderr.write("[Getting UID info for unstable...")
q = projectB.query("""
SELECT DISTINCT u.uid FROM suite su, src_associations sa, source s, fingerprint f, uid u
WHERE f.uid = u.id AND sa.source = s.id AND sa.suite = su.id
......@@ -96,39 +96,39 @@ SELECT DISTINCT u.uid FROM suite su, src_associations sa, source s, fingerprint
UNION
SELECT DISTINCT u.uid FROM suite su, bin_associations ba, binaries b, fingerprint f, uid u
WHERE f.uid = u.id AND ba.bin = b.id AND ba.suite = su.id
AND su.suite_name = 'unstable' AND b.sig_fpr = f.id""");
sys.stderr.write("done. (%d seconds)]\n" % (int(time.time()-before)));
AND su.suite_name = 'unstable' AND b.sig_fpr = f.id""")
sys.stderr.write("done. (%d seconds)]\n" % (int(time.time()-before)))
for i in q.getresult():
db_unstable_uid[i[0]] = "";
db_unstable_uid[i[0]] = ""
now = time.time();
now = time.time()
for i in Attrs:
entry = i[1];
uid = entry["uid"][0];
created = time.mktime(time.strptime(entry["createtimestamp"][0][:8], '%Y%m%d'));
diff = now - created;
entry = i[1]
uid = entry["uid"][0]
created = time.mktime(time.strptime(entry["createtimestamp"][0][:8], '%Y%m%d'))
diff = now - created
# 31536000 is 1 year in seconds, i.e. 60 * 60 * 24 * 365
if diff < 31536000 / 2:
when = "Less than 6 months ago";
when = "Less than 6 months ago"
elif diff < 31536000:
when = "Less than 1 year ago";
when = "Less than 1 year ago"
elif diff < 31536000 * 1.5:
when = "Less than 18 months ago";
when = "Less than 18 months ago"
elif diff < 31536000 * 2:
when = "Less than 2 years ago";
when = "Less than 2 years ago"
elif diff < 31536000 * 3:
when = "Less than 3 years ago";
when = "Less than 3 years ago"
else:
when = "More than 3 years ago";
when = "More than 3 years ago"
name = " ".join([get_ldap_value(entry, "cn"),
get_ldap_value(entry, "mn"),
get_ldap_value(entry, "sn")]);
get_ldap_value(entry, "sn")])
if not db_uid.has_key(uid):
print "NONE %s (%s) %s" % (uid, name, when);
print "NONE %s (%s) %s" % (uid, name, when)
else:
if not db_unstable_uid.has_key(uid):
print "NOT_UNSTABLE %s (%s) %s" % (uid, name, when);
print "NOT_UNSTABLE %s (%s) %s" % (uid, name, when)
############################################################
......
......@@ -36,10 +36,10 @@ import utils
################################################################################
projectB = None;
Cnf = None;
Logger = None;
Options = None;
projectB = None
Cnf = None
Logger = None
Options = None
################################################################################
......@@ -52,7 +52,7 @@ Write out ed-style diffs to Packages/Source lists
-p name for the patch (defaults to current time)
-n take no action
"""
sys.exit(exit_code);
sys.exit(exit_code)
def tryunlink(file):
......@@ -286,9 +286,9 @@ def genchanges(Options, outdir, oldfile, origfile, maxdiffs = 14):
def main():
global Cnf, Options, Logger
os.umask(0002);
os.umask(0002)
Cnf = utils.get_conf();
Cnf = utils.get_conf()
Arguments = [ ('h', "help", "Tiffani::Options::Help"),
('c', None, "Tiffani::Options::CanonicalPath", "hasArg"),
('p', "patchname", "Tiffani::Options::PatchName", "hasArg"),
......@@ -296,10 +296,10 @@ def main():
('d', "tmpdir", "Tiffani::Options::TempDir", "hasArg"),
('m', "maxdiffs", "Tiffani::Options::MaxDiffs", "hasArg"),
('n', "n-act", "Tiffani::Options::NoAct"),
];
suites = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv);
Options = Cnf.SubTree("Tiffani::Options");
if Options.has_key("Help"): usage();
]
suites = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv)
Options = Cnf.SubTree("Tiffani::Options")
if Options.has_key("Help"): usage()
maxdiffs = Options.get("MaxDiffs::Default", "14")
maxpackages = Options.get("MaxDiffs::Packages", maxdiffs)
......@@ -340,11 +340,11 @@ def main():
else:
components = []
suite_suffix = Cnf.Find("Dinstall::SuiteSuffix");
suite_suffix = Cnf.Find("Dinstall::SuiteSuffix")
if components and suite_suffix:
longsuite = suite + "/" + suite_suffix;
longsuite = suite + "/" + suite_suffix
else:
longsuite = suite;
longsuite = suite
tree = SuiteBlock.get("Tree", "dists/%s" % (longsuite))
......@@ -353,8 +353,8 @@ def main():
elif AptCnf.has_key("bindirectory::%s" % (tree)):
sections = AptCnf["bindirectory::%s::Sections" % (tree)].split()
else:
aptcnf_filename = os.path.basename(utils.which_apt_conf_file());
print "ALERT: suite %s not in %s, nor untouchable!" % (suite, aptcnf_filename);
aptcnf_filename = os.path.basename(utils.which_apt_conf_file())
print "ALERT: suite %s not in %s, nor untouchable!" % (suite, aptcnf_filename)
continue
for architecture in architectures:
......
......@@ -123,20 +123,20 @@ def print_sha1_files (tree, files):
def main ():
global Cnf, AptCnf, projectB, out
out = sys.stdout;
out = sys.stdout
Cnf = utils.get_conf()
Arguments = [('h',"help","Ziyi::Options::Help")];
Arguments = [('h',"help","Ziyi::Options::Help")]
for i in [ "help" ]:
if not Cnf.has_key("Ziyi::Options::%s" % (i)):
Cnf["Ziyi::Options::%s" % (i)] = "";
Cnf["Ziyi::Options::%s" % (i)] = ""
suites = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv)
Options = Cnf.SubTree("Ziyi::Options")
if Options["Help"]:
usage();
usage()
AptCnf = apt_pkg.newConfiguration()
apt_pkg.ReadConfigFileISC(AptCnf,utils.which_apt_conf_file())
......@@ -169,11 +169,11 @@ def main ():
else:
components = []
suite_suffix = Cnf.Find("Dinstall::SuiteSuffix");
suite_suffix = Cnf.Find("Dinstall::SuiteSuffix")
if components and suite_suffix:
longsuite = suite + "/" + suite_suffix;
longsuite = suite + "/" + suite_suffix
else:
longsuite = suite;
longsuite = suite
tree = SuiteBlock.get("Tree", "dists/%s" % (longsuite))
......@@ -182,8 +182,8 @@ def main ():
elif AptCnf.has_key("bindirectory::%s" % (tree)):
pass
else:
aptcnf_filename = os.path.basename(utils.which_apt_conf_file());
print "ALERT: suite %s not in %s, nor untouchable!" % (suite, aptcnf_filename);
aptcnf_filename = os.path.basename(utils.which_apt_conf_file())
print "ALERT: suite %s not in %s, nor untouchable!" % (suite, aptcnf_filename)
continue
print Cnf["Dir::Root"] + tree + "/Release"
......@@ -238,15 +238,15 @@ def main ():
release = open(relpath, "w")
#release = open(longsuite.replace("/","_") + "_" + arch + "_" + sec + "_Release", "w")
except IOError:
utils.fubar("Couldn't write to " + relpath);
utils.fubar("Couldn't write to " + relpath)
release.write("Archive: %s\n" % (suite))
if version != "":
release.write("Version: %s\n" % (version))
if suite_suffix:
release.write("Component: %s/%s\n" % (suite_suffix,sec));
release.write("Component: %s/%s\n" % (suite_suffix,sec))
else:
release.write("Component: %s\n" % (sec));
release.write("Component: %s\n" % (sec))
release.write("Origin: %s\n" % (origin))
release.write("Label: %s\n" % (label))
if notautomatic != "":
......
此差异已折叠。
......@@ -45,17 +45,17 @@
################################################################################
import commands, ldap, pg, re, sys, time;
import apt_pkg;
import db_access, utils;
import commands, ldap, pg, re, sys, time
import apt_pkg
import db_access, utils
################################################################################
Cnf = None;
projectB = None;
Cnf = None
projectB = None
re_gpg_fingerprint = re.compile(r"^\s+Key fingerprint = (.*)$", re.MULTILINE);
re_debian_address = re.compile(r"^.*<(.*)@debian\.org>$", re.MULTILINE);
re_gpg_fingerprint = re.compile(r"^\s+Key fingerprint = (.*)$", re.MULTILINE)
re_debian_address = re.compile(r"^.*<(.*)@debian\.org>$", re.MULTILINE)
################################################################################
......@@ -69,148 +69,148 @@ Syncs fingerprint and uid tables with a debian.org LDAP DB
################################################################################
def get_ldap_value(entry, value):
ret = entry.get(value);
ret = entry.get(value)
if not ret:
return "";
return ""
else:
# FIXME: what about > 0 ?
return ret[0];
return ret[0]
def main():
global Cnf, projectB;
global Cnf, projectB
Cnf = utils.get_conf()
Arguments = [('h',"help","Emilie::Options::Help")];
Arguments = [('h',"help","Emilie::Options::Help")]
for i in [ "help" ]:
if not Cnf.has_key("Emilie::Options::%s" % (i)):
Cnf["Emilie::Options::%s" % (i)] = "";
Cnf["Emilie::Options::%s" % (i)] = ""
apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv);
apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv)
Options = Cnf.SubTree("Emilie::Options")
if Options["Help"]:
usage();
usage()
projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]));
db_access.init(Cnf, projectB);
projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
db_access.init(Cnf, projectB)
#before = time.time();
#sys.stderr.write("[Getting info from the LDAP server...");
LDAPDn = Cnf["Emilie::LDAPDn"];
LDAPServer = Cnf["Emilie::LDAPServer"];
l = ldap.open(LDAPServer);
l.simple_bind_s("","");
#before = time.time()
#sys.stderr.write("[Getting info from the LDAP server...")
LDAPDn = Cnf["Emilie::LDAPDn"]
LDAPServer = Cnf["Emilie::LDAPServer"]
l = ldap.open(LDAPServer)
l.simple_bind_s("","")
Attrs = l.search_s(LDAPDn, ldap.SCOPE_ONELEVEL,
"(&(keyfingerprint=*)(gidnumber=%s))" % (Cnf["Julia::ValidGID"]),
["uid", "keyfingerprint"]);
#sys.stderr.write("done. (%d seconds)]\n" % (int(time.time()-before)));
["uid", "keyfingerprint"])
#sys.stderr.write("done. (%d seconds)]\n" % (int(time.time()-before)))
projectB.query("BEGIN WORK");
projectB.query("BEGIN WORK")
# Sync LDAP with DB
db_fin_uid = {};
ldap_fin_uid_id = {};
db_fin_uid = {}
ldap_fin_uid_id = {}
q = projectB.query("""
SELECT f.fingerprint, f.id, u.uid FROM fingerprint f, uid u WHERE f.uid = u.id
UNION SELECT f.fingerprint, f.id, null FROM fingerprint f where f.uid is null""");
UNION SELECT f.fingerprint, f.id, null FROM fingerprint f where f.uid is null""")
for i in q.getresult():
(fingerprint, fingerprint_id, uid) = i;
db_fin_uid[fingerprint] = (uid, fingerprint_id);
(fingerprint, fingerprint_id, uid) = i
db_fin_uid[fingerprint] = (uid, fingerprint_id)
for i in Attrs:
entry = i[1];
fingerprints = entry["keyFingerPrint"];
uid = entry["uid"][0];
uid_id = db_access.get_or_set_uid_id(uid);
entry = i[1]
fingerprints = entry["keyFingerPrint"]
uid = entry["uid"][0]
uid_id = db_access.get_or_set_uid_id(uid)
for fingerprint in fingerprints:
ldap_fin_uid_id[fingerprint] = (uid, uid_id);
ldap_fin_uid_id[fingerprint] = (uid, uid_id)
if db_fin_uid.has_key(fingerprint):
(existing_uid, fingerprint_id) = db_fin_uid[fingerprint];
(existing_uid, fingerprint_id) = db_fin_uid[fingerprint]
if not existing_uid:
q = projectB.query("UPDATE fingerprint SET uid = %s WHERE id = %s" % (uid_id, fingerprint_id));
print "Assigning %s to 0x%s." % (uid, fingerprint);
q = projectB.query("UPDATE fingerprint SET uid = %s WHERE id = %s" % (uid_id, fingerprint_id))
print "Assigning %s to 0x%s." % (uid, fingerprint)
else:
if existing_uid != uid:
utils.fubar("%s has %s in LDAP, but projectB says it should be %s." % (uid, fingerprint, existing_uid));
utils.fubar("%s has %s in LDAP, but projectB says it should be %s." % (uid, fingerprint, existing_uid))
# Try to update people who sign with non-primary key
q = projectB.query("SELECT fingerprint, id FROM fingerprint WHERE uid is null");
q = projectB.query("SELECT fingerprint, id FROM fingerprint WHERE uid is null")
for i in q.getresult():
(fingerprint, fingerprint_id) = i;
(fingerprint, fingerprint_id) = i
cmd = "gpg --no-default-keyring --keyring=%s --keyring=%s --fingerprint %s" \
% (Cnf["Dinstall::PGPKeyring"], Cnf["Dinstall::GPGKeyring"],
fingerprint);
(result, output) = commands.getstatusoutput(cmd);
fingerprint)
(result, output) = commands.getstatusoutput(cmd)
if result == 0:
m = re_gpg_fingerprint.search(output);
m = re_gpg_fingerprint.search(output)
if not m:
print output
utils.fubar("0x%s: No fingerprint found in gpg output but it returned 0?\n%s" % (fingerprint, utils.prefix_multi_line_string(output, " [GPG output:] ")));
primary_key = m.group(1);
primary_key = primary_key.replace(" ","");
utils.fubar("0x%s: No fingerprint found in gpg output but it returned 0?\n%s" % (fingerprint, utils.prefix_multi_line_string(output, " [GPG output:] ")))
primary_key = m.group(1)
primary_key = primary_key.replace(" ","")
if not ldap_fin_uid_id.has_key(primary_key):
utils.fubar("0x%s (from 0x%s): no UID found in LDAP" % (primary_key, fingerprint));
(uid, uid_id) = ldap_fin_uid_id[primary_key];
q = projectB.query("UPDATE fingerprint SET uid = %s WHERE id = %s" % (uid_id, fingerprint_id));
print "Assigning %s to 0x%s." % (uid, fingerprint);
utils.fubar("0x%s (from 0x%s): no UID found in LDAP" % (primary_key, fingerprint))
(uid, uid_id) = ldap_fin_uid_id[primary_key]
q = projectB.query("UPDATE fingerprint SET uid = %s WHERE id = %s" % (uid_id, fingerprint_id))
print "Assigning %s to 0x%s." % (uid, fingerprint)
else:
extra_keyrings = "";
extra_keyrings = ""
for keyring in Cnf.ValueList("Emilie::ExtraKeyrings"):
extra_keyrings += " --keyring=%s" % (keyring);
extra_keyrings += " --keyring=%s" % (keyring)
cmd = "gpg --keyring=%s --keyring=%s %s --list-key %s" \
% (Cnf["Dinstall::PGPKeyring"], Cnf["Dinstall::GPGKeyring"],
extra_keyrings, fingerprint);
(result, output) = commands.getstatusoutput(cmd);
extra_keyrings, fingerprint)
(result, output) = commands.getstatusoutput(cmd)
if result != 0:
cmd = "gpg --keyserver=%s --allow-non-selfsigned-uid --recv-key %s" % (Cnf["Emilie::KeyServer"], fingerprint);
(result, output) = commands.getstatusoutput(cmd);
cmd = "gpg --keyserver=%s --allow-non-selfsigned-uid --recv-key %s" % (Cnf["Emilie::KeyServer"], fingerprint)
(result, output) = commands.getstatusoutput(cmd)
if result != 0:
print "0x%s: NOT found on keyserver." % (fingerprint);
print "0x%s: NOT found on keyserver." % (fingerprint)
print cmd
print result
print output
continue;
continue
else:
cmd = "gpg --list-key %s" % (fingerprint);
(result, output) = commands.getstatusoutput(cmd);
cmd = "gpg --list-key %s" % (fingerprint)
(result, output) = commands.getstatusoutput(cmd)
if result != 0:
print "0x%s: --list-key returned error after --recv-key didn't." % (fingerprint);
print "0x%s: --list-key returned error after --recv-key didn't." % (fingerprint)
print cmd
print result
print output
continue;
m = re_debian_address.search(output);
continue
m = re_debian_address.search(output)
if m:
guess_uid = m.group(1);
guess_uid = m.group(1)
else:
guess_uid = "???";
name = " ".join(output.split('\n')[0].split()[3:]);
print "0x%s -> %s -> %s" % (fingerprint, name, guess_uid);
guess_uid = "???"
name = " ".join(output.split('\n')[0].split()[3:])
print "0x%s -> %s -> %s" % (fingerprint, name, guess_uid)
# FIXME: make me optionally non-interactive
# FIXME: default to the guessed ID
uid = None;
uid = None
while not uid:
uid = utils.our_raw_input("Map to which UID ? ");
uid = utils.our_raw_input("Map to which UID ? ")
Attrs = l.search_s(LDAPDn,ldap.SCOPE_ONELEVEL,"(uid=%s)" % (uid), ["cn","mn","sn"])
if not Attrs:
print "That UID doesn't exist in LDAP!"
uid = None;
uid = None
else:
entry = Attrs[0][1];
entry = Attrs[0][1]
name = " ".join([get_ldap_value(entry, "cn"),
get_ldap_value(entry, "mn"),
get_ldap_value(entry, "sn")]);
prompt = "Map to %s - %s (y/N) ? " % (uid, name.replace(" "," "));
yn = utils.our_raw_input(prompt).lower();
get_ldap_value(entry, "sn")])
prompt = "Map to %s - %s (y/N) ? " % (uid, name.replace(" "," "))
yn = utils.our_raw_input(prompt).lower()
if yn == "y":
uid_id = db_access.get_or_set_uid_id(uid);
projectB.query("UPDATE fingerprint SET uid = %s WHERE id = %s" % (uid_id, fingerprint_id));
print "Assigning %s to 0x%s." % (uid, fingerprint);
uid_id = db_access.get_or_set_uid_id(uid)
projectB.query("UPDATE fingerprint SET uid = %s WHERE id = %s" % (uid_id, fingerprint_id))
print "Assigning %s to 0x%s." % (uid, fingerprint)
else:
uid = None;
projectB.query("COMMIT WORK");
uid = None
projectB.query("COMMIT WORK")
############################################################
......
......@@ -30,14 +30,14 @@
################################################################################
import pg, pwd, sys;
import utils;
import apt_pkg;
import pg, pwd, sys
import utils
import apt_pkg
################################################################################
Cnf = None;
projectB = None;
Cnf = None
projectB = None
################################################################################
def usage (exit_code=0):
......@@ -53,66 +53,66 @@ Sync PostgreSQL's users with system users.
################################################################################
def main ():
global Cnf, projectB;
global Cnf, projectB
Cnf = utils.get_conf()
Arguments = [('n', "no-action", "Julia::Options::No-Action"),
('q', "quiet", "Julia::Options::Quiet"),
('v', "verbose", "Julia::Options::Verbose"),
('h', "help", "Julia::Options::Help")];
('h', "help", "Julia::Options::Help")]
for i in [ "no-action", "quiet", "verbose", "help" ]:
if not Cnf.has_key("Julia::Options::%s" % (i)):
Cnf["Julia::Options::%s" % (i)] = "";
Cnf["Julia::Options::%s" % (i)] = ""
arguments = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv);
arguments = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv)
Options = Cnf.SubTree("Julia::Options")
if Options["Help"]:
usage();
usage()
elif arguments:
utils.warn("julia takes no non-option arguments.");
usage(1);
utils.warn("julia takes no non-option arguments.")
usage(1)
projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]));
valid_gid = int(Cnf.get("Julia::ValidGID",""));
projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
valid_gid = int(Cnf.get("Julia::ValidGID",""))
passwd_unames = {};
passwd_unames = {}
for entry in pwd.getpwall():
uname = entry[0];
gid = entry[3];
uname = entry[0]
gid = entry[3]
if valid_gid and gid != valid_gid:
if Options["Verbose"]:
print "Skipping %s (GID %s != Valid GID %s)." % (uname, gid, valid_gid);
continue;
passwd_unames[uname] = "";
print "Skipping %s (GID %s != Valid GID %s)." % (uname, gid, valid_gid)
continue
passwd_unames[uname] = ""
postgres_unames = {};
q = projectB.query("SELECT usename FROM pg_user");
ql = q.getresult();
postgres_unames = {}
q = projectB.query("SELECT usename FROM pg_user")
ql = q.getresult()
for i in ql:
uname = i[0];
postgres_unames[uname] = "";
uname = i[0]
postgres_unames[uname] = ""
known_postgres_unames = {};
known_postgres_unames = {}
for i in Cnf.get("Julia::KnownPostgres","").split(","):
uname = i.strip();
known_postgres_unames[uname] = "";
uname = i.strip()
known_postgres_unames[uname] = ""
keys = postgres_unames.keys()
keys.sort();
keys.sort()
for uname in keys:
if not passwd_unames.has_key(uname)and not known_postgres_unames.has_key(uname):
print "W: %s is in Postgres but not the passwd file or list of known Postgres users." % (uname);
print "W: %s is in Postgres but not the passwd file or list of known Postgres users." % (uname)
keys = passwd_unames.keys()
keys.sort();
keys.sort()
for uname in keys:
if not postgres_unames.has_key(uname):
if not Options["Quiet"]:
print "Creating %s user in Postgres." % (uname);
print "Creating %s user in Postgres." % (uname)
if not Options["No-Action"]:
q = projectB.query('CREATE USER "%s"' % (uname));
q = projectB.query('CREATE USER "%s"' % (uname))
#######################################################################################
......
......@@ -20,14 +20,14 @@
################################################################################
import pg, sys;
import utils, db_access;
import apt_pkg;
import pg, sys
import utils, db_access
import apt_pkg
################################################################################
Cnf = None;
projectB = None;
Cnf = None
projectB = None
################################################################################
......@@ -42,136 +42,136 @@ Initalizes some tables in the projectB database based on the config file.
def get (c, i):
if c.has_key(i):
return "'%s'" % (c[i]);
return "'%s'" % (c[i])
else:
return "NULL";
return "NULL"
def main ():
global Cnf, projectB;
global Cnf, projectB
Cnf = utils.get_conf()
Arguments = [('h',"help","Alyson::Options::Help")];
Arguments = [('h',"help","Alyson::Options::Help")]
for i in [ "help" ]:
if not Cnf.has_key("Alyson::Options::%s" % (i)):
Cnf["Alyson::Options::%s" % (i)] = "";
Cnf["Alyson::Options::%s" % (i)] = ""
apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv);
apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv)
Options = Cnf.SubTree("Alyson::Options")
if Options["Help"]:
usage();
usage()
projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]));
db_access.init(Cnf, projectB);
projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
db_access.init(Cnf, projectB)
# archive
projectB.query("BEGIN WORK");
projectB.query("DELETE FROM archive");
projectB.query("BEGIN WORK")
projectB.query("DELETE FROM archive")
for name in Cnf.SubTree("Archive").List():
Archive = Cnf.SubTree("Archive::%s" % (name));
origin_server = get(Archive, "OriginServer");
description = get(Archive, "Description");
projectB.query("INSERT INTO archive (name, origin_server, description) VALUES ('%s', %s, %s)" % (name, origin_server, description));
projectB.query("COMMIT WORK");
Archive = Cnf.SubTree("Archive::%s" % (name))
origin_server = get(Archive, "OriginServer")
description = get(Archive, "Description")
projectB.query("INSERT INTO archive (name, origin_server, description) VALUES ('%s', %s, %s)" % (name, origin_server, description))
projectB.query("COMMIT WORK")
# architecture
projectB.query("BEGIN WORK");
projectB.query("DELETE FROM architecture");
projectB.query("BEGIN WORK")
projectB.query("DELETE FROM architecture")
for arch in Cnf.SubTree("Architectures").List():
description = Cnf["Architectures::%s" % (arch)];
projectB.query("INSERT INTO architecture (arch_string, description) VALUES ('%s', '%s')" % (arch, description));
projectB.query("COMMIT WORK");
description = Cnf["Architectures::%s" % (arch)]
projectB.query("INSERT INTO architecture (arch_string, description) VALUES ('%s', '%s')" % (arch, description))
projectB.query("COMMIT WORK")
# component
projectB.query("BEGIN WORK");
projectB.query("DELETE FROM component");
projectB.query("BEGIN WORK")
projectB.query("DELETE FROM component")
for name in Cnf.SubTree("Component").List():
Component = Cnf.SubTree("Component::%s" % (name));
description = get(Component, "Description");
Component = Cnf.SubTree("Component::%s" % (name))
description = get(Component, "Description")
if Component.get("MeetsDFSG").lower() == "true":
meets_dfsg = "true";
meets_dfsg = "true"
else:
meets_dfsg = "false";
projectB.query("INSERT INTO component (name, description, meets_dfsg) VALUES ('%s', %s, %s)" % (name, description, meets_dfsg));
projectB.query("COMMIT WORK");
meets_dfsg = "false"
projectB.query("INSERT INTO component (name, description, meets_dfsg) VALUES ('%s', %s, %s)" % (name, description, meets_dfsg))
projectB.query("COMMIT WORK")
# location
projectB.query("BEGIN WORK");
projectB.query("DELETE FROM location");
projectB.query("BEGIN WORK")
projectB.query("DELETE FROM location")
for location in Cnf.SubTree("Location").List():
Location = Cnf.SubTree("Location::%s" % (location));
archive_id = db_access.get_archive_id(Location["Archive"]);
type = Location.get("type");
Location = Cnf.SubTree("Location::%s" % (location))
archive_id = db_access.get_archive_id(Location["Archive"])
type = Location.get("type")
if type == "legacy-mixed":
projectB.query("INSERT INTO location (path, archive, type) VALUES ('%s', %d, '%s')" % (location, archive_id, Location["type"]));
projectB.query("INSERT INTO location (path, archive, type) VALUES ('%s', %d, '%s')" % (location, archive_id, Location["type"]))
elif type == "legacy" or type == "pool":
for component in Cnf.SubTree("Component").List():
component_id = db_access.get_component_id(component);
component_id = db_access.get_component_id(component)
projectB.query("INSERT INTO location (path, component, archive, type) VALUES ('%s', %d, %d, '%s')" %
(location, component_id, archive_id, type));
(location, component_id, archive_id, type))
else:
utils.fubar("E: type '%s' not recognised in location %s." % (type, location));
projectB.query("COMMIT WORK");
utils.fubar("E: type '%s' not recognised in location %s." % (type, location))
projectB.query("COMMIT WORK")
# suite
projectB.query("BEGIN WORK");
projectB.query("BEGIN WORK")
projectB.query("DELETE FROM suite")
for suite in Cnf.SubTree("Suite").List():
Suite = Cnf.SubTree("Suite::%s" %(suite))
version = get(Suite, "Version");
origin = get(Suite, "Origin");
description = get(Suite, "Description");
version = get(Suite, "Version")
origin = get(Suite, "Origin")
description = get(Suite, "Description")
projectB.query("INSERT INTO suite (suite_name, version, origin, description) VALUES ('%s', %s, %s, %s)"
% (suite.lower(), version, origin, description));
% (suite.lower(), version, origin, description))
for architecture in Cnf.ValueList("Suite::%s::Architectures" % (suite)):
architecture_id = db_access.get_architecture_id (architecture);
architecture_id = db_access.get_architecture_id (architecture)
if architecture_id < 0:
utils.fubar("architecture '%s' not found in architecture table for suite %s." % (architecture, suite));
projectB.query("INSERT INTO suite_architectures (suite, architecture) VALUES (currval('suite_id_seq'), %d)" % (architecture_id));
projectB.query("COMMIT WORK");
utils.fubar("architecture '%s' not found in architecture table for suite %s." % (architecture, suite))
projectB.query("INSERT INTO suite_architectures (suite, architecture) VALUES (currval('suite_id_seq'), %d)" % (architecture_id))
projectB.query("COMMIT WORK")
# override_type
projectB.query("BEGIN WORK");
projectB.query("DELETE FROM override_type");
projectB.query("BEGIN WORK")
projectB.query("DELETE FROM override_type")
for type in Cnf.ValueList("OverrideType"):
projectB.query("INSERT INTO override_type (type) VALUES ('%s')" % (type));
projectB.query("COMMIT WORK");
projectB.query("INSERT INTO override_type (type) VALUES ('%s')" % (type))
projectB.query("COMMIT WORK")
# priority
projectB.query("BEGIN WORK");
projectB.query("DELETE FROM priority");
projectB.query("BEGIN WORK")
projectB.query("DELETE FROM priority")
for priority in Cnf.SubTree("Priority").List():
projectB.query("INSERT INTO priority (priority, level) VALUES ('%s', %s)" % (priority, Cnf["Priority::%s" % (priority)]));
projectB.query("COMMIT WORK");
projectB.query("INSERT INTO priority (priority, level) VALUES ('%s', %s)" % (priority, Cnf["Priority::%s" % (priority)]))
projectB.query("COMMIT WORK")
# section
projectB.query("BEGIN WORK");
projectB.query("DELETE FROM section");
projectB.query("BEGIN WORK")
projectB.query("DELETE FROM section")
for component in Cnf.SubTree("Component").List():
if Cnf["Natalie::ComponentPosition"] == "prefix":
suffix = "";
suffix = ""
if component != "main":
prefix = component + '/';
prefix = component + '/'
else:
prefix = "";
prefix = ""
else:
prefix = "";
component = component.replace("non-US/", "");
prefix = ""
component = component.replace("non-US/", "")
if component != "main":
suffix = '/' + component;
suffix = '/' + component
else:
suffix = "";
suffix = ""
for section in Cnf.ValueList("Section"):
projectB.query("INSERT INTO section (section) VALUES ('%s%s%s')" % (prefix, section, suffix));
projectB.query("COMMIT WORK");
projectB.query("INSERT INTO section (section) VALUES ('%s%s%s')" % (prefix, section, suffix))
projectB.query("COMMIT WORK")
################################################################################
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -121,12 +121,12 @@ for f in functionality:
def main():
if len(sys.argv) == 0:
print "err, argc == 0? how is that possible?"
sys.exit(1);
sys.exit(1)
elif len(sys.argv) == 1 or (len(sys.argv) == 2 and sys.argv[1] == "--help"):
print "Sub commands:"
for f in functionality:
print " %-23s %s" % (f[0], f[1])
sys.exit(0);
sys.exit(0)
else:
# should set PATH based on sys.argv[0] maybe
# possibly should set names based on sys.argv[0] too
......@@ -148,10 +148,10 @@ def main():
cmdname = match[0]
elif len(match) > 1:
print "ambiguous command: %s" % ", ".join(match)
sys.exit(1);
sys.exit(1)
else:
print "unknown command \"%s\"" % (cmdname)
sys.exit(1);
sys.exit(1)
func = names[cmdname]
x = __import__(func[0])
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册