X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=melanie;h=5d0efde9a0b7473c8b0bab9c3378941df435eee1;hb=cabe09b4d162c7f680b07863cc043359545dabdd;hp=aa7bd05e9d3ff9be1836ec4728efb7a8ad1b0ef1;hpb=c862e435b16bcebb9d8c25fecb6064f4dfba1d01;p=dak.git diff --git a/melanie b/melanie index aa7bd05e..5d0efde9 100755 --- a/melanie +++ b/melanie @@ -1,8 +1,8 @@ #!/usr/bin/env python # General purpose package removal tool for ftpmaster -# Copyright (C) 2000, 2001 James Troup -# $Id: melanie,v 1.21 2002-01-28 18:53:01 troup Exp $ +# Copyright (C) 2000, 2001, 2002 James Troup +# $Id: melanie,v 1.29 2002-07-30 18:55:19 troup Exp $ # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,11 +18,29 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# X-Listening-To: Astronomy, Metallica - Garage Inc. +################################################################################ + +# o OpenBSD team wants to get changes incorporated into IPF. Darren no +# respond. +# o Ask again -> No respond. Darren coder supreme. +# o OpenBSD decide to make changes, but only in OpenBSD source +# tree. Darren hears, gets angry! Decides: "LICENSE NO ALLOW!" +# o Insert Flame War. +# o OpenBSD team decide to switch to different packet filter under BSD +# license. Because Project Goal: Every user should be able to make +# changes to source tree. IPF license bad!! +# o Darren try get back: says, NetBSD, FreeBSD allowed! MUAHAHAHAH!!! +# o Theo say: no care, pf much better than ipf! +# o Darren changes mind: changes license. But OpenBSD will not change +# back to ipf. Darren even much more bitter. +# o Darren so bitterbitter. Decides: I'LL GET BACK BY FORKING OPENBSD AND +# RELEASING MY OWN VERSION. HEHEHEHEHE. + +# http://slashdot.org/comments.pl?sid=26697&cid=2883271 ################################################################################ -import commands, os, pg, pwd, re, string, sys, tempfile +import commands, os, pg, re, string, sys, tempfile import utils, db_access import apt_pkg, apt_inst; @@ -64,8 +82,7 @@ ARCH, BUG#, COMPONENT and SUITE can be space seperated lists, e.g. # going to do now?" def game_over(): - print "Continue (y/N)? ", - answer = string.lower(utils.our_raw_input()); + answer = string.lower(utils.our_raw_input("Continue (y/N)? ")); if answer != "y": print "Aborted." sys.exit(1); @@ -139,71 +156,41 @@ def main (): else: utils.fubar("Invalid -C/--carbon-copy argument '%s'; not a bug number, 'package' or email address." % (copy_to)); - packages = {}; if Options["Binary-Only"]: field = "b.package"; else: field = "s.source"; - quoted_packages_list = [] - for package in arguments: - quoted_packages_list.append("'%s'" % package) - packages[package] = ""; - con_packages = "AND %s IN (%s)" % (field, string.join(quoted_packages_list, ", ")); - suites = []; - suite_ids_list = []; - for suite in string.split(Options["Suite"]): - - if not Options["No-Action"] and suite == "stable": - print "**WARNING** About to remove from the stable suite!" - print "This should only be done just prior to a (point) release and not at" - print "any other time." - game_over(); - elif not Options["No-Action"] and suite == "testing": - print "**WARNING About to remove from the testing suite!" - print "There's no need to do this normally as removals from unstable will" - print "propogate to testing automagically." - game_over(); - - suite_id = db_access.get_suite_id(suite); - if suite_id == -1: - utils.warn("suite '%s' not recognised." % (suite)); - else: - suites.append(suite); - suite_ids_list.append(suite_id); - if suite_ids_list: - suites_list = string.join(suites, ", ") - con_suites = "AND su.id IN (%s)" % string.join(map(str, suite_ids_list), ", "); - else: - utils.fubar("No correct suite given."); - if Options["Component"]: - components_ids_list = []; - for component in string.split(Options["Component"]): - component_id = db_access.get_component_id(component); - if component_id == -1: - utils.warn("component '%s' not recognised." % (component)); - else: - components_ids_list.append(component_id); - con_components = "AND c.id IN (%s)" % string.join(map(str, components_ids_list), ", "); - over_con_components = "AND component IN (%s)" % string.join(map(str, components_ids_list), ", "); - else: - con_components = ""; - over_con_components = ""; - - if Options["Architecture"]: - arch_ids_list = []; - for architecture in string.split(Options["Architecture"]): - architecture_id = db_access.get_architecture_id(architecture); - if architecture_id == -1: - utils.warn("architecture '%s' not recognised." % (architecture)); - else: - arch_ids_list.append(architecture_id); - if arch_ids_list: - con_architectures = "AND a.id IN (%s)" % string.join(map(str, arch_ids_list), ", "); - else: - utils.fubar("No correct architecture given"); - else: - con_architectures = ""; + con_packages = "AND %s IN (%s)" % (field, string.join(map(repr, arguments), ", ")); + (con_suites, con_architectures, con_components, check_source) = \ + utils.parse_args(Options); + + # Additional suite checks + suite_ids_list = []; + suites = string.split(Options["Suite"]); + suites_list = utils.join_with_commas_and(suites); + if not Options["No-Action"]: + for suite in suites: + suite_id = db_access.get_suite_id(suite); + if suite_id != -1: + suite_ids_list.append(suite_id); + if suite == "stable": + print "**WARNING** About to remove from the stable suite!" + print "This should only be done just prior to a (point) release and not at" + print "any other time." + game_over(); + elif suite == "testing": + print "**WARNING About to remove from the testing suite!" + print "There's no need to do this normally as removals from unstable will" + print "propogate to testing automagically." + game_over(); + + # Additional architecture checks + if Options["Architecture"] and check_source: + utils.warn("'source' in -a/--argument makes no sense and is ignored."); + + # Additional component processing + over_con_components = string.replace(con_components, "c.id", "component"); print "Working...", sys.stdout.flush(); @@ -238,7 +225,7 @@ def main (): for i in source_packages.keys(): filename = string.join(source_packages[i], '/'); try: - dsc = utils.parse_changes(filename, 0); + dsc = utils.parse_changes(filename); except utils.cant_open_exc: utils.warn("couldn't open '%s'." % (filename)); continue; @@ -260,6 +247,10 @@ def main (): to_remove.append(i[2:]); print "done." + if not to_remove: + print "Nothing to do." + sys.exit(0); + # If we don't have a reason; spawn an editor so the user can add one # Write the rejection email out as the .reason file if not Options["Reason"] and not Options["No-Action"]: @@ -377,7 +368,7 @@ def main (): Subst["__BCC__"] = "Bcc: " + string.join(bcc, ", "); else: Subst["__BCC__"] = "X-Filler: 42"; - Subst["__CC__"] = "X-Melanie: $Revision: 1.21 $"; + Subst["__CC__"] = "X-Melanie: $Revision: 1.29 $"; if carbon_copy: Subst["__CC__"] = Subst["__CC__"] + "\nCc: " + string.join(carbon_copy, ", "); Subst["__SUITE_LIST__"] = suites_list; @@ -391,7 +382,7 @@ def main (): Subst["__PRIMARY_MIRROR__"] = Archive["PrimaryMirror"]; for bug in string.split(Options["Done"]): Subst["__BUG_NUMBER__"] = bug; - mail_message = utils.TemplateSubst(Subst,open(Cnf["Dir::TemplatesDir"]+"/melanie.bug-close","r").read()); + mail_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/melanie.bug-close"); utils.send_mail (mail_message, "") logfile.write("=========================================================================\n");