Improve pkg detection.

This is based on the section in the pkg manpage:

  The following script is the safest way to detect if pkg is installed
  and activated:

    if TMPDIR=/dev/null ASSUME_ALWAYS_YES=1 \
         PACKAGESITE=file:///nonexistent \
         pkg info pkg >/dev/null 2>&1; then
      # pkgng-specifics
    else
      # pkg_install-specifics
    fi

This fits my workload better.