]> git.decadent.org.uk Git - dak.git/blob - dak/rm.py
Use check_reverse_depends function from utils
[dak.git] / dak / rm.py
1 #!/usr/bin/env python
2
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>
6
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.
11
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.
16
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
20
21 ################################################################################
22
23 # o OpenBSD team wants to get changes incorporated into IPF. Darren no
24 #    respond.
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!"
28 # o Insert Flame War.
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.
38
39 #                        http://slashdot.org/comments.pl?sid=26697&cid=2883271
40
41 ################################################################################
42
43 import commands
44 import os
45 import sys
46 import apt_pkg
47 import apt_inst
48 from re import sub
49
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_bin_only_nmu
55 import debianbts as bts
56
57 ################################################################################
58
59 Options = None
60
61 ################################################################################
62
63 def usage (exit_code=0):
64     print """Usage: dak rm [OPTIONS] PACKAGE[...]
65 Remove PACKAGE(s) from suite(s).
66
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
80
81 ARCH, BUG#, COMPONENT and SUITE can be comma (or space) separated lists, e.g.
82     --architecture=amd64,i386"""
83
84     sys.exit(exit_code)
85
86 ################################################################################
87
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?"
92
93 def game_over():
94     answer = utils.our_raw_input("Continue (y/N)? ").lower()
95     if answer != "y":
96         print "Aborted."
97         sys.exit(1)
98
99 ################################################################################
100
101 def reverse_depends_check(removals, suite, arches=None, session=None):
102     print "Checking reverse dependencies..."
103     if utils.check_reverse_depends(removals, suite, arches, session):
104         print "Dependency problem found."
105         if not Options["No-Action"]:
106             game_over()
107     else:
108         print "No dependency problem found."
109     print
110
111 ################################################################################
112
113 def main ():
114     global Options
115
116     cnf = Config()
117
118     Arguments = [('h',"help","Rm::Options::Help"),
119                  ('a',"architecture","Rm::Options::Architecture", "HasArg"),
120                  ('b',"binary", "Rm::Options::Binary-Only"),
121                  ('c',"component", "Rm::Options::Component", "HasArg"),
122                  ('C',"carbon-copy", "Rm::Options::Carbon-Copy", "HasArg"), # Bugs to Cc
123                  ('d',"done","Rm::Options::Done", "HasArg"), # Bugs fixed
124                  ('D',"do-close","Rm::Options::Do-Close"),
125                  ('R',"rdep-check", "Rm::Options::Rdep-Check"),
126                  ('m',"reason", "Rm::Options::Reason", "HasArg"), # Hysterical raisins; -m is old-dinstall option for rejection reason
127                  ('n',"no-action","Rm::Options::No-Action"),
128                  ('p',"partial", "Rm::Options::Partial"),
129                  ('s',"suite","Rm::Options::Suite", "HasArg"),
130                  ('S',"source-only", "Rm::Options::Source-Only"),
131                  ]
132
133     for i in [ "architecture", "binary-only", "carbon-copy", "component",
134                "done", "help", "no-action", "partial", "rdep-check", "reason",
135                "source-only", "Do-Close" ]:
136         if not cnf.has_key("Rm::Options::%s" % (i)):
137             cnf["Rm::Options::%s" % (i)] = ""
138     if not cnf.has_key("Rm::Options::Suite"):
139         cnf["Rm::Options::Suite"] = "unstable"
140
141     arguments = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv)
142     Options = cnf.subtree("Rm::Options")
143
144     if Options["Help"]:
145         usage()
146
147     session = DBConn().session()
148
149     # Sanity check options
150     if not arguments:
151         utils.fubar("need at least one package name as an argument.")
152     if Options["Architecture"] and Options["Source-Only"]:
153         utils.fubar("can't use -a/--architecture and -S/--source-only options simultaneously.")
154     if Options["Binary-Only"] and Options["Source-Only"]:
155         utils.fubar("can't use -b/--binary-only and -S/--source-only options simultaneously.")
156     if Options.has_key("Carbon-Copy") and not Options.has_key("Done"):
157         utils.fubar("can't use -C/--carbon-copy without also using -d/--done option.")
158     if Options["Architecture"] and not Options["Partial"]:
159         utils.warn("-a/--architecture implies -p/--partial.")
160         Options["Partial"] = "true"
161     if Options["Do-Close"] and not Options["Done"]:
162         utils.fubar("No.")
163     if Options["Do-Close"] and Options["Binary-Only"]:
164         utils.fubar("No.")
165     if Options["Do-Close"] and Options["Source-Only"]:
166         utils.fubar("No.")
167     if Options["Do-Close"] and Options["Suite"] != 'unstable':
168         utils.fubar("No.")
169
170     # Force the admin to tell someone if we're not doing a 'dak
171     # cruft-report' inspired removal (or closing a bug, which counts
172     # as telling someone).
173     if not Options["No-Action"] and not Options["Carbon-Copy"] \
174            and not Options["Done"] and Options["Reason"].find("[auto-cruft]") == -1:
175         utils.fubar("Need a -C/--carbon-copy if not closing a bug and not doing a cruft removal.")
176
177     # Process -C/--carbon-copy
178     #
179     # Accept 3 types of arguments (space separated):
180     #  1) a number - assumed to be a bug number, i.e. nnnnn@bugs.debian.org
181     #  2) the keyword 'package' - cc's $package@packages.debian.org for every argument
182     #  3) contains a '@' - assumed to be an email address, used unmofidied
183     #
184     carbon_copy = []
185     for copy_to in utils.split_args(Options.get("Carbon-Copy")):
186         if copy_to.isdigit():
187             if cnf.has_key("Dinstall::BugServer"):
188                 carbon_copy.append(copy_to + "@" + cnf["Dinstall::BugServer"])
189             else:
190                 utils.fubar("Asked to send mail to #%s in BTS but Dinstall::BugServer is not configured" % copy_to)
191         elif copy_to == 'package':
192             for package in arguments:
193                 if cnf.has_key("Dinstall::PackagesServer"):
194                     carbon_copy.append(package + "@" + cnf["Dinstall::PackagesServer"])
195                 if cnf.has_key("Dinstall::TrackingServer"):
196                     carbon_copy.append(package + "@" + cnf["Dinstall::TrackingServer"])
197         elif '@' in copy_to:
198             carbon_copy.append(copy_to)
199         else:
200             utils.fubar("Invalid -C/--carbon-copy argument '%s'; not a bug number, 'package' or email address." % (copy_to))
201
202     if Options["Binary-Only"]:
203         field = "b.package"
204     else:
205         field = "s.source"
206     con_packages = "AND %s IN (%s)" % (field, ", ".join([ repr(i) for i in arguments ]))
207
208     (con_suites, con_architectures, con_components, check_source) = \
209                  utils.parse_args(Options)
210
211     # Additional suite checks
212     suite_ids_list = []
213     suites = utils.split_args(Options["Suite"])
214     suites_list = utils.join_with_commas_and(suites)
215     if not Options["No-Action"]:
216         for suite in suites:
217             s = get_suite(suite, session=session)
218             if s is not None:
219                 suite_ids_list.append(s.suite_id)
220             if suite in ("oldstable", "stable"):
221                 print "**WARNING** About to remove from the (old)stable suite!"
222                 print "This should only be done just prior to a (point) release and not at"
223                 print "any other time."
224                 game_over()
225             elif suite == "testing":
226                 print "**WARNING About to remove from the testing suite!"
227                 print "There's no need to do this normally as removals from unstable will"
228                 print "propogate to testing automagically."
229                 game_over()
230
231     # Additional architecture checks
232     if Options["Architecture"] and check_source:
233         utils.warn("'source' in -a/--argument makes no sense and is ignored.")
234
235     # Additional component processing
236     over_con_components = con_components.replace("c.id", "component")
237
238     # Don't do dependency checks on multiple suites
239     if Options["Rdep-Check"] and len(suites) > 1:
240         utils.fubar("Reverse dependency check on multiple suites is not implemented.")
241
242     print "Working...",
243     sys.stdout.flush()
244     to_remove = []
245     maintainers = {}
246
247     # We have 3 modes of package selection: binary-only, source-only
248     # and source+binary.  The first two are trivial and obvious; the
249     # latter is a nasty mess, but very nice from a UI perspective so
250     # we try to support it.
251
252     # XXX: TODO: This all needs converting to use placeholders or the object
253     #            API. It's an SQL injection dream at the moment
254
255     if Options["Binary-Only"]:
256         # Binary-only
257         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))
258         for i in q.fetchall():
259             to_remove.append(i)
260     else:
261         # Source-only
262         source_packages = {}
263         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))
264         for i in q.fetchall():
265             source_packages[i[2]] = i[:2]
266             to_remove.append(i[2:])
267         if not Options["Source-Only"]:
268             # Source + Binary
269             binary_packages = {}
270             # First get a list of binary package names we suspect are linked to the source
271             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))
272             for i in q.fetchall():
273                 binary_packages[i[0]] = ""
274             # Then parse each .dsc that we found earlier to see what binary packages it thinks it produces
275             for i in source_packages.keys():
276                 filename = "/".join(source_packages[i])
277                 try:
278                     dsc = utils.parse_changes(filename, dsc_file=1)
279                 except CantOpenError:
280                     utils.warn("couldn't open '%s'." % (filename))
281                     continue
282                 for package in dsc.get("binary").split(','):
283                     package = package.strip()
284                     binary_packages[package] = ""
285             # Then for each binary package: find any version in
286             # unstable, check the Source: field in the deb matches our
287             # source package and if so add it to the list of packages
288             # to be removed.
289             for package in binary_packages.keys():
290                 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))
291                 for i in q.fetchall():
292                     filename = "/".join(i[:2])
293                     control = apt_pkg.TagSection(utils.deb_extract_control(utils.open_file(filename)))
294                     source = control.find("Source", control.find("Package"))
295                     source = re_strip_source_version.sub('', source)
296                     if source_packages.has_key(source):
297                         to_remove.append(i[2:])
298     print "done."
299
300     if not to_remove:
301         print "Nothing to do."
302         sys.exit(0)
303
304     # If we don't have a reason; spawn an editor so the user can add one
305     # Write the rejection email out as the <foo>.reason file
306     if not Options["Reason"] and not Options["No-Action"]:
307         (fd, temp_filename) = utils.temp_filename()
308         editor = os.environ.get("EDITOR","vi")
309         result = os.system("%s %s" % (editor, temp_filename))
310         if result != 0:
311             utils.fubar ("vi invocation failed for `%s'!" % (temp_filename), result)
312         temp_file = utils.open_file(temp_filename)
313         for line in temp_file.readlines():
314             Options["Reason"] += line
315         temp_file.close()
316         os.unlink(temp_filename)
317
318     # Generate the summary of what's to be removed
319     d = {}
320     for i in to_remove:
321         package = i[0]
322         version = i[1]
323         architecture = i[2]
324         maintainer = i[4]
325         maintainers[maintainer] = ""
326         if not d.has_key(package):
327             d[package] = {}
328         if not d[package].has_key(version):
329             d[package][version] = []
330         if architecture not in d[package][version]:
331             d[package][version].append(architecture)
332
333     maintainer_list = []
334     for maintainer_id in maintainers.keys():
335         maintainer_list.append(get_maintainer(maintainer_id).name)
336     summary = ""
337     removals = d.keys()
338     removals.sort()
339     versions = []
340     for package in removals:
341         versions = d[package].keys()
342         versions.sort(apt_pkg.version_compare)
343         for version in versions:
344             d[package][version].sort(utils.arch_compare_sw)
345             summary += "%10s | %10s | %s\n" % (package, version, ", ".join(d[package][version]))
346     print "Will remove the following packages from %s:" % (suites_list)
347     print
348     print summary
349     print "Maintainer: %s" % ", ".join(maintainer_list)
350     if Options["Done"]:
351         print "Will also close bugs: "+Options["Done"]
352     if carbon_copy:
353         print "Will also send CCs to: " + ", ".join(carbon_copy)
354     if Options["Do-Close"]:
355         print "Will also close associated bug reports."
356     print
357     print "------------------- Reason -------------------"
358     print Options["Reason"]
359     print "----------------------------------------------"
360     print
361
362     if Options["Rdep-Check"]:
363         arches = utils.split_args(Options["Architecture"])
364         reverse_depends_check(removals, suites[0], arches, session)
365
366     # If -n/--no-action, drop out here
367     if Options["No-Action"]:
368         sys.exit(0)
369
370     print "Going to remove the packages now."
371     game_over()
372
373     whoami = utils.whoami()
374     date = commands.getoutput('date -R')
375
376     # Log first; if it all falls apart I want a record that we at least tried.
377     logfile = utils.open_file(cnf["Rm::LogFile"], 'a')
378     logfile.write("=========================================================================\n")
379     logfile.write("[Date: %s] [ftpmaster: %s]\n" % (date, whoami))
380     logfile.write("Removed the following packages from %s:\n\n%s" % (suites_list, summary))
381     if Options["Done"]:
382         logfile.write("Closed bugs: %s\n" % (Options["Done"]))
383     logfile.write("\n------------------- Reason -------------------\n%s\n" % (Options["Reason"]))
384     logfile.write("----------------------------------------------\n")
385
386     # Do the same in rfc822 format
387     logfile822 = utils.open_file(cnf["Rm::LogFile822"], 'a')
388     logfile822.write("Date: %s\n" % date)
389     logfile822.write("Ftpmaster: %s\n" % whoami)
390     logfile822.write("Suite: %s\n" % suites_list)
391     sources = []
392     binaries = []
393     for package in summary.split("\n"):
394         for row in package.split("\n"):
395             element = row.split("|")
396             if len(element) == 3:
397                 if element[2].find("source") > 0:
398                     sources.append("%s_%s" % tuple(elem.strip(" ") for elem in element[:2]))
399                     element[2] = sub("source\s?,?", "", element[2]).strip(" ")
400                 if element[2]:
401                     binaries.append("%s_%s [%s]" % tuple(elem.strip(" ") for elem in element))
402     if sources:
403         logfile822.write("Sources:\n")
404         for source in sources:
405             logfile822.write(" %s\n" % source)
406     if binaries:
407         logfile822.write("Binaries:\n")
408         for binary in binaries:
409             logfile822.write(" %s\n" % binary)
410     logfile822.write("Reason: %s\n" % Options["Reason"].replace('\n', '\n '))
411     if Options["Done"]:
412         logfile822.write("Bug: %s\n" % Options["Done"])
413
414     dsc_type_id = get_override_type('dsc', session).overridetype_id
415     deb_type_id = get_override_type('deb', session).overridetype_id
416
417     # Do the actual deletion
418     print "Deleting...",
419     sys.stdout.flush()
420
421     for i in to_remove:
422         package = i[0]
423         architecture = i[2]
424         package_id = i[3]
425         for suite_id in suite_ids_list:
426             if architecture == "source":
427                 session.execute("DELETE FROM src_associations WHERE source = :packageid AND suite = :suiteid",
428                                 {'packageid': package_id, 'suiteid': suite_id})
429                 #print "DELETE FROM src_associations WHERE source = %s AND suite = %s" % (package_id, suite_id)
430             else:
431                 session.execute("DELETE FROM bin_associations WHERE bin = :packageid AND suite = :suiteid",
432                                 {'packageid': package_id, 'suiteid': suite_id})
433                 #print "DELETE FROM bin_associations WHERE bin = %s AND suite = %s" % (package_id, suite_id)
434             # Delete from the override file
435             if not Options["Partial"]:
436                 if architecture == "source":
437                     type_id = dsc_type_id
438                 else:
439                     type_id = deb_type_id
440                 # TODO: Again, fix this properly to remove the remaining non-bind argument
441                 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})
442     session.commit()
443     print "done."
444
445     # If we don't have a Bug server configured, we're done
446     if not cnf.has_key("Dinstall::BugServer"):
447         if Options["Done"] or Options["Do-Close"]:
448             print "Cannot send mail to BugServer as Dinstall::BugServer is not configured"
449
450         logfile.write("=========================================================================\n")
451         logfile.close()
452
453         logfile822.write("\n")
454         logfile822.close()
455
456         return
457
458     # read common subst variables for all bug closure mails
459     Subst_common = {}
460     Subst_common["__RM_ADDRESS__"] = cnf["Dinstall::MyEmailAddress"]
461     Subst_common["__BUG_SERVER__"] = cnf["Dinstall::BugServer"]
462     Subst_common["__CC__"] = "X-DAK: dak rm"
463     if carbon_copy:
464         Subst_common["__CC__"] += "\nCc: " + ", ".join(carbon_copy)
465     Subst_common["__SUITE_LIST__"] = suites_list
466     Subst_common["__SUBJECT__"] = "Removed package(s) from %s" % (suites_list)
467     Subst_common["__ADMIN_ADDRESS__"] = cnf["Dinstall::MyAdminAddress"]
468     Subst_common["__DISTRO__"] = cnf["Dinstall::MyDistribution"]
469     Subst_common["__WHOAMI__"] = whoami
470
471     # Send the bug closing messages
472     if Options["Done"]:
473         Subst_close_rm = Subst_common
474         bcc = []
475         if cnf.find("Dinstall::Bcc") != "":
476             bcc.append(cnf["Dinstall::Bcc"])
477         if cnf.find("Rm::Bcc") != "":
478             bcc.append(cnf["Rm::Bcc"])
479         if bcc:
480             Subst_close_rm["__BCC__"] = "Bcc: " + ", ".join(bcc)
481         else:
482             Subst_close_rm["__BCC__"] = "X-Filler: 42"
483         summarymail = "%s\n------------------- Reason -------------------\n%s\n" % (summary, Options["Reason"])
484         summarymail += "----------------------------------------------\n"
485         Subst_close_rm["__SUMMARY__"] = summarymail
486
487         whereami = utils.where_am_i()
488         Archive = get_archive(whereami, session)
489         if Archive is None:
490             utils.warn("Cannot find archive %s.  Setting blank values for origin" % whereami)
491             Subst_close_rm["__PRIMARY_MIRROR__"] = ""
492         else:
493             Subst_close_rm["__PRIMARY_MIRROR__"] = Archive.primary_mirror
494
495         for bug in utils.split_args(Options["Done"]):
496             Subst_close_rm["__BUG_NUMBER__"] = bug
497             if Options["Do-Close"]:
498                 mail_message = utils.TemplateSubst(Subst_close_rm,cnf["Dir::Templates"]+"/rm.bug-close-with-related")
499             else:
500                 mail_message = utils.TemplateSubst(Subst_close_rm,cnf["Dir::Templates"]+"/rm.bug-close")
501             utils.send_mail(mail_message)
502
503     # close associated bug reports
504     if Options["Do-Close"]:
505         Subst_close_other = Subst_common
506         bcc = []
507         wnpp = utils.parse_wnpp_bug_file()
508         versions = list(set([re_bin_only_nmu.sub('', v) for v in versions]))
509         if len(versions) == 1:
510             Subst_close_other["__VERSION__"] = versions[0]
511         else:
512             utils.fubar("Closing bugs with multiple package versions is not supported.  Do it yourself.")
513         if bcc:
514             Subst_close_other["__BCC__"] = "Bcc: " + ", ".join(bcc)
515         else:
516             Subst_close_other["__BCC__"] = "X-Filler: 42"
517         # at this point, I just assume, that the first closed bug gives
518         # some useful information on why the package got removed
519         Subst_close_other["__BUG_NUMBER__"] = utils.split_args(Options["Done"])[0]
520         if len(sources) == 1:
521             source_pkg = source.split("_", 1)[0]
522         else:
523             utils.fubar("Closing bugs for multiple source packages is not supported.  Do it yourself.")
524         Subst_close_other["__BUG_NUMBER_ALSO__"] = ""
525         Subst_close_other["__SOURCE__"] = source_pkg
526         other_bugs = bts.get_bugs('src', source_pkg, 'status', 'open')
527         if other_bugs:
528             logfile.write("Also closing bug(s):")
529             logfile822.write("Also-Bugs:")
530             for bug in other_bugs:
531                 Subst_close_other["__BUG_NUMBER_ALSO__"] += str(bug) + "-done@" + cnf["Dinstall::BugServer"] + ","
532                 logfile.write(" " + str(bug))
533                 logfile822.write(" " + str(bug))
534             logfile.write("\n")
535             logfile822.write("\n")
536         if source_pkg in wnpp.keys():
537             logfile.write("Also closing WNPP bug(s):")
538             logfile822.write("Also-WNPP:")
539             for bug in wnpp[source_pkg]:
540                 # the wnpp-rm file we parse also contains our removal
541                 # bugs, filtering that out
542                 if bug != Subst_close_other["__BUG_NUMBER__"]:
543                     Subst_close_other["__BUG_NUMBER_ALSO__"] += str(bug) + "-done@" + cnf["Dinstall::BugServer"] + ","
544                     logfile.write(" " + str(bug))
545                     logfile822.write(" " + str(bug))
546             logfile.write("\n")
547             logfile822.write("\n")
548
549         mail_message = utils.TemplateSubst(Subst_close_other,cnf["Dir::Templates"]+"/rm.bug-close-related")
550         if Subst_close_other["__BUG_NUMBER_ALSO__"]:
551             utils.send_mail(mail_message)
552
553
554     logfile.write("=========================================================================\n")
555     logfile.close()
556
557     logfile822.write("\n")
558     logfile822.close()
559
560 #######################################################################################
561
562 if __name__ == '__main__':
563     main()