A Wired.com user account lets you create, edit and comment on Webmonkey articles. You will also be able to contribute to the Wired How-To Wiki and comment on news stories at Wired.com.
It's fast and free.
processing...Retrieve Sign In
Please enter your e-mail address or username below. Your username and password will be sent to the e-mail address you provided us.
processing...Welcome to Webmonkey
- edit articles
- add to the code library
- design and write a tutorial
- comment on any Webmonkey article
Sign In Information Sent
Patch Open Source Software
/skill level/
/viewed/
(�Apply a Patch) |
(�Troubleshooting) |
||
| Line 41: | Line 41: | ||
Occasionally, a patch will fail, typically if you're trying to apply a patch that was written for a different version of the software than the one you're patching. It'll say something like | Occasionally, a patch will fail, typically if you're trying to apply a patch that was written for a different version of the software than the one you're patching. It'll say something like | ||
| - | |||
<pre> | <pre> | ||
Hunk #6 FAILED at 804. | Hunk #6 FAILED at 804. | ||
</pre> | </pre> | ||
| + | |||
Often that means that code has been rearranged and the patch can't find where it's supposed to go. You can try to manually apply the patch code by hand-editing the file, or just try to get a proper patch. | Often that means that code has been rearranged and the patch can't find where it's supposed to go. You can try to manually apply the patch code by hand-editing the file, or just try to get a proper patch. | ||
If you decide you want to undo the patching job you just did, the patch can be reversed with the command: | If you decide you want to undo the patching job you just did, the patch can be reversed with the command: | ||
| - | |||
<pre> | <pre> | ||
patch -R -p1 -i ../DelText.patch | patch -R -p1 -i ../DelText.patch | ||
</pre> | </pre> | ||
| - | pat | ||
Revision as of 17:41, 16 May 2008
One of the countless joys of open source software is that -- because its source code is open -- you can modify programs to make its behavior closer to exactly what you want. You can look right at the way a program does its thing, institute subtle or massive changes and compile a personal copy that's just the way you want it. Depending on the software license, you can also probably distribute your changes so the rest of the world can enjoy them.
Commonly, people make this sort of change and then distribute it in the form of a patch. Users download the original source to the software as well as the patch code, use the patch to modify the software, compile and enjoy. Here's how.
Apply a Patch
Alpine is an excellent e-mail program but also an excellent example of patchability. There are quite a few patches available for Alpine to add and modify little features. Patching is done on the command line, on Linux or OS X or the Cygwin add-on to Windows. To get started, first download the original source code for Alpine. Also download Eduardo Chappa's handy patch that implements a delete-to-end-of-file command in Alpine.
At the command line, unzip the patch:
gunzip DelText.patch.gz
If you're curious, you can look at it; it's a series of code snippets along with instructions as to where in the Alpine source they belong. Each of these snippets is called a "hunk".
Unpack the Alpine source code:
tar xzvf alpine.tar.gz
This will create a new directory; cd into that directory. To apply the patch, use the "patch" command:
patch -p1 -i ../DelText.patch
This command patches files in the current directory, using the patch it's told to use. It should say what it's doing:
Patching file pico/basic.c Patching file pico/efunc.h
Now build the patched source code as normal.
Troubleshooting
Occasionally, a patch will fail, typically if you're trying to apply a patch that was written for a different version of the software than the one you're patching. It'll say something like
Hunk #6 FAILED at 804.
Often that means that code has been rearranged and the patch can't find where it's supposed to go. You can try to manually apply the patch code by hand-editing the file, or just try to get a proper patch.
If you decide you want to undo the patching job you just did, the patch can be reversed with the command:
patch -R -p1 -i ../DelText.patch
/related_articles/
Special Offer For Webmonkey Users
WIRED magazine:
The first word on how technology is changing our world.
