Avoid installing build dependencies unless needed

In some setups the shell user might not be able to run sudo, thus causing the deploy task to fail even when the dependencies are installed.

This patch makes capistrano check whether the dependencies are already installed, and runs sudo only if they are missing.