Saturday, April 4, 2009

How to Use a Patch for an Open Source Project

How to Use a Patch for an Open Source Project

Use a Patch for an Open Source Project

Step1
Set up a build environment. To use patches, you have to be able to buildsoftware from source code. This means installing tools like gcc and make, as well as installing development libraries for all the packages you'll be using.
Step2
Download the source code for the open source project. Downloading a software's source code can be done in two ways: you can download the tarball provided at release time or you can access the developer's Concurrent Versions System (CVS) source code repository. The source code repository will allow you to download the up-to-the-minute source code for the software. The tarball is static, while the source code can be in any state.
Step3
Extract the source code from a tar.gz file: "tar -xzvf software-3.14.tar.gz". If you downloaded the source code from CVS, the source code isn't compressed and won't need to be extracted.
Step4
Extract the source code from a tar.bz2 package, which uses a different compression algorithm than a tar.gz package. Therefore, the command is different: "tar -xjvf software-3.14.tar.bz2".
Step5
Apply the patch to the open source software. Patches come in the form of a "unified diff." Once you get the source code unpacked, change the directory to the new directory created by tar. Copy the patch into this directory and use the following command: "patch -p0 >patch.txt".
Step6
Replace patch.txt with the filename of the patch. Sometimes a developer will be creating a patch from two source code trees. If that's the case and you get an error from the previous command, use this command instead:"patch -p1 .
Step7
Build the software. Most open source software is managed with the GNU automake software. To make software in this form, run the following command: ."/configure:make".
Step8
Uninstall any old versions of the software you may have installed.
Step9
Install the new software now that you have the new version built. You must become root to install software because you have to write files to system directories, which normal users don't have permission to do. Either use sudo, su or login as root before running the following command: "make install".
Step10
Test the new software, running it to ensure it's working correctly.

No comments: