Significant refactor of appliance build.sh to be easier to use from jenkins.

* Use traps for cleanup code to reduce chance that a bad build leaves VMs running.
* Get rid of eager cleanup which removes more files than the script creates.
* Add support for passing in version and BUILD_NUMBER.
* Inject version into postinstall so it ends up in /etc/cloudstack-release.