Use get_dists to get packages matching a spec

This makes sure to ignore "bad" packages (packages with nonexisting
dependencies).