refactor rpmdb handling to remove some code duplication