refactored cache generation into module

@wjwwood Please review.
With this merged I will add another test into ros/rosdistro which generates the cache to ensure released packages are fetchable.