Simple enough: it looks at the files in the tarball and sees what will be overwritten when you installpkg the thing. It also digs around in install/doinst.sh to see what links are going to be removed, like installpkg -warn does.
(Of course, the doinst.sh script could do some crazy stuff that this script won't detect. You'll have to take your chances.)
Run it with a given package name and it'll tell you what will be overwritten:
$ warnpkg fvwm-2.5.23-i686-1beej.tgz Existing files that will be affected are (*** means rm -rf!): /usr/bin/fvwm2 [***] /usr/bin/xpmroot [***] /usr/man/man1/fvwm2.1.gz [***] /usr/man/man1/xpmroot.1.gz [***] /usr/libexec/fvwm/2.5.23/FvwmAudio [***] /usr/lib/X11/fvwm2 [***] /usr/bin/fvwm /usr/bin/FvwmCommand /usr/bin/fvwm-root /usr/bin/fvwm-config [etc] $ warnpkg wxgtk-2.6.3-i686-1beej.tgz No existing files will be overwritten.
Then stick it in your PATH someplace. :)
Email me any issues!