Factor index creation from repo collections

Move index generation from OpamRepositoryCommand and OpamState into OpamRepository