import commands, pg, os, sys, time
import apt_pkg
-import daklib.database
-import daklib.utils
+from daklib import database
+from daklib import utils
################################################################################
################################################################################
def do_nviu():
- experimental_id = daklib.database.get_suite_id("experimental")
+ experimental_id = database.get_suite_id("experimental")
if experimental_id == -1:
return
# Check for packages in experimental obsoleted by versions in unstable
WHERE sa.suite = %s AND sa2.suite = %d AND sa.source = s.id
AND sa2.source = s2.id AND s.source = s2.source
AND versioncmp(s.version, s2.version) < 0""" % (experimental_id,
- daklib.database.get_suite_id("unstable")))
+ database.get_suite_id("unstable")))
ql = q.getresult()
if ql:
nviu_to_remove = []
print " dak rm -S -p -m \"[auto-cruft] obsolete source package\" %s" % (" ".join(to_remove))
print
+def get_suite_binaries():
+ # Initalize a large hash table of all binary packages
+ binaries = {}
+ before = time.time()
+
+ sys.stderr.write("[Getting a list of binary packages in %s..." % (suite))
+ q = projectB.query("SELECT distinct b.package FROM binaries b, bin_associations ba WHERE ba.suite = %s AND ba.bin = b.id" % (suite_id))
+ ql = q.getresult()
+ sys.stderr.write("done. (%d seconds)]\n" % (int(time.time()-before)))
+ for i in ql:
+ binaries[i[0]] = ""
+
+ return binaries
+
################################################################################
def main ():
global Cnf, projectB, suite, suite_id, source_binaries, source_versions
- Cnf = daklib.utils.get_conf()
+ Cnf = utils.get_conf()
Arguments = [('h',"help","Cruft-Report::Options::Help"),
('m',"mode","Cruft-Report::Options::Mode", "HasArg"),
elif Options["Mode"] == "full":
checks = [ "nbs", "nviu", "obsolete source", "dubious nbs", "bnb", "bms", "anais" ]
else:
- daklib.utils.warn("%s is not a recognised mode - only 'full' or 'daily' are understood." % (Options["Mode"]))
+ utils.warn("%s is not a recognised mode - only 'full' or 'daily' are understood." % (Options["Mode"]))
usage(1)
projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
- daklib.database.init(Cnf, projectB)
+ database.init(Cnf, projectB)
bin_pkgs = {}
src_pkgs = {}
duplicate_bins = {}
suite = Options["Suite"]
- suite_id = daklib.database.get_suite_id(suite)
+ suite_id = database.get_suite_id(suite)
bin_not_built = {}
if "bnb" in checks:
- # Initalize a large hash table of all binary packages
- before = time.time()
- sys.stderr.write("[Getting a list of binary packages in %s..." % (suite))
- q = projectB.query("SELECT distinct b.package FROM binaries b, bin_associations ba WHERE ba.suite = %s AND ba.bin = b.id" % (suite_id))
- ql = q.getresult()
- sys.stderr.write("done. (%d seconds)]\n" % (int(time.time()-before)))
- for i in ql:
- bins_in_suite[i[0]] = ""
+ bins_in_suite = get_suite_binaries()
# Checks based on the Sources files
components = Cnf.ValueList("Suite::%s::Components" % (suite))
for component in components:
filename = "%s/dists/%s/%s/source/Sources.gz" % (Cnf["Dir::Root"], suite, component)
# apt_pkg.ParseTagFile needs a real file handle and can't handle a GzipFile instance...
- temp_filename = daklib.utils.temp_filename()
+ temp_filename = utils.temp_filename()
(result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename))
if (result != 0):
sys.stderr.write("Gunzip invocation failed!\n%s\n" % (output))
sys.exit(result)
- sources = daklib.utils.open_file(temp_filename)
+ sources = utils.open_file(temp_filename)
Sources = apt_pkg.ParseTagFile(sources)
while Sources.Step():
source = Sources.Section.Find('Package')
if suite != "experimental":
check_components.append('main/debian-installer');
for component in check_components:
- architectures = filter(daklib.utils.real_arch, Cnf.ValueList("Suite::%s::Architectures" % (suite)))
+ architectures = filter(utils.real_arch, Cnf.ValueList("Suite::%s::Architectures" % (suite)))
for architecture in architectures:
filename = "%s/dists/%s/%s/binary-%s/Packages.gz" % (Cnf["Dir::Root"], suite, component, architecture)
# apt_pkg.ParseTagFile needs a real file handle
- temp_filename = daklib.utils.temp_filename()
+ temp_filename = utils.temp_filename()
(result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename))
if (result != 0):
sys.stderr.write("Gunzip invocation failed!\n%s\n" % (output))
sys.exit(result)
- packages = daklib.utils.open_file(temp_filename)
+ packages = utils.open_file(temp_filename)
Packages = apt_pkg.ParseTagFile(packages)
while Packages.Step():
package = Packages.Section.Find('Package')
bin2source[package]["version"] = version
bin2source[package]["source"] = source
if source.find("(") != -1:
- m = daklib.utils.re_extract_src_version.match(source)
+ m = utils.re_extract_src_version.match(source)
source = m.group(1)
version = m.group(2)
if not bin_pkgs.has_key(package):