The background of this patch is available at:
Even a pkg -N success, the following pkg install may still fail because of
the repository version doesn't match between client and server.
Use pkg update as checker and perform a force bootstrap if needed.
The second pkg update is for ensuring pkg install will fetch the latest
packages as pkg bootstrap doesn't include updating the index.