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