Limit pkg.latest to 1 refresh per run unless overridden

This fixes #6292 by moving the rtag check to the call to
pkg.latest_version, and never refreshing if/when pkg.install is run.