The syntax for pkg_patch usage is:
usage: ./pkg_patch -c [-b] package_file_1 package_file_2 patch_file ./pkg_patch -a patch_file ./pkg_patch -m [-b] [-r url_repo] package_dir_1 package_dir_2 patch_dir ./pkg_patch -u [url]
The target usage scenario for the end-user is to use the "-u" flag to pkg_patch in order to update the currently running system.
Creating the patch file
To create the patch file apache-2.2.13-2.2.15_1.tbz (compressed, bsdiff-powered):
pkg_patch -cb apache-2.2.13.tbz apache-2.2.15_1.tbz apache-2.2.13-2.2.15_1.tbz
Applying the patch file
To apply the patch file apache-2.2.13-2.2.15_1.tbz to the system having apache-2.2.13.tbz installed:
pkg_patch -a apache-2.2.13-2.2.15_1.tbz
Mass package generation
To mass-generate a directory of package patches from two directories of packages containing the "old" and "new" packages (with the regular naming convention), with the intention that the patch directory be hosted as "http://ftp.freebsd.org/pub/packages/8.0-8.1/":
./pkg_patch -mb -r http://ftp.freebsd.org/pub/packages/8.0-8.1/ olddir newdir patchdir
This will generate the patches from found files and create the patch index file referencing the above URL. This index file describes available patches and the URL from which to get them.
Automatic updates with new patches
To compare the currently installed packages with the list of package patches generated in the last step and update available packages with patches:
./pkg_patch -u http://ftp.freebsd.org/pub/packages/8.0-8.1/