odb_pack: handle duplicate objects from different packs

This is based on 24634c6fd02b2240e4a93fad70a08220f8fb793a.

This also corrects an issue with error codes being mixed up with the
number of found objects.
Merge pull request #1638 from brodie/brodie/handle-duplicate-objects-across-packs

odb_pack: handle duplicate objects from different packs