Solved Edit file from port tree


I am using www/hiawatha and a bug has been discovered by the developer.
I was told that the fix will be to edit the file src/http.c and change lines 848 and 849 to:
while ((forwarded = strcasestr(forwarded, "for=")) != NULL) {
    begin = forwarded + 4;
Could someone please tell me if I can do that when using the port tree?
Sure you can.
cd /usr/ports/www/hiawatha
make configure
Then edit work/hiawatha-10.1/src/http.c
make package install
(or reinstall if you already have it installed)
  1. Run make patch to extract and apply patches that live in files/
  2. Go to work/hiawatha-10.1/src and cp http.c http.c.orig then edit http.c and apply the fix
  3. Go back to /usr/ports/www/hiawatha
  4. Run make makepatch. This will generate a patch file in files/patch-src_http.c. You can save this for later or submit it to the port maintainer.
  5. It's safe to run make clean now. If you later reinstall the port the patch will be automatically applied.
  6. Build your port as you normally would.
The porter's handbook explains this too:
Thank you guys.
I copied your reply over to the Hiawatha forum. I hope you don't mind.
I'm sure it will help other people.
Just a quick suggestion on this: Get your ports tree from SVN instead of portsnap. It's maybe a bit slower and it definitely uses more diskspace, but gives you two advantages when you ever edit a file in there:
  1. Subsequent updates won't affect your edit (but might lead to a conflict instead if the same file was touched in the official ports tree -- if you hit that, see SVN handbook)
  2. you can easily get a diff of your changes for submitting using svn diff