How to Make a Patch for an Open Source Project
By eHow Computers Editor
source: (http://www.ehow.com/how_2091741_make-patch-open-source-project.html)
One of the greatest advantages of open source is the ability to view and modify the source code. For programmers, this means diagnosing and fixing problems themselves instead of waiting for someone else to do it. In order to contribute this fix to the developers of the open source project, you need to send them a patch.
Step1
Identify a problem or bug in a piece of open source software. This usually occurs as you're using the software. The program either crashes or behaves in an unexpected or unintended manner. Sometimes it's a matter of being able to visualize a better way of accomplishing something.Step2
Download the source code. Since you're going to make a patch to send to the developers, you need the original code to write it. This is done with source code management software like Concurrent Versions System (CVS) or Subversion (SVN).Step3
Go to the software's project page and click on "Code" if the developer is using CVS on SourceForge. Follow the directions for anonymous CVS access. This will allow you to download the developer source code from CVS.Step4
Search the developer's website for instructions to download the source code if he is using a service other than SourceForge. If the instructions are not on the website, you will need to email the developer or a related mailing list for assistance.Step5
Diagnose the problem without making any modifications. Now that you have the source code, you can find out where the software is breaking.Step6
Copy every file you're going to modify to a temporary .old.* file. For example, if you were going to change "eval.c," you would copy "eval.c" to "eval.old.c." This keeps a record of the old file so the diff
program has something to work from.Step7
Get coding and fix the problem. It could be as simple as one-line fix, such as changing a function parameter or adding some parentheses to some arithmetic, or much more complicated. Sometimes you may need to rewrite an entire function.Step8
Clean up your work to make the developer's job easier. Clean up any junk lines or comments you may have left while fixing the code and make sure your indentation and whitespace style is the same as the developer's. You should also be sure that you followed any naming conventions the developer used if you want your patch to be submitted. Not doing the cleanup means the developer may not have time to clean up your code and your patch will never be accepted.Step9
Run the diff
program. The diff
program compares two files and records the differences between them. This will generate the patch, so later the patch program can add these changes to the developer's source code. For every file you modified, you need to run the diff
program like this:"patch -uN eval.old.c eval.c > eval.patch"
Step10
Send the patch to the developer, emailing it to him in an attachment. The developer can download source from CVS, apply the patch and commit the changes. He will probably also add you to the credits if the software has any (usually located in the readme file).
No comments:
Post a Comment