[PATCH v2 49/60] buildman: Move bulid code into its own function