Tuesday, 31 January 2012

Manual patching a of FreeBSD Port

Sometime you want to modify only a little bit of the code for a port to add a new function. The method below shows how you can do this easily.

1) Go in to the port directory
2) Type make clean to remove any existing work directories
3) type make extract to uncompress the port
4) Type make patch to apply any patches that the port maintainer has included
5) Enter the directory where the problem source file is - usually work/portname-version/some subdir
6) Copy it to filename.c.orig (If the port maintainer has already patched filename.c, 'make patch' will already have created filename.c.orig) so you will need to move the current orig to a new name and then create you one.
7) Edit filename.c to include your changes
8) Diff the two files and put the resulting patch file in portdir/files

I.e., if filename.c is in work/foo-x.y/bar/ you should cd to
work/foo-x.y/ and then run

diff -u bar/filename.c.orig bar/filename.c > ../../files/patch-filename.c

10) Return to the portdir and type make clean
11) Type make extract and then make patch - if it works, you should be able to do the install - if it doesn't work, post the errors here
and we'll figure it out

No comments:

Post a Comment