Various improvements to builds.

Fix execute permissions, support custom Lua versions, improve
robustness.