Chapter 9. Debugging

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.

  1. Make sure PKG_DEVELOPER=1 is in /etc/mk.conf

  2. Retrieve port from FreeBSD collection

  3. Fix RCS-ID in the package's Makefile, see Makefile.

  4. 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)
        

  5. If you did a CVS import, check it out to apply the following fixes (not needed if you don't have CVS access!)

  6. Look at Makefile, fix if necessary; see Makefile.

  7. Look at patches, remember if not appropriate

  8. Have a look at pkg/PLIST, add a "@comment $NetBSD$" line at the beginning of any PLIST file (see PLIST* issues).

  9. make

  10. 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 :)

  11. If all builds OK: ``touch /tmp/bla''

  12. make install

  13. ``find /usr/pkg/ /usr/X11R6/ -newer /tmp/bla >/tmp/x'' (or whatever you set LOCALBASE and X11BASE to)

  14. ``pkg_delete blub''

  15. ``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.

  16. 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'' )

  17. ``make reinstall && make package''

  18. ``pkg_delete blub''

  19. ``find /usr/pkg/ /usr/X11R6/ -type f -newer /tmp/bla'' shouldn't find anything now

  20. ``pkg_add .../blub.tgz''

  21. Play with it :)

  22. ``pkg_delete'' - still no file should be left (re-run above ``find'')

  23. ``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.

  24. submit (or commit, if you have CVS access); see Submitting.