lib/db: fix resolving virtual packages

try finding a real package first and lookup virtual ones on failure

Signed-off-by: Andreas Beckmann <anbe@debian.org>