Fix ports.installed state for pkg names that don't match origin

This fixes a bug where ports.installed states report failure to install,
due to the package name not matching the name of the port. For example,
if installing www/mod_perl2 for use with www/apache22, this results in a
package name of ap22-mod_perl2.

This fix checks the origin names of installed packages, instead of the
name of the package itself.