Add auto repo-update. Refactor lots of stuff around repo management to minimize code duplication.