refactor solv demo a bit
refactor: split off openpkgdb()
Reimplement state handling in rpm_by functions

We now have rpm_state_create and rpm_state_free to create/free
the state. API change, but should be pretty internal.