]> git.decadent.org.uk Git - dak.git/blob - dak/rm.py
move generate_contents_information to utils.py
[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
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
20 ################################################################################
21
22 # o OpenBSD team wants to get changes incorporated into IPF. Darren no
23 #    respond.
24 # o Ask again -> No respond. Darren coder supreme.
25 # o OpenBSD decide to make changes, but only in OpenBSD source
26 #    tree. Darren hears, gets angry! Decides: "LICENSE NO ALLOW!"
27 # o Insert Flame War.
28 # o OpenBSD team decide to switch to different packet filter under BSD
29 #    license. Because Project Goal: Every user should be able to make
30 #    changes to source tree. IPF license bad!!
31 # o Darren try get back: says, NetBSD, FreeBSD allowed! MUAHAHAHAH!!!
32 # o Theo say: no care, pf much better than ipf!
33 # o Darren changes mind: changes license. But OpenBSD will not change
34 #    back to ipf. Darren even much more bitter.
35 # o Darren so bitterbitter. Decides: I'LL GET BACK BY FORKING OPENBSD AND
36 #    RELEASING MY OWN VERSION. HEHEHEHEHE.
37
38 #                        http://slashdot.org/comments.pl?sid=26697&cid=2883271
39
40 ################################################################################
41
42 import commands, os, pg, re, sys
43 import apt_pkg, apt_inst
44 from daklib import database
45 from daklib import utils
46 from daklib.dak_exceptions import *
47
48 ################################################################################
49
50 re_strip_source_version = re.compile (r'\s+.*$')
51 re_build_dep_arch = re.compile(r"\[[^]]+\]")
52
53 ################################################################################
54
55 Cnf = None
56 Options = None
57 projectB = None
58
59 ################################################################################
60
61 def usage (exit_code=0):
62     print """Usage: dak rm [OPTIONS] PACKAGE[...]
63 Remove PACKAGE(s) from suite(s).
64
65   -a, --architecture=ARCH    only act on this architecture
66   -b, --binary               remove binaries only
67   -c, --component=COMPONENT  act on this component
68   -C, --carbon-copy=EMAIL    send a CC of removal message to EMAIL
69   -d, --done=BUG#            send removal message as closure to bug#
70   -h, --help                 show this help and exit
71   -m, --reason=MSG           reason for removal
72   -n, --no-action            don't do anything
73   -p, --partial              don't affect override files
74   -R, --rdep-check           check reverse dependencies
75   -s, --suite=SUITE          act on this suite
76   -S, --source-only          remove source only
77
78 ARCH, BUG#, COMPONENT and SUITE can be comma (or space) separated lists, e.g.
79     --architecture=m68k,i386"""
80
81     sys.exit(exit_code)
82
83 ################################################################################
84
85 # "Hudson: What that's great, that's just fucking great man, now what
86 #  the fuck are we supposed to do? We're in some real pretty shit now
87 #  man...That's it man, game over man, game over, man! Game over! What
88 #  the fuck are we gonna do now? What are we gonna do?"
89
90 def game_over():
91     answer = utils.our_raw_input("Continue (y/N)? ").lower()
92     if answer != "y":
93         print "Aborted."
94         sys.exit(1)
95
96 ################################################################################
97
98 def reverse_depends_check(removals, suites, arches=None):
99     print "Checking reverse dependencies..."
100     components = Cnf.ValueList("Suite::%s::Components" % suites[0])
101     dep_problem = 0
102     p2c = {}
103     all_broken = {}
104     if arches:
105         all_arches = set(arches)
106     else:
107         all_arches = set(Cnf.ValueList("Suite::%s::Architectures" % suites[0]))
108     all_arches -= set(["source", "all"])
109     for architecture in all_arches:
110         deps = {}
111         sources = {}
112         virtual_packages = {}
113         for component in components:
114             filename = "%s/dists/%s/%s/binary-%s/Packages.gz" % (Cnf["Dir::Root"], suites[0], component, architecture)
115             # apt_pkg.ParseTagFile needs a real file handle and can't handle a GzipFile instance...
116             temp_filename = utils.temp_filename()
117             (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename))
118             if (result != 0):
119                 utils.fubar("Gunzip invocation failed!\n%s\n" % (output), result)
120             packages = utils.open_file(temp_filename)
121             Packages = apt_pkg.ParseTagFile(packages)
122             while Packages.Step():
123                 package = Packages.Section.Find("Package")
124                 source = Packages.Section.Find("Source")
125                 if not source:
126                     source = package
127                 elif ' ' in source:
128                     source = source.split(' ', 1)[0]
129                 sources[package] = source
130                 depends = Packages.Section.Find("Depends")
131                 if depends:
132                     deps[package] = depends
133                 provides = Packages.Section.Find("Provides")
134                 # Maintain a counter for each virtual package.  If a
135                 # Provides: exists, set the counter to 0 and count all
136                 # provides by a package not in the list for removal.
137                 # If the counter stays 0 at the end, we know that only
138                 # the to-be-removed packages provided this virtual
139                 # package.
140                 if provides:
141                     for virtual_pkg in provides.split(","):
142                         virtual_pkg = virtual_pkg.strip()
143                         if virtual_pkg == package: continue
144                         if not virtual_packages.has_key(virtual_pkg):
145                             virtual_packages[virtual_pkg] = 0
146                         if package not in removals:
147                             virtual_packages[virtual_pkg] += 1
148                 p2c[package] = component
149             packages.close()
150             os.unlink(temp_filename)
151
152         # If a virtual package is only provided by the to-be-removed
153         # packages, treat the virtual package as to-be-removed too.
154         for virtual_pkg in virtual_packages.keys():
155             if virtual_packages[virtual_pkg] == 0:
156                 removals.append(virtual_pkg)
157
158         # Check binary dependencies (Depends)
159         for package in deps.keys():
160             if package in removals: continue
161             parsed_dep = []
162             try:
163                 parsed_dep += apt_pkg.ParseDepends(deps[package])
164             except ValueError, e:
165                 print "Error for package %s: %s" % (package, e)
166             for dep in parsed_dep:
167                 # Check for partial breakage.  If a package has a ORed
168                 # dependency, there is only a dependency problem if all
169                 # packages in the ORed depends will be removed.
170                 unsat = 0
171                 for dep_package, _, _ in dep:
172                     if dep_package in removals:
173                         unsat += 1
174                 if unsat == len(dep):
175                     component = p2c[package]
176                     source = sources[package]
177                     if component != "main":
178                         source = "%s/%s" % (source, component)
179                     all_broken.setdefault(source, {}).setdefault(package, set()).add(architecture)
180                     dep_problem = 1
181
182     if all_broken:
183         print "# Broken Depends:"
184         for source, bindict in sorted(all_broken.items()):
185             lines = []
186             for binary, arches in sorted(bindict.items()):
187                 if arches == all_arches:
188                     lines.append(binary)
189                 else:
190                     lines.append('%s [%s]' % (binary, ' '.join(sorted(arches))))
191             print '%s: %s' % (source, lines[0])
192             for line in lines[1:]:
193                 print ' ' * (len(source) + 2) + line
194         print
195
196     # Check source dependencies (Build-Depends and Build-Depends-Indep)
197     all_broken.clear()
198     for component in components:
199         filename = "%s/dists/%s/%s/source/Sources.gz" % (Cnf["Dir::Root"], suites[0], component)
200         # apt_pkg.ParseTagFile needs a real file handle and can't handle a GzipFile instance...
201         temp_filename = utils.temp_filename()
202         result, output = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename))
203         if result != 0:
204             sys.stderr.write("Gunzip invocation failed!\n%s\n" % (output))
205             sys.exit(result)
206         sources = utils.open_file(temp_filename, "r")
207         Sources = apt_pkg.ParseTagFile(sources)
208         while Sources.Step():
209             source = Sources.Section.Find("Package")
210             if source in removals: continue
211             parsed_dep = []
212             for build_dep_type in ["Build-Depends", "Build-Depends-Indep"]:
213                 build_dep = Sources.Section.get(build_dep_type)
214                 if build_dep:
215                     # Remove [arch] information since we want to see breakage on all arches
216                     build_dep = re_build_dep_arch.sub("", build_dep)
217                     try:
218                         parsed_dep += apt_pkg.ParseDepends(build_dep)
219                     except ValueError, e:
220                         print "Error for source %s: %s" % (source, e)
221             for dep in parsed_dep:
222                 unsat = 0
223                 for dep_package, _, _ in dep:
224                     if dep_package in removals:
225                         unsat += 1
226                 if unsat == len(dep):
227                     if component != "main":
228                         source = "%s/%s" % (source, component)
229                     all_broken.setdefault(source, set()).add(utils.pp_deps(dep))
230                     dep_problem = 1
231         sources.close()
232         os.unlink(temp_filename)
233
234     if all_broken:
235         print "# Broken Build-Depends:"
236         for source, bdeps in sorted(all_broken.items()):
237             bdeps = sorted(bdeps)
238             print '%s: %s' % (source, bdeps[0])
239             for bdep in bdeps[1:]:
240                 print ' ' * (len(source) + 2) + bdep
241         print
242
243     if dep_problem:
244         print "Dependency problem found."
245         if not Options["No-Action"]:
246             game_over()
247     else:
248         print "No dependency problem found."
249     print
250
251 ################################################################################
252
253 def main ():
254     global Cnf, Options, projectB
255
256     Cnf = utils.get_conf()
257
258     Arguments = [('h',"help","Rm::Options::Help"),
259                  ('a',"architecture","Rm::Options::Architecture", "HasArg"),
260                  ('b',"binary", "Rm::Options::Binary-Only"),
261                  ('c',"component", "Rm::Options::Component", "HasArg"),
262                  ('C',"carbon-copy", "Rm::Options::Carbon-Copy", "HasArg"), # Bugs to Cc
263                  ('d',"done","Rm::Options::Done", "HasArg"), # Bugs fixed
264                  ('R',"rdep-check", "Rm::Options::Rdep-Check"),
265                  ('m',"reason", "Rm::Options::Reason", "HasArg"), # Hysterical raisins; -m is old-dinstall option for rejection reason
266                  ('n',"no-action","Rm::Options::No-Action"),
267                  ('p',"partial", "Rm::Options::Partial"),
268                  ('s',"suite","Rm::Options::Suite", "HasArg"),
269                  ('S',"source-only", "Rm::Options::Source-Only"),
270                  ]
271
272     for i in [ "architecture", "binary-only", "carbon-copy", "component",
273                "done", "help", "no-action", "partial", "rdep-check", "reason",
274                "source-only" ]:
275         if not Cnf.has_key("Rm::Options::%s" % (i)):
276             Cnf["Rm::Options::%s" % (i)] = ""
277     if not Cnf.has_key("Rm::Options::Suite"):
278         Cnf["Rm::Options::Suite"] = "unstable"
279
280     arguments = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv)
281     Options = Cnf.SubTree("Rm::Options")
282
283     if Options["Help"]:
284         usage()
285
286     projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
287     database.init(Cnf, projectB)
288
289     # Sanity check options
290     if not arguments:
291         utils.fubar("need at least one package name as an argument.")
292     if Options["Architecture"] and Options["Source-Only"]:
293         utils.fubar("can't use -a/--architecture and -S/--source-only options simultaneously.")
294     if Options["Binary-Only"] and Options["Source-Only"]:
295         utils.fubar("can't use -b/--binary-only and -S/--source-only options simultaneously.")
296     if Options.has_key("Carbon-Copy") and not Options.has_key("Done"):
297         utils.fubar("can't use -C/--carbon-copy without also using -d/--done option.")
298     if Options["Architecture"] and not Options["Partial"]:
299         utils.warn("-a/--architecture implies -p/--partial.")
300         Options["Partial"] = "true"
301
302     # Force the admin to tell someone if we're not doing a 'dak
303     # cruft-report' inspired removal (or closing a bug, which counts
304     # as telling someone).
305     if not Options["No-Action"] and not Options["Carbon-Copy"] \
306            and not Options["Done"] and Options["Reason"].find("[auto-cruft]") == -1:
307         utils.fubar("Need a -C/--carbon-copy if not closing a bug and not doing a cruft removal.")
308
309     # Process -C/--carbon-copy
310     #
311     # Accept 3 types of arguments (space separated):
312     #  1) a number - assumed to be a bug number, i.e. nnnnn@bugs.debian.org
313     #  2) the keyword 'package' - cc's $package@packages.debian.org for every argument
314     #  3) contains a '@' - assumed to be an email address, used unmofidied
315     #
316     carbon_copy = []
317     for copy_to in utils.split_args(Options.get("Carbon-Copy")):
318         if copy_to.isdigit():
319             carbon_copy.append(copy_to + "@" + Cnf["Dinstall::BugServer"])
320         elif copy_to == 'package':
321             for package in arguments:
322                 carbon_copy.append(package + "@" + Cnf["Dinstall::PackagesServer"])
323                 if Cnf.has_key("Dinstall::TrackingServer"):
324                     carbon_copy.append(package + "@" + Cnf["Dinstall::TrackingServer"])
325         elif '@' in copy_to:
326             carbon_copy.append(copy_to)
327         else:
328             utils.fubar("Invalid -C/--carbon-copy argument '%s'; not a bug number, 'package' or email address." % (copy_to))
329
330     if Options["Binary-Only"]:
331         field = "b.package"
332     else:
333         field = "s.source"
334     con_packages = "AND %s IN (%s)" % (field, ", ".join([ repr(i) for i in arguments ]))
335
336     (con_suites, con_architectures, con_components, check_source) = \
337                  utils.parse_args(Options)
338
339     # Additional suite checks
340     suite_ids_list = []
341     suites = utils.split_args(Options["Suite"])
342     suites_list = utils.join_with_commas_and(suites)
343     if not Options["No-Action"]:
344         for suite in suites:
345             suite_id = database.get_suite_id(suite)
346             if suite_id != -1:
347                 suite_ids_list.append(suite_id)
348             if suite == "stable":
349                 print "**WARNING** About to remove from the stable suite!"
350                 print "This should only be done just prior to a (point) release and not at"
351                 print "any other time."
352                 game_over()
353             elif suite == "testing":
354                 print "**WARNING About to remove from the testing suite!"
355                 print "There's no need to do this normally as removals from unstable will"
356                 print "propogate to testing automagically."
357                 game_over()
358
359     # Additional architecture checks
360     if Options["Architecture"] and check_source:
361         utils.warn("'source' in -a/--argument makes no sense and is ignored.")
362
363     # Additional component processing
364     over_con_components = con_components.replace("c.id", "component")
365
366     print "Working...",
367     sys.stdout.flush()
368     to_remove = []
369     maintainers = {}
370
371     # We have 3 modes of package selection: binary-only, source-only
372     # and source+binary.  The first two are trivial and obvious; the
373     # latter is a nasty mess, but very nice from a UI perspective so
374     # we try to support it.
375
376     if Options["Binary-Only"]:
377         # Binary-only
378         q = projectB.query("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))
379         for i in q.getresult():
380             to_remove.append(i)
381     else:
382         # Source-only
383         source_packages = {}
384         q = projectB.query("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))
385         for i in q.getresult():
386             source_packages[i[2]] = i[:2]
387             to_remove.append(i[2:])
388         if not Options["Source-Only"]:
389             # Source + Binary
390             binary_packages = {}
391             # First get a list of binary package names we suspect are linked to the source
392             q = projectB.query("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))
393             for i in q.getresult():
394                 binary_packages[i[0]] = ""
395             # Then parse each .dsc that we found earlier to see what binary packages it thinks it produces
396             for i in source_packages.keys():
397                 filename = "/".join(source_packages[i])
398                 try:
399                     dsc = utils.parse_changes(filename)
400                 except CantOpenError:
401                     utils.warn("couldn't open '%s'." % (filename))
402                     continue
403                 for package in dsc.get("binary").split(','):
404                     package = package.strip()
405                     binary_packages[package] = ""
406             # Then for each binary package: find any version in
407             # unstable, check the Source: field in the deb matches our
408             # source package and if so add it to the list of packages
409             # to be removed.
410             for package in binary_packages.keys():
411                 q = projectB.query("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))
412                 for i in q.getresult():
413                     filename = "/".join(i[:2])
414                     control = apt_pkg.ParseSection(apt_inst.debExtractControl(utils.open_file(filename)))
415                     source = control.Find("Source", control.Find("Package"))
416                     source = re_strip_source_version.sub('', source)
417                     if source_packages.has_key(source):
418                         to_remove.append(i[2:])
419     print "done."
420
421     if not to_remove:
422         print "Nothing to do."
423         sys.exit(0)
424
425     # If we don't have a reason; spawn an editor so the user can add one
426     # Write the rejection email out as the <foo>.reason file
427     if not Options["Reason"] and not Options["No-Action"]:
428         temp_filename = utils.temp_filename()
429         editor = os.environ.get("EDITOR","vi")
430         result = os.system("%s %s" % (editor, temp_filename))
431         if result != 0:
432             utils.fubar ("vi invocation failed for `%s'!" % (temp_filename), result)
433         temp_file = utils.open_file(temp_filename)
434         for line in temp_file.readlines():
435             Options["Reason"] += line
436         temp_file.close()
437         os.unlink(temp_filename)
438
439     # Generate the summary of what's to be removed
440     d = {}
441     for i in to_remove:
442         package = i[0]
443         version = i[1]
444         architecture = i[2]
445         maintainer = i[4]
446         maintainers[maintainer] = ""
447         if not d.has_key(package):
448             d[package] = {}
449         if not d[package].has_key(version):
450             d[package][version] = []
451         if architecture not in d[package][version]:
452             d[package][version].append(architecture)
453
454     maintainer_list = []
455     for maintainer_id in maintainers.keys():
456         maintainer_list.append(database.get_maintainer(maintainer_id))
457     summary = ""
458     removals = d.keys()
459     removals.sort()
460     for package in removals:
461         versions = d[package].keys()
462         versions.sort(apt_pkg.VersionCompare)
463         for version in versions:
464             d[package][version].sort(utils.arch_compare_sw)
465             summary += "%10s | %10s | %s\n" % (package, version, ", ".join(d[package][version]))
466     print "Will remove the following packages from %s:" % (suites_list)
467     print
468     print summary
469     print "Maintainer: %s" % ", ".join(maintainer_list)
470     if Options["Done"]:
471         print "Will also close bugs: "+Options["Done"]
472     if carbon_copy:
473         print "Will also send CCs to: " + ", ".join(carbon_copy)
474     print
475     print "------------------- Reason -------------------"
476     print Options["Reason"]
477     print "----------------------------------------------"
478     print
479
480     if Options["Rdep-Check"]:
481         arches = utils.split_args(Options["Architecture"])
482         reverse_depends_check(removals, suites, arches)
483
484     # If -n/--no-action, drop out here
485     if Options["No-Action"]:
486         sys.exit(0)
487
488     print "Going to remove the packages now."
489     game_over()
490
491     whoami = utils.whoami()
492     date = commands.getoutput('date -R')
493
494     # Log first; if it all falls apart I want a record that we at least tried.
495     logfile = utils.open_file(Cnf["Rm::LogFile"], 'a')
496     logfile.write("=========================================================================\n")
497     logfile.write("[Date: %s] [ftpmaster: %s]\n" % (date, whoami))
498     logfile.write("Removed the following packages from %s:\n\n%s" % (suites_list, summary))
499     if Options["Done"]:
500         logfile.write("Closed bugs: %s\n" % (Options["Done"]))
501     logfile.write("\n------------------- Reason -------------------\n%s\n" % (Options["Reason"]))
502     logfile.write("----------------------------------------------\n")
503     logfile.flush()
504
505     dsc_type_id = database.get_override_type_id('dsc')
506     deb_type_id = database.get_override_type_id('deb')
507
508     # Do the actual deletion
509     print "Deleting...",
510     sys.stdout.flush()
511     projectB.query("BEGIN WORK")
512     for i in to_remove:
513         package = i[0]
514         architecture = i[2]
515         package_id = i[3]
516         for suite_id in suite_ids_list:
517             if architecture == "source":
518                 projectB.query("DELETE FROM src_associations WHERE source = %s AND suite = %s" % (package_id, suite_id))
519                 #print "DELETE FROM src_associations WHERE source = %s AND suite = %s" % (package_id, suite_id)
520             else:
521                 projectB.query("DELETE FROM bin_associations WHERE bin = %s AND suite = %s" % (package_id, suite_id))
522                 #print "DELETE FROM bin_associations WHERE bin = %s AND suite = %s" % (package_id, suite_id)
523             # Delete from the override file
524             if not Options["Partial"]:
525                 if architecture == "source":
526                     type_id = dsc_type_id
527                 else:
528                     type_id = deb_type_id
529                 projectB.query("DELETE FROM override WHERE package = '%s' AND type = %s AND suite = %s %s" % (package, type_id, suite_id, over_con_components))
530     projectB.query("COMMIT WORK")
531     print "done."
532
533     # Send the bug closing messages
534     if Options["Done"]:
535         Subst = {}
536         Subst["__RM_ADDRESS__"] = Cnf["Rm::MyEmailAddress"]
537         Subst["__BUG_SERVER__"] = Cnf["Dinstall::BugServer"]
538         bcc = []
539         if Cnf.Find("Dinstall::Bcc") != "":
540             bcc.append(Cnf["Dinstall::Bcc"])
541         if Cnf.Find("Rm::Bcc") != "":
542             bcc.append(Cnf["Rm::Bcc"])
543         if bcc:
544             Subst["__BCC__"] = "Bcc: " + ", ".join(bcc)
545         else:
546             Subst["__BCC__"] = "X-Filler: 42"
547         Subst["__CC__"] = "X-DAK: dak rm\nX-Katie: melanie"
548         if carbon_copy:
549             Subst["__CC__"] += "\nCc: " + ", ".join(carbon_copy)
550         Subst["__SUITE_LIST__"] = suites_list
551         Subst["__SUMMARY__"] = summary
552         Subst["__ADMIN_ADDRESS__"] = Cnf["Dinstall::MyAdminAddress"]
553         Subst["__DISTRO__"] = Cnf["Dinstall::MyDistribution"]
554         Subst["__WHOAMI__"] = whoami
555         whereami = utils.where_am_i()
556         Archive = Cnf.SubTree("Archive::%s" % (whereami))
557         Subst["__MASTER_ARCHIVE__"] = Archive["OriginServer"]
558         Subst["__PRIMARY_MIRROR__"] = Archive["PrimaryMirror"]
559         for bug in utils.split_args(Options["Done"]):
560             Subst["__BUG_NUMBER__"] = bug
561             mail_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/rm.bug-close")
562             utils.send_mail(mail_message)
563
564     logfile.write("=========================================================================\n")
565     logfile.close()
566
567 #######################################################################################
568
569 if __name__ == '__main__':
570     main()