Member Sign In
Not a member?

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.

Sign in with OpenID
Sign In
Webmonkey is a property of Wired Digital.
processing...
Join Webmonkey

Please send me occasional e-mail updates about new features and special offers from Wired/Webmonkey.
Yes No

Please send occasional e-mail offers from Wired/Webmonkey affiliated web sites and publications, and carefully selected companies.
Yes No

I understand and agree that registration on or use of this site constitutes agreement to Webmonkey's User Agreement and Privacy Policy.
Webmonkey is a property of Wired Digital.
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.

or
Webmonkey is a property of Wired Digital.
processing...

Welcome to Webmonkey

A private profile page has been created for you.
As a member of Webmonkey, you can now:
  • edit articles
  • add to the code library
  • design and write a tutorial
  • comment on any Webmonkey article
Close
Webmonkey is a property of Wired Digital.

Sign In Information Sent

An e-mail has been sent to the e-mail address registered in this account.
If you cannot find it in your in-box, please check your bulk or junk folders.
Sign In
Webmonkey is a property of Wired Digital.

Patch Open Source Software

/skill level/
/viewed/
0 Times

m
m
Line 4: Line 4:
''This article is a '''wiki'''. Got extra advice? Log in and add it.''
''This article is a '''wiki'''. Got extra advice? Log in and add it.''
-
 
- 
__TOC__
__TOC__
-
 
==Apply a Patch==
==Apply a Patch==

Revision as of 17:43, 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.

This article is a wiki. Got extra advice? Log in and add it.

Contents


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
Edit this article
Reddit Digg
 
Subscribe now

Special Offer For Webmonkey Users

WIRED magazine:
The first word on how technology is changing our world.

Subscribe for just $10 a year