################################################################################
-import warnings
-warnings.filterwarnings('ignore', \
- "apt_pkg\.ParseTagFile\(\) is deprecated\. Please see apt_pkg\.TagFile\(\) for the replacement\.", \
- DeprecationWarning)
-warnings.filterwarnings('ignore', \
- "Attribute '.*' of the 'apt_pkg\.TagFile' object is deprecated, use '.*' instead\.", \
- DeprecationWarning)
-warnings.filterwarnings('ignore', \
- "Attribute 'Find' of the 'apt_pkg\.TagSection' object is deprecated, use 'find' instead\.", \
- DeprecationWarning)
-
-################################################################################
-
import commands, os, sys, re
import apt_pkg
Check for obsolete or duplicated packages.
-h, --help show this help and exit.
- -m, --mode=MODE chose the MODE to run in (full or daily).
+ -m, --mode=MODE chose the MODE to run in (full, daily, bdo).
-s, --suite=SUITE check suite SUITE.
-w, --wanna-build-dump where to find the copies of http://buildd.debian.org/stats/*.txt"""
sys.exit(exit_code)
version = i[1]
if architectures.has_key(arch):
versions.append(version)
- versions.sort(apt_pkg.VersionCompare)
+ versions.sort(apt_pkg.version_compare)
if versions:
latest_version = versions.pop()
else:
if versions_d != {}:
anais_output += "\n (*) %s_%s [%s]: %s\n" % (binary, latest_version, source, architecture)
versions = versions_d.keys()
- versions.sort(apt_pkg.VersionCompare)
+ versions.sort(apt_pkg.version_compare)
for version in versions:
arches = versions_d[version]
arches.sort()
source_binaries.get(source, "(source does not exist)"))
print " won't admit to building:"
versions = dubious_nbs[source].keys()
- versions.sort(apt_pkg.VersionCompare)
+ versions.sort(apt_pkg.version_compare)
for version in versions:
packages = dubious_nbs[source][version].keys()
packages.sort()
################################################################################
+def report_outdated_nonfree(suite, session):
+
+ packages = {}
+ query = """WITH outdated_sources AS (
+ SELECT s.source, s.version, s.id
+ FROM source s
+ JOIN src_associations sa ON sa.source = s.id
+ WHERE sa.suite IN (
+ SELECT id
+ FROM suite
+ WHERE suite_name = :suite )
+ AND sa.created < (now() - interval :delay)
+ EXCEPT SELECT s.source, max(s.version) AS version, max(s.id)
+ FROM source s
+ JOIN src_associations sa ON sa.source = s.id
+ WHERE sa.suite IN (
+ SELECT id
+ FROM suite
+ WHERE suite_name = :suite )
+ AND sa.created < (now() - interval :delay)
+ GROUP BY s.source ),
+ binaries AS (
+ SELECT b.package, s.source, (
+ SELECT a.arch_string
+ FROM architecture a
+ WHERE a.id = b.architecture ) AS arch
+ FROM binaries b
+ JOIN outdated_sources s ON s.id = b.source
+ JOIN bin_associations ba ON ba.bin = b.id
+ JOIN override o ON o.package = b.package AND o.suite = ba.suite
+ WHERE ba.suite IN (
+ SELECT id
+ FROM suite
+ WHERE suite_name = :suite )
+ AND o.component IN (
+ SELECT id
+ FROM component
+ WHERE name = 'non-free' ) )
+ SELECT DISTINCT package, source, arch
+ FROM binaries
+ ORDER BY source, package, arch"""
+
+ res = session.execute(query, {'suite': suite, 'delay': "'15 days'"})
+ for package in res:
+ binary = package[0]
+ source = package[1]
+ arch = package[2]
+ if arch == 'all':
+ continue
+ if not source in packages:
+ packages[source] = {}
+ if not binary in packages[source]:
+ packages[source][binary] = set()
+ packages[source][binary].add(arch)
+ if packages:
+ title = 'Outdated non-free binaries in suite %s' % suite
+ message = '"[auto-cruft] outdated non-free binaries"'
+ print '%s\n%s\n' % (title, '-' * len(title))
+ for source in sorted(packages):
+ archs = set()
+ binaries = set()
+ print '* package %s has outdated non-free binaries' % source
+ print ' - suggested command:'
+ for binary in sorted(packages[source]):
+ binaries.add(binary)
+ archs = archs.union(packages[source][binary])
+ print ' dak rm -m %s -s %s -a %s -p -R -b %s\n' % \
+ (message, suite, ','.join(archs), ' '.join(binaries))
+
+################################################################################
+
def main ():
global suite, suite_id, source_binaries, source_versions
for i in [ "help" ]:
if not cnf.has_key("Cruft-Report::Options::%s" % (i)):
cnf["Cruft-Report::Options::%s" % (i)] = ""
- cnf["Cruft-Report::Options::Suite"] = cnf["Dinstall::DefaultSuite"]
+
+ cnf["Cruft-Report::Options::Suite"] = cnf.get("Dinstall::DefaultSuite", "unstable")
if not cnf.has_key("Cruft-Report::Options::Mode"):
cnf["Cruft-Report::Options::Mode"] = "daily"
if not cnf.has_key("Cruft-Report::Options::Wanna-Build-Dump"):
cnf["Cruft-Report::Options::Wanna-Build-Dump"] = "/srv/ftp-master.debian.org/scripts/nfu"
- apt_pkg.ParseCommandLine(cnf.Cnf, Arguments, sys.argv)
+ apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv)
- Options = cnf.SubTree("Cruft-Report::Options")
+ Options = cnf.subtree("Cruft-Report::Options")
if Options["Help"]:
usage()
# Set up checks based on mode
if Options["Mode"] == "daily":
- checks = [ "nbs", "nviu", "nvit", "obsolete source", "nfu" ]
+ checks = [ "nbs", "nviu", "nvit", "obsolete source", "outdated non-free", "nfu" ]
elif Options["Mode"] == "full":
- checks = [ "nbs", "nviu", "nvit", "obsolete source", "nfu", "dubious nbs", "bnb", "bms", "anais" ]
+ checks = [ "nbs", "nviu", "nvit", "obsolete source", "outdated non-free", "nfu", "dubious nbs", "bnb", "bms", "anais" ]
+ elif Options["Mode"] == "bdo":
+ checks = [ "nbs", "obsolete source" ]
else:
- 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', 'daily' or 'bdo' are understood." % (Options["Mode"]))
usage(1)
session = DBConn().session()
nfu_packages = {}
suite = get_suite(Options["Suite"].lower(), session)
+ if not suite:
+ utils.fubar("Cannot find suite %s" % Options["Suite"].lower())
+
suite_id = suite.suite_id
suite_name = suite.suite_name.lower()
if "nbs" in checks:
reportAllNBS(suite_name, suite_id, session)
+ if "outdated non-free" in checks:
+ report_outdated_nonfree(suite_name, session)
+
bin_not_built = {}
if "bnb" in checks:
bins_in_suite = get_suite_binaries(suite, session)
# Checks based on the Sources files
- components = cnf.ValueList("Suite::%s::Components" % (suite_name))
+ components = get_component_names(session)
for component in components:
filename = "%s/dists/%s/%s/source/Sources.gz" % (cnf["Dir::Root"], suite_name, component)
# apt_pkg.ParseTagFile needs a real file handle and can't handle a GzipFile instance...
if source == "":
source = package
if bin2source.has_key(package) and \
- apt_pkg.VersionCompare(version, bin2source[package]["version"]) > 0:
+ apt_pkg.version_compare(version, bin2source[package]["version"]) > 0:
bin2source[package]["version"] = version
bin2source[package]["source"] = source
else:
for source in nbs.keys():
for package in nbs[source].keys():
versions = nbs[source][package].keys()
- versions.sort(apt_pkg.VersionCompare)
+ versions.sort(apt_pkg.version_compare)
latest_version = versions.pop()
source_version = source_versions.get(source,"0")
- if apt_pkg.VersionCompare(latest_version, source_version) == 0:
+ if apt_pkg.version_compare(latest_version, source_version) == 0:
add_nbs(dubious_nbs, source, latest_version, package, suite_id, session)
if "nviu" in checks: