From: Mark Hymers Date: Fri, 29 Jul 2011 07:31:42 +0000 (+0100) Subject: Remove old, broken and unused code X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9a1689ebec7e8fd9bcb16d14fa6a5adc8dfb731f;p=dak Remove old, broken and unused code Signed-off-by: Mark Hymers --- diff --git a/dak/check_proposed_updates.py b/dak/check_proposed_updates.py deleted file mode 100755 index d45fd489..00000000 --- a/dak/check_proposed_updates.py +++ /dev/null @@ -1,317 +0,0 @@ -#!/usr/bin/env python - -""" Dependency check proposed-updates """ -# Copyright (C) 2001, 2002, 2004, 2006 James Troup - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -################################################################################ - -# | > amd64 is more mature than even some released architectures -# | -# | This might be true of the architecture, unfortunately it seems to be the -# | exact opposite for most of the people involved with it. -# -# <1089213290.24029.6.camel@descent.netsplit.com> - -################################################################################ - -import sys, os -import apt_pkg, apt_inst - -from daklib.dbconn import * -from daklib.config import Config -from daklib import utils -from daklib.regexes import re_no_epoch - -################################################################################ - -Options = None -stable = {} -stable_virtual = {} -architectures = None - -################################################################################ - -def usage (exit_code=0): - print """Usage: dak check-proposed-updates [OPTION] [...] -(Very) Basic dependency checking for proposed-updates. - - -q, --quiet be quieter about what is being done - -v, --verbose be more verbose about what is being done - -h, --help show this help and exit - -Need either changes files, deb files or an admin.txt file with a '.joey' suffix.""" - sys.exit(exit_code) - -################################################################################ - -def d_test (dict, key, positive, negative): - if not dict: - return negative - if dict.has_key(key): - return positive - else: - return negative - -################################################################################ - -def check_dep (depends, dep_type, check_archs, filename, files): - pkg_unsat = 0 - for arch in check_archs: - for parsed_dep in apt_pkg.ParseDepends(depends): - unsat = [] - for atom in parsed_dep: - (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 - # 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 - # As part of the same .changes? - epochless_version = re_no_epoch.sub('', version) - 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 - # 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]) - else: - error += "%s:-:-" % (dep) - else: - error += "-:-:-" - error += ", Virtual: " - if stable_virtual.has_key(dep): - if stable_virtual[dep].has_key(arch): - error += "%s:%s" % (dep, arch) - else: - error += "%s:-" - else: - error += "-:-" - error += ", Upload: " - if files.has_key(dep_filename): - error += "yes" - else: - 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)) - for error in unsat: - sys.stderr.write(" %s\n" % (error)) - pkg_unsat = 1 - - return pkg_unsat - -def check_package(filename, files): - try: - 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) - if pkg_arch == "all": - check_archs = architectures - else: - check_archs = [pkg_arch] - - pkg_unsat = 0 - if Pre_Depends: - 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) - #if Recommends: - #pkg_unsat += check_dep(Recommends, "recommendation", check_archs, base_file, files) - - return pkg_unsat - -################################################################################ - -def pass_fail (filename, result): - if not Options["quiet"]: - print "%s:" % (os.path.basename(filename)), - if result: - print "FAIL" - else: - print "ok" - -################################################################################ - -def check_changes (filename): - cnf = Config() - - try: - changes = utils.parse_changes(filename) - files = utils.build_file_list(changes) - except ChangesUnicodeError: - utils.warn("Improperly encoded changes file, not utf-8") - return - except: - utils.warn("Error parsing changes file '%s'" % (filename)) - return - - result = 0 - - # Move to the pool directory - cwd = os.getcwd() - f = files.keys()[0] - pool_dir = cnf["Dir::Pool"] + '/' + utils.poolify(changes["source"], files[f]["component"]) - os.chdir(pool_dir) - - changes_result = 0 - for f in files.keys(): - if f.endswith(".deb"): - result = check_package(f, files) - if Options["verbose"]: - pass_fail(f, result) - changes_result += result - - pass_fail (filename, changes_result) - - # Move back - os.chdir(cwd) - -################################################################################ - -def check_deb (filename): - result = check_package(filename, {}) - pass_fail(filename, result) - - -################################################################################ - -def check_joey (filename): - cnf = Config() - - f = utils.open_file(filename) - - cwd = os.getcwd() - os.chdir("%s/dists/proposed-updates" % (cnf["Dir::Root"])) - - for line in f.readlines(): - line = line.rstrip() - if line.find('install') != -1: - split_line = line.split() - if len(split_line) != 2: - 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)) - changes_filename = split_line[1] - if Options["debug"]: - print "Processing %s..." % (changes_filename) - check_changes(changes_filename) - f.close() - - os.chdir(cwd) - -################################################################################ - -def parse_packages(): - global stable, stable_virtual, architectures - - cnf = Config() - - # Parse the Packages files (since it's a sub-second operation on auric) - suite = "stable" - stable = {} - components = get_component_names() - architectures = [ a.arch_string for a in get_suite_architectures(suite, skipsrc=True, skipall=True) ] - 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) - while Packages.Step(): - 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 - if provides: - for virtual_pkg in provides.split(","): - virtual_pkg = virtual_pkg.strip() - if not stable_virtual.has_key(virtual_pkg): - stable_virtual[virtual_pkg] = {} - stable_virtual[virtual_pkg][architecture] = "NA" - packages.close() - -################################################################################ - -def main (): - global Options - - cnf = Config() - - Arguments = [('d', "debug", "Check-Proposed-Updates::Options::Debug"), - ('q',"quiet","Check-Proposed-Updates::Options::Quiet"), - ('v',"verbose","Check-Proposed-Updates::Options::Verbose"), - ('h',"help","Check-Proposed-Updates::Options::Help")] - for i in [ "debug", "quiet", "verbose", "help" ]: - if not cnf.has_key("Check-Proposed-Updates::Options::%s" % (i)): - cnf["Check-Proposed-Updates::Options::%s" % (i)] = "" - - arguments = apt_pkg.ParseCommandLine(cnf.Cnf, Arguments, sys.argv) - Options = cnf.SubTree("Check-Proposed-Updates::Options") - - if Options["Help"]: - usage(0) - if not arguments: - utils.fubar("need at least one package name as an argument.") - - DBConn() - - print "Parsing packages files...", - parse_packages() - print "done." - - for f in arguments: - if f.endswith(".changes"): - check_changes(f) - elif f.endswith(".deb"): - check_deb(f) - elif f.endswith(".joey"): - check_joey(f) - else: - utils.fubar("Unrecognised file type: '%s'." % (f)) - -####################################################################################### - -if __name__ == '__main__': - main() diff --git a/dak/clean_proposed_updates.py b/dak/clean_proposed_updates.py deleted file mode 100755 index 7733e7a0..00000000 --- a/dak/clean_proposed_updates.py +++ /dev/null @@ -1,203 +0,0 @@ -#!/usr/bin/env python - -""" Remove obsolete .changes files from proposed-updates """ -# Copyright (C) 2001, 2002, 2003, 2004, 2006, 2008 James Troup - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -################################################################################ - -import os, sys -import apt_pkg - -from daklib.dbconn import * -from daklib.config import Config -from daklib import utils -from daklib.regexes import re_isdeb, re_isadeb, re_issource, re_no_epoch - -################################################################################ - -Options = None -pu = {} - -################################################################################ - -def usage (exit_code=0): - print """Usage: dak clean-proposed-updates [OPTION] [...] -Remove obsolete changes files from proposed-updates. - - -v, --verbose be more verbose about what is being done - -h, --help show this help and exit - -Need either changes files or an admin.txt file with a '.joey' suffix.""" - sys.exit(exit_code) - -################################################################################ - -def check_changes (filename): - cnf = Config() - - try: - 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()) - for f in files.keys(): - if re_isadeb.match(f): - m = re_isdeb.match(f) - pkg = m.group(1) - version = m.group(2) - arch = m.group(3) - if Options["debug"]: - print "BINARY: %s ==> %s_%s_%s" % (f, pkg, version, arch) - else: - m = re_issource.match(f) - if m: - pkg = m.group(1) - version = m.group(2) - ftype = m.group(3) - if ftype != "dsc": - del files[f] - num_files -= 1 - continue - arch = "source" - if Options["debug"]: - print "SOURCE: %s ==> %s_%s_%s" % (f, pkg, version, arch) - else: - utils.fubar("unknown type, fix me") - if not pu.has_key(pkg): - # FIXME - utils.warn("%s doesn't seem to exist in %s?? (from %s [%s])" % (pkg, Options["suite"], f, filename)) - continue - if not pu[pkg].has_key(arch): - # FIXME - utils.warn("%s doesn't seem to exist for %s in %s?? (from %s [%s])" % (pkg, arch, Options["suite"], f, filename)) - continue - pu_version = re_no_epoch.sub('', pu[pkg][arch]) - if pu_version == version: - if Options["verbose"]: - print "%s: ok" % (f) - else: - if Options["verbose"]: - print "%s: superseded, removing. [%s]" % (f, pu_version) - del files[f] - - 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/" - if not Options["no-action"]: - utils.move(filename, dest) - elif new_num_files < num_files: - print "%s: lost files, MWAAP." % (filename) - else: - if Options["verbose"]: - print "%s: ok" % (filename) - -################################################################################ - -def check_joey (filename): - cnf = Config() - - f = utils.open_file(filename) - - cwd = os.getcwd() - os.chdir("%s/dists/%s" % (cnf["Dir::Root"]), Options["suite"]) - - for line in f.readlines(): - line = line.rstrip() - if line.find('install') != -1: - split_line = line.split() - if len(split_line) != 2: - 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)) - changes_filename = split_line[1] - if Options["debug"]: - print "Processing %s..." % (changes_filename) - check_changes(changes_filename) - - os.chdir(cwd) - -################################################################################ - -def init_pu (): - global pu - - q = DBConn().session().execute(""" -SELECT b.package, b.version, a.arch_string - FROM bin_associations ba, binaries b, suite su, architecture a - WHERE b.id = ba.bin AND ba.suite = su.id - AND su.suite_name = :suite_name AND a.id = b.architecture -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 = :suite_name -ORDER BY package, version, arch_string -""" % {'suite_name': Options["suite"]}) - - for i in q.fetchall(): - pkg = i[0] - version = i[1] - arch = i[2] - if not pu.has_key(pkg): - pu[pkg] = {} - pu[pkg][arch] = version - -def main (): - global Options - - cnf = Config() - - Arguments = [('d', "debug", "Clean-Proposed-Updates::Options::Debug"), - ('v', "verbose", "Clean-Proposed-Updates::Options::Verbose"), - ('h', "help", "Clean-Proposed-Updates::Options::Help"), - ('s', "suite", "Clean-Proposed-Updates::Options::Suite", "HasArg"), - ('n', "no-action", "Clean-Proposed-Updates::Options::No-Action"),] - for i in [ "debug", "verbose", "help", "no-action" ]: - if not cnf.has_key("Clean-Proposed-Updates::Options::%s" % (i)): - cnf["Clean-Proposed-Updates::Options::%s" % (i)] = "" - - # suite defaults to proposed-updates - if not cnf.has_key("Clean-Proposed-Updates::Options::Suite"): - cnf["Clean-Proposed-Updates::Options::Suite"] = "proposed-updates" - - arguments = apt_pkg.ParseCommandLine(cnf.Cnf, Arguments, sys.argv) - Options = cnf.SubTree("Clean-Proposed-Updates::Options") - - if Options["Help"]: - usage(0) - if not arguments: - utils.fubar("need at least one package name as an argument.") - - DBConn() - - init_pu() - - for f in arguments: - if f.endswith(".changes"): - check_changes(f) - elif f.endswith(".joey"): - check_joey(f) - else: - utils.fubar("Unrecognised file type: '%s'." % (f)) - -####################################################################################### - -if __name__ == '__main__': - main() diff --git a/dak/dak.py b/dak/dak.py index 2a3c2308..4d9ac076 100755 --- a/dak/dak.py +++ b/dak/dak.py @@ -98,15 +98,11 @@ def init(): "Clean and update metadata for build queues"), ("clean-queues", "Clean cruft from incoming"), - ("clean-proposed-updates", - "Remove obsolete .changes from proposed-updates"), ("transitions", "Manage the release transition file"), ("check-overrides", "Override cruft checks"), - ("check-proposed-updates", - "Dependency checking for proposed-updates"), ("control-overrides", "Manipulate/list override entries in bulk"), ("control-suite", diff --git a/docs/README.first b/docs/README.first index 86cb73cd..10fcde93 100644 --- a/docs/README.first +++ b/docs/README.first @@ -74,9 +74,6 @@ Mostly Debian(.org) specific ---------------------------- o dak security-install - wrapper for Debian security team -o dak clean-proposed-updates - removes obsolete .changes files from proposed-updates -o dak check-proposed-updates - basic dependency checking for proposed-updates -o dak reject-proposed-updates - manually reject packages from proposed-updates o dak import-ldap-fingerprints - syncs fingerprint and uid information with a debian.org LDAP DB Very Incomplete or otherwise not generally useful diff --git a/docs/TODO.old b/docs/TODO.old index d31d85e8..717b89eb 100644 --- a/docs/TODO.old +++ b/docs/TODO.old @@ -11,10 +11,6 @@ Others ------ - o 'dak reject-proposed-updates' should only start an editor once to - capture a message; it will usually be the same message for all - files on the same command line. - o drop map-unreleased o check email only portions of addresses match too, iff the names @@ -67,16 +63,6 @@ Others o 'dak control-suite' should have a diff mode that accepts diff output! - o 'dak clean-proposed-updates' doesn't deal with 'dak rm'-d - packages, partial replacements etc. and more. - - o 'dak reject-proposed-updates' blindly deletes with no check that - the delete failed which it might well given we only look for - package/version, not package/version _in p-u_. duh. - - o 'dak rm' should remove obsolete changes when removing from p-u, or - at least warn. or 'dak reject-proposed-updates' should handle it. - o 'dak process-unchecked' crashes if run as a user in -n mode when orig.tar.gz is in queue/new... @@ -104,11 +90,6 @@ Others null and s.name linked from it != the source given in -S/--source-and-binary ignore. - o 'dak reject-proposed-updates' sucks; it should a) only spam d-i - for sourceful rejections, b) sort stuff so it rejects sourceful - stuff first. the non-sourceful should probably get a form mail, c) - automate the non-sourceful stuff (see b). - o 'dak process-unchecked' should do q-d stuff for faster AA [ryan] o split the morgue into source and binary so binaries can be purged first! @@ -120,8 +101,6 @@ Others o 'dak init-archive' shouldn't be using location, it should run down suites instead - o 'dak clean-proposed-updates' needs to know about udebs - o by default hamstring dak's mail sending so that it won't send anything until someone edits a script; it's been used far too much to send spam atm :( @@ -302,9 +281,6 @@ Less Urgent o check linking of .tar.gz's to .dsc's.. see proftpd 1.2.1 as an example o archive needs md5sum'ed regularly, but takes too long to do all in one go; make progressive or weekly. - o something needs to clear out .changes files from p-u when - removing stuff superseded by newer versions. [but for now we have - 'dak clean-proposed-updates'] o test sig checking stuff in test/ (stupid thing is not modularized due to global abuse) o when encountering suspicous things (e.g. file tainting) do something more drastic @@ -360,8 +336,6 @@ Packaging ----------------------------------------------------------------------------- check-archive X check-overrides X X -check-proposed-updates X -clean-proposed-updates X clean-queues X clean-suites X X compare-suites X