Write a lock file when executing Pkg commands

Possible fix for https://github.com/JuliaLang/julia/issues/5622.  Write a simple lock file to the package directory when executing Pkg commands to prevent multiple instances of Pkg clobbering the same directory.