contributing.txt 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. Contributing To Busybox
  2. =======================
  3. This document describes what you need to do to contribute to Busybox, where
  4. you can help, guidelines on testing, and how to submit a well-formed patch
  5. that is more likely to be accepted.
  6. The Busybox home page is at: http://busybox.net/
  7. Pre-Contribution Checklist
  8. --------------------------
  9. So you want to contribute to Busybox, eh? Great, wonderful, glad you want to
  10. help. However, before you dive in, headlong and hotfoot, there are some things
  11. you need to do:
  12. Checkout the Latest Code from CVS
  13. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  14. This is a necessary first step. Please do not try to work with the last
  15. released version, as there is a good chance that somebody has already fixed
  16. the bug you found. Somebody might have even added the feature you had in mind.
  17. Don't make your work obsolete before you start!
  18. For information on how to check out Busybox from CVS, please look at the
  19. following links:
  20. http://busybox.net/cvs_anon.html
  21. http://busybox.net/cvs_howto.html
  22. Read the Mailing List
  23. ~~~~~~~~~~~~~~~~~~~~~
  24. No one is required to read the entire archives of the mailing list, but you
  25. should at least read up on what people have been talking about lately. If
  26. you've recently discovered a problem, chances are somebody else has too. If
  27. you're the first to discover a problem, post a message and let the rest of us
  28. know.
  29. Archives can be found here:
  30. http://busybox.net/lists/busybox/
  31. If you have a serious interest in Busybox, i.e., you are using it day-to-day or
  32. as part of an embedded project, it would be a good idea to join the mailing
  33. list.
  34. A web-based sign-up form can be found here:
  35. http://busybox.net/mailman/listinfo/busybox
  36. Coordinate with the Applet Maintainer
  37. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  38. Some (not all) of the applets in Busybox are "owned" by a maintainer who has
  39. put significant effort into it and is probably more familiar with it than
  40. others. To find the maintainer of an applet, look at the top of the .c file
  41. for a name following the word 'Copyright' or 'Written by' or 'Maintainer'.
  42. Before plunging ahead, it's a good idea to send a message to the mailing list
  43. that says: "Hey, I was thinking about adding the 'transmogrify' feature to the
  44. 'foo' applet. Would this be useful? Is anyone else working on it?" You might
  45. want to CC the maintainer (if any) with your question.
  46. Areas Where You Can Help
  47. ------------------------
  48. Busybox can always use improvement! If you're looking for ways to help, there
  49. are a variety of areas where you could help.
  50. What Busybox Doesn't Need
  51. ~~~~~~~~~~~~~~~~~~~~~~~~~
  52. Before listing the areas where you _can_ help, it's worthwhile to mention the
  53. areas where you shouldn't bother. While Busybox strives to be the "Swiss Army
  54. Knife" of embedded Linux, there are some applets that will not be accepted:
  55. - Any filesystem manipulation tools: Busybox is filesystem independent and
  56. we do not want to start adding mkfs/fsck tools for every (or any)
  57. filesystem under the sun. (fsck_minix.c and mkfs_minix.c are living on
  58. borrowed time.) There are far too many of these tools out there. Use
  59. the upstream version. Not everything has to be part of Busybox.
  60. - Any partitioning tools: Partitioning a device is typically done once and
  61. only once, and tools which do this generally do not need to reside on the
  62. target device (esp a flash device). If you need a partitioning tool, grab
  63. one (such as fdisk, sfdisk, or cfdisk from util-linux) and use that, but
  64. don't try to merge it into busybox. These are nasty and complex and we
  65. don't want to maintain them.
  66. - Any disk, device, or media-specific tools: Use the -utils or -tools package
  67. that was designed for your device; don't try to shoehorn them into Busybox.
  68. - Any architecture specific tools: Busybox is (or should be) architecture
  69. independent. Do not send us tools that cannot be used across multiple
  70. platforms / arches.
  71. - Any daemons that are not essential to basic system operation. To date, only
  72. syslogd and klogd meet this requirement. We do not need a web server, an
  73. ftp daemon, a dhcp server, a mail transport agent or a dns resolver. If you
  74. need one of those, you are welcome to ask the folks on the mailing list for
  75. recommendations, but please don't bloat up Busybox with any of these.
  76. Bug Reporting
  77. ~~~~~~~~~~~~~
  78. If you find bugs, please submit a detailed bug report to the busybox mailing
  79. list at busybox@busybox.net. A well-written bug report should include a
  80. transcript of a shell session that demonstrates the bad behavior and enables
  81. anyone else to duplicate the bug on their own machine. The following is such
  82. an example:
  83. To: busybox@busybox.net
  84. From: diligent@testing.linux.org
  85. Subject: /bin/date doesn't work
  86. Package: busybox
  87. Version: 1.00
  88. When I execute Busybox 'date' it produces unexpected results.
  89. With GNU date I get the following output:
  90. $ date
  91. Wed Mar 21 14:19:41 MST 2001
  92. But when I use BusyBox date I get this instead:
  93. $ date
  94. llegal instruction
  95. I am using Debian unstable, kernel version 2.4.19-rmk1 on an Netwinder,
  96. and the latest uClibc from CVS. Thanks for the wonderful program!
  97. -Diligent
  98. Note the careful description and use of examples showing not only what BusyBox
  99. does, but also a counter example showing what an equivalent GNU app does. Bug
  100. reports lacking such detail may never be fixed... Thanks for understanding.
  101. Write Documentation
  102. ~~~~~~~~~~~~~~~~~~~
  103. Chances are, documentation in Busybox is either missing or needs improvement.
  104. Either way, help is welcome.
  105. Work is being done to automatically generate documentation from sources,
  106. especially from the usage.h file. If you want to correct the documentation,
  107. please make changes to the pre-generation parts, rather than the generated
  108. documentation. [More to come on this later...]
  109. It is preferred that modifications to documentation be submitted in patch
  110. format (more on this below), but we're a little more lenient when it comes to
  111. docs. You could, for example, just say "after the listing of the mount
  112. options, the following example would be helpful..."
  113. Consult Existing Sources
  114. ~~~~~~~~~~~~~~~~~~~~~~~~
  115. For a quick listing of "needs work" spots in the sources, cd into the Busybox
  116. directory and run the following:
  117. for i in TODO FIXME XXX; do find -name '*.[ch]'|xargs grep $i; done
  118. This will show all of the trouble spots or 'questionable' code. Pick a spot,
  119. any spot, these are all invitations for you to contribute.
  120. Add a New Applet
  121. ~~~~~~~~~~~~~~~~
  122. If you want to add a new applet to Busybox, we'd love to see it. However,
  123. before you write any code, please ask beforehand on the mailing list something
  124. like "Do you think applet 'foo' would be useful in Busybox?" or "Would you
  125. guys accept applet 'foo' into Busybox if I were to write it?" If the answer is
  126. "no" by the folks on the mailing list, then you've saved yourself some time.
  127. Conversely, you could get some positive responses from folks who might be
  128. interested in helping you implement it, or can recommend the best approach.
  129. Perhaps most importantly, this is your way of calling "dibs" on something and
  130. avoiding duplication of effort.
  131. Also, before you write a line of code, please read the 'new-applet-HOWTO.txt'
  132. file in the docs/ directory.
  133. Janitorial Work
  134. ~~~~~~~~~~~~~~~
  135. These are dirty jobs, but somebody's gotta do 'em.
  136. - Converting applets to use getopt() for option processing. Type 'find -name
  137. '*.c'|grep -L getopt' to get a listing of the applets that currently don't
  138. use getopt. If a .c file processes no options, it should have a line that
  139. reads: /* no options, no getopt */ somewhere in the file.
  140. - Replace any "naked" calls to malloc, calloc, realloc, str[n]dup, fopen with
  141. the x* equivalents found in libbb/xfuncs.c.
  142. - Security audits:
  143. http://www.securityfocus.com/popups/forums/secprog/intro.shtml
  144. - Synthetic code removal: http://www.perl.com/pub/2000/06/commify.html - This
  145. is very Perl-specific, but the advice given in here applies equally well to
  146. C.
  147. - C library function use audits: Verifying that functions are being used
  148. properly (called with the right args), replacing unsafe library functions
  149. with safer versions, making sure return codes are being checked, etc.
  150. - Where appropriate, replace preprocessor defined macros and values with
  151. compile-time equivalents.
  152. - Style guide compliance. See: docs/style-guide.txt
  153. - Add testcases to tests/testcases.
  154. - Makefile improvements:
  155. http://www.canb.auug.org.au/~millerp/rmch/recu-make-cons-harm.html
  156. (I think the recursive problems are pretty much taken care of at this point, non?)
  157. - "Ten Commandments" compliance: (this is a "maybe", certainly not as
  158. important as any of the previous items.)
  159. http://www.lysator.liu.se/c/ten-commandments.html
  160. Other useful links:
  161. - the comp.lang.c FAQ: http://web.onetelnet.ch/~twolf/tw/c/index.html#Sources
  162. Submitting Patches To Busybox
  163. -----------------------------
  164. Here are some guidelines on how to submit a patch to Busybox.
  165. Making A Patch
  166. ~~~~~~~~~~~~~~
  167. If you've got anonymous CVS access set up, making a patch is simple. Just make
  168. sure you're in the busybox/ directory and type 'cvs diff -bwu > mychanges.patch'.
  169. You can send the resulting .patch file to the mailing list with a description
  170. of what it does. (But not before you test it! See the next section for some
  171. guidelines.) It is preferred that patches be sent as attachments, but it is
  172. not required.
  173. Also, feel free to help test other people's patches and reply to them with
  174. comments. You can apply a patch by saving it into your busybox/ directory and
  175. typing 'patch < mychanges.patch'. Then you can recompile, see if it runs, test
  176. if it works as advertised, and post your findings to the mailing list.
  177. NOTE: Please do not include extraneous or irrelevant changes in your patches.
  178. Please do not try to "bundle" two patches together into one. Make single,
  179. discreet changes on a per-patch basis. Sometimes you need to make a patch that
  180. touches code in many places, but these kind of patches are rare and should be
  181. coordinated with a maintainer.
  182. Testing Guidelines
  183. ~~~~~~~~~~~~~~~~~~
  184. It's considered good form to test your new feature before you submit a patch
  185. to the mailing list, and especially before you commit a change to CVS. Here
  186. are some guidelines on how to test your changes.
  187. - Always test Busybox applets against GNU counterparts and make sure the
  188. behavior / output is identical between the two.
  189. - Try several different permutations and combinations of the features you're
  190. adding (i.e., different combinations of command-line switches) and make sure
  191. they all work; make sure one feature does not interfere with another.
  192. - Make sure you test compiling against the source both with the feature
  193. turned on and turned off in Config.h and make sure Busybox compiles cleanly
  194. both ways.
  195. - Run the multibuild.pl script in the tests directory and make sure
  196. everything checks out OK. (Do this from within the busybox/ directory by
  197. typing: 'tests/multibuild.pl'.)
  198. Making Sure Your Patch Doesn't Get Lost
  199. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  200. If you don't want your patch to be lost or forgotten, send it to the busybox
  201. mailing list with a subject line something like this:
  202. [PATCH] - Adds "transmogrify" feature to "foo"
  203. In the body, you should have a pseudo-header that looks like the following:
  204. Package: busybox
  205. Version: v1.01pre (or whatever the current version is)
  206. Severity: wishlist
  207. The remainder of the body should read along these lines:
  208. This patch adds the "transmogrify" feature to the "foo" applet. I have
  209. tested this on [arch] system(s) and it works. I have tested it against the
  210. GNU counterparts and the outputs are identical. I have run the scripts in
  211. the 'tests' directory and nothing breaks.
  212. Improving Your Chances of Patch Acceptance
  213. ------------------------------------------
  214. Even after you send a brilliant patch to the mailing list, sometimes it can go
  215. unnoticed, un-replied-to, and sometimes (sigh) even lost. This is an
  216. unfortunate fact of life, but there are steps you can take to help your patch
  217. get noticed and convince a maintainer that it should be added:
  218. Be Succinct
  219. ~~~~~~~~~~~
  220. A patch that includes small, isolated, obvious changes is more likely to be
  221. accepted than a patch that touches code in lots of different places or makes
  222. sweeping, dubious changes.
  223. Back It Up
  224. ~~~~~~~~~~
  225. Hard facts on why your patch is better than the existing code will go a long
  226. way toward convincing maintainers that your patch should be included.
  227. Specifically, patches are more likely to be accepted if they are provably more
  228. correct, smaller, faster, simpler, or more maintainable than the existing
  229. code.
  230. Conversely, any patch that is supported with nothing more than "I think this
  231. would be cool" or "this patch is good because I say it is and I've got a Phd
  232. in Computer Science" will likely be ignored.
  233. Follow The Style Guide
  234. ~~~~~~~~~~~~~~~~~~~~~~
  235. It's considered good form to abide by the established coding style used in a
  236. project; Busybox is no exception. We have gone so far as to delineate the
  237. "elements of Busybox style" in the file docs/style-guide.txt. Please follow
  238. them.
  239. Work With Someone Else
  240. ~~~~~~~~~~~~~~~~~~~~~~
  241. Working on a patch in isolation is less effective than working with someone
  242. else for a variety of reasons. If another Busybox user is interested in what
  243. you're doing, then it's two (or more) voices instead of one that can petition
  244. for inclusion of the patch. You'll also have more people that can test your
  245. changes, or even offer suggestions on better approaches you could take.
  246. Getting other folks interested follows as a natural course if you've received
  247. responses from queries to applet maintainer or positive responses from folks
  248. on the mailing list.
  249. We've made strident efforts to put a useful "collaboration" infrastructure in
  250. place in the form of mailing lists, the bug tracking system, and CVS. Please
  251. use these resources.
  252. Send Patches to the Bug Tracking System
  253. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  254. This was mentioned above in the "Making Sure Your Patch Doesn't Get Lost"
  255. section, but it is worth mentioning again. A patch sent to the mailing list
  256. might be unnoticed and forgotten. A patch sent to the bug tracking system will
  257. be stored and closely connected to the bug it fixes.
  258. Be Polite
  259. ~~~~~~~~~
  260. The old saying "You'll catch more flies with honey than you will with vinegar"
  261. applies when submitting patches to the mailing list for approval. The way you
  262. present your patch is sometimes just as important as the actual patch itself
  263. (if not more so). Being rude to the maintainers is not an effective way to
  264. convince them that your patch should be included; it will likely have the
  265. opposite effect.
  266. Committing Changes to CVS
  267. -------------------------
  268. If you submit several patches that demonstrate that you are a skilled and wise
  269. coder, you may be invited to become a committer, thus enabling you to commit
  270. changes directly to CVS. This is nice because you don't have to wait for
  271. someone else to commit your change for you, you can just do it yourself.
  272. But note that this is a privilege that comes with some responsibilities. You
  273. should test your changes before you commit them. You should also talk to an
  274. applet maintainer before you make any kind of sweeping changes to somebody
  275. else's code. Big changes should still go to the mailing list first. Remember,
  276. being wise, polite, and discreet is more important than being clever.
  277. When To Commit
  278. ~~~~~~~~~~~~~~
  279. Generally, you should feel free to commit a change if:
  280. - Your changes are small and don't touch many files
  281. - You are fixing a bug
  282. - Somebody has told you that it's okay
  283. - It's obviously the Right Thing
  284. The more of the above are true, the better it is to just commit a change
  285. directly to CVS.
  286. When Not To Commit
  287. ~~~~~~~~~~~~~~~~~~
  288. Even if you have commit rights, you should probably still post a patch to the
  289. mailing list if:
  290. - Your changes are broad and touch many different files
  291. - You are adding a feature
  292. - Your changes are speculative or experimental (i.e., trying a new algorithm)
  293. - You are not the maintainer and your changes make the maintainer cringe
  294. The more of the above are true, the better it is to post a patch to the
  295. mailing list instead of committing.
  296. Final Words
  297. -----------
  298. If all of this seems complicated, don't panic, it's really not that tough. If
  299. you're having difficulty following some of the steps outlined in this
  300. document don't worry, the folks on the Busybox mailing list are a fairly
  301. good-natured bunch and will work with you to help get your patches into shape
  302. or help you make contributions.