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