I'm trying to use
pkg search on FreeBSD to search for "known packages" in the configured repos. The existing code uses
pkg search -R <format_args> all to query remote repos and update the local catalog copy, then return raw info on all packages.
The problem is that this works fine if the repo is available. But if the remote repo isn't available (DNS issues, no internet, whatever) then the local copy is removed too, so whatever info could have been obtained from the local catalog copy (even if one or two packages out of date) is lost until online contact is next made with the remote repo. This means that after repo access failure, any kind of offline activity requiring a search of the local catalog will be impossible.
The only options I can find that don't imply clearing the local copy on failure are -U (which simply prevents any update that might have been available from being attempted whether or not it would have succeeded), and
pkg info (which provides local installed pkg data and doesn't provide repo copy catalog data); neither seem helpful.
Is there a way I can use pkg that updates the catalog copy beforehand as usual, iff a valid update can be obtained, but doesn't wipe it if it can't?