pkg: ensure we actually have a package object before caching it