README.developers 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. ===================================
  2. reportbug's Features for Developers
  3. ===================================
  4. (Adapted from original "bug" documentation.)
  5. Bug allows maintainers to control the bug reporting process by placing
  6. files in special places.
  7. Template Information & Interaction with the user
  8. ================================================
  9. If /usr/share/bug/$package is executable, then bug executes it and
  10. takes what comes out from the file descriptor 3 and puts it in the bug
  11. template.
  12. The maintainer can then ask questions to the user or run whatever
  13. information gathering script he likes, and echo all the content to fd 3.
  14. e.g.::
  15. read -p 'color? '
  16. echo "Color: $REPLY" >&3
  17. ...
  18. system-information-tool >&3
  19. If /usr/share/bug/$package is a directory, then
  20. /usr/share/bug/$package/script is executed.
  21. While the script is executed, the following shell functions are
  22. available ONLY IF IT IS RUN UNDER /bin/bash::
  23. getkey - asks for a key
  24. yesno <prompt> "yep"|"nop" - ask for a yes/no answer (with i18n)
  25. leaves response as yep or nop
  26. in REPLY. The second argument is
  27. the default.
  28. If the file /usr/share/bug/$package/presubj exists, its content is
  29. shown to the user before asking him for the bug's subject.
  30. Note: It's your responsibility to check if the information included
  31. in the template can put the user in any security risk.
  32. Package redirection
  33. ===================
  34. The package maintainer can control to which packages bug reports are
  35. submitted, by setting the Package: field of the bug report. This will
  36. be mainly used to redirect bugs in packages coming from a single
  37. source to where the maintainer likes to have them.
  38. This is done by having this line in /usr/share/bug/$package/control::
  39. Submit-As: $new-package
  40. Note that bug will not check if the $new-package exists as a valid package.
  41. BTS selection
  42. =============
  43. Packages not distributed by Debian can take advantage of this utility too.
  44. They just need to add a "send-to" header to the control file
  45. /usr/share/bug/$package/control::
  46. Send-To: bugs.myproject.com
  47. ``reportbug`` will add ``submit@` ``quiet@`` or ``maintonly@`` to form the address the
  48. bug report mail is send to.
  49. (Note: you probably should use dpkg's support for Origin and Bugs tags
  50. in lieu of this support.)
  51. Nicolás Lichtmaier.-
  52. nick@debian.org
  53. Related packages
  54. ================
  55. Often programs are distributed across several different packages, for
  56. example an upstream package 'foo' may be packaged in Debian as foo, libfoo,
  57. foo-common and foo-data. In such cases it can be useful to include related
  58. package information in bugreports, to minimise the need for 'moreinfo' requests
  59. to the submitter :) This is done by adding a "report-with" header to the
  60. control file::
  61. report-with: foo libfoo foo-common foo-data
  62. Package information will be added to the bug report for each extra package
  63. listed.
  64. You can also request that the status information for other packages
  65. (that are not dependencies or recommendations) be included with the
  66. report using the "package-status" header::
  67. package-status: bar baz
  68. Addendum: Languages other than SH
  69. =================================
  70. The script in /usr/share/bug/reportbug/script is an example of a bug
  71. handling script written in Python. You can also write bug handlers in
  72. many other languages that allow direct access to file descriptors,
  73. including Perl and C/C++.
  74. Note that the getkey and yesno functions are only available in scripts
  75. written using /bin/bash as their interpreter; for other shells or
  76. languages, you will need to write your own input parsing functions.
  77. Add Headers and Pseudo-Headers from the bugscript
  78. =================================================
  79. From the bugscript it's possible to extend the bug report with additional (mail)
  80. headers and (bug) pseudo-headers. They need to be enclosed in a begin/end block:
  81. -- BEGIN HEADERS --
  82. ...
  83. -- END HEADERS --
  84. for mail headers, and:
  85. -- BEGIN PSEUDOHEADERS --
  86. ...
  87. -- END PSEUDOHEADERS --
  88. for bug pseudo-headers.
  89. They can be emitted in any place of the output (they will be removed during
  90. parsing), can be repeated several times, and support several headers in the same
  91. block:
  92. -- BEGIN PSEUDOHEADERS --
  93. User: morph@debian.org
  94. Usertags: dd
  95. -- END PSEUDOHEADERS --
  96. will correctly identify the two pseudo-headers (as needed for usertagging a
  97. report).
  98. Please pay attention to not interleave blocks with each other and to always
  99. close blocks, else the parser could produce undesired results. Also note that
  100. those headers are added to the ones already presente so a header with the same
  101. name will appear twice, since it won't replace the existing one.
  102. Add attachments from the bugscript
  103. ==================================
  104. Similarly to headers and pseudo-headers, it's possible to add an attachment
  105. from the bugscript using this syntax:
  106. -- BEGIN ATTACHMENTS --
  107. /path/to/the/file/to/attach
  108. -- END ATTACHMENTS --
  109. and that will attach the mentioned files to the bug report (if that's allowed,
  110. in particular with not using a MUA but the internal reportbug mail facility).
  111. Source layout
  112. =============
  113. The source tree for ``reportbug`` is organised this way:
  114. * Top level
  115. * Programs (e.g. ``reportbug``, ``querybts``, etc.).
  116. * Python library modules, used by the programs.
  117. * Manual pages.
  118. * Debian packaging
  119. * ``debian/`` contains the control files used to build the Debian
  120. source and binary packages.
  121. * `Unit testing framework`_
  122. * ``test/`` contains the unit test suite. Unit test modules are
  123. discovered and run using the ``nosetests`` program, and are named
  124. as ``test_*.py``.
  125. * ?? TODO: describe the purpose
  126. * ``checks/`` contains ???
  127. * Internationalisation and localisation
  128. * ``po4a/`` contains configuration and data for localisation of
  129. source files using the ``po4a`` tool.
  130. Unit testing framework
  131. ======================
  132. The reportbug source package now has a unit testing framework.
  133. The directory ``test/`` contains unit test modules and supporting
  134. files. New unit test modules should be added to this directory and
  135. named ``test_*.py``.
  136. The unit test suite depends on the `python-nose` package being
  137. installed, to make the ``nosetests`` command available. The unit tests
  138. themselves can be written using either the `unittest` or `doctest`
  139. modules in the standard Python library.
  140. The `scaffold` module (from the ``test/scaffold.py`` file) contains
  141. some helper functionality for unit tests, including an extended
  142. `TestCase` class.
  143. ``make`` targets for testing and quality checks
  144. -----------------------------------------------
  145. The following ``make`` targets are useful for testing and related
  146. tasks.
  147. * ``make test`` runs the unit test suite, preceded by a timestamp
  148. banner, and reports any test failures or "OK" if all tests pass.
  149. * ``make test-continuous`` starts a loop which clears the screen, runs
  150. ``make test``, then waits for any of the tests or source code to
  151. change, and starts the loop again.
  152. This is useful to run in a separate terminal during a development
  153. session, so that whenever a change is made the test suite will be
  154. run automatically. You might want to keep the window hidden while
  155. actually editing files, and only look at it when you've created or
  156. modified a file and want to check its effect on the test run.
  157. This uses the ``inotifywait`` command from the `inotify-tools`
  158. package to wait for `create` and `modify` events.
  159. * ``make coverage`` runs the test suite and collects test coverage
  160. information, then reports the current statement coverage of the test
  161. suite.
  162. This requires the `python-coverage` package to be installed. See its
  163. documentation for more about its operation.
  164. * ``make pyflakes`` runs the `pyflakes` static code checker on all
  165. Python files found in the project tree.
  166. This requires the `pyflakes` package to be installed. See its
  167. documentation for more about its operation.
  168. * ``make pylint`` runs the `pylint` code checker on all code modules
  169. and programs.
  170. This requires the `pylint` package to be installed. See its
  171. documentation for more about its operation.
  172. ..
  173. Local Variables:
  174. coding: utf-8
  175. mode: rst
  176. End:
  177. vim: filetype=rst :