rm.py 26 KB

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