To check out all the gotchas when building a package (either from a FreeBSD port, or from scratch), here are the steps that I do in order to get a package working. Please note this is basically the same as what was explained in the previous sections, only with some debugging aids.
Make sure PKG_DEVELOPER=1 is in /etc/mk.conf
Retrieve port from FreeBSD collection
Fix RCS-ID in the package's Makefile, see Makefile.
Import unchanged FreeBSD source (only if you have CVS write access, not needed otherwise):
(cd .../pkgsrc/category/pkgname ; cvs import pkgsrc/category/pkgname \ FREEBSD FreeBSD-current-yyyy-mm-dd)
If you did a CVS import, check it out to apply the following fixes (not needed if you don't have CVS access!)
Look at Makefile, fix if necessary; see Makefile.
Look at patches, remember if not appropriate
Have a look at pkg/PLIST, add a "@comment $NetBSD$" line at the beginning of any PLIST file (see PLIST* issues).
make
If something is not ok, fix; for patches: fix the file, then re-generate the diff: ``diff -bu foo.orig foo >../../patches/patch-xx'' (``mv patch-xx patch-xx.orig'' before); If there's no foo.orig from a previous patch, be sure to have an old version of the file somewhere; re-iterate :)
If all builds OK: ``touch /tmp/bla''
make install
``find /usr/pkg/ /usr/X11R6/ -newer /tmp/bla >/tmp/x'' (or whatever you set LOCALBASE and X11BASE to)
``pkg_delete blub''
``find /usr/pkg/ /usr/X11R6/ -newer /tmp/bla'' (or diff against output of ``make print-PLIST''): if this brings up any files, that are missing in pkg/PLIST*; add them.
Compare pkg/PLIST* against /tmp/x, fix the former one ( ``sort /tmp/x >/tmp/x2 ; sort pkg/PLIST >/tmp/P ; sdiff /tmp/x2 /tmp/P'' )
``make reinstall && make package''
``pkg_delete blub''
``find /usr/pkg/ /usr/X11R6/ -type f -newer /tmp/bla'' shouldn't find anything now
``pkg_add .../blub.tgz''
Play with it :)
``pkg_delete'' - still no file should be left (re-run above ``find'')
``make clean && touch /tmp/bla && make install && make clean && make deinstall'' then run the ``find'' again. Yes, some software authors write Makefiles that install files during the build target. Sigh. Re-run the ``find'', and fix the PLIST. Repeat until certain the software does not install any files that aren't in PLIST.
submit (or commit, if you have CVS access); see Submitting.