Apt race condition

If certain libraries are not installed as part of the base distro, adding an apt repo will fail. I've moved the dependency install task to happen earlier, as well as an initial cache update if the cache is stale. This might be slightly slower but will be safer in most cases.