Refactor platform detection code

This separates the platform detection from dependency installation to
allow for the $platform to be used in the input validation section of
the code.

Change-Id: I92062b115f0125b83719bde51fc5edb7adba4224
Merge "Refactor platform detection code"