You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

debbugs.py 46 KiB

17 years ago
17 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196
  1. #
  2. # debbugs.py - Routines to deal with BTS web pages
  3. #
  4. # Written by Chris Lawrence <lawrencc@debian.org>
  5. # (C) 1999-2008 Chris Lawrence
  6. # Copyright (C) 2008-2017 Sandro Tosi <morph@debian.org>
  7. #
  8. # This program is freely distributable per the following license:
  9. #
  10. # Permission to use, copy, modify, and distribute this software and its
  11. # documentation for any purpose and without fee is hereby granted,
  12. # provided that the above copyright notice appears in all copies and that
  13. # both that copyright notice and this permission notice appear in
  14. # supporting documentation.
  15. #
  16. # I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  17. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
  18. # BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
  19. # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  20. # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  21. # ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  22. # SOFTWARE.
  23. from . import utils
  24. import sys
  25. import mailbox
  26. import email
  27. import email.parser
  28. import email.errors
  29. import io
  30. import glob
  31. import os
  32. import re
  33. import time
  34. import urllib.request, urllib.parse, urllib.error
  35. import textwrap
  36. import pprint
  37. # SOAP interface to Debian BTS
  38. import debianbts
  39. from collections import defaultdict
  40. from . import checkversions
  41. from .exceptions import (
  42. NoNetwork,
  43. QuertBTSError,
  44. )
  45. from .urlutils import open_url
  46. def msgfactory(fp):
  47. try:
  48. return email.message_from_file(fp)
  49. except email.errors.MessageParseError:
  50. # Don't return None since that will
  51. # stop the mailbox iterator
  52. return ''
  53. class Error(Exception):
  54. pass
  55. # Severity levels
  56. SEVERITIES = {
  57. 'critical': """makes unrelated software on the system (or the
  58. whole system) break, or causes serious data loss, or introduces a
  59. security hole on systems where you install the package.""",
  60. 'grave': """makes the package in question unusable by most or all users,
  61. or causes data loss, or introduces a security hole allowing access
  62. to the accounts of users who use the package.""",
  63. 'serious': """is a severe violation of Debian policy (that is,
  64. the problem is a violation of a 'must' or 'required' directive);
  65. may or may not affect the usability of the package. Note that non-severe
  66. policy violations may be 'normal,' 'minor,' or 'wishlist' bugs.
  67. (Package maintainers may also designate other bugs as 'serious' and thus
  68. release-critical; however, end users should not do so.). For the canonical
  69. list of issues worthing a serious severity you can refer to this webpage:
  70. http://release.debian.org/testing/rc_policy.txt .""",
  71. 'important': """a bug which has a major effect on the usability
  72. of a package, without rendering it completely unusable to
  73. everyone.""",
  74. 'does-not-build': """a bug that stops the package from being built
  75. from source. (This is a 'virtual severity'.)""",
  76. 'normal': """a bug that does not undermine the usability of the
  77. whole package; for example, a problem with a particular option or
  78. menu item.""",
  79. 'minor': """things like spelling mistakes and other minor
  80. cosmetic errors that do not affect the core functionality of the
  81. package.""",
  82. 'wishlist': "suggestions and requests for new features.",
  83. }
  84. # justifications for critical bugs
  85. JUSTIFICATIONS = {
  86. 'critical': (
  87. ('breaks unrelated software', """breaks unrelated software on the system
  88. (packages that have a dependency relationship are not unrelated)"""),
  89. ('breaks the whole system', """renders the entire system unusable (e.g.,
  90. unbootable, unable to reach a multiuser runlevel, etc.)"""),
  91. ('causes serious data loss', """causes loss of important, irreplaceable
  92. data"""),
  93. ('root security hole', """introduces a security hole allowing access to
  94. root (or another privileged system account), or data normally
  95. accessible only by such accounts"""),
  96. ('unknown', """not sure, or none of the above"""),
  97. ),
  98. 'grave': (
  99. ('renders package unusable', """renders the package unusable, or mostly
  100. so, on all or nearly all possible systems on which it could be installed
  101. (i.e., not a hardware-specific bug); or renders package uninstallable
  102. or unremovable without special effort"""),
  103. ('causes non-serious data loss', """causes the loss of data on the system
  104. that is unimportant, or restorable without resorting to backup media"""),
  105. ('user security hole', """introduces a security hole allowing access to
  106. user accounts or data not normally accessible"""),
  107. ('unknown', """not sure, or none of the above"""),
  108. )
  109. }
  110. # Ordering for justifications
  111. JUSTORDER = {
  112. 'critical': ['breaks unrelated software',
  113. 'breaks the whole system',
  114. 'causes serious data loss',
  115. 'root security hole',
  116. 'unknown'],
  117. 'grave': ['renders package unusable',
  118. 'causes non-serious data loss',
  119. 'user security hole',
  120. 'unknown']
  121. }
  122. SEVERITIES_gnats = {
  123. 'critical': 'The product, component or concept is completely'
  124. 'non-operational or some essential functionality is missing. No'
  125. 'workaround is known.',
  126. 'serious': 'The product, component or concept is not working'
  127. 'properly or significant functionality is missing. Problems that'
  128. 'would otherwise be considered ''critical'' are rated ''serious'' when'
  129. 'a workaround is known.',
  130. 'non-critical': 'The product, component or concept is working'
  131. 'in general, but lacks features, has irritating behavior, does'
  132. 'something wrong, or doesn''t match its documentation.',
  133. }
  134. # Rank order of severities, for sorting
  135. SEVLIST = ['critical', 'grave', 'serious', 'important', 'does-not-build',
  136. 'normal', 'non-critical', 'minor', 'wishlist', 'fixed']
  137. def convert_severity(severity, type='debbugs'):
  138. "Convert severity names if needed."
  139. if type == 'debbugs':
  140. return {'non-critical': 'normal'}.get(severity, severity)
  141. elif type == 'gnats':
  142. return {'grave': 'critical',
  143. 'important': 'serious',
  144. 'normal': 'non-critical',
  145. 'minor': 'non-critical',
  146. 'wishlist': 'non-critical'}.get(severity, severity)
  147. else:
  148. return severity
  149. # These packages are virtual in Debian; we don't look them up...
  150. debother = {
  151. 'bugs.debian.org': 'The bug tracking system, @bugs.debian.org',
  152. 'buildd.debian.org': 'Problems and requests related to the Debian Buildds',
  153. 'buildd.emdebian.org': 'Problems related to building packages for Emdebian',
  154. 'cdimage.debian.org': 'CD Image issues',
  155. 'cdrom': 'Installation system',
  156. 'cloud.debian.org': 'Issues involving Debian images for public/private clouds',
  157. 'd-i.debian.org': 'Issues regarding the d-i.debian.org service and general Debian Installer tasks',
  158. 'debian-maintainers': 'Problems and requests related to Debian Maintainers',
  159. 'debian-i18n': 'Requests regarding Internationalization (i18n) of the distribution',
  160. 'debian-live': 'General problems with Debian Live systems',
  161. 'ftp.debian.org': 'Problems with the FTP site and Package removal requests',
  162. 'general': 'General problems (e.g. "many manpages are mode 755")',
  163. 'installation-reports': 'Reports of installation problems with stable & testing',
  164. 'jenkins.debian.org': 'Issues with the jenkins.debian.org service',
  165. 'lists.debian.org': 'The mailing lists, debian-*@lists.debian.org',
  166. 'mirrors': 'Problems with the official mirrors',
  167. 'nm.debian.org': 'New Member process and nm.debian.org webpages',
  168. 'pet.debian.net': 'The Debian Package Entropy Tracker',
  169. 'piuparts.debian.org': 'Issues with the piuparts.debian.org service',
  170. 'press': 'Press release issues',
  171. 'project': 'Problems related to project administration',
  172. 'qa.debian.org': 'The Quality Assurance group',
  173. 'release.debian.org': 'Requests regarding Debian releases and release team tools',
  174. 'release-notes': 'Problems with the Release Notes',
  175. 'rtc.debian.org': 'Issues in the operation of the Debian RTC services which are not package-specific bugs',
  176. 'security-tracker': 'The Debian Security Bug Tracker',
  177. 'security.debian.org': 'The Debian Security Team',
  178. 'snapshot.debian.org': 'Issues with the snapshot.debian.org service ',
  179. 'spam': 'Spam (reassign spam to here so we can complain about it)',
  180. 'sponsorship-requests': 'Requests for package review and sponsorship',
  181. 'sso.debian.org': 'Problems and requests related to the Debian Single Sign On system',
  182. 'summit.debconf.org': 'Problems and requests related to the DebConf Summit instance',
  183. 'tech-ctte': 'The Debian Technical Committee (see the Constitution)',
  184. 'tracker.debian.org': 'Issues with the Debian Package Tracker and coordination of its maintenance',
  185. 'upgrade-reports': 'Reports of upgrade problems for stable & testing',
  186. 'wiki.debian.org': 'Problems with the Debian wiki',
  187. 'wnpp': 'Work-Needing and Prospective Packages list',
  188. 'www.debian.org': 'Problems with the WWW site'
  189. }
  190. progenyother = {
  191. 'debian-general': 'Any non-package-specific bug',
  192. }
  193. def handle_debian_ftp(package, bts, ui, fromaddr, timeout, online=True, http_proxy=None):
  194. body = reason = archs = section = priority = ''
  195. suite = 'unstable'
  196. headers = []
  197. pseudos = []
  198. query = True
  199. tag = ui.menu('What sort of request is this? (If none of these '
  200. 'things mean anything to you, or you are trying to report '
  201. 'a bug in an existing package, please press Enter to '
  202. 'exit reportbug.)', {
  203. 'ROM': "Package removal - Request Of Maintainer.",
  204. 'RoQA': "Package removal - Requested by the QA team.",
  205. 'ROP': "Package removal - Request of Porter.",
  206. 'NBS': "Package removal - Not Built [by] Source.",
  207. 'NPOASR': "Package removal - Never Part Of A Stable Release.",
  208. 'NVIU': "Package removal - Newer Version In Unstable.",
  209. 'ANAIS': "Package removal - Architecture Not Allowed In Source.",
  210. 'ICE': "Package removal - Internal Compiler Error.",
  211. 'override': "Change override request.",
  212. 'other': "Not a package removal request, report other problems.",
  213. }, 'Choose the request type: ', empty_ok=True)
  214. if not tag:
  215. ui.long_message('To report a bug in a package, use the name of the package, not ftp.debian.org.\n')
  216. raise SystemExit
  217. severity = 'normal'
  218. if tag == 'other':
  219. return
  220. else:
  221. prompt = 'Please enter the name of the package: '
  222. package = ui.get_string(prompt)
  223. if not package:
  224. ui.log_message('You seem to want to report a generic bug, not request a removal\n')
  225. return
  226. ui.log_message('Checking status database...\n')
  227. info = utils.get_package_status(package)
  228. available = info[1]
  229. query = False
  230. if not available:
  231. info = utils.get_source_package(package)
  232. if info:
  233. info = utils.get_package_status(info[0][0])
  234. if not info:
  235. cont = ui.select_options(
  236. "This package doesn't appear to exist; continue?",
  237. 'yN', {'y': 'Ignore this problem and continue.',
  238. 'n': 'Exit without filing a report.'})
  239. if cont == 'n':
  240. sys.exit(1)
  241. else:
  242. # don't try to convert it to source if it's an 'override'
  243. if tag != 'override':
  244. package = info[12] or package
  245. # get package section and priority, for override
  246. section, priority = info[16], info[10]
  247. if tag == 'override':
  248. # we handle here the override change request
  249. new_section = ui.menu('Select the new section', {
  250. 'admin': "", 'cli-mono': "", 'comm': "", 'database': "",
  251. 'debian-installer': "", 'debug': "", 'devel': "", 'doc': "",
  252. 'editors': "", 'education': "", 'electronics': "",
  253. 'embedded': "", 'fonts': "", 'games': "", 'gnome': "",
  254. 'gnu-r': "", 'gnustep': "", 'graphics': "", 'hamradio': "",
  255. 'haskell': "", 'httpd': "", 'interpreters': "",
  256. 'introspection': "", 'java': "", "javascript": "",
  257. 'kde': "", 'kernel': "",
  258. 'libdevel': "", 'libs': "", 'lisp': "", 'localization': "",
  259. 'mail': "", 'math': "", 'metapackages': "", 'misc': "",
  260. 'net': "", 'news': "", 'ocaml': "", 'oldlibs': "",
  261. 'otherosfs': "", 'perl': "", 'php': "", 'python': "",
  262. 'ruby': "", 'rust': "",
  263. 'science': "", 'shells': "", 'sound': "", 'tex': "",
  264. 'text': "", 'utils': "", 'vcs': "", 'video': "", 'web': "",
  265. 'x11': "", 'xfce': "", 'zope': "",
  266. }, 'Choose the section: ', default=section, empty_ok=True)
  267. if not new_section:
  268. new_section = section
  269. new_priority = ui.menu('Select the new priority', {
  270. 'required': "",
  271. 'important': "",
  272. 'standard': "",
  273. 'optional': "",
  274. 'extra': "",
  275. }, 'Choose the priority: ', default=priority, empty_ok=True)
  276. if not new_priority:
  277. new_priority = priority
  278. if new_section == section and new_priority == priority:
  279. cont = ui.select_options(
  280. "You didn't change section nor priority: is this because it's "
  281. "ftp.debian.org override file that needs updating?",
  282. 'Yn', {'y': 'ftp.debian.org override file needs updating',
  283. 'n': 'No, it\'s not the override file'})
  284. if cont == 'n':
  285. ui.long_message("There's nothing we can do for you, then; "
  286. "exiting...")
  287. sys.exit(1)
  288. arch_section = ui.menu('Is this request for an archive section other than "main"?', {
  289. 'main': "",
  290. 'contrib': "",
  291. 'non-free': "",
  292. }, 'Choose the archive section: ', default='main', empty_ok=True)
  293. if not arch_section:
  294. arch_section = 'main'
  295. if arch_section != 'main':
  296. subject = "override: %s:%s/%s %s" % (package, arch_section, new_section, new_priority)
  297. else:
  298. subject = "override: %s:%s/%s" % (package, new_section, new_priority)
  299. body = "(Describe here the reason for this change)"
  300. else:
  301. # we handle here the removal requests
  302. suite = ui.menu('Is the removal to be done in a suite other than'
  303. ' "unstable"? Don\'t select anything for "unstable"', {
  304. 'oldstable': "Old stable.",
  305. 'oldstable-proposed-updates': "Old stable proposed updates.",
  306. 'stable': "Stable.",
  307. 'stable-proposed-updates': "Stable proposed updates.",
  308. 'testing': "Testing only (NOT unstable)",
  309. 'testing-proposed-updates': "Testing proposed updates",
  310. 'experimental': "Experimental.",
  311. }, 'Choose the suite: ', empty_ok=True)
  312. if not suite:
  313. suite = 'unstable'
  314. if suite not in ('testing', 'unstable', 'experimental'):
  315. headers.append('X-Debbugs-CC: debian-release@lists.debian.org')
  316. ui.log_message('Your report will be carbon-copied to debian-release.\n')
  317. why = 'Please enter the reason for removal: '
  318. reason = ui.get_string(why)
  319. if not reason:
  320. return
  321. partial = ui.select_options(
  322. "Is this removal request for specific architectures?",
  323. 'yN', {'y': 'This is a partial (specific architectures) removal.',
  324. 'n': 'This removal is for all architectures.'})
  325. if partial == 'y':
  326. prompt = 'Please enter the arch list separated by a space: '
  327. archs = ui.get_string(prompt)
  328. if not archs:
  329. ui.long_message('Partial removal requests must have a list of architectures.\n')
  330. raise SystemExit
  331. if suite == 'testing' and archs:
  332. ui.long_message('Partial removal for testing; forcing suite to '
  333. '\'unstable\', since it\'s the proper way to do that.')
  334. suite = 'unstable'
  335. body = '(please explain the reason for the removal here)\n\n' + \
  336. 'Note: this was a request for a partial removal from testing, ' + \
  337. 'converted in one for unstable'
  338. if archs:
  339. if suite != 'unstable':
  340. subject = 'RM: %s/%s [%s] -- %s; %s' % (package, suite, archs, tag, reason)
  341. else:
  342. subject = 'RM: %s [%s] -- %s; %s' % (package, archs, tag, reason)
  343. else:
  344. if suite != 'unstable':
  345. subject = 'RM: %s/%s -- %s; %s' % (package, suite, tag, reason)
  346. else:
  347. subject = 'RM: %s -- %s; %s' % (package, tag, reason)
  348. if suite == 'testing':
  349. ui.long_message('Please use release.debian.org pseudo-package and '
  350. 'report a bug there.')
  351. sys.exit(1)
  352. return (subject, severity, headers, pseudos, body, query)
  353. def handle_debian_release(package, bts, ui, fromaddr, timeout, online=True, http_proxy=None):
  354. body = ''
  355. headers = []
  356. pseudos = []
  357. query = True
  358. archs = None
  359. version = None
  360. oldstable = utils.SUITE2CODENAME['oldstable']
  361. oldstable_pu = oldstable + '-pu'
  362. oldstable_backports = oldstable + '-backports'
  363. oldstable_security = oldstable + '-security'
  364. stable = utils.SUITE2CODENAME['stable']
  365. stable_pu = stable + '-pu'
  366. stable_backports = stable + '-backports'
  367. stable_security = stable + '-security'
  368. testing = utils.SUITE2CODENAME['testing']
  369. tag = ui.menu('What sort of request is this? (If none of these '
  370. 'things mean anything to you, or you are trying to report '
  371. 'a bug in an existing package, please press Enter to '
  372. 'exit reportbug.)', {
  373. 'binnmu': "binNMU requests",
  374. 'britney': "testing migration script bugs",
  375. 'transition': "transition tracking",
  376. 'unblock': "unblock requests",
  377. oldstable_pu: "%s proposed updates requests" % oldstable,
  378. stable_pu: "%s proposed updates requests" % stable,
  379. 'rm': "Stable/Testing removal requests",
  380. 'other': "None of the other options",
  381. }, 'Choose the request type: ', empty_ok=True)
  382. if not tag:
  383. ui.long_message('To report a bug in a package, use the name of the package, not release.debian.org.\n')
  384. raise SystemExit
  385. severity = 'normal'
  386. if tag == 'other':
  387. return
  388. if tag == 'britney':
  389. subject_britney = ui.get_string('Please enter the subject of the bug report: ')
  390. if not subject_britney:
  391. ui.long_message('No subject specified, exiting')
  392. sys.exit(1)
  393. else:
  394. # package checks code
  395. prompt = 'Please enter the name of the package: '
  396. package = ui.get_string(prompt)
  397. if not package:
  398. ui.log_message('You seem to want to report a generic bug.\n')
  399. return
  400. ui.log_message('Checking status database...\n')
  401. info = utils.get_package_status(package)
  402. available = info[1]
  403. query = False
  404. if not available:
  405. info = utils.get_source_package(package)
  406. if info:
  407. info = utils.get_package_status(info[0][0])
  408. if not info:
  409. cont = ui.select_options(
  410. "This package doesn't appear to exist; continue?",
  411. 'yN', {'y': 'Ignore this problem and continue.',
  412. 'n': 'Exit without filing a report.'})
  413. if cont == 'n':
  414. sys.exit(1)
  415. else:
  416. package = info[12] or package
  417. if tag in ('binnmu', 'unblock', stable_pu, oldstable_pu, 'rm'):
  418. # FIXME: pu/rm should lookup the version elsewhere
  419. version = info and info[0]
  420. if online and tag.endswith('-pu'):
  421. version = list(checkversions.get_versions_available(package, timeout, (tag[:-3],)).values())[0]
  422. if version:
  423. cont = ui.select_options(
  424. "Latest version seems to be %s, is this the proper one ?" % (version),
  425. "Yn", {'y': "This is the correct version",
  426. 'n': "Enter the proper version"})
  427. if cont == 'n':
  428. version = None
  429. if not version:
  430. version = ui.get_string('Please enter the version of the package: ')
  431. if not version:
  432. ui.log_message("A version is required for action %s, not sending bug\n" % (tag))
  433. return
  434. if tag in ('binnmu', 'rm'):
  435. partial = ui.select_options(
  436. "Is this request for specific architectures?",
  437. 'yN', {'y': 'This is a partial (specific architectures) request.',
  438. 'n': 'This request is for all architectures.'})
  439. if partial == 'y':
  440. if tag == 'rm':
  441. ui.long_message('The proper way to request a partial removal '
  442. 'from testing is to file a partial removal from unstable: '
  443. 'this way the package for the specified architectures will '
  444. 'be automatically removed from testing too. Please re-run '
  445. 'reportbug against ftp.debian.org package.')
  446. raise SystemExit
  447. prompt = 'Please enter the arch list separated by a space: '
  448. archs = ui.get_string(prompt)
  449. if not archs:
  450. ui.long_message('No architecture specified, skipping...')
  451. if tag == 'binnmu':
  452. suite = ui.menu("For which suite are you requesting this binNMU?"
  453. " Don't select anything for \"unstable\"", {
  454. stable: "",
  455. stable_backports: "",
  456. stable_security: "",
  457. oldstable: "",
  458. oldstable_backports: "",
  459. oldstable_security: "",
  460. testing: "",
  461. 'experimental': "",
  462. }, 'Choose the suite: ', empty_ok=True)
  463. if not suite:
  464. suite = 'unstable'
  465. pseudos.append("User: release.debian.org@packages.debian.org")
  466. if tag.endswith('-pu'):
  467. pseudos.append("Usertags: pu")
  468. pseudos.append("Tags: %s" % (tag[:-3]))
  469. else:
  470. pseudos.append("Usertags: %s" % (tag))
  471. if tag == 'binnmu':
  472. reason = ui.get_string("binNMU changelog entry: ")
  473. subject = "nmu: %s_%s" % (package, version)
  474. body = "nmu %s_%s . %s . %s . -m \"%s\"\n" % (package, version, archs or "ANY", suite, reason)
  475. elif tag == 'transition':
  476. subject = 'transition: %s' % (package)
  477. body = '(please explain about the transition: impacted packages, reason, ...\n' \
  478. ' for more info see: https://wiki.debian.org/Teams/ReleaseTeam/Transitions)\n'
  479. affected = '<Fill out>'
  480. good = '<Fill out>'
  481. bad = '<Fill out>'
  482. ui.long_message('To assist the release team, please fill in the following information. '
  483. 'You will be asked to provide package names of the library package(s) '
  484. 'that are the source of the transition. If more than one library is '
  485. 'changing the name, please use a space separated list. Alternatively '
  486. 'you can use a regex by enclosing the regex in slashes ("/"). Please '
  487. 'ensure that the "old" regex does not match the "new" packages. '
  488. 'Example: old="/libapt-pkg4.10|libapt-inst1.2/ libept1" '
  489. 'new="/libapt-pkg4.12|libapt-inst1.5|libept1.4.12/". For futher '
  490. 'reference, please refer to http://ben.debian.net/ .')
  491. prompt = 'Please enter old binary package name of the library (or a regex matching it):'
  492. tfrom = ui.get_string(prompt)
  493. if tfrom:
  494. prompt = 'Please enter new binary package name of the library (or a regex matching it):'
  495. tto = ui.get_string(prompt)
  496. else:
  497. tto = None
  498. if tfrom and tto:
  499. # Compute a ben file from this.
  500. # (quote if x does not start with a "/")
  501. quote = lambda x: (x[0] == '/' and x) or '"%s"' % x
  502. listbad = [quote(x) for x in tfrom.strip().split()]
  503. listgood = [quote(x) for x in tto.strip().split()]
  504. j = " | .depends ~ ".join
  505. affected = ".depends ~ " + j(listbad + listgood)
  506. good = ".depends ~ " + j(listgood)
  507. bad = ".depends ~ " + j(listbad)
  508. body += textwrap.dedent("""\
  509. Ben file:
  510. title = "%s";
  511. is_affected = %s;
  512. is_good = %s;
  513. is_bad = %s;
  514. """ % (package, affected, good, bad))
  515. elif tag == 'britney':
  516. subject = subject_britney
  517. body = ''
  518. elif tag == 'unblock':
  519. subject = 'unblock: %s/%s' % (package, version)
  520. body = textwrap.dedent("""\
  521. Please unblock package %s
  522. (explain the reason for the unblock here)
  523. (include/attach the debdiff against the package in testing)
  524. unblock %s/%s
  525. """ % (package, package, version))
  526. elif tag.endswith('-pu'):
  527. subject = '%s: package %s/%s' % (tag, package, version)
  528. body = '(please explain the reason for this update here)\n'
  529. elif tag == 'rm':
  530. subject = 'RM: %s/%s' % (package, version)
  531. body = '(explain the reason for the removal here)\n'
  532. return (subject, severity, headers, pseudos, body, query)
  533. itp_template = textwrap.dedent("""\
  534. * Package name : %(package)s
  535. Version : x.y.z
  536. Upstream Author : Name <somebody@example.org>
  537. * URL : http://www.example.org/
  538. * License : (GPL, LGPL, BSD, MIT/X, etc.)
  539. Programming Lang: (C, C++, C#, Perl, Python, etc.)
  540. Description : %(short_desc)s
  541. (Include the long description here.)
  542. Please also include as much relevant information as possible.
  543. For example, consider answering the following questions:
  544. - why is this package useful/relevant? is it a dependency for
  545. another package? do you use it? if there are other packages
  546. providing similar functionality, how does it compare?
  547. - how do you plan to maintain it? inside a packaging team
  548. (check list at https://wiki.debian.org/Teams)? are you
  549. looking for co-maintainers? do you need a sponsor?
  550. """)
  551. def handle_wnpp(package, bts, ui, fromaddr, timeout, online=True, http_proxy=None):
  552. short_desc = body = ''
  553. headers = []
  554. pseudos = []
  555. query = True
  556. tag = ui.menu('What sort of request is this? (If none of these '
  557. 'things mean anything to you, or you are trying to report '
  558. 'a bug in an existing package, please press Enter to '
  559. 'exit reportbug.)', {
  560. 'O': "The package has been `Orphaned'. It needs a new maintainer as soon as possible.",
  561. 'RFA': "This is a `Request for Adoption'. Due to lack of time, resources, interest or something similar, the current maintainer is asking for someone else to maintain this package. They will maintain it in the meantime, but perhaps not in the best possible way. In short: the package needs a new maintainer.",
  562. 'RFH': "This is a `Request For Help'. The current maintainer wants to continue to maintain this package, but they need some help to do this because their time is limited or the package is quite big and needs several maintainers.",
  563. 'ITP': "This is an `Intent To Package'. Please submit a package description along with copyright and URL in such a report.",
  564. 'RFP': "This is a `Request For Package'. You have found an interesting piece of software and would like someone else to maintain it for Debian. Please submit a package description along with copyright and URL in such a report.",
  565. }, 'Choose the request type: ', empty_ok=True)
  566. if not tag:
  567. ui.long_message('To report a bug in a package, use the name of the package, not wnpp.\n')
  568. raise SystemExit
  569. # keep asking for package name until one is entered
  570. package = ""
  571. while not package:
  572. if tag in ('RFP', 'ITP'):
  573. prompt = 'Please enter the proposed package name: '
  574. else:
  575. prompt = 'Please enter the package name: '
  576. package = ui.get_string(prompt)
  577. if not utils.check_package_name(package):
  578. ui.long_message('Invalid package name')
  579. package = ""
  580. ui.log_message('Checking status database...\n')
  581. info = utils.get_package_status(package, avail=True)
  582. available = info[1]
  583. severity = 'normal'
  584. if tag in ('ITP', 'RFP'):
  585. if available and (not online or checkversions.check_available(
  586. package, '0', timeout, http_proxy=http_proxy)):
  587. if not ui.yes_no(
  588. ('A package called %s already appears to exist (at least on '
  589. 'your system); continue?' % package),
  590. 'Ignore this problem and continue. If you have '
  591. 'already locally created a package with this name, this '
  592. 'warning message may have been produced in error.',
  593. 'Exit without filing a report.', default=0):
  594. sys.exit(1)
  595. severity = 'wishlist'
  596. # keep asking for short description until one is entered
  597. short_desc = ""
  598. while not short_desc:
  599. short_desc = ui.get_string(
  600. 'Please briefly describe this package; this should be an '
  601. 'appropriate short description for the eventual package: ')
  602. if tag == 'ITP':
  603. headers.append('X-Debbugs-CC: debian-devel@lists.debian.org')
  604. pseudos.append('Owner: %s' % fromaddr)
  605. ui.log_message('Your report will be carbon-copied to debian-devel, '
  606. 'per Debian policy.\n')
  607. body = itp_template % vars()
  608. elif tag in ('O', 'RFA', 'RFH'):
  609. severity = 'normal'
  610. query = False
  611. if not available:
  612. info = utils.get_source_package(package)
  613. if info:
  614. info = utils.get_package_status(info[0][0])
  615. if not info:
  616. cont = ui.select_options(
  617. "This package doesn't appear to exist; continue?",
  618. 'yN', {'y': 'Ignore this problem and continue.',
  619. 'n': 'Exit without filing a report.'})
  620. if cont == 'n':
  621. sys.exit(1)
  622. short_desc = long_desc = ''
  623. else:
  624. short_desc = info[11] or ''
  625. package = info[12] or package
  626. long_desc = info[13]
  627. if tag == 'O' and info and info[9] in \
  628. ('required', 'important', 'standard'):
  629. severity = 'important'
  630. if tag == 'RFH':
  631. headers.append('X-Debbugs-CC: debian-devel@lists.debian.org')
  632. ui.log_message('Your request will be carbon-copied to debian-devel, '
  633. 'per Debian policy.\n')
  634. if long_desc:
  635. orphstr = 'intend to orphan'
  636. if tag == 'RFA':
  637. orphstr = 'request an adopter for'
  638. elif tag == 'RFH':
  639. orphstr = 'request assistance with maintaining'
  640. body = ('I %s the %s package.\n\n'
  641. 'The package description is:\n') % (orphstr, package)
  642. body = body + long_desc + '\n'
  643. if short_desc:
  644. subject = '%s: %s -- %s' % (tag, package, short_desc)
  645. else:
  646. subject = '%s: %s' % (tag, package)
  647. return (subject, severity, headers, pseudos, body, query)
  648. def dpkg_infofunc():
  649. debarch = utils.get_arch()
  650. utsmachine = os.uname()[4]
  651. multiarch = utils.get_multiarch()
  652. if debarch:
  653. if utsmachine == debarch:
  654. debinfo = 'Architecture: %s\n' % debarch
  655. else:
  656. debinfo = 'Architecture: %s (%s)\n' % (debarch, utsmachine)
  657. else:
  658. debinfo = 'Architecture: ? (%s)\n' % utsmachine
  659. if multiarch:
  660. debinfo += 'Foreign Architectures: %s\n' % multiarch
  661. debinfo += '\n'
  662. return debinfo
  663. def debian_infofunc():
  664. return utils.get_debian_release_info() + dpkg_infofunc()
  665. def ubuntu_infofunc():
  666. return utils.lsb_release_info() + dpkg_infofunc()
  667. def generic_infofunc():
  668. utsmachine = os.uname()[4]
  669. return utils.lsb_release_info() + 'Architecture: %s\n\n' % utsmachine
  670. # Supported servers
  671. # Theoretically support for GNATS and Jitterbug could be added here.
  672. SYSTEMS = {'debian':
  673. {'name': 'Debian', 'email': '%s@bugs.debian.org',
  674. 'btsroot': 'http://www.debian.org/Bugs/',
  675. 'otherpkgs': debother,
  676. 'nonvirtual': ['linux-image', 'kernel-image'],
  677. 'specials':
  678. {'wnpp': handle_wnpp,
  679. 'ftp.debian.org': handle_debian_ftp,
  680. 'release.debian.org': handle_debian_release},
  681. # Dependency packages
  682. 'deppkgs': ('gcc', 'g++', 'cpp', 'gcj', 'gpc', 'gobjc',
  683. 'chill', 'gij', 'g77', 'python', 'python-base',
  684. 'x-window-system-core', 'x-window-system'),
  685. 'cgiroot': 'https://bugs.debian.org/cgi-bin/',
  686. 'infofunc': debian_infofunc,
  687. },
  688. 'ubuntu':
  689. {'name': 'Ubuntu', 'email': 'ubuntu-users@lists.ubuntu.com',
  690. 'type': 'mailto',
  691. 'infofunc': ubuntu_infofunc,
  692. },
  693. 'guug':
  694. {'name': 'GUUG (German Unix User Group)',
  695. 'email': '%s@bugs.guug.de', 'query-dpkg': False},
  696. }
  697. CLASSES = {
  698. 'sw-bug': 'The problem is a bug in the software or code. For'
  699. 'example, a crash would be a sw-bug.',
  700. 'doc-bug': 'The problem is in the documentation. For example,'
  701. 'an error in a man page would be a doc-bug.',
  702. 'change-request': 'You are requesting a new feature or a change'
  703. 'in the behavior of software, or are making a suggestion. For'
  704. 'example, if you wanted reportbug to be able to get your local'
  705. 'weather forecast, as well as report bugs, that would be a'
  706. 'change-request.',
  707. }
  708. CLASSLIST = ['sw-bug', 'doc-bug', 'change-request']
  709. CRITICAL_TAGS = {
  710. 'security': 'This problem is a security vulnerability in Debian.',
  711. }
  712. EXPERT_TAGS = {
  713. 'security': 'This problem is a security vulnerability in Debian.',
  714. }
  715. TAGS = {
  716. 'patch': 'You are including a patch to fix this problem.',
  717. 'upstream': 'This bug applies to the upstream part of the package.',
  718. 'd-i': 'This bug is relevant to the development of debian-installer.',
  719. 'ipv6': 'This bug affects support for Internet Protocol version 6.',
  720. 'lfs': 'This bug affects support for large files (over 2 gigabytes).',
  721. 'l10n': 'This bug reports a localization/internationalization issue.',
  722. 'newcomer': 'This bug has a known solution but the maintainer requests someone else implement it.',
  723. }
  724. def get_tags(severity='', mode=utils.MODE_NOVICE):
  725. """Returns the current tags list.
  726. If severity is release critical, than add additional tags not always present.
  727. If mode is higher than STANDARD, then add suite tags."""
  728. tags = TAGS.copy()
  729. if severity in ('grave', 'critical', 'serious'):
  730. tags.update(CRITICAL_TAGS)
  731. if mode > utils.MODE_STANDARD:
  732. tags.update(EXPERT_TAGS)
  733. return tags
  734. def yn_bool(setting):
  735. if setting:
  736. if str(setting) == 'no':
  737. return 'no'
  738. return 'yes'
  739. else:
  740. return 'no'
  741. def cgi_report_url(system, number, archived=False, mbox=False):
  742. root = SYSTEMS[system].get('cgiroot')
  743. if root:
  744. return '%sbugreport.cgi?bug=%d&archived=%s&mbox=%s' % (
  745. root, number, archived, yn_bool(mbox))
  746. return None
  747. def cgi_package_url(system, package, archived=False, source=False,
  748. repeatmerged=True, version=None):
  749. root = SYSTEMS[system].get('cgiroot')
  750. if not root:
  751. return None
  752. # package = urllib.quote_plus(package.lower())
  753. if source:
  754. query = {'src': package.lower()}
  755. else:
  756. query = {'pkg': package.lower()}
  757. query['repeatmerged'] = yn_bool(repeatmerged)
  758. query['archived'] = yn_bool(archived)
  759. if version:
  760. query['version'] = str(version)
  761. qstr = urllib.parse.urlencode(query)
  762. # print qstr
  763. return '%spkgreport.cgi?%s' % (root, qstr)
  764. # TODO: to be removed
  765. def package_url(system, package, mirrors=None, source=False,
  766. repeatmerged=True):
  767. btsroot = get_btsroot(system, mirrors)
  768. package = urllib.parse.quote_plus(package.lower())
  769. return btsroot + ('db/pa/l%s.html' % package)
  770. # TODO: to be removed
  771. def report_url(system, number, mirrors=None):
  772. number = str(number)
  773. if len(number) < 2:
  774. return None
  775. btsroot = get_btsroot(system, mirrors)
  776. return btsroot + ('db/%s/%s.html' % (number[:2], number))
  777. def get_package_url(system, package, mirrors=None, source=False,
  778. archived=False, repeatmerged=True):
  779. return (cgi_package_url(system, package, archived, source, repeatmerged) or
  780. package_url(system, package, mirrors, source, repeatmerged))
  781. def get_report_url(system, number, mirrors=None, archived=False, mbox=False):
  782. return (cgi_report_url(system, number, archived, mbox) or
  783. report_url(system, number, mirrors))
  784. def parse_bts_url(url):
  785. bits = url.split(':', 1)
  786. if len(bits) != 2:
  787. return None
  788. type, loc = bits
  789. if loc.startswith('//'):
  790. loc = loc[2:]
  791. while loc.endswith('/'):
  792. loc = loc[:-1]
  793. return type, loc
  794. # Dynamically add any additional systems found
  795. for origin in glob.glob('/etc/dpkg/origins/*'):
  796. try:
  797. fp = open(origin)
  798. system = os.path.basename(origin)
  799. SYSTEMS[system] = SYSTEMS.get(system, {'otherpkgs': {},
  800. 'query-dpkg': True,
  801. 'mirrors': {},
  802. 'cgiroot': None})
  803. for line in fp:
  804. try:
  805. (header, content) = line.split(': ', 1)
  806. header = header.lower()
  807. content = content.strip()
  808. if header == 'vendor':
  809. SYSTEMS[system]['name'] = content
  810. elif header == 'bugs':
  811. (type, root) = parse_bts_url(content)
  812. SYSTEMS[system]['type'] = type
  813. if type == 'debbugs':
  814. SYSTEMS[system]['btsroot'] = 'http://' + root + '/'
  815. SYSTEMS[system]['email'] = '%s@' + root
  816. elif type == 'mailto':
  817. SYSTEMS[system]['btsroot'] = None
  818. SYSTEMS[system]['email'] = root
  819. else:
  820. # We don't know what to do...
  821. pass
  822. except ValueError:
  823. pass
  824. fp.close()
  825. except IOError:
  826. pass
  827. # TODO: to be removed
  828. def parse_html_report(number, url, http_proxy, timeout, followups=False, cgi=True):
  829. page = open_url(url, http_proxy, timeout)
  830. if not page:
  831. return None
  832. parser = BTSParser(cgi=cgi, followups=followups)
  833. for line in page:
  834. parser.feed(line)
  835. parser.close()
  836. try:
  837. page.fp._sock.recv = None
  838. except:
  839. pass
  840. page.close()
  841. items = parser.preblock
  842. title = "#%d: %s" % (number, parser.title)
  843. if not followups:
  844. items = [items]
  845. output = []
  846. for stuff in items:
  847. parts = stuff.split('\n\n')
  848. match = re.search('^Date: (.*)$', parts[0], re.M | re.I)
  849. date_submitted = ''
  850. if match:
  851. date_submitted = 'Date: %s\n' % match.group(1)
  852. stuff = ('\n\n'.join(parts[1:])).rstrip()
  853. if not stuff:
  854. continue
  855. item = date_submitted + stuff + os.linesep
  856. output.append(item)
  857. if not output:
  858. return None
  859. return (title, output)
  860. # XXX: Need to handle charsets properly
  861. def parse_mbox_report(number, url, http_proxy, timeout, followups=False):
  862. page = open_url(url, http_proxy, timeout)
  863. if not page:
  864. return None
  865. # Make this seekable
  866. wholefile = io.StringIO(page.read())
  867. try:
  868. page.fp._sock.recv = None
  869. except:
  870. pass
  871. page.close()
  872. mbox = mailbox.UnixMailbox(wholefile, msgfactory)
  873. title = ''
  874. output = []
  875. for message in mbox:
  876. if not message:
  877. pass
  878. subject = message.get('Subject')
  879. if not title:
  880. title = subject
  881. date = message.get('Date')
  882. fromhdr = message.get('From')
  883. body = entry = ''
  884. for part in message.walk():
  885. if part.get_content_type() == 'text/plain' and not body:
  886. body = part.get_payload(None, True)
  887. if fromhdr:
  888. entry += 'From: %s%s' % (fromhdr, os.linesep)
  889. if subject and subject != title:
  890. entry += 'Subject: %s%s' % (subject, os.linesep)
  891. if date:
  892. entry += 'Date: %s%s' % (date, os.linesep)
  893. if entry:
  894. entry += os.linesep
  895. entry += body.rstrip('\n') + os.linesep
  896. output.append(entry)
  897. if not output:
  898. return None
  899. title = "#%d: %s" % (number, title)
  900. return (title, output)
  901. def get_btsroot(system, mirrors=None):
  902. if mirrors:
  903. alternates = SYSTEMS[system].get('mirrors')
  904. for mirror in mirrors:
  905. if mirror in alternates:
  906. return alternates[mirror]
  907. return SYSTEMS[system].get('btsroot', '')
  908. def get_reports(package, timeout, system='debian', mirrors=None, version=None,
  909. http_proxy='', archived=False, source=False):
  910. if system == 'debian':
  911. if isinstance(package, str):
  912. if source:
  913. pkg_filter = 'src'
  914. else:
  915. pkg_filter = 'package'
  916. bugs = debianbts.get_bugs(pkg_filter, package)
  917. else:
  918. bugs = list(map(int, package))
  919. try:
  920. # retrieve bugs and generate the hierarchy
  921. stats = debianbts.get_status(bugs)
  922. except:
  923. raise QuertBTSError
  924. d = defaultdict(list)
  925. for s in stats:
  926. # We now return debianbts.Bugreport objects, containing all the info
  927. # for a bug, so UIs can extract them as needed
  928. d[s.severity].append(s)
  929. # keep the bugs ordered per severity
  930. # XXX: shouldn't it be something UI-related?
  931. #
  932. # The hierarchy is a list of tuples:
  933. # (description of the severity, list of bugs for that severity)
  934. hier = []
  935. for sev in SEVLIST:
  936. if sev in d:
  937. hier.append(('Bugs with severity %s' % sev, d[sev]))
  938. return (len(bugs), 'Bug reports for %s' % package, hier)
  939. # XXX: is the code below used at all now? can we remove it?
  940. if isinstance(package, str):
  941. if SYSTEMS[system].get('cgiroot'):
  942. try:
  943. result = get_cgi_reports(package, timeout, system, http_proxy, archived,
  944. source, version=version)
  945. except:
  946. raise NoNetwork
  947. if result:
  948. return result
  949. url = package_url(system, package, mirrors, source)
  950. try:
  951. page = open_url(url, http_proxy, timeout)
  952. except:
  953. raise NoNetwork
  954. if not page:
  955. return (0, None, None)
  956. # content = page.read()
  957. # if 'Maintainer' not in content:
  958. # return (0, None, None)
  959. parser = BTSParser()
  960. for line in page:
  961. parser.feed(line)
  962. parser.close()
  963. try:
  964. page.fp._sock.recv = None
  965. except:
  966. pass
  967. page.close()
  968. return parser.bugcount, parser.title, parser.hierarchy
  969. # A list of bug numbers
  970. this_hierarchy = []
  971. package = [int(x) for x in package]
  972. package.sort()
  973. for bug in package:
  974. result = get_report(bug, timeout, system, mirrors, http_proxy, archived)
  975. if result:
  976. title, body = result
  977. this_hierarchy.append(title)
  978. # print title
  979. title = "Multiple bug reports"
  980. bugcount = len(this_hierarchy)
  981. hierarchy = [('Reports', this_hierarchy)]
  982. return bugcount, title, hierarchy
  983. def get_report(number, timeout, system='debian', mirrors=None,
  984. http_proxy='', archived=False, followups=False):
  985. number = int(number)
  986. if system == 'debian':
  987. status = debianbts.get_status(number)[0]
  988. log = debianbts.get_bug_log(number)
  989. # add Date/Subject/From headers to the msg bodies
  990. bodies = []
  991. for l in log:
  992. f = email.parser.FeedParser()
  993. f.feed(l['header'])
  994. h = f.close()
  995. hdrs = []
  996. for i in ['Date', 'Subject', 'From']:
  997. if i in h:
  998. hdrs.append(i + ': ' + h.get(i))
  999. bodies.append('\n'.join(sorted(hdrs)) + '\n\n' + l['body'])
  1000. # returns the bug status and a list of mail bodies
  1001. return (status, bodies)
  1002. if SYSTEMS[system].get('cgiroot'):
  1003. result = get_cgi_report(number, timeout, system, http_proxy,
  1004. archived, followups)
  1005. if result:
  1006. return result
  1007. url = report_url(system, number, mirrors)
  1008. if not url:
  1009. return None
  1010. return parse_html_report(number, url, http_proxy, timeout, followups, cgi=False)