buildman: Move setting up the output dir into a function