Remove use of function and fix REPO_DIR

Turns out function doesn't work in /bin/sh

And that REPO_DIR was being set to repo/tools instead of repo.