writes pkg by repo, in the right order