Sunday, January 1, 2012

How to Create a Patch for an OpenBSD Program from the Ports Tree



Much easier way to create a patch!

1. Determine the workdist directory: "make show=WRKDIST"
2. Navigate to the $WRKDIST
3. cp original file to [original file name].orig, "dpid.c.orig"
4. Edit original file, "vi dpid.c"
5. Navigate to /usr/ports/[project], "cd /usr/ports/www/dillo"
6. Execute update-patches!, "make update-patches"
... and it creates the patch file for you!


Much easier than the way below!

A while back I was running mail servers for High Country Rugby and the Georgia Rugby Union.  During that time I had reason to use the Teapop mail server but wanted it to work with the Maildir format and with 'htpasswd'.  For whatever reason Teapop did not support this out of the box so I patched it to meet my needs.  I kept this note on how to create a patch and thought I would share it today. 

1. Determined how to force Teapop to use Maildir format with htpasswd:

   A. Make patch!
      1. cp pop_passwd.c to pop_passwd.c.orig
      2. edit pop_passwd.c and add "strcat(pinfo->maildrop, "/"); at  line 998(?)
      3. Create patch with diff -u pop_passwd.c.orig pop_passwd.c
 3.1 Name patch like so: patch-pop_passwd.c_in
  patch-[file name]_in
      4. place patch file in /usr/ports/mail/teapop/patches/patch-pop_passwd.c_in
      5. Execute "sudo make clean" and "sudo make package".
      6. Scp package to server.
      7. Unzip on server (my servers did not have gcc or other tools installed for security reasons).
      8. mv /usr/local/libexec/teapop to /usr/local/libexec/teapop.orig
      9. Copy new teapop executable to /usr/local/libexec/teapop
      10. Enjoy your patched program!

No comments:

Post a Comment