Spack builds that fail can sometimes leave staged source files and CMake caches in the build area. These are cleaned up when builds are successful, but are left around when builds fail to allow for post-mortem analysis of the build errors.
There is a small possibility that new builds will have the same unique hash as previous builds, even if details of the build have changed. In this case, old source and CMake caches from the previous faild build attempt may be re-used for the new build. This is almost always undesired.
We can just go ahead and clean the spack build staging directory of any cruft prior to attempting a new build to avoid this, while also keeping these staged artifacts after build failures for study.
Latest versions of spack can clean the staging directory with the command:
spack clean --stage --misc-cache
but older versions used the command:
spack purge --stage --misc-cache
in case this error re-appears when using older Spack v0.10 or earlier.
This commit also adds annotation to the deployment scripts explaining the purpose of each of the spack setup and build steps.