5.3. patches/*

This directory contains files that are used by the patch(1) command to modify the sources as distributed in the distribution file into a form that will compile and run perfectly on NetBSD. The files are applied successively in alphabetic order (as returned by a shell "patches/patch-*" glob expansion), so patch-aa is applied before patch-ab etc.

The patch-?? files should be in ``diff -bu'' format, and apply without a fuzz to avoid problems. (The latter condition is ensured by setting PKG_DEVELOPER in /etc/mk.conf - the build will fail if a patch applies with fuzz only). Furthermore, do not put changes for more than one file into a single patch-file, as this will make future modifications and maintainance more difficult.

One important thing to mention is to pay attention that no RCS IDs get stored in the patch files, as these will cause problems when later checked into the NetBSD CVS tree. To avoid this, use the ``-U 2'' or ``-U 1'' option to diff. handle this.

If you don't want to worry about the problems in the last two paragraphs yourself, use ``pkgdiff'' from the pkgsrc/pkgtools/pkgdiff package, which takes care of any RCS IDs by itself.

For even more automation, we recommend using ``mkpatches'' from the same package to make a whole set of patches. You just have to backup files before you edit them to filename.orig, e.g. with ``cp -p filename filename.orig''. If you upgrade a package this way, you can easily compare the new set of patches with the previously existing one with the ``patchdiff'' command.

When preparing a FreeBSD port for the NetBSD packages system, it's likely that the FreeBSD port will work on NetBSD. However, check that the person who ported the software to FreeBSD has not played fast and loose with the __FreeBSD__ cpp definition without good cause - a simple way to do this is to do

	grep -i freebsd patches/patch-??
  
in the package directory.

Besides taking care of any FreeBSDisms, be sure to provide patches to replace any occurrence of /usr/local in any Makefiles in the original package with ${PREFIX}.

When you have finished a package, remember to generate the checksums for the patch files by using the ``make makepatchsum'' command, see files/*.