Pull in changes from FreeBSD ports

Please changes from FreeBSD ports. They've been in use in ports for a while and should be fine. More work needs to be done. For example, cleaning up the comments and documention, adding support for pkgng, adding logic to figure out which package provider to use (falling back to ports), etc. But this should be a good start towards improving the current situation. These changes have some issues with Ruby 1.9 such as the warning about "class variable access from toplevel" about @@lock and @@ports_index. Suggestions welcome.