generalize code for repositories, add package dir cache