Update gen.sh to use functions

Updated gen.sh to be more flexible, move main parts into separate functions and included some basic command line argument interpretation. Tested building and installs and works as it it before.

This is one of the pull requests that replaces https://github.com/directhex/steamos-installer/pull/15