pkg: refactor pkg_get_comparator().