6. Applying patches

Contents of this section

If the patch is compressed, decompress it. Don't worry about stripping any leading text (e-mail headers, etc.); patch will do that itself. The patch itself should start with a path name and a timestamp and then another line with a different path name and timestamp. See how many directories you need to drop from the second path name in order to get a name relative to the source directory of the program you want to patch. (See patch's manpage or info file for examples and a more detailed explanation.) Now change to the program's source directory and type patch -s -pn < patchfile, where n is the number of directories you need to drop and patchfile is the path to the patch you want to supply. Do not omit the -p flag even if n is zero; otherwise, directory structure will not be preserved correctly.

If patch prompts you for a file to patch, you probably got n wrong; take another look at the patch and try again (leading slashes count too). If it complains about hunks failing, do not panic. Look at the resulting .rej files one by one, figure out what changes they are trying to make, and make them yourself. If you feel uncomfortable doing this, ask somebody more experienced or politely post a query to an appropriate mailing list or newsgroup.


Next Chapter, Previous Chapter

Table of contents of this chapter, General table of contents

Top of the document, Beginning of this Chapter