rm.py 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  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. from __future__ import absolute_import, print_function
  35. import commands
  36. import apt_pkg
  37. import fcntl
  38. import functools
  39. import sqlalchemy.sql as sql
  40. from re import sub
  41. from collections import defaultdict
  42. from .regexes import re_build_dep_arch
  43. from daklib.dbconn import *
  44. from daklib import utils
  45. from daklib.regexes import re_bin_only_nmu
  46. import debianbts as bts
  47. ################################################################################
  48. class ReverseDependencyChecker(object):
  49. """A bulk tester for reverse dependency checks
  50. This class is similar to the check_reverse_depends method from "utils". However,
  51. it is primarily focused on facilitating bulk testing of reverse dependencies.
  52. It caches the state of the suite and then uses that as basis for answering queries.
  53. This saves a significant amount of time if multiple reverse dependency checks are
  54. required.
  55. """
  56. def __init__(self, session, suite):
  57. """Creates a new ReverseDependencyChecker instance
  58. This will spend a significant amount of time caching data.
  59. @type session: SQLA Session
  60. @param session: The database session in use
  61. @type suite: str
  62. @param suite: The name of the suite that is used as basis for removal tests.
  63. """
  64. self._session = session
  65. dbsuite = get_suite(suite, session)
  66. suite_archs2id = dict((x.arch_string, x.arch_id) for x in get_suite_architectures(suite))
  67. package_dependencies, arch_providers_of, arch_provided_by = self._load_package_information(session,
  68. dbsuite.suite_id,
  69. suite_archs2id)
  70. self._package_dependencies = package_dependencies
  71. self._arch_providers_of = arch_providers_of
  72. self._arch_provided_by = arch_provided_by
  73. self._archs_in_suite = set(suite_archs2id)
  74. @staticmethod
  75. def _load_package_information(session, suite_id, suite_archs2id):
  76. package_dependencies = defaultdict(lambda: defaultdict(set))
  77. arch_providers_of = defaultdict(lambda: defaultdict(set))
  78. arch_provided_by = defaultdict(lambda: defaultdict(set))
  79. source_deps = defaultdict(set)
  80. metakey_d = get_or_set_metadatakey("Depends", session)
  81. metakey_p = get_or_set_metadatakey("Provides", session)
  82. params = {
  83. 'suite_id': suite_id,
  84. 'arch_all_id': suite_archs2id['all'],
  85. 'metakey_d_id': metakey_d.key_id,
  86. 'metakey_p_id': metakey_p.key_id,
  87. }
  88. all_arches = set(suite_archs2id)
  89. all_arches.discard('source')
  90. package_dependencies['source'] = source_deps
  91. for architecture in all_arches:
  92. deps = defaultdict(set)
  93. providers_of = defaultdict(set)
  94. provided_by = defaultdict(set)
  95. arch_providers_of[architecture] = providers_of
  96. arch_provided_by[architecture] = provided_by
  97. package_dependencies[architecture] = deps
  98. params['arch_id'] = suite_archs2id[architecture]
  99. statement = sql.text('''
  100. SELECT b.package,
  101. (SELECT bmd.value FROM binaries_metadata bmd WHERE bmd.bin_id = b.id AND bmd.key_id = :metakey_d_id) AS depends,
  102. (SELECT bmp.value FROM binaries_metadata bmp WHERE bmp.bin_id = b.id AND bmp.key_id = :metakey_p_id) AS provides
  103. FROM binaries b
  104. JOIN bin_associations ba ON b.id = ba.bin AND ba.suite = :suite_id
  105. WHERE b.architecture = :arch_id OR b.architecture = :arch_all_id''')
  106. query = session.query('package', 'depends', 'provides'). \
  107. from_statement(statement).params(params)
  108. for package, depends, provides in query:
  109. if depends is not None:
  110. try:
  111. parsed_dep = []
  112. for dep in apt_pkg.parse_depends(depends):
  113. parsed_dep.append(frozenset(d[0] for d in dep))
  114. deps[package].update(parsed_dep)
  115. except ValueError as e:
  116. print("Error for package %s: %s" % (package, e))
  117. # Maintain a counter for each virtual package. If a
  118. # Provides: exists, set the counter to 0 and count all
  119. # provides by a package not in the list for removal.
  120. # If the counter stays 0 at the end, we know that only
  121. # the to-be-removed packages provided this virtual
  122. # package.
  123. if provides is not None:
  124. for virtual_pkg in provides.split(","):
  125. virtual_pkg = virtual_pkg.strip()
  126. if virtual_pkg == package:
  127. continue
  128. provided_by[virtual_pkg].add(package)
  129. providers_of[package].add(virtual_pkg)
  130. # Check source dependencies (Build-Depends and Build-Depends-Indep)
  131. metakey_bd = get_or_set_metadatakey("Build-Depends", session)
  132. metakey_bdi = get_or_set_metadatakey("Build-Depends-Indep", session)
  133. params = {
  134. 'suite_id': suite_id,
  135. 'metakey_ids': (metakey_bd.key_id, metakey_bdi.key_id),
  136. }
  137. statement = sql.text('''
  138. SELECT s.source, string_agg(sm.value, ', ') as build_dep
  139. FROM source s
  140. JOIN source_metadata sm ON s.id = sm.src_id
  141. WHERE s.id in
  142. (SELECT source FROM src_associations
  143. WHERE suite = :suite_id)
  144. AND sm.key_id in :metakey_ids
  145. GROUP BY s.id, s.source''')
  146. query = session.query('source', 'build_dep').from_statement(statement). \
  147. params(params)
  148. for source, build_dep in query:
  149. if build_dep is not None:
  150. # Remove [arch] information since we want to see breakage on all arches
  151. build_dep = re_build_dep_arch.sub("", build_dep)
  152. try:
  153. parsed_dep = []
  154. for dep in apt_pkg.parse_src_depends(build_dep):
  155. parsed_dep.append(frozenset(d[0] for d in dep))
  156. source_deps[source].update(parsed_dep)
  157. except ValueError as e:
  158. print("Error for package %s: %s" % (source, e))
  159. return package_dependencies, arch_providers_of, arch_provided_by
  160. def check_reverse_depends(self, removal_requests):
  161. """Bulk check reverse dependencies
  162. Example:
  163. removal_request = {
  164. "eclipse-rcp": None, # means ALL architectures (incl. source)
  165. "eclipse": None, # means ALL architectures (incl. source)
  166. "lintian": ["source", "all"], # Only these two "architectures".
  167. }
  168. obj.check_reverse_depends(removal_request)
  169. @type removal_requests: dict (or a list of tuples)
  170. @param removal_requests: A dictionary mapping a package name to a list of architectures. The list of
  171. architectures decides from which the package will be removed - if the list is empty the package will
  172. be removed on ALL architectures in the suite (including "source").
  173. @rtype: dict
  174. @return: A mapping of "removed package" (as a "(pkg, arch)"-tuple) to a set of broken
  175. broken packages (also as "(pkg, arch)"-tuple). Note that the architecture values
  176. in these tuples /can/ be "source" to reflect a breakage in build-dependencies.
  177. """
  178. archs_in_suite = self._archs_in_suite
  179. removals_by_arch = defaultdict(set)
  180. affected_virtual_by_arch = defaultdict(set)
  181. package_dependencies = self._package_dependencies
  182. arch_providers_of = self._arch_providers_of
  183. arch_provided_by = self._arch_provided_by
  184. arch_provides2removal = defaultdict(lambda: defaultdict(set))
  185. dep_problems = defaultdict(set)
  186. src_deps = package_dependencies['source']
  187. src_removals = set()
  188. arch_all_removals = set()
  189. if isinstance(removal_requests, dict):
  190. removal_requests = removal_requests.iteritems()
  191. for pkg, arch_list in removal_requests:
  192. if not arch_list:
  193. arch_list = archs_in_suite
  194. for arch in arch_list:
  195. if arch == 'source':
  196. src_removals.add(pkg)
  197. continue
  198. if arch == 'all':
  199. arch_all_removals.add(pkg)
  200. continue
  201. removals_by_arch[arch].add(pkg)
  202. if pkg in arch_providers_of[arch]:
  203. affected_virtual_by_arch[arch].add(pkg)
  204. if arch_all_removals:
  205. for arch in archs_in_suite:
  206. if arch in ('all', 'source'):
  207. continue
  208. removals_by_arch[arch].update(arch_all_removals)
  209. for pkg in arch_all_removals:
  210. if pkg in arch_providers_of[arch]:
  211. affected_virtual_by_arch[arch].add(pkg)
  212. if not removals_by_arch:
  213. # Nothing to remove => no problems
  214. return dep_problems
  215. for arch, removed_providers in affected_virtual_by_arch.iteritems():
  216. provides2removal = arch_provides2removal[arch]
  217. removals = removals_by_arch[arch]
  218. for virtual_pkg, virtual_providers in arch_provided_by[arch].iteritems():
  219. v = virtual_providers & removed_providers
  220. if len(v) == len(virtual_providers):
  221. # We removed all the providers of virtual_pkg
  222. removals.add(virtual_pkg)
  223. # Pick one to take the blame for the removal
  224. # - we sort for determinism, optimally we would prefer to blame the same package
  225. # to minimise the number of blamed packages.
  226. provides2removal[virtual_pkg] = sorted(v)[0]
  227. for arch, removals in removals_by_arch.iteritems():
  228. deps = package_dependencies[arch]
  229. provides2removal = arch_provides2removal[arch]
  230. # Check binary dependencies (Depends)
  231. for package, dependencies in deps.iteritems():
  232. if package in removals:
  233. continue
  234. for clause in dependencies:
  235. if not (clause <= removals):
  236. # Something probably still satisfies this relation
  237. continue
  238. # whoops, we seemed to have removed all packages that could possibly satisfy
  239. # this relation. Lets blame something for it
  240. for dep_package in clause:
  241. removal = dep_package
  242. if dep_package in provides2removal:
  243. removal = provides2removal[dep_package]
  244. dep_problems[(removal, arch)].add((package, arch))
  245. for source, build_dependencies in src_deps.iteritems():
  246. if source in src_removals:
  247. continue
  248. for clause in build_dependencies:
  249. if not (clause <= removals):
  250. # Something probably still satisfies this relation
  251. continue
  252. # whoops, we seemed to have removed all packages that could possibly satisfy
  253. # this relation. Lets blame something for it
  254. for dep_package in clause:
  255. removal = dep_package
  256. if dep_package in provides2removal:
  257. removal = provides2removal[dep_package]
  258. dep_problems[(removal, arch)].add((source, 'source'))
  259. return dep_problems
  260. def remove(session, reason, suites, removals,
  261. whoami=None, partial=False, components=None, done_bugs=None, date=None,
  262. carbon_copy=None, close_related_bugs=False):
  263. """Batch remove a number of packages
  264. Verify that the files listed in the Files field of the .dsc are
  265. those expected given the announced Format.
  266. @type session: SQLA Session
  267. @param session: The database session in use
  268. @type reason: string
  269. @param reason: The reason for the removal (e.g. "[auto-cruft] NBS (no longer built by <source>)")
  270. @type suites: list
  271. @param suites: A list of the suite names in which the removal should occur
  272. @type removals: list
  273. @param removals: A list of the removals. Each element should be a tuple (or list) of at least the following
  274. for 4 items from the database (in order): package, version, architecture, (database) id.
  275. For source packages, the "architecture" should be set to "source".
  276. @type partial: bool
  277. @param partial: Whether the removal is "partial" (e.g. architecture specific).
  278. @type components: list
  279. @param components: List of components involved in a partial removal. Can be an empty list to not restrict the
  280. removal to any components.
  281. @type whoami: string
  282. @param whoami: The person (or entity) doing the removal. Defaults to utils.whoami()
  283. @type date: string
  284. @param date: The date of the removal. Defaults to commands.getoutput("date -R")
  285. @type done_bugs: list
  286. @param done_bugs: A list of bugs to be closed when doing this removal.
  287. @type close_related_bugs: bool
  288. @param done_bugs: Whether bugs related to the package being removed should be closed as well. NB: Not implemented
  289. for more than one suite.
  290. @type carbon_copy: list
  291. @param carbon_copy: A list of mail addresses to CC when doing removals. NB: all items are taken "as-is" unlike
  292. "dak rm".
  293. @rtype: None
  294. @return: Nothing
  295. """
  296. # Generate the summary of what's to be removed
  297. d = {}
  298. summary = ""
  299. sources = []
  300. binaries = []
  301. whitelists = []
  302. versions = []
  303. newest_source = ''
  304. suite_ids_list = []
  305. suites_list = utils.join_with_commas_and(suites)
  306. cnf = utils.get_conf()
  307. con_components = ''
  308. #######################################################################################################
  309. if not reason:
  310. raise ValueError("Empty removal reason not permitted")
  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 = commands.getoutput("date -R")
  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("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 utils.open_file(log_filename, "a") as logfile, utils.open_file(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")