rm.py 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. """General purpose package removal code for ftpmaster
  2. @contact: Debian FTP Master <ftpmaster@debian.org>
  3. @copyright: 2000, 2001, 2002, 2003, 2004, 2006 James Troup <james@nocrew.org>
  4. @copyright: 2010 Alexander Reichle-Schmehl <tolimar@debian.org>
  5. @copyright: 2015 Niels Thykier <niels@thykier.net>
  6. @license: GNU General Public License version 2 or later
  7. """
  8. # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 James Troup <james@nocrew.org>
  9. # Copyright (C) 2010 Alexander Reichle-Schmehl <tolimar@debian.org>
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; either version 2 of the License, or
  13. # (at your option) any later version.
  14. # This program is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. # GNU General Public License for more details.
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program; if not, write to the Free Software
  20. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. ################################################################################
  22. # From: Andrew Morton <akpm@osdl.org>
  23. # Subject: 2.6.6-mm5
  24. # To: linux-kernel@vger.kernel.org
  25. # Date: Sat, 22 May 2004 01:36:36 -0700
  26. # X-Mailer: Sylpheed version 0.9.7 (GTK+ 1.2.10; i386-redhat-linux-gnu)
  27. #
  28. # [...]
  29. #
  30. # Although this feature has been around for a while it is new code, and the
  31. # usual cautions apply. If it munches all your files please tell Jens and
  32. # he'll type them in again for you.
  33. ################################################################################
  34. import commands
  35. import apt_pkg
  36. import fcntl
  37. from re import sub
  38. from collections import defaultdict
  39. from regexes import re_build_dep_arch
  40. from daklib.dbconn import *
  41. from daklib import utils
  42. from daklib.regexes import re_bin_only_nmu
  43. import debianbts as bts
  44. ################################################################################
  45. class ReverseDependencyChecker(object):
  46. """A bulk tester for reverse dependency checks
  47. This class is similar to the check_reverse_depends method from "utils". However,
  48. it is primarily focused on facilitating bulk testing of reverse dependencies.
  49. It caches the state of the suite and then uses that as basis for answering queries.
  50. This saves a significant amount of time if multiple reverse dependency checks are
  51. required.
  52. """
  53. def __init__(self, session, suite):
  54. """Creates a new ReverseDependencyChecker instance
  55. This will spend a significant amount of time caching data.
  56. @type session: SQLA Session
  57. @param session: The database session in use
  58. @type suite: str
  59. @param suite: The name of the suite that is used as basis for removal tests.
  60. """
  61. self._session = session
  62. dbsuite = get_suite(suite, session)
  63. suite_archs2id = dict((x.arch_string, x.arch_id) for x in get_suite_architectures(suite))
  64. package_dependencies, arch_providers_of, arch_provided_by = self._load_package_information(session,
  65. dbsuite.suite_id,
  66. suite_archs2id)
  67. self._package_dependencies = package_dependencies
  68. self._arch_providers_of = arch_providers_of
  69. self._arch_provided_by = arch_provided_by
  70. self._archs_in_suite = set(suite_archs2id)
  71. @staticmethod
  72. def _load_package_information(session, suite_id, suite_archs2id):
  73. package_dependencies = defaultdict(lambda: defaultdict(set))
  74. arch_providers_of = defaultdict(lambda: defaultdict(set))
  75. arch_provided_by = defaultdict(lambda: defaultdict(set))
  76. source_deps = defaultdict(set)
  77. metakey_d = get_or_set_metadatakey("Depends", session)
  78. metakey_p = get_or_set_metadatakey("Provides", session)
  79. params = {
  80. 'suite_id': suite_id,
  81. 'arch_all_id': suite_archs2id['all'],
  82. 'metakey_d_id': metakey_d.key_id,
  83. 'metakey_p_id': metakey_p.key_id,
  84. }
  85. all_arches = set(suite_archs2id)
  86. all_arches.discard('source')
  87. package_dependencies['source'] = source_deps
  88. for architecture in all_arches:
  89. deps = defaultdict(set)
  90. providers_of = defaultdict(set)
  91. provided_by = defaultdict(set)
  92. arch_providers_of[architecture] = providers_of
  93. arch_provided_by[architecture] = provided_by
  94. package_dependencies[architecture] = deps
  95. params['arch_id'] = suite_archs2id[architecture]
  96. statement = '''
  97. SELECT b.package,
  98. (SELECT bmd.value FROM binaries_metadata bmd WHERE bmd.bin_id = b.id AND bmd.key_id = :metakey_d_id) AS depends,
  99. (SELECT bmp.value FROM binaries_metadata bmp WHERE bmp.bin_id = b.id AND bmp.key_id = :metakey_p_id) AS provides
  100. FROM binaries b
  101. JOIN bin_associations ba ON b.id = ba.bin AND ba.suite = :suite_id
  102. WHERE b.architecture = :arch_id OR b.architecture = :arch_all_id'''
  103. query = session.query('package', 'depends', 'provides'). \
  104. from_statement(statement).params(params)
  105. for package, depends, provides in query:
  106. if depends is not None:
  107. try:
  108. parsed_dep = []
  109. for dep in apt_pkg.parse_depends(depends):
  110. parsed_dep.append(frozenset(d[0] for d in dep))
  111. deps[package].update(parsed_dep)
  112. except ValueError as e:
  113. print "Error for package %s: %s" % (package, e)
  114. # Maintain a counter for each virtual package. If a
  115. # Provides: exists, set the counter to 0 and count all
  116. # provides by a package not in the list for removal.
  117. # If the counter stays 0 at the end, we know that only
  118. # the to-be-removed packages provided this virtual
  119. # package.
  120. if provides is not None:
  121. for virtual_pkg in provides.split(","):
  122. virtual_pkg = virtual_pkg.strip()
  123. if virtual_pkg == package:
  124. continue
  125. provided_by[virtual_pkg].add(package)
  126. providers_of[package].add(virtual_pkg)
  127. # Check source dependencies (Build-Depends and Build-Depends-Indep)
  128. metakey_bd = get_or_set_metadatakey("Build-Depends", session)
  129. metakey_bdi = get_or_set_metadatakey("Build-Depends-Indep", session)
  130. params = {
  131. 'suite_id': suite_id,
  132. 'metakey_ids': (metakey_bd.key_id, metakey_bdi.key_id),
  133. }
  134. statement = '''
  135. SELECT s.source, string_agg(sm.value, ', ') as build_dep
  136. FROM source s
  137. JOIN source_metadata sm ON s.id = sm.src_id
  138. WHERE s.id in
  139. (SELECT source FROM src_associations
  140. WHERE suite = :suite_id)
  141. AND sm.key_id in :metakey_ids
  142. GROUP BY s.id, s.source'''
  143. query = session.query('source', 'build_dep').from_statement(statement). \
  144. params(params)
  145. for source, build_dep in query:
  146. if build_dep is not None:
  147. # Remove [arch] information since we want to see breakage on all arches
  148. build_dep = re_build_dep_arch.sub("", build_dep)
  149. try:
  150. parsed_dep = []
  151. for dep in apt_pkg.parse_src_depends(build_dep):
  152. parsed_dep.append(frozenset(d[0] for d in dep))
  153. source_deps[source].update(parsed_dep)
  154. except ValueError as e:
  155. print "Error for package %s: %s" % (source, e)
  156. return package_dependencies, arch_providers_of, arch_provided_by
  157. def check_reverse_depends(self, removal_requests):
  158. """Bulk check reverse dependencies
  159. Example:
  160. removal_request = {
  161. "eclipse-rcp": None, # means ALL architectures (incl. source)
  162. "eclipse": None, # means ALL architectures (incl. source)
  163. "lintian": ["source", "all"], # Only these two "architectures".
  164. }
  165. obj.check_reverse_depends(removal_request)
  166. @type removal_requests: dict (or a list of tuples)
  167. @param removal_requests: A dictionary mapping a package name to a list of architectures. The list of
  168. architectures decides from which the package will be removed - if the list is empty the package will
  169. be removed on ALL architectures in the suite (including "source").
  170. @rtype: dict
  171. @return: A mapping of "removed package" (as a "(pkg, arch)"-tuple) to a set of broken
  172. broken packages (also as "(pkg, arch)"-tuple). Note that the architecture values
  173. in these tuples /can/ be "source" to reflect a breakage in build-dependencies.
  174. """
  175. archs_in_suite = self._archs_in_suite
  176. removals_by_arch = defaultdict(set)
  177. affected_virtual_by_arch = defaultdict(set)
  178. package_dependencies = self._package_dependencies
  179. arch_providers_of = self._arch_providers_of
  180. arch_provided_by = self._arch_provided_by
  181. arch_provides2removal = defaultdict(lambda: defaultdict(set))
  182. dep_problems = defaultdict(set)
  183. src_deps = package_dependencies['source']
  184. src_removals = set()
  185. arch_all_removals = set()
  186. if isinstance(removal_requests, dict):
  187. removal_requests = removal_requests.iteritems()
  188. for pkg, arch_list in removal_requests:
  189. if not arch_list:
  190. arch_list = archs_in_suite
  191. for arch in arch_list:
  192. if arch == 'source':
  193. src_removals.add(pkg)
  194. continue
  195. if arch == 'all':
  196. arch_all_removals.add(pkg)
  197. continue
  198. removals_by_arch[arch].add(pkg)
  199. if pkg in arch_providers_of[arch]:
  200. affected_virtual_by_arch[arch].add(pkg)
  201. if arch_all_removals:
  202. for arch in archs_in_suite:
  203. if arch in ('all', 'source'):
  204. continue
  205. removals_by_arch[arch].update(arch_all_removals)
  206. for pkg in arch_all_removals:
  207. if pkg in arch_providers_of[arch]:
  208. affected_virtual_by_arch[arch].add(pkg)
  209. if not removals_by_arch:
  210. # Nothing to remove => no problems
  211. return dep_problems
  212. for arch, removed_providers in affected_virtual_by_arch.iteritems():
  213. provides2removal = arch_provides2removal[arch]
  214. removals = removals_by_arch[arch]
  215. for virtual_pkg, virtual_providers in arch_provided_by[arch].iteritems():
  216. v = virtual_providers & removed_providers
  217. if len(v) == len(virtual_providers):
  218. # We removed all the providers of virtual_pkg
  219. removals.add(virtual_pkg)
  220. # Pick one to take the blame for the removal
  221. # - we sort for determinism, optimally we would prefer to blame the same package
  222. # to minimise the number of blamed packages.
  223. provides2removal[virtual_pkg] = sorted(v)[0]
  224. for arch, removals in removals_by_arch.iteritems():
  225. deps = package_dependencies[arch]
  226. provides2removal = arch_provides2removal[arch]
  227. # Check binary dependencies (Depends)
  228. for package, dependencies in deps.iteritems():
  229. if package in removals:
  230. continue
  231. for clause in dependencies:
  232. if not (clause <= removals):
  233. # Something probably still satisfies this relation
  234. continue
  235. # whoops, we seemed to have removed all packages that could possibly satisfy
  236. # this relation. Lets blame something for it
  237. for dep_package in clause:
  238. removal = dep_package
  239. if dep_package in provides2removal:
  240. removal = provides2removal[dep_package]
  241. dep_problems[(removal, arch)].add((package, arch))
  242. for source, build_dependencies in src_deps.iteritems():
  243. if source in src_removals:
  244. continue
  245. for clause in build_dependencies:
  246. if not (clause <= removals):
  247. # Something probably still satisfies this relation
  248. continue
  249. # whoops, we seemed to have removed all packages that could possibly satisfy
  250. # this relation. Lets blame something for it
  251. for dep_package in clause:
  252. removal = dep_package
  253. if dep_package in provides2removal:
  254. removal = provides2removal[dep_package]
  255. dep_problems[(removal, arch)].add((source, 'source'))
  256. return dep_problems
  257. def remove(session, reason, suites, removals,
  258. whoami=None, partial=False, components=None, done_bugs=None, date=None,
  259. carbon_copy=None, close_related_bugs=False):
  260. """Batch remove a number of packages
  261. Verify that the files listed in the Files field of the .dsc are
  262. those expected given the announced Format.
  263. @type session: SQLA Session
  264. @param session: The database session in use
  265. @type reason: string
  266. @param reason: The reason for the removal (e.g. "[auto-cruft] NBS (no longer built by <source>)")
  267. @type suites: list
  268. @param suites: A list of the suite names in which the removal should occur
  269. @type removals: list
  270. @param removals: A list of the removals. Each element should be a tuple (or list) of at least the following
  271. for 4 items from the database (in order): package, version, architecture, (database) id.
  272. For source packages, the "architecture" should be set to "source".
  273. @type partial: bool
  274. @param partial: Whether the removal is "partial" (e.g. architecture specific).
  275. @type components: list
  276. @param components: List of components involved in a partial removal. Can be an empty list to not restrict the
  277. removal to any components.
  278. @type whoami: string
  279. @param whoami: The person (or entity) doing the removal. Defaults to utils.whoami()
  280. @type date: string
  281. @param date: The date of the removal. Defaults to commands.getoutput("date -R")
  282. @type done_bugs: list
  283. @param done_bugs: A list of bugs to be closed when doing this removal.
  284. @type close_related_bugs: bool
  285. @param done_bugs: Whether bugs related to the package being removed should be closed as well. NB: Not implemented
  286. for more than one suite.
  287. @type carbon_copy: list
  288. @param carbon_copy: A list of mail addresses to CC when doing removals. NB: all items are taken "as-is" unlike
  289. "dak rm".
  290. @rtype: None
  291. @return: Nothing
  292. """
  293. # Generate the summary of what's to be removed
  294. d = {}
  295. summary = ""
  296. sources = []
  297. binaries = []
  298. whitelists = []
  299. versions = []
  300. suite_ids_list = []
  301. suites_list = utils.join_with_commas_and(suites)
  302. cnf = utils.get_conf()
  303. con_components = ''
  304. #######################################################################################################
  305. if not reason:
  306. raise ValueError("Empty removal reason not permitted")
  307. if not removals:
  308. raise ValueError("Nothing to remove!?")
  309. if not suites:
  310. raise ValueError("Removals without a suite!?")
  311. if whoami is None:
  312. whoami = utils.whoami()
  313. if date is None:
  314. date = commands.getoutput("date -R")
  315. if partial and components:
  316. component_ids_list = []
  317. for componentname in components:
  318. component = get_component(componentname, session=session)
  319. if component is None:
  320. raise ValueError("component '%s' not recognised." % componentname)
  321. else:
  322. component_ids_list.append(component.component_id)
  323. if component_ids_list:
  324. con_components = "AND component IN (%s)" % ", ".join([str(i) for i in component_ids_list])
  325. for i in removals:
  326. package = i[0]
  327. version = i[1]
  328. architecture = i[2]
  329. if package not in d:
  330. d[package] = {}
  331. if version not in d[package]:
  332. d[package][version] = []
  333. if architecture not in d[package][version]:
  334. d[package][version].append(architecture)
  335. for package in sorted(d):
  336. versions = sorted(d[package], cmp=apt_pkg.version_compare)
  337. for version in versions:
  338. d[package][version].sort(utils.arch_compare_sw)
  339. summary += "%10s | %10s | %s\n" % (package, version, ", ".join(d[package][version]))
  340. for package in summary.split("\n"):
  341. for row in package.split("\n"):
  342. element = row.split("|")
  343. if len(element) == 3:
  344. if element[2].find("source") > 0:
  345. sources.append("%s_%s" % tuple(elem.strip(" ") for elem in element[:2]))
  346. element[2] = sub("source\s?,?", "", element[2]).strip(" ")
  347. if element[2]:
  348. binaries.append("%s_%s [%s]" % tuple(elem.strip(" ") for elem in element))
  349. dsc_type_id = get_override_type('dsc', session).overridetype_id
  350. deb_type_id = get_override_type('deb', session).overridetype_id
  351. for suite in suites:
  352. s = get_suite(suite, session=session)
  353. if s is not None:
  354. suite_ids_list.append(s.suite_id)
  355. whitelists.append(s.mail_whitelist)
  356. #######################################################################################################
  357. log_filename = cnf["Rm::LogFile"]
  358. log822_filename = cnf["Rm::LogFile822"]
  359. with utils.open_file(log_filename, "a") as logfile, utils.open_file(log822_filename, "a") as logfile822:
  360. fcntl.lockf(logfile, fcntl.LOCK_EX)
  361. fcntl.lockf(logfile822, fcntl.LOCK_EX)
  362. logfile.write("=========================================================================\n")
  363. logfile.write("[Date: %s] [ftpmaster: %s]\n" % (date, whoami))
  364. logfile.write("Removed the following packages from %s:\n\n%s" % (suites_list, summary))
  365. if done_bugs:
  366. logfile.write("Closed bugs: %s\n" % (", ".join(done_bugs)))
  367. logfile.write("\n------------------- Reason -------------------\n%s\n" % reason)
  368. logfile.write("----------------------------------------------\n")
  369. logfile822.write("Date: %s\n" % date)
  370. logfile822.write("Ftpmaster: %s\n" % whoami)
  371. logfile822.write("Suite: %s\n" % suites_list)
  372. if sources:
  373. logfile822.write("Sources:\n")
  374. for source in sources:
  375. logfile822.write(" %s\n" % source)
  376. if binaries:
  377. logfile822.write("Binaries:\n")
  378. for binary in binaries:
  379. logfile822.write(" %s\n" % binary)
  380. logfile822.write("Reason: %s\n" % reason.replace('\n', '\n '))
  381. if done_bugs:
  382. logfile822.write("Bug: %s\n" % (", ".join(done_bugs)))
  383. for i in removals:
  384. package = i[0]
  385. architecture = i[2]
  386. package_id = i[3]
  387. for suite_id in suite_ids_list:
  388. if architecture == "source":
  389. session.execute("DELETE FROM src_associations WHERE source = :packageid AND suite = :suiteid",
  390. {'packageid': package_id, 'suiteid': suite_id})
  391. else:
  392. session.execute("DELETE FROM bin_associations WHERE bin = :packageid AND suite = :suiteid",
  393. {'packageid': package_id, 'suiteid': suite_id})
  394. # Delete from the override file
  395. if not partial:
  396. if architecture == "source":
  397. type_id = dsc_type_id
  398. else:
  399. type_id = deb_type_id
  400. # TODO: Fix this properly to remove the remaining non-bind argument
  401. session.execute("DELETE FROM override WHERE package = :package AND type = :typeid AND suite = :suiteid %s" % (con_components), {'package': package, 'typeid': type_id, 'suiteid': suite_id})
  402. session.commit()
  403. # ### REMOVAL COMPLETE - send mail time ### #
  404. # If we don't have a Bug server configured, we're done
  405. if "Dinstall::BugServer" not in cnf:
  406. if done_bugs or close_related_bugs:
  407. utils.warn("Cannot send mail to BugServer as Dinstall::BugServer is not configured")
  408. logfile.write("=========================================================================\n")
  409. logfile822.write("\n")
  410. return
  411. # read common subst variables for all bug closure mails
  412. Subst_common = {}
  413. Subst_common["__RM_ADDRESS__"] = cnf["Dinstall::MyEmailAddress"]
  414. Subst_common["__BUG_SERVER__"] = cnf["Dinstall::BugServer"]
  415. Subst_common["__CC__"] = "X-DAK: dak rm"
  416. if carbon_copy:
  417. Subst_common["__CC__"] += "\nCc: " + ", ".join(carbon_copy)
  418. Subst_common["__SUITE_LIST__"] = suites_list
  419. Subst_common["__SUBJECT__"] = "Removed package(s) from %s" % (suites_list)
  420. Subst_common["__ADMIN_ADDRESS__"] = cnf["Dinstall::MyAdminAddress"]
  421. Subst_common["__DISTRO__"] = cnf["Dinstall::MyDistribution"]
  422. Subst_common["__WHOAMI__"] = whoami
  423. # Send the bug closing messages
  424. if done_bugs:
  425. Subst_close_rm = Subst_common
  426. bcc = []
  427. if cnf.find("Dinstall::Bcc") != "":
  428. bcc.append(cnf["Dinstall::Bcc"])
  429. if cnf.find("Rm::Bcc") != "":
  430. bcc.append(cnf["Rm::Bcc"])
  431. if bcc:
  432. Subst_close_rm["__BCC__"] = "Bcc: " + ", ".join(bcc)
  433. else:
  434. Subst_close_rm["__BCC__"] = "X-Filler: 42"
  435. summarymail = "%s\n------------------- Reason -------------------\n%s\n" % (summary, reason)
  436. summarymail += "----------------------------------------------\n"
  437. Subst_close_rm["__SUMMARY__"] = summarymail
  438. for bug in done_bugs:
  439. Subst_close_rm["__BUG_NUMBER__"] = bug
  440. if close_related_bugs:
  441. mail_message = utils.TemplateSubst(Subst_close_rm,cnf["Dir::Templates"]+"/rm.bug-close-with-related")
  442. else:
  443. mail_message = utils.TemplateSubst(Subst_close_rm,cnf["Dir::Templates"]+"/rm.bug-close")
  444. utils.send_mail(mail_message, whitelists=whitelists)
  445. # close associated bug reports
  446. if close_related_bugs:
  447. Subst_close_other = Subst_common
  448. bcc = []
  449. wnpp = utils.parse_wnpp_bug_file()
  450. versions = list(set([re_bin_only_nmu.sub('', v) for v in versions]))
  451. if len(versions) == 1:
  452. Subst_close_other["__VERSION__"] = versions[0]
  453. else:
  454. logfile.write("=========================================================================\n")
  455. logfile822.write("\n")
  456. raise ValueError("Closing bugs with multiple package versions is not supported. Do it yourself.")
  457. if bcc:
  458. Subst_close_other["__BCC__"] = "Bcc: " + ", ".join(bcc)
  459. else:
  460. Subst_close_other["__BCC__"] = "X-Filler: 42"
  461. # at this point, I just assume, that the first closed bug gives
  462. # some useful information on why the package got removed
  463. Subst_close_other["__BUG_NUMBER__"] = done_bugs[0]
  464. if len(sources) == 1:
  465. source_pkg = source.split("_", 1)[0]
  466. else:
  467. logfile.write("=========================================================================\n")
  468. logfile822.write("\n")
  469. raise ValueError("Closing bugs for multiple source packages is not supported. Please do it yourself.")
  470. Subst_close_other["__BUG_NUMBER_ALSO__"] = ""
  471. Subst_close_other["__SOURCE__"] = source_pkg
  472. merged_bugs = set()
  473. other_bugs = bts.get_bugs('src', source_pkg, 'status', 'open', 'status', 'forwarded')
  474. if other_bugs:
  475. for bugno in other_bugs:
  476. if bugno not in merged_bugs:
  477. for bug in bts.get_status(bugno):
  478. for merged in bug.mergedwith:
  479. other_bugs.remove(merged)
  480. merged_bugs.add(merged)
  481. logfile.write("Also closing bug(s):")
  482. logfile822.write("Also-Bugs:")
  483. for bug in other_bugs:
  484. Subst_close_other["__BUG_NUMBER_ALSO__"] += str(bug) + "-done@" + cnf["Dinstall::BugServer"] + ","
  485. logfile.write(" " + str(bug))
  486. logfile822.write(" " + str(bug))
  487. logfile.write("\n")
  488. logfile822.write("\n")
  489. if source_pkg in wnpp:
  490. logfile.write("Also closing WNPP bug(s):")
  491. logfile822.write("Also-WNPP:")
  492. for bug in wnpp[source_pkg]:
  493. # the wnpp-rm file we parse also contains our removal
  494. # bugs, filtering that out
  495. if bug != Subst_close_other["__BUG_NUMBER__"]:
  496. Subst_close_other["__BUG_NUMBER_ALSO__"] += str(bug) + "-done@" + cnf["Dinstall::BugServer"] + ","
  497. logfile.write(" " + str(bug))
  498. logfile822.write(" " + str(bug))
  499. logfile.write("\n")
  500. logfile822.write("\n")
  501. mail_message = utils.TemplateSubst(Subst_close_other, cnf["Dir::Templates"]+"/rm.bug-close-related")
  502. if Subst_close_other["__BUG_NUMBER_ALSO__"]:
  503. utils.send_mail(mail_message)
  504. logfile.write("=========================================================================\n")
  505. logfile822.write("\n")