TODO: concurrency issues with pkgdb.