3 """ General purpose package removal tool for ftpmaster """
4 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 James Troup <james@nocrew.org>
5 # Copyright (C) 2010 Alexander Reichle-Schmehl <tolimar@debian.org>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 ################################################################################
23 # o OpenBSD team wants to get changes incorporated into IPF. Darren no
25 # o Ask again -> No respond. Darren coder supreme.
26 # o OpenBSD decide to make changes, but only in OpenBSD source
27 # tree. Darren hears, gets angry! Decides: "LICENSE NO ALLOW!"
29 # o OpenBSD team decide to switch to different packet filter under BSD
30 # license. Because Project Goal: Every user should be able to make
31 # changes to source tree. IPF license bad!!
32 # o Darren try get back: says, NetBSD, FreeBSD allowed! MUAHAHAHAH!!!
33 # o Theo say: no care, pf much better than ipf!
34 # o Darren changes mind: changes license. But OpenBSD will not change
35 # back to ipf. Darren even much more bitter.
36 # o Darren so bitterbitter. Decides: I'LL GET BACK BY FORKING OPENBSD AND
37 # RELEASING MY OWN VERSION. HEHEHEHEHE.
39 # http://slashdot.org/comments.pl?sid=26697&cid=2883271
41 ################################################################################
50 from daklib.config import Config
51 from daklib.dbconn import *
52 from daklib import utils
53 from daklib.dak_exceptions import *
54 from daklib.regexes import re_strip_source_version, re_build_dep_arch
55 import debianbts as bts
57 ################################################################################
61 ################################################################################
63 def usage (exit_code=0):
64 print """Usage: dak rm [OPTIONS] PACKAGE[...]
65 Remove PACKAGE(s) from suite(s).
67 -a, --architecture=ARCH only act on this architecture
68 -b, --binary remove binaries only
69 -c, --component=COMPONENT act on this component
70 -C, --carbon-copy=EMAIL send a CC of removal message to EMAIL
71 -d, --done=BUG# send removal message as closure to bug#
72 -D, --do-close also close all bugs associated to that package
73 -h, --help show this help and exit
74 -m, --reason=MSG reason for removal
75 -n, --no-action don't do anything
76 -p, --partial don't affect override files
77 -R, --rdep-check check reverse dependencies
78 -s, --suite=SUITE act on this suite
79 -S, --source-only remove source only
81 ARCH, BUG#, COMPONENT and SUITE can be comma (or space) separated lists, e.g.
82 --architecture=amd64,i386"""
86 ################################################################################
88 # "Hudson: What that's great, that's just fucking great man, now what
89 # the fuck are we supposed to do? We're in some real pretty shit now
90 # man...That's it man, game over man, game over, man! Game over! What
91 # the fuck are we gonna do now? What are we gonna do?"
94 answer = utils.our_raw_input("Continue (y/N)? ").lower()
99 ################################################################################
101 def reverse_depends_check(removals, suites, arches=None):
104 print "Checking reverse dependencies..."
105 components = cnf.ValueList("Suite::%s::Components" % suites[0])
110 all_arches = set(arches)
112 all_arches = set([x.arch_string for x in get_suite_architectures(suites[0])])
113 all_arches -= set(["source", "all"])
114 for architecture in all_arches:
117 virtual_packages = {}
118 for component in components:
119 filename = "%s/dists/%s/%s/binary-%s/Packages.gz" % (cnf["Dir::Root"], suites[0], component, architecture)
120 # apt_pkg.ParseTagFile needs a real file handle and can't handle a GzipFile instance...
121 (fd, temp_filename) = utils.temp_filename()
122 (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename))
124 utils.fubar("Gunzip invocation failed!\n%s\n" % (output), result)
125 # Also check for udebs
126 filename = "%s/dists/%s/%s/debian-installer/binary-%s/Packages.gz" % (cnf["Dir::Root"], suites[0], component, architecture)
127 if os.path.exists(filename):
128 (result, output) = commands.getstatusoutput("gunzip -c %s >> %s" % (filename, temp_filename))
130 utils.fubar("Gunzip invocation failed!\n%s\n" % (output), result)
131 packages = utils.open_file(temp_filename)
132 Packages = apt_pkg.ParseTagFile(packages)
133 while Packages.Step():
134 package = Packages.Section.Find("Package")
135 source = Packages.Section.Find("Source")
139 source = source.split(' ', 1)[0]
140 sources[package] = source
141 depends = Packages.Section.Find("Depends")
143 deps[package] = depends
144 provides = Packages.Section.Find("Provides")
145 # Maintain a counter for each virtual package. If a
146 # Provides: exists, set the counter to 0 and count all
147 # provides by a package not in the list for removal.
148 # If the counter stays 0 at the end, we know that only
149 # the to-be-removed packages provided this virtual
152 for virtual_pkg in provides.split(","):
153 virtual_pkg = virtual_pkg.strip()
154 if virtual_pkg == package: continue
155 if not virtual_packages.has_key(virtual_pkg):
156 virtual_packages[virtual_pkg] = 0
157 if package not in removals:
158 virtual_packages[virtual_pkg] += 1
159 p2c[package] = component
161 os.unlink(temp_filename)
163 # If a virtual package is only provided by the to-be-removed
164 # packages, treat the virtual package as to-be-removed too.
165 for virtual_pkg in virtual_packages.keys():
166 if virtual_packages[virtual_pkg] == 0:
167 removals.append(virtual_pkg)
169 # Check binary dependencies (Depends)
170 for package in deps.keys():
171 if package in removals: continue
174 parsed_dep += apt_pkg.ParseDepends(deps[package])
175 except ValueError, e:
176 print "Error for package %s: %s" % (package, e)
177 for dep in parsed_dep:
178 # Check for partial breakage. If a package has a ORed
179 # dependency, there is only a dependency problem if all
180 # packages in the ORed depends will be removed.
182 for dep_package, _, _ in dep:
183 if dep_package in removals:
185 if unsat == len(dep):
186 component = p2c[package]
187 source = sources[package]
188 if component != "main":
189 source = "%s/%s" % (source, component)
190 all_broken.setdefault(source, {}).setdefault(package, set()).add(architecture)
194 print "# Broken Depends:"
195 for source, bindict in sorted(all_broken.items()):
197 for binary, arches in sorted(bindict.items()):
198 if arches == all_arches:
201 lines.append('%s [%s]' % (binary, ' '.join(sorted(arches))))
202 print '%s: %s' % (source, lines[0])
203 for line in lines[1:]:
204 print ' ' * (len(source) + 2) + line
207 # Check source dependencies (Build-Depends and Build-Depends-Indep)
209 for component in components:
210 filename = "%s/dists/%s/%s/source/Sources.gz" % (cnf["Dir::Root"], suites[0], component)
211 # apt_pkg.ParseTagFile needs a real file handle and can't handle a GzipFile instance...
212 (fd, temp_filename) = utils.temp_filename()
213 result, output = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename))
215 sys.stderr.write("Gunzip invocation failed!\n%s\n" % (output))
217 sources = utils.open_file(temp_filename, "r")
218 Sources = apt_pkg.ParseTagFile(sources)
219 while Sources.Step():
220 source = Sources.Section.Find("Package")
221 if source in removals: continue
223 for build_dep_type in ["Build-Depends", "Build-Depends-Indep"]:
224 build_dep = Sources.Section.get(build_dep_type)
226 # Remove [arch] information since we want to see breakage on all arches
227 build_dep = re_build_dep_arch.sub("", build_dep)
229 parsed_dep += apt_pkg.ParseDepends(build_dep)
230 except ValueError, e:
231 print "Error for source %s: %s" % (source, e)
232 for dep in parsed_dep:
234 for dep_package, _, _ in dep:
235 if dep_package in removals:
237 if unsat == len(dep):
238 if component != "main":
239 source = "%s/%s" % (source, component)
240 all_broken.setdefault(source, set()).add(utils.pp_deps(dep))
243 os.unlink(temp_filename)
246 print "# Broken Build-Depends:"
247 for source, bdeps in sorted(all_broken.items()):
248 bdeps = sorted(bdeps)
249 print '%s: %s' % (source, bdeps[0])
250 for bdep in bdeps[1:]:
251 print ' ' * (len(source) + 2) + bdep
255 print "Dependency problem found."
256 if not Options["No-Action"]:
259 print "No dependency problem found."
262 ################################################################################
269 Arguments = [('h',"help","Rm::Options::Help"),
270 ('a',"architecture","Rm::Options::Architecture", "HasArg"),
271 ('b',"binary", "Rm::Options::Binary-Only"),
272 ('c',"component", "Rm::Options::Component", "HasArg"),
273 ('C',"carbon-copy", "Rm::Options::Carbon-Copy", "HasArg"), # Bugs to Cc
274 ('d',"done","Rm::Options::Done", "HasArg"), # Bugs fixed
275 ('D',"do-close","Rm::Options::Do-Close"),
276 ('R',"rdep-check", "Rm::Options::Rdep-Check"),
277 ('m',"reason", "Rm::Options::Reason", "HasArg"), # Hysterical raisins; -m is old-dinstall option for rejection reason
278 ('n',"no-action","Rm::Options::No-Action"),
279 ('p',"partial", "Rm::Options::Partial"),
280 ('s',"suite","Rm::Options::Suite", "HasArg"),
281 ('S',"source-only", "Rm::Options::Source-Only"),
284 for i in [ "architecture", "binary-only", "carbon-copy", "component",
285 "done", "help", "no-action", "partial", "rdep-check", "reason",
286 "source-only", "Do-Close" ]:
287 if not cnf.has_key("Rm::Options::%s" % (i)):
288 cnf["Rm::Options::%s" % (i)] = ""
289 if not cnf.has_key("Rm::Options::Suite"):
290 cnf["Rm::Options::Suite"] = "unstable"
292 arguments = apt_pkg.ParseCommandLine(cnf.Cnf, Arguments, sys.argv)
293 Options = cnf.SubTree("Rm::Options")
298 session = DBConn().session()
300 # Sanity check options
302 utils.fubar("need at least one package name as an argument.")
303 if Options["Architecture"] and Options["Source-Only"]:
304 utils.fubar("can't use -a/--architecture and -S/--source-only options simultaneously.")
305 if Options["Binary-Only"] and Options["Source-Only"]:
306 utils.fubar("can't use -b/--binary-only and -S/--source-only options simultaneously.")
307 if Options.has_key("Carbon-Copy") and not Options.has_key("Done"):
308 utils.fubar("can't use -C/--carbon-copy without also using -d/--done option.")
309 if Options["Architecture"] and not Options["Partial"]:
310 utils.warn("-a/--architecture implies -p/--partial.")
311 Options["Partial"] = "true"
312 if Options["Do-Close"] and not Options["Done"]:
314 if Options["Do-Close"] and Options["Binary-Only"]:
316 if Options["Do-Close"] and Options["Source-Only"]:
318 if Options["Do-Close"] and Options["Suite"] != 'unstable':
321 # Force the admin to tell someone if we're not doing a 'dak
322 # cruft-report' inspired removal (or closing a bug, which counts
323 # as telling someone).
324 if not Options["No-Action"] and not Options["Carbon-Copy"] \
325 and not Options["Done"] and Options["Reason"].find("[auto-cruft]") == -1:
326 utils.fubar("Need a -C/--carbon-copy if not closing a bug and not doing a cruft removal.")
328 # Process -C/--carbon-copy
330 # Accept 3 types of arguments (space separated):
331 # 1) a number - assumed to be a bug number, i.e. nnnnn@bugs.debian.org
332 # 2) the keyword 'package' - cc's $package@packages.debian.org for every argument
333 # 3) contains a '@' - assumed to be an email address, used unmofidied
336 for copy_to in utils.split_args(Options.get("Carbon-Copy")):
337 if copy_to.isdigit():
338 carbon_copy.append(copy_to + "@" + cnf["Dinstall::BugServer"])
339 elif copy_to == 'package':
340 for package in arguments:
341 carbon_copy.append(package + "@" + cnf["Dinstall::PackagesServer"])
342 if cnf.has_key("Dinstall::TrackingServer"):
343 carbon_copy.append(package + "@" + cnf["Dinstall::TrackingServer"])
345 carbon_copy.append(copy_to)
347 utils.fubar("Invalid -C/--carbon-copy argument '%s'; not a bug number, 'package' or email address." % (copy_to))
349 if Options["Binary-Only"]:
353 con_packages = "AND %s IN (%s)" % (field, ", ".join([ repr(i) for i in arguments ]))
355 (con_suites, con_architectures, con_components, check_source) = \
356 utils.parse_args(Options)
358 # Additional suite checks
360 suites = utils.split_args(Options["Suite"])
361 suites_list = utils.join_with_commas_and(suites)
362 if not Options["No-Action"]:
364 s = get_suite(suite, session=session)
366 suite_ids_list.append(s.suite_id)
367 if suite == "stable":
368 print "**WARNING** About to remove from the stable suite!"
369 print "This should only be done just prior to a (point) release and not at"
370 print "any other time."
372 elif suite == "testing":
373 print "**WARNING About to remove from the testing suite!"
374 print "There's no need to do this normally as removals from unstable will"
375 print "propogate to testing automagically."
378 # Additional architecture checks
379 if Options["Architecture"] and check_source:
380 utils.warn("'source' in -a/--argument makes no sense and is ignored.")
382 # Additional component processing
383 over_con_components = con_components.replace("c.id", "component")
390 # We have 3 modes of package selection: binary-only, source-only
391 # and source+binary. The first two are trivial and obvious; the
392 # latter is a nasty mess, but very nice from a UI perspective so
393 # we try to support it.
395 # XXX: TODO: This all needs converting to use placeholders or the object
396 # API. It's an SQL injection dream at the moment
398 if Options["Binary-Only"]:
400 q = session.execute("SELECT b.package, b.version, a.arch_string, b.id, b.maintainer FROM binaries b, bin_associations ba, architecture a, suite su, files f, location l, component c WHERE ba.bin = b.id AND ba.suite = su.id AND b.architecture = a.id AND b.file = f.id AND f.location = l.id AND l.component = c.id %s %s %s %s" % (con_packages, con_suites, con_components, con_architectures))
401 for i in q.fetchall():
406 q = session.execute("SELECT l.path, f.filename, s.source, s.version, 'source', s.id, s.maintainer FROM source s, src_associations sa, suite su, files f, location l, component c WHERE sa.source = s.id AND sa.suite = su.id AND s.file = f.id AND f.location = l.id AND l.component = c.id %s %s %s" % (con_packages, con_suites, con_components))
407 for i in q.fetchall():
408 source_packages[i[2]] = i[:2]
409 to_remove.append(i[2:])
410 if not Options["Source-Only"]:
413 # First get a list of binary package names we suspect are linked to the source
414 q = session.execute("SELECT DISTINCT b.package FROM binaries b, source s, src_associations sa, suite su, files f, location l, component c WHERE b.source = s.id AND sa.source = s.id AND sa.suite = su.id AND s.file = f.id AND f.location = l.id AND l.component = c.id %s %s %s" % (con_packages, con_suites, con_components))
415 for i in q.fetchall():
416 binary_packages[i[0]] = ""
417 # Then parse each .dsc that we found earlier to see what binary packages it thinks it produces
418 for i in source_packages.keys():
419 filename = "/".join(source_packages[i])
421 dsc = utils.parse_changes(filename, dsc_file=1)
422 except CantOpenError:
423 utils.warn("couldn't open '%s'." % (filename))
425 for package in dsc.get("binary").split(','):
426 package = package.strip()
427 binary_packages[package] = ""
428 # Then for each binary package: find any version in
429 # unstable, check the Source: field in the deb matches our
430 # source package and if so add it to the list of packages
432 for package in binary_packages.keys():
433 q = session.execute("SELECT l.path, f.filename, b.package, b.version, a.arch_string, b.id, b.maintainer FROM binaries b, bin_associations ba, architecture a, suite su, files f, location l, component c WHERE ba.bin = b.id AND ba.suite = su.id AND b.architecture = a.id AND b.file = f.id AND f.location = l.id AND l.component = c.id %s %s %s AND b.package = '%s'" % (con_suites, con_components, con_architectures, package))
434 for i in q.fetchall():
435 filename = "/".join(i[:2])
436 control = apt_pkg.ParseSection(apt_inst.debExtractControl(utils.open_file(filename)))
437 source = control.Find("Source", control.Find("Package"))
438 source = re_strip_source_version.sub('', source)
439 if source_packages.has_key(source):
440 to_remove.append(i[2:])
444 print "Nothing to do."
447 # If we don't have a reason; spawn an editor so the user can add one
448 # Write the rejection email out as the <foo>.reason file
449 if not Options["Reason"] and not Options["No-Action"]:
450 (fd, temp_filename) = utils.temp_filename()
451 editor = os.environ.get("EDITOR","vi")
452 result = os.system("%s %s" % (editor, temp_filename))
454 utils.fubar ("vi invocation failed for `%s'!" % (temp_filename), result)
455 temp_file = utils.open_file(temp_filename)
456 for line in temp_file.readlines():
457 Options["Reason"] += line
459 os.unlink(temp_filename)
461 # Generate the summary of what's to be removed
468 maintainers[maintainer] = ""
469 if not d.has_key(package):
471 if not d[package].has_key(version):
472 d[package][version] = []
473 if architecture not in d[package][version]:
474 d[package][version].append(architecture)
477 for maintainer_id in maintainers.keys():
478 maintainer_list.append(get_maintainer(maintainer_id).name)
483 for package in removals:
484 versions = d[package].keys()
485 versions.sort(apt_pkg.VersionCompare)
486 for version in versions:
487 d[package][version].sort(utils.arch_compare_sw)
488 summary += "%10s | %10s | %s\n" % (package, version, ", ".join(d[package][version]))
489 print "Will remove the following packages from %s:" % (suites_list)
492 print "Maintainer: %s" % ", ".join(maintainer_list)
494 print "Will also close bugs: "+Options["Done"]
496 print "Will also send CCs to: " + ", ".join(carbon_copy)
497 if Options["Do-Close"]:
498 print "Will also close associated bug reports."
500 print "------------------- Reason -------------------"
501 print Options["Reason"]
502 print "----------------------------------------------"
505 if Options["Rdep-Check"]:
506 arches = utils.split_args(Options["Architecture"])
507 reverse_depends_check(removals, suites, arches)
509 # If -n/--no-action, drop out here
510 if Options["No-Action"]:
513 print "Going to remove the packages now."
516 whoami = utils.whoami()
517 date = commands.getoutput('date -R')
519 # Log first; if it all falls apart I want a record that we at least tried.
520 logfile = utils.open_file(cnf["Rm::LogFile"], 'a')
521 logfile.write("=========================================================================\n")
522 logfile.write("[Date: %s] [ftpmaster: %s]\n" % (date, whoami))
523 logfile.write("Removed the following packages from %s:\n\n%s" % (suites_list, summary))
525 logfile.write("Closed bugs: %s\n" % (Options["Done"]))
526 logfile.write("\n------------------- Reason -------------------\n%s\n" % (Options["Reason"]))
527 logfile.write("----------------------------------------------\n")
529 # Do the same in rfc822 format
530 logfile822 = utils.open_file(cnf["Rm::LogFile822"], 'a')
531 logfile822.write("Date: %s\n" % date)
532 logfile822.write("Ftpmaster: %s\n" % whoami)
533 logfile822.write("Suite: %s\n" % suites_list)
536 for package in summary.split("\n"):
537 for row in package.split("\n"):
538 element = row.split("|")
539 if len(element) == 3:
540 if element[2].find("source") > 0:
541 sources.append("%s_%s" % tuple(elem.strip(" ") for elem in element[:2]))
542 element[2] = sub("source\s?,?", "", element[2]).strip(" ")
544 binaries.append("%s_%s [%s]" % tuple(elem.strip(" ") for elem in element))
546 logfile822.write("Sources:\n")
547 for source in sources:
548 logfile822.write(" %s\n" % source)
550 logfile822.write("Binaries:\n")
551 for binary in binaries:
552 logfile822.write(" %s\n" % binary)
553 logfile822.write("Reason: %s\n" % Options["Reason"].replace('\n', '\n '))
555 logfile822.write("Bug: %s\n" % Options["Done"])
557 dsc_type_id = get_override_type('dsc', session).overridetype_id
558 deb_type_id = get_override_type('deb', session).overridetype_id
560 # Do the actual deletion
568 for suite_id in suite_ids_list:
569 if architecture == "source":
570 session.execute("DELETE FROM src_associations WHERE source = :packageid AND suite = :suiteid",
571 {'packageid': package_id, 'suiteid': suite_id})
572 #print "DELETE FROM src_associations WHERE source = %s AND suite = %s" % (package_id, suite_id)
574 session.execute("DELETE FROM bin_associations WHERE bin = :packageid AND suite = :suiteid",
575 {'packageid': package_id, 'suiteid': suite_id})
576 #print "DELETE FROM bin_associations WHERE bin = %s AND suite = %s" % (package_id, suite_id)
577 # Delete from the override file
578 if not Options["Partial"]:
579 if architecture == "source":
580 type_id = dsc_type_id
582 type_id = deb_type_id
583 # TODO: Again, fix this properly to remove the remaining non-bind argument
584 session.execute("DELETE FROM override WHERE package = :package AND type = :typeid AND suite = :suiteid %s" % (over_con_components), {'package': package, 'typeid': type_id, 'suiteid': suite_id})
588 # read common subst variables for all bug closure mails
590 Subst_common["__RM_ADDRESS__"] = cnf["Dinstall::MyEmailAddress"]
591 Subst_common["__BUG_SERVER__"] = cnf["Dinstall::BugServer"]
592 Subst_common["__CC__"] = "X-DAK: dak rm"
594 Subst_common["__CC__"] += "\nCc: " + ", ".join(carbon_copy)
595 Subst_common["__SUITE_LIST__"] = suites_list
596 Subst_common["__SUBJECT__"] = "Removed package(s) from %s" % (suites_list)
597 Subst_common["__ADMIN_ADDRESS__"] = cnf["Dinstall::MyAdminAddress"]
598 Subst_common["__DISTRO__"] = cnf["Dinstall::MyDistribution"]
599 Subst_common["__WHOAMI__"] = whoami
601 # Send the bug closing messages
603 Subst_close_rm = Subst_common
605 if cnf.Find("Dinstall::Bcc") != "":
606 bcc.append(cnf["Dinstall::Bcc"])
607 if cnf.Find("Rm::Bcc") != "":
608 bcc.append(cnf["Rm::Bcc"])
610 Subst_close_rm["__BCC__"] = "Bcc: " + ", ".join(bcc)
612 Subst_close_rm["__BCC__"] = "X-Filler: 42"
613 summarymail = "%s\n------------------- Reason -------------------\n%s\n" % (summary, Options["Reason"])
614 summarymail += "----------------------------------------------\n"
615 Subst_close_rm["__SUMMARY__"] = summarymail
616 whereami = utils.where_am_i()
617 Archive = cnf.SubTree("Archive::%s" % (whereami))
618 Subst_close_rm["__MASTER_ARCHIVE__"] = Archive["OriginServer"]
619 Subst_close_rm["__PRIMARY_MIRROR__"] = Archive["PrimaryMirror"]
620 for bug in utils.split_args(Options["Done"]):
621 Subst_close_rm["__BUG_NUMBER__"] = bug
622 if Options["Do-Close"]:
623 mail_message = utils.TemplateSubst(Subst_close_rm,cnf["Dir::Templates"]+"/rm.bug-close-with-related")
625 mail_message = utils.TemplateSubst(Subst_close_rm,cnf["Dir::Templates"]+"/rm.bug-close")
626 utils.send_mail(mail_message)
628 # close associated bug reports
629 if Options["Do-Close"]:
630 Subst_close_other = Subst_common
632 wnpp = utils.parse_wnpp_bug_file()
633 if len(versions) == 1:
634 Subst_close_other["__VERSION__"] = versions[0]
636 utils.fubar("Closing bugs with multiple package versions is not supported. Do it yourself.")
638 Subst_close_other["__BCC__"] = "Bcc: " + ", ".join(bcc)
640 Subst_close_other["__BCC__"] = "X-Filler: 42"
641 # at this point, I just assume, that the first closed bug gives
642 # some useful information on why the package got removed
643 Subst_close_other["__BUG_NUMBER__"] = utils.split_args(Options["Done"])[0]
644 if len(sources) == 1:
645 source_pkg = source.split("_", 1)[0]
647 utils.fubar("Closing bugs for multiple source pakcages is not supported. Do it yourself.")
648 Subst_close_other["__BUG_NUMBER_ALSO__"] = ""
649 Subst_close_other["__SOURCE__"] = source_pkg
650 other_bugs = bts.get_bugs('src', source_pkg, 'status', 'open')
652 logfile.write("Also closing bug(s):")
653 logfile822.write("Also-Bugs:")
654 for bug in other_bugs:
655 Subst_close_other["__BUG_NUMBER_ALSO__"] += str(bug) + "-done@" + cnf["Dinstall::BugServer"] + ","
656 logfile.write(" " + str(bug))
657 logfile822.write(" " + str(bug))
659 logfile822.write("\n")
660 if source_pkg in wnpp.keys():
661 logfile.write("Also closing WNPP bug(s):")
662 logfile822.write("Also-WNPP:")
663 for bug in wnpp[source_pkg]:
664 # the wnpp-rm file we parse also contains our removal
665 # bugs, filtering that out
666 if bug != Subst_close_other["__BUG_NUMBER__"]:
667 Subst_close_other["__BUG_NUMBER_ALSO__"] += str(bug) + "-done@" + cnf["Dinstall::BugServer"] + ","
668 logfile.write(" " + str(bug))
669 logfile822.write(" " + str(bug))
671 logfile822.write("\n")
673 mail_message = utils.TemplateSubst(Subst_close_other,cnf["Dir::Templates"]+"/rm.bug-close-related")
674 if Subst_close_other["__BUG_NUMBER_ALSO__"]:
675 utils.send_mail(mail_message)
678 logfile.write("=========================================================================\n")
681 logfile822.write("\n")
684 #######################################################################################
686 if __name__ == '__main__':