travis: Split build logic into a separate script (rebased onto dev_5_0)



This is the same as gh-2277 but rebased onto dev_5_0.

----

- allows testing of travis logic locally
- allows simple extension and modification of tests
- similar to the existing way bioformats does this

Testing:
- if travis is green, that's about it
- verify that the logic used before and after the change is the same