internal/gen: add Repackage

Factored out often used functionality to rewrite files in a package that
are used used both for generation and the package itself.

Change-Id: I94da2afb701ffe9ebef333ac0ef504585f12af88
Reviewed-on: https://go-review.googlesource.com/17189
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
5 files changed