packagebuild: extract package builder library to separate modules